EmployeeManage.aspx.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using BizCom;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Web;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using Utils;
  11. using SiteCore;
  12. using NHibernate.Mapping;
  13. public partial class Ehr_EmployeeManage : TreeBasePage, ITreePage
  14. {
  15. protected override void OnPreInit(EventArgs e)
  16. {
  17. PmTag = "employee";
  18. TreeTitle = "选择组织机构";
  19. ContentTitle = "员工信息";
  20. TreeSelValue = "0";
  21. }
  22. protected void Page_Load(object sender, EventArgs e)
  23. {
  24. if (!IsPostBack)
  25. {
  26. if (_permissions.Contains("account"))
  27. {
  28. //accountPlace.Visible = true;
  29. }
  30. }
  31. }
  32. #region 左边数据
  33. System.Data.DataView dv = null;
  34. public object GetTreeData()
  35. {
  36. StringBuilder str = new StringBuilder();
  37. DataTable resources = null;
  38. resources = CeErpOrganization.Get();
  39. //if (_permissions.Contains("all")) resources = CeErpOrganization.Get();
  40. //else resources = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  41. int i = 0;
  42. if (resources != null && resources.Rows.Count > 0)
  43. {
  44. //if (i == 0)
  45. //{
  46. // TreeSelValue = "-1";
  47. // str.Append("{");
  48. //}
  49. //else
  50. string orgids = CurrentUser.User.ManageOrgIds;
  51. string[] list = orgids != null ? orgids.Split(',') : new string[0];
  52. if (CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "HumanResMr")
  53. {
  54. TreeSelValue = "0";
  55. str.Append("{");
  56. str.AppendFormat("\"id\":\"0\",\"name\":\"{0}\",\"path\":\"\",\"expanded\": true", "公司");
  57. str.Append("}");
  58. dv = new System.Data.DataView(resources);
  59. dv.RowFilter = "ParentID=0";
  60. }
  61. else
  62. {
  63. TreeSelValue = CurrentUser.UserPost.OrgID;
  64. dv = new System.Data.DataView(resources);
  65. dv.RowFilter = "ParentID=0";
  66. }
  67. foreach (DataRowView drv in dv)
  68. {
  69. if (list.Contains(drv["id"].ToString()) || CurrentUser.UserPost.Post.Code == "SysAdmin")
  70. {
  71. str.Append(",{");
  72. str.AppendFormat("\"id\":\"{0}\",\"name\":\"{1}\",\"path\":\"\",\"pid\":\"{2}\",\"expanded\": true", drv["id"], drv["Name"], 0);
  73. str.Append("}");
  74. GetOtherTree(drv["ID"], ref str);
  75. i++;
  76. }
  77. }
  78. // }
  79. // else
  80. //{
  81. // TreeSelValue = CurrentUser.UserPost.OrgID;
  82. // dv = new System.Data.DataView(resources);
  83. // dv.RowFilter = "ID=" + CurrentUser.UserPost.OrgID;
  84. //foreach (DataRowView drv in dv)
  85. //{
  86. // if (list.Contains(drv["id"].ToString()) || CurrentUser.UserPost.Post.Code == "SysAdmin")
  87. // {
  88. // str.Append("{");
  89. // str.AppendFormat("\"id\":\"{0}\",\"name\":\"{1}\",\"path\":\"\",\"expanded\": true", drv["id"], drv["Name"], 0);
  90. //str.Append("}");
  91. //GetOtherTree(drv["ID"], ref str);
  92. //i++;
  93. //}
  94. //}
  95. // }
  96. }
  97. string vstr = str.ToString().Trim(',');
  98. str = new StringBuilder();
  99. str.Append("[");
  100. str.Append(vstr);
  101. str.Append("]");
  102. return str.ToString();
  103. }
  104. private void GetOtherTree(object id, ref StringBuilder str)
  105. {
  106. dv.RowFilter = "ParentID=" + id;
  107. dv.Sort = "Sort asc";
  108. if (dv.Count < 1)
  109. {
  110. return;
  111. }
  112. string orgids = CurrentUser.User.ManageOrgIds;
  113. string[] list = orgids != null ? orgids.Split(',') : new string[0];
  114. foreach (DataRowView drv in dv)
  115. {
  116. if (list.Contains(drv["id"].ToString()) || CurrentUser.UserPost.Post.Code == "SysAdmin")
  117. {
  118. //if (TreeSelValue.ToString() == "0") TreeSelValue = drv["id"].ToString();
  119. str.Append(",{");
  120. str.AppendFormat("\"id\":\"{0}\",\"name\":\"{1}\",\"pid\":\"{3}\",\"path\":\"{2}\",\"expanded\": true", drv["ID"], drv["Name"], drv["Path"], drv["ParentID"]);
  121. str.Append("}");
  122. GetOtherTree(drv["ID"], ref str);
  123. }
  124. }
  125. }
  126. #endregion
  127. }