SystemAcl.aspx.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13. /// <summary>
  14. /// Summary description for AdministratorACL.
  15. /// </summary>
  16.     public partial class SystemACL : PortalPage
  17. {
  18. protected void Page_Load(object sender, System.EventArgs e)
  19. {
  20.             this.UserSelector.SelectUserUrl = PageName_SelectUser;
  21.             this.UserSelector.SelectUserImageUrl = PageName_SelectUserImage;
  22. if(!this.IsPostBack)
  23. {
  24.                 // 验证是否具有管理员权限
  25.                 if (!this.UserValidator.ValidateAdministrator())
  26.                 {
  27.                     this.NotifyMessage(LackOfAuth);
  28.                 }
  29. this.WorkflowAclTable = OThinker.H3.Server.Engine.SystemAclManager.QueryDataTable();
  30. }
  31. this.SelectionCheckBoxes.Clear();
  32. this.WorkflowACLGrid.DataSource = this.WorkflowAclTable;
  33. this.WorkflowACLGrid.DataBind();
  34. }
  35. // CaseGrid对应的表
  36. private System.Data.DataTable WorkflowAclTable
  37. {
  38. get
  39. {
  40. return (System.Data.DataTable)this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLTable()];
  41. }
  42. set
  43. {
  44. this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLTable()] = value;
  45. }
  46. }
  47. #region Web Form Designer generated code
  48. override protected void OnInit(EventArgs e)
  49. {
  50. //
  51. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  52. //
  53. InitializeComponent();
  54. base.OnInit(e);
  55. }
  56. /// <summary>
  57. /// Required method for Designer support - do not modify
  58. /// the contents of this method with the code editor.
  59. /// </summary>
  60. private void InitializeComponent()
  61. {
  62. this.imgAdd.Click += new System.Web.UI.ImageClickEventHandler(this.imgAdd_Click);
  63. this.imgDel.Click += new System.Web.UI.ImageClickEventHandler(this.imgDel_Click);
  64. this.WorkflowACLGrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.InstanceGrid_ItemDataBound);
  65. }
  66. #endregion
  67. #region 获得选中的ID
  68. private System.Collections.ArrayList SelectionCheckBoxes
  69. {
  70. get
  71. {
  72. if(this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLCheckBoxes()] == null)
  73. {
  74. this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLCheckBoxes()] = new System.Collections.ArrayList();
  75. }
  76. return (System.Collections.ArrayList)this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLCheckBoxes()];
  77. }
  78. }
  79. // 获得选中的Acl ID
  80.         private string[] GetSelectedACLs()
  81. {
  82. // 获得选中的
  83.             System.Collections.Generic.List<string> selections = new System.Collections.Generic.List<string>();
  84. for(int count=0; count<this.SelectionCheckBoxes.Count; count++)
  85. {
  86. if(((System.Web.UI.WebControls.CheckBox)this.SelectionCheckBoxes[count]).Checked)
  87. {
  88. System.Data.DataRow row = this.WorkflowAclTable.Rows[count];
  89. selections.Add(row["ObjectID"].ToString());
  90. }
  91. }
  92.             return selections.ToArray();
  93. }
  94. private void InstanceGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  95. {
  96. if(
  97. e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Header && 
  98. e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Footer)
  99. {
  100. CheckBox box = new System.Web.UI.WebControls.CheckBox();
  101. this.SelectionCheckBoxes.Add(box);
  102. e.Item.Cells[0].Controls.Add(box);
  103. e.Item.Cells[2].Text = OThinker.H3.Server.Engine.Organization.GetFullName(e.Item.Cells[2].Text);
  104. // 发布新版本 
  105. CheckBox administrator = new CheckBox();
  106. administrator.Enabled = false;
  107. if(e.Item.Cells[3].Text == "1")
  108. {
  109. administrator.Checked = true;
  110. }
  111. else
  112. {
  113. administrator.Checked = false;
  114. }
  115. e.Item.Cells[3].Controls.Add(administrator);
  116. // 发布新版本 
  117. CheckBox publishWorkflow = new CheckBox();
  118. publishWorkflow.Enabled = false;
  119. if(e.Item.Cells[4].Text == "1")
  120. {
  121. publishWorkflow.Checked = true;
  122. }
  123. else
  124. {
  125. publishWorkflow.Checked = false;
  126. }
  127. e.Item.Cells[4].Controls.Add(publishWorkflow);
  128.                 // 查看报表
  129.                 CheckBox viewReport = new CheckBox();
  130.                 viewReport.Enabled = false;
  131.                 if (e.Item.Cells[5].Text == "1")
  132.                 {
  133.                     viewReport.Checked = true;
  134.                 }
  135.                 else
  136.                 {
  137.                     viewReport.Checked = false;
  138.                 }
  139.                 e.Item.Cells[5].Controls.Add(viewReport);
  140. }
  141. }
  142. #endregion
  143. protected void btnAdd_Click(object sender, System.EventArgs e)
  144. {
  145. this.Add();
  146. }
  147. private void imgAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  148. {
  149. this.Add();
  150. }
  151. private void Add()
  152. {
  153. OThinker.H3.Acl.SystemAcl acl = new OThinker.H3.Acl.SystemAcl();
  154. acl.UserID = this.UserSelector.SelectedUser;
  155. acl.Administrator = this.chkAdministrator.Checked;
  156. acl.PublishWorkflow = this.chkPublishWorkflow.Checked;
  157.             acl.ViewReport = this.chkViewReport.Checked;
  158.             acl.CreateBy = this.UserValidator.UserID;
  159.             acl.CreateTime = System.DateTime.Now;
  160. if(OThinker.H3.Server.Engine.SystemAclManager.Add(acl))
  161. {
  162. // 添加成功
  163. this.Response.Redirect(this.Request.Url.AbsolutePath);
  164. }
  165. else
  166. {
  167. // 添加不成功
  168. this.lblError.Text = "添加不成功";
  169. }
  170. }
  171. protected void btnDel_Click(object sender, System.EventArgs e)
  172. {
  173. this.Remove();
  174. }
  175. private void imgDel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  176. {
  177. this.Remove();
  178. }
  179. private void Remove()
  180. {
  181.             string[] ids = this.GetSelectedACLs();
  182.             foreach (string id in ids)
  183. {
  184. OThinker.H3.Server.Engine.SystemAclManager.Delete(id);
  185. }
  186. // ERROR,显示删除成功
  187. this.Response.Redirect(this.Request.Url.AbsolutePath);
  188. }
  189.         protected void btnUpdate_Click(object sender, EventArgs e)
  190.         {
  191.             string[] acls = this.GetSelectedACLs();
  192.             if (acls.Length == 0)
  193.             {
  194.                 // ERROR,导到错误页面上
  195.             }
  196.             else
  197.             {
  198.                 this.Response.Redirect(PageName_UpdateSystemAcl + "?" + Param_AclID + "=" + acls[0]);
  199.             }
  200.         }
  201. }
  202. }