Exemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Save_Click(object sender, EventArgs e)
        {
            string pwd_old  = textBox_Pwd_Old.Text;
            string pwd_new  = textBox_Pwd_New.Text;
            string pwd_new2 = textBox_Pwd_New2.Text;

            label_Err_Pwd_Old.Text  = "";
            label_Err_Pwd_New.Text  = "";
            label_Err_Pwd_New2.Text = "";

            #region 密码验证

            if (string.IsNullOrEmpty(pwd_old))
            {
                label_Err_Pwd_Old.Text = "原密码不能为空";
                return;
            }
            label_Err_Pwd_Old.Text = "";

            if (string.IsNullOrEmpty(pwd_new))
            {
                label_Err_Pwd_New.Text = "新密码不能为空";
                return;
            }
            label_Err_Pwd_New.Text = "";

            if (pwd_new != pwd_new2)
            {
                label_Err_Pwd_New2.Text = "两次密码不一致";
                return;
            }
            label_Err_Pwd_New2.Text = "";



            pwd_old = _usersBll.GetMD5(pwd_old);

            if (pwd_old != _curUser.Password)
            {
                label_Err_Pwd_Old.Text = "原密码错误";
                return;
            }
            label_Err_Pwd_Old.Text = "";

            #endregion

            pwd_new = _usersBll.GetMD5(pwd_new);

            if (_usersBll.EditPwd(_curUser, pwd_new) > 0)
            {
                _curUser.Password = pwd_new;
                this.Dispose();
            }
            else
            {
                label_Err_Pwd_New.Text = "密码修改失败";
            }
        }