Exemplo n.º 1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo();
     WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(SessionUtil.GetAdminSession().AdminID);
     if (this.txtOldPwd.Text.Trim() == "")
     {
         MessageBox.Show(this, "原密码不能为空!");
     }
     else if (this.txtNewPwd.Text.Trim() == "")
     {
         MessageBox.Show(this, "新密码不能为空!");
     }
     else if (this.txtOkNewPwd.Text.Trim() == "")
     {
         MessageBox.Show(this, "新密码不能为空!");
     }
     else if (this.txtNewPwd.Text.Trim() != this.txtOkNewPwd.Text.Trim())
     {
         MessageBox.Show(this, "两次输入的新密码不一致!");
     }
     else if (WebProject.Common.Encrypt.MD5Encrypt.MD5(this.txtOldPwd.Text.Trim()) != model_AdminInfo.Password.ToString())
     {
         MessageBox.Show(this, "原密码不正确,请重新输入!");
     }
     else
     {
         model_AdminInfo.Password = WebProject.Common.Encrypt.MD5Encrypt.MD5(this.txtNewPwd.Text.Trim());
         bll_AdminInfo.Update(model_AdminInfo);
         LogManage.WriteLog(Request.UserHostAddress, "用户管理", "修改密码", "成功", "操作名:" + SessionUtil.GetAdminSession().AdminNo);
         MessageBox.ShowAndRedirect(this, "密码修改成功!", "Main.aspx");
     }
 }
Exemplo n.º 2
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Session["ZT_ADMIN"] == null)
     {
         Response.Redirect("Login.aspx");
     }
     else
     {
         if (Request["AdminID"] + "" == "")
         {
             Response.Redirect("RightsWarn.aspx");
         }
         else
         {
             if (CheckString.CheckSqlKeyWord(this.txtPassword.Text) == true)
             {
                 MessageBox.Show(this, "密码中请不要包含非法字段!");
                 return;
             }
             try
             {
                 WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo();
                 WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(Int32.Parse(Request["AdminID"].ToString()));
                 model_AdminInfo.RoleNo = this.txtRole.SelectedValue;
                 model_AdminInfo.IsLockedOut = this.txtIsLockedOut.SelectedValue;
                 model_AdminInfo.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo;
                 model_AdminInfo.LastUpdateDate = DateTime.Now;
                 if (this.txtPassword.Text.Trim() != "")
                 {
                     model_AdminInfo.Password = WebProject.Common.Encrypt.MD5Encrypt.MD5(this.txtPassword.Text.Trim());
                 }
                 bll_AdminInfo.Update(model_AdminInfo);
                 LogManage.WriteLog(Request.UserHostAddress, "用户管理", "修改用户", "成功", "用户名:" + model_AdminInfo.AdminNo + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo);
                 MessageBox.ShowAndRedirect(this, "修改用户信息成功!", "AdminList.aspx");
             }
             catch
             {
                 Response.Redirect("RightsWarn.aspx");
             }
         }
     }
 }
Exemplo n.º 3
0
 protected void btnLogin_Click(object sender, ImageClickEventArgs e)
 {
     if (this.txtAdminName.Text.Trim() == "")   //当用户名为空时触发的事件
     {
         MessageBox.Show(this, "用户名不能为空,请重新输入!");
         this.txtPassword.Text = "";
         this.txtCheckNum.Text = "";
         this.txtAdminName.Focus();
     }
     else
     {
         if (this.txtPassword.Text.Trim() == "")   //当密码为空时触发的事件
         {
             MessageBox.Show(this, "密码不能为空,请重新输入!");
             this.txtCheckNum.Text = "";
             this.txtPassword.Focus();
         }
         else
         {
             if (this.txtCheckNum.Text.Trim() == "")   //当验证码为空时触发的事件
             {
                 MessageBox.Show(this, "验证码不能为空,请重新输入!");
                 this.txtPassword.Text = "";
                 this.txtPassword.Focus();
             }
             else  //当所有项全部不为空时触发的事件
             {
                 if (this.txtCheckNum.Text.Trim().ToLower() != Session["validate_code"].ToString().ToLower())  //判断用户填写的验证码和生成的验证码是否一致,当不一致时触发的事件
                 {
                     MessageBox.Show(this, "验证码不正确,请重新输入!");
                     this.txtPassword.Text = "";
                     this.txtCheckNum.Text = "";
                     this.txtPassword.Focus();
                 }
                 else  //判断用户填写的验证码和生成的验证码是否一致,当一致时触发的事件
                 {
                     //判断用户名和密码中是否含有非法字段
                     if (CheckString.CheckSqlKeyWord(this.txtAdminName.Text) == true || CheckString.CheckSqlKeyWord(this.txtPassword.Text) == true)
                     {
                         MessageBox.ShowAndRedirect(this, "你的IP地址为:" + Page.Request.UserHostAddress + ",请不要输入非法字段!", "Login.aspx");
                     }
                     else
                     {
                         WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo();
                         DataSet ds = bll_AdminInfo.GetList("AdminNo='" + this.txtAdminName.Text.Trim() + "'");
                         if (ds.Tables[0].Rows.Count == 0)  //当用户名不存在触发的事件
                         {
                             MessageBox.Show(this, "用户名不存在,请重新输入!");
                             this.txtAdminName.Text = "";
                             this.txtPassword.Text = "";
                             this.txtCheckNum.Text = "";
                             this.txtAdminName.Focus();
                         }
                         else if (ds.Tables[0].Rows.Count > 0)
                         {
                             string PassWord = MD5Encrypt.MD5(this.txtPassword.Text.Trim());
                             if (ds.Tables[0].Rows[0]["Password"].ToString() != PassWord)
                             {
                                 MessageBox.Show(this, "密码错误,请重新输入!");
                                 this.txtPassword.Text = "";
                                 this.txtCheckNum.Text = "";
                                 this.txtPassword.Focus();
                             }
                             else
                             {
                                 if (ds.Tables[0].Rows[0]["IsLockedOut"].ToString() == "1")
                                 {
                                     MessageBox.Show(this, "此帐号已被禁用!");
                                     this.txtPassword.Text = "";
                                     this.txtCheckNum.Text = "";
                                     this.txtPassword.Focus();
                                 }
                                 else
                                 {
                                     if (ds.Tables[0].Rows[0]["RoleNo"].ToString() == "")
                                     {
                                         MessageBox.Show(this, "此帐号还没有被分配权限!");
                                         this.txtPassword.Text = "";
                                         this.txtCheckNum.Text = "";
                                         this.txtPassword.Focus();
                                     }
                                     else
                                     {
                                         int AdminID = 0;
                                         string AdminNo = "", AdminName = "", RoleNo = "";
                                         if (ds.Tables[0].Rows[0]["AdminID"].ToString() != "")
                                         {
                                             AdminID = Convert.ToInt32(ds.Tables[0].Rows[0]["AdminID"]);
                                         }
                                         if (ds.Tables[0].Rows[0]["AdminNo"].ToString() != "")
                                         {
                                             AdminNo = ds.Tables[0].Rows[0]["AdminNo"].ToString();
                                         }
                                         if (ds.Tables[0].Rows[0]["AdminName"].ToString() != "")
                                         {
                                             AdminName = ds.Tables[0].Rows[0]["AdminName"].ToString();
                                         }
                                         if (ds.Tables[0].Rows[0]["RoleNo"].ToString() != "")
                                         {
                                             RoleNo = ds.Tables[0].Rows[0]["RoleNo"].ToString();
                                         }
                                         WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo();
                                         string RoleName = "";
                                         DataSet ds2 = bll_RoleInfo.GetList(" RoleNo='" + RoleNo + "'");
                                         if (ds2.Tables[0].Rows.Count > 0)
                                         {
                                             if (ds2.Tables[0].Rows[0]["RoleName"].ToString() != "")
                                             {
                                                 RoleName = ds2.Tables[0].Rows[0]["RoleName"].ToString();
                                             }
                                         }
                                         AdminSession adminSession = new AdminSession(AdminID, AdminNo, AdminName, RoleNo, RoleName);
                                         SessionUtil.SaveAdminSession(adminSession);
                                         this.txtAdminName.Text = "";
                                         this.txtPassword.Text = "";
                                         this.txtCheckNum.Text = "";
                                         this.txtAdminName.Focus();
                                         LogManage.WriteLog(Request.UserHostAddress, "登陆退出", "系统登陆", "成功", " 管理员登陆系统");
                                         WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(AdminID);
                                         model_AdminInfo.LastLoginDate = DateTime.Now;
                                         bll_AdminInfo.Update(model_AdminInfo);
                                         Page.Response.Redirect("Index.aspx");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }