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

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 CaseACL.
  15. /// </summary>
  16.     public partial class InstanceAcl : PortalPage
  17. {
  18. #region 参数
  19. private string InstanceId
  20. {
  21. get
  22. {
  23.                 return this.Request.QueryString[Param_InstanceId];
  24. }
  25. }
  26. #endregion
  27. protected void Page_Load(object sender, System.EventArgs e)
  28. {
  29. if(!this.IsPostBack)
  30. {
  31. if(!this.UserValidator.ValidateInstanceAdministrator(this.InstanceId))
  32. {
  33. // 没有操作的权限
  34. this.NotifyMessage("您不具有该权限!");
  35. }
  36. else
  37. {
  38. this.InstanceACLTable = OThinker.H3.Server.Engine.InstanceAclManager.QueryDataTable(
  39. new string[]{this.UserValidator.UserID}, 
  40. this.InstanceId, 
  41. OThinker.Data.BoolMatchValue.Unspecified, 
  42. OThinker.Data.BoolMatchValue.Unspecified);
  43. }
  44. }
  45. this.SelectionCheckBoxes.Clear();
  46. this.InstanceACLGrid.DataSource = this.InstanceACLTable;
  47. this.InstanceACLGrid.DataBind();
  48. }
  49. // CaseACLGrid对应的表
  50.         private System.Data.DataTable InstanceACLTable
  51. {
  52. get
  53. {
  54. return (System.Data.DataTable)this.Session[OThinker.H3.WorkSheet.Sessions.GetInstanceACLTable(this.InstanceId)];
  55. }
  56. set
  57. {
  58.                 this.Session[OThinker.H3.WorkSheet.Sessions.GetInstanceACLTable(this.InstanceId)] = value;
  59. }
  60. }
  61. #region 获得选中的ID
  62. private System.Collections.ArrayList SelectionCheckBoxes
  63. {
  64. get
  65. {
  66. if(this.Session[OThinker.H3.WorkSheet.Sessions.GetInstanceACLCheckBoxes(this.InstanceId)] == null)
  67. {
  68.                     this.Session[OThinker.H3.WorkSheet.Sessions.GetInstanceACLCheckBoxes(this.InstanceId)] = new System.Collections.ArrayList();
  69. }
  70.                 return (System.Collections.ArrayList)this.Session[OThinker.H3.WorkSheet.Sessions.GetInstanceACLCheckBoxes(this.InstanceId)];
  71. }
  72. }
  73. // 获得选中的Case ID
  74. private long[] GetSelectedACLs()
  75. {
  76. // 获得选中的
  77. System.Collections.ArrayList selections = new ArrayList();
  78. for(int count=0; count<this.SelectionCheckBoxes.Count; count++)
  79. {
  80. if(((System.Web.UI.WebControls.CheckBox)this.SelectionCheckBoxes[count]).Checked)
  81. {
  82. System.Data.DataRow row = this.InstanceACLTable.Rows[count];
  83. selections.Add(row["ObjectID"]);
  84. }
  85. }
  86. long[] selectedCases = new long[selections.Count];
  87. for(int count=0; count<selectedCases.Length; count++)
  88. {
  89. selectedCases[count] = long.Parse(selections[count].ToString());
  90. }
  91. return selectedCases;
  92. }
  93. #endregion
  94. #region Web Form Designer generated code
  95. override protected void OnInit(EventArgs e)
  96. {
  97. //
  98. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  99. //
  100. InitializeComponent();
  101. base.OnInit(e);
  102. }
  103. /// <summary>
  104. /// Required method for Designer support - do not modify
  105. /// the contents of this method with the code editor.
  106. /// </summary>
  107. private void InitializeComponent()
  108. {    
  109. this.InstanceACLGrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.InstanceACLGrid_ItemDataBound);
  110. }
  111. #endregion
  112.         private void InstanceACLGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  113. {
  114. if(
  115. e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Header && 
  116. e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Footer)
  117. {
  118. CheckBox box = new System.Web.UI.WebControls.CheckBox();
  119. this.SelectionCheckBoxes.Add(box);
  120. e.Item.Cells[0].Controls.Add(box);
  121. e.Item.Cells[2].Text = OThinker.H3.Server.Engine.Organization.GetFullName(e.Item.Cells[2].Text);
  122. // 授予权限 
  123. CheckBox administrator = new CheckBox();
  124. administrator.Enabled = false;
  125. if(e.Item.Cells[3].Text == "1")
  126. {
  127. administrator.Checked = true;
  128. }
  129. else
  130. {
  131. administrator.Checked = false;
  132. }
  133. e.Item.Cells[3].Controls.Add(administrator);
  134. // 查看
  135. CheckBox view = new CheckBox();
  136. view.Enabled = false;
  137. if(e.Item.Cells[4].Text == "1")
  138. {
  139. view.Checked = true;
  140. }
  141. else
  142. {
  143. view.Checked = false;
  144. }
  145. e.Item.Cells[4].Controls.Add(view);
  146. }
  147. }
  148. }
  149. }