RoadFlow2.1 临时演示

UserAdd.aspx.cs 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace WebForm.Platform.Members
  8. {
  9. public partial class UserAdd : Common.BasePage
  10. {
  11. protected void Page_Load(object sender, EventArgs e)
  12. {
  13. this.Account.Attributes.Add("validate_url", "CheckAccount.ashx");
  14. RoadFlow.Platform.Organize borganize = new RoadFlow.Platform.Organize();
  15. RoadFlow.Platform.Users busers = new RoadFlow.Platform.Users();
  16. string id = Request.QueryString["id"];
  17. string name = string.Empty;
  18. string account = string.Empty;
  19. string status = string.Empty;
  20. string note = string.Empty;
  21. Guid parentID;
  22. if (IsPostBack && id.IsGuid(out parentID))
  23. {
  24. name = Request.Form["Name"];
  25. account = Request.Form["Account"];
  26. status = Request.Form["Status"];
  27. note = Request.Form["Note"];
  28. Guid userID = Guid.NewGuid();
  29. string userXML = string.Empty;
  30. using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
  31. {
  32. //添加人员
  33. RoadFlow.Data.Model.Users user = new RoadFlow.Data.Model.Users();
  34. user.Account = account.Trim();
  35. user.Name = name.Trim();
  36. user.Note = note.IsNullOrEmpty() ? null : note;
  37. user.Password = busers.GetUserEncryptionPassword(userID.ToString(), busers.GetInitPassword());
  38. user.Sort = 1;
  39. user.Status = status.IsInt() ? status.ToInt() : 0;
  40. user.ID = userID;
  41. busers.Add(user);
  42. //添加关系
  43. RoadFlow.Data.Model.UsersRelation userRelation = new RoadFlow.Data.Model.UsersRelation();
  44. userRelation.IsMain = 1;
  45. userRelation.OrganizeID = parentID;
  46. userRelation.Sort = new RoadFlow.Platform.UsersRelation().GetMaxSort(parentID);
  47. userRelation.UserID = userID;
  48. new RoadFlow.Platform.UsersRelation().Add(userRelation);
  49. //更新父级[ChildsLength]字段
  50. borganize.UpdateChildsLength(parentID);
  51. //更新角色
  52. new RoadFlow.Platform.UsersRole().UpdateByUserID(userID);
  53. userXML = user.Serialize();
  54. scope.Complete();
  55. }
  56. RoadFlow.Platform.Log.Add("添加了人员", userXML, RoadFlow.Platform.Log.Types.组织机构);
  57. Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;", true);
  58. }
  59. this.StatusRadios.Text = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
  60. }
  61. }
  62. }