SystemAcl.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace OThinker.H3.Portal
- {
- /// <summary>
- /// Summary description for AdministratorACL.
- /// </summary>
- public partial class SystemACL : PortalPage
- {
- protected void Page_Load(object sender, System.EventArgs e)
- {
- this.UserSelector.SelectUserUrl = PageName_SelectUser;
- this.UserSelector.SelectUserImageUrl = PageName_SelectUserImage;
- if(!this.IsPostBack)
- {
- // 验证是否具有管理员权限
- if (!this.UserValidator.ValidateAdministrator())
- {
- this.NotifyMessage(LackOfAuth);
- }
- this.WorkflowAclTable = OThinker.H3.Server.Engine.SystemAclManager.QueryDataTable();
- }
- this.SelectionCheckBoxes.Clear();
- this.WorkflowACLGrid.DataSource = this.WorkflowAclTable;
- this.WorkflowACLGrid.DataBind();
- }
- // CaseGrid对应的表
- private System.Data.DataTable WorkflowAclTable
- {
- get
- {
- return (System.Data.DataTable)this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLTable()];
- }
- set
- {
- this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLTable()] = value;
- }
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.imgAdd.Click += new System.Web.UI.ImageClickEventHandler(this.imgAdd_Click);
- this.imgDel.Click += new System.Web.UI.ImageClickEventHandler(this.imgDel_Click);
- this.WorkflowACLGrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.InstanceGrid_ItemDataBound);
- }
- #endregion
- #region 获得选中的ID
- private System.Collections.ArrayList SelectionCheckBoxes
- {
- get
- {
- if(this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLCheckBoxes()] == null)
- {
- this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLCheckBoxes()] = new System.Collections.ArrayList();
- }
- return (System.Collections.ArrayList)this.Session[OThinker.H3.WorkSheet.Sessions.GetAdministatorACLCheckBoxes()];
- }
- }
- // 获得选中的Acl ID
- private string[] GetSelectedACLs()
- {
- // 获得选中的
- System.Collections.Generic.List<string> selections = new System.Collections.Generic.List<string>();
- for(int count=0; count<this.SelectionCheckBoxes.Count; count++)
- {
- if(((System.Web.UI.WebControls.CheckBox)this.SelectionCheckBoxes[count]).Checked)
- {
- System.Data.DataRow row = this.WorkflowAclTable.Rows[count];
- selections.Add(row["ObjectID"].ToString());
- }
- }
- return selections.ToArray();
- }
- private void InstanceGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
- {
- if(
- e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Header &&
- e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Footer)
- {
- CheckBox box = new System.Web.UI.WebControls.CheckBox();
- this.SelectionCheckBoxes.Add(box);
- e.Item.Cells[0].Controls.Add(box);
- e.Item.Cells[2].Text = OThinker.H3.Server.Engine.Organization.GetFullName(e.Item.Cells[2].Text);
- // 发布新版本
- CheckBox administrator = new CheckBox();
- administrator.Enabled = false;
- if(e.Item.Cells[3].Text == "1")
- {
- administrator.Checked = true;
- }
- else
- {
- administrator.Checked = false;
- }
- e.Item.Cells[3].Controls.Add(administrator);
- // 发布新版本
- CheckBox publishWorkflow = new CheckBox();
- publishWorkflow.Enabled = false;
- if(e.Item.Cells[4].Text == "1")
- {
- publishWorkflow.Checked = true;
- }
- else
- {
- publishWorkflow.Checked = false;
- }
- e.Item.Cells[4].Controls.Add(publishWorkflow);
- // 查看报表
- CheckBox viewReport = new CheckBox();
- viewReport.Enabled = false;
- if (e.Item.Cells[5].Text == "1")
- {
- viewReport.Checked = true;
- }
- else
- {
- viewReport.Checked = false;
- }
- e.Item.Cells[5].Controls.Add(viewReport);
- }
- }
- #endregion
- protected void btnAdd_Click(object sender, System.EventArgs e)
- {
- this.Add();
- }
- private void imgAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- this.Add();
- }
- private void Add()
- {
- OThinker.H3.Acl.SystemAcl acl = new OThinker.H3.Acl.SystemAcl();
- acl.UserID = this.UserSelector.SelectedUser;
- acl.Administrator = this.chkAdministrator.Checked;
- acl.PublishWorkflow = this.chkPublishWorkflow.Checked;
- acl.ViewReport = this.chkViewReport.Checked;
- acl.CreateBy = this.UserValidator.UserID;
- acl.CreateTime = System.DateTime.Now;
- if(OThinker.H3.Server.Engine.SystemAclManager.Add(acl))
- {
- // 添加成功
- this.Response.Redirect(this.Request.Url.AbsolutePath);
- }
- else
- {
- // 添加不成功
- this.lblError.Text = "添加不成功";
- }
- }
- protected void btnDel_Click(object sender, System.EventArgs e)
- {
- this.Remove();
- }
- private void imgDel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- this.Remove();
- }
- private void Remove()
- {
- string[] ids = this.GetSelectedACLs();
- foreach (string id in ids)
- {
- OThinker.H3.Server.Engine.SystemAclManager.Delete(id);
- }
- // ERROR,显示删除成功
- this.Response.Redirect(this.Request.Url.AbsolutePath);
- }
- protected void btnUpdate_Click(object sender, EventArgs e)
- {
- string[] acls = this.GetSelectedACLs();
- if (acls.Length == 0)
- {
- // ERROR,导到错误页面上
- }
- else
- {
- this.Response.Redirect(PageName_UpdateSystemAcl + "?" + Param_AclID + "=" + acls[0]);
- }
- }
- }
- }