private void btnOK_Click(object sender, EventArgs e)
        {
            string  userName        = this.txtBoxMyName.Text.ToString();
            string  passWord        = this.txtBoxMyPassWord.Text.ToString();
            string  newPassword     = this.txtBoxNewPassWord.Text.ToString();
            string  confirmPassword = this.txtBoxConfirm.Text.ToString();
            BUUsers myBUUsers       = new BUUsers();
            string  md5_Password    = DbEncrypt.MD5Encrypt(passWord);
            string  md5_NewPassword = DbEncrypt.MD5Encrypt(newPassword);
            bool    isCheckPassword = myBUUsers.CheckUserPassword(userName, md5_Password);

            if (isCheckPassword)
            {
                if (newPassword == confirmPassword)
                {
                    bool check = myBUUsers.UpdateMyPassword(userName, md5_NewPassword);
                    if (check)
                    {
                        if (passWord != newPassword)
                        {
                            MessageBox.Show("密码修改成功", "恭喜您", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.txtBoxMyPassWord.Text  = string.Empty;
                            this.txtBoxNewPassWord.Text = string.Empty;
                            this.txtBoxConfirm.Text     = string.Empty;
                            this.txtBoxMyPassWord.Focus();
                        }
                        else if (passWord == newPassword)
                        {
                            MessageBox.Show("新密码与旧密码相同,请输入不同密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            this.txtBoxMyPassWord.Text  = string.Empty;
                            this.txtBoxNewPassWord.Text = string.Empty;
                            this.txtBoxConfirm.Text     = string.Empty;
                            this.txtBoxMyPassWord.Focus();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("您前后二次输入的密码不一致,请重新输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.txtBoxConfirm.Text = string.Empty;
                    this.txtBoxConfirm.Focus();
                }
            }
            else
            {
                MessageBox.Show("您输入的旧密码有误,请重新输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.txtBoxMyPassWord.Text = string.Empty;
                this.txtBoxMyPassWord.Focus();
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = this.textUserName.Text.Trim();
                string passWord = this.textBoxPwd.Text.Trim();

                //输入判断
                if (IsInput(userName, passWord))
                {
                    return;
                }
                bool IsCheckUser = false;
                IsCheckUser = myBULogin.CheckUser(userName);
                if (!IsCheckUser)
                {
                    this.lblErr.Text       = "用户不存在,请重新输入!";
                    this.textUserName.Text = "";
                    this.textUserName.Focus();
                    return;
                }
                bool   IsCheckPwd   = false;
                string md5_Password = DbEncrypt.MD5Encrypt(passWord);
                IsCheckPwd = myBULogin.IsCheckPwd(userName, md5_Password);
                if (!IsCheckPwd)
                {
                    this.lblErr.Text     = "密码错误,请重新输入";
                    this.textBoxPwd.Text = "";
                    this.textBoxPwd.Focus();
                    return;
                }
                this.lblErr.Text = "";
                this.Hide();


                Frmmain myFrmmain = new Frmmain(userName); //将this.textUserName.Text的值做为参数传给窗体Frmmail,并在下一步打开开窗体时,将this.textUserName.Text的值传给frmmain窗体
                myFrmmain.ShowDialog();
            }
            catch
            {
                MessageBox.Show("数据库连接失败,请确认数据库是否配置成功");
                return;
            }
        }