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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.HtmlControls;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. namespace OThinker.H3.Portal
  12. {
  13.     public partial class EditGroupChild : PortalPage
  14.     {
  15.         public const char Seperator = ';';
  16.         #region 参数
  17.         protected string EditID
  18.         {
  19.             get
  20.             {
  21.                 return HttpUtility.UrlDecode(this.Request.QueryString[Param_ID]);
  22.             }
  23.         }
  24.         private OThinker.Organization.Group _EditUnit;
  25.         protected OThinker.Organization.Group EditUnit
  26.         {
  27.             get
  28.             {
  29.                 if (this._EditUnit != null)
  30.                 {
  31.                     return this._EditUnit;
  32.                 }
  33.                 else if (EditID == null || EditID == "")
  34.                 {
  35.                     return null;
  36.                 }
  37.                 else
  38.                 {
  39.                     OThinker.Organization.Unit unit = OThinker.H3.Server.Engine.Organization.GetUnit(this.EditID);
  40.                     if (unit == null || unit.UnitType != OThinker.Organization.UnitType.Group)
  41.                     {
  42.                         return null;
  43.                     }
  44.                     this._EditUnit = (OThinker.Organization.Group)unit;
  45.                     return this._EditUnit;
  46.                 }
  47.             }
  48.         }
  49.         #endregion
  50.         protected void Page_Load(object sender, EventArgs e)
  51.         {
  52.             if (!this.IsPostBack)
  53.             {
  54.                 // 验证是否具有管理员权限
  55.                 if (!this.UserValidator.ValidateAdministrator())
  56.                 {
  57.                     this.NotifyMessage(LackOfAuth);
  58.                 }
  59.                 // 加载已有成员
  60.                 if (this.EditUnit.Children != null && this.EditUnit.Children.Length != 0)
  61.                 {
  62.                     foreach (string child in this.EditUnit.Children)
  63.                     {
  64.                         string name = OThinker.H3.Server.Engine.Organization.GetFullName(child);
  65.                         this.lstChild.Items.Add(new ListItem(name, child));
  66.                         this.txtSelectedIds.Text += child + Seperator;
  67.                     }
  68.                 }
  69.                 // 添加子成员
  70.                 HtmlButton btnAdd = new HtmlButton();
  71.                 btnAdd.Attributes.Add("id", "btnAdd");
  72.                 btnAdd.InnerText = "添加";
  73.                 btnAdd.Attributes.Add(
  74.                     "onclick",
  75.                     "javascript:selectedUser('" + this.txtChild.User.ClientID + "', '" + this.txtChild.UserIDs.ClientID + "', '" + this.lstChild.ClientID + "', '" + this.txtSelectedIds.ClientID + "');");
  76.                 this.PlaceHolderEdit.Controls.Add(btnAdd);
  77.                 // 删除子成员
  78.                 HtmlButton btnDel = new HtmlButton();
  79.                 btnDel.InnerText = "删除";
  80.                 btnDel.Attributes.Add(
  81.                     "onclick",
  82.                     "javascript:removeUser('" + this.lstChild.ClientID + "', '" + this.txtSelectedIds.ClientID + "');");
  83.                 this.PlaceHolderEdit.Controls.Add(btnDel);
  84.             }
  85.         }
  86.         protected void lnkOk_Click(object sender, EventArgs e)
  87.         {
  88.             string[] children = null;
  89.             if (this.txtSelectedIds.Text != null && this.txtSelectedIds.Text != "")
  90.             {
  91.                 children = this.txtSelectedIds.Text.Split(new char[]{Seperator});
  92.             }
  93.             System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
  94.             if (children != null)
  95.             {
  96.                 foreach (string child in children)
  97.                 {
  98.                     if (child != null && child != "")
  99.                     {
  100.                         list.Add(child);
  101.                     }
  102.                 }
  103.             }
  104.             this.EditUnit.Children = list.ToArray();
  105.             OThinker.Organization.HandleResult result = OThinker.H3.Server.Engine.Organization.UpdateUnit(this.UserValidator.UserID, this.EditUnit);
  106.             this.NotifyResult(result);
  107.         }
  108.     }
  109. }