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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13.     public partial class SetPassword : PortalPage
  14.     {
  15.         #region 参数
  16.         private string _EditID = OThinker.Organization.Unit.NullID;
  17.         protected string EditID
  18.         {
  19.             get
  20.             {
  21.                 if (this._EditID == OThinker.Organization.Unit.NullID)
  22.                 {
  23.                     this._EditID = HttpUtility.UrlDecode(this.Request.QueryString[Param_ID]);
  24.                 }
  25.                 return this._EditID;
  26.             }
  27.         }
  28.         #endregion
  29.         private EditUserType _EditMode = EditUserType.Unspecified;
  30.         /// <summary>
  31.         /// 是否是自己修改自己信息的模式
  32.         /// </summary>
  33.         protected EditUserType EditMode
  34.         {
  35.             get
  36.             {
  37.                 if (this._EditMode == EditUserType.Unspecified)
  38.                 {
  39.                     if (this.UserValidator.ValidateAdministrator())
  40.                     {
  41.                         this._EditMode = EditUserType.Admin;
  42.                     }
  43.                     else if (this.UserValidator.UserID == this.EditID)
  44.                     {
  45.                         this._EditMode = EditUserType.Profile;
  46.                     }
  47.                     else
  48.                     {
  49.                         this._EditMode = EditUserType.Unspecified;
  50.                     }
  51.                 }
  52.                 return this._EditMode;
  53.             }
  54.         }
  55.         private OThinker.Organization.User _EditUnit;
  56.         protected OThinker.Organization.User EditUnit
  57.         {
  58.             get
  59.             {
  60.                 if (this._EditUnit == null)
  61.                 {
  62.                     string id = null;
  63.                     switch (this.EditMode)
  64.                     {
  65.                         case EditUserType.Admin:
  66.                             id = this.EditID;
  67.                             break;
  68.                         case EditUserType.Profile:
  69.                             id = this.UserValidator.UserID;
  70.                             break;
  71.                         default:
  72.                             throw new NotImplementedException();
  73.                     }
  74.                     this._EditUnit = (OThinker.Organization.User)OThinker.H3.Server.Engine.Organization.GetUnit(id);
  75.                 } 
  76.                 return this._EditUnit;
  77.             }
  78.         }
  79.         protected void Page_Load(object sender, EventArgs e)
  80.         {
  81.             if (!this.IsPostBack)
  82.             {
  83.                 // 验证是否具有管理员权限
  84.                 if (this.EditMode == EditUserType.Unspecified)
  85.                 {
  86.                     this.NotifyMessage(LackOfAuth);
  87.                 }
  88.                 this.txtUserAlias.Text = this.EditUnit.Alias;
  89.                 this.txtUserName.Text = this.EditUnit.Name;
  90.                 this.txtDescription.Text = this.EditUnit.Description;
  91.             }
  92.         }
  93.         protected void lnkOk_Click(object sender, EventArgs e)
  94.         {
  95.             this.SavePassword();
  96.         }
  97.         protected void btnOk_Click(object sender, ImageClickEventArgs e)
  98.         {
  99.             this.SavePassword();
  100.         }
  101.         private void SavePassword()
  102.         {
  103.             this.EditUnit.Password = this.txtPassword.Text;
  104.             OThinker.H3.Server.Engine.Organization.UpdateUnit(this.UserValidator.UserID, this.EditUnit);
  105.             this.NotifyMessage("修改密码成功");
  106.         }
  107.     }
  108. }