Пример #1
0
        //确定
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!VerifyUserInput())
            {
                return;
            }

            MyUtil.SetLoginPassword(txtNewPassword.Text.Trim());
            MessageBox.Show(this, "操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //----
            this.Close();
        }
Пример #2
0
        private bool VerifyUserInput()
        {
            if (txtOldPassword.Text.Trim() == "")
            {
                MessageBox.Show(this, "请输入旧密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtOldPassword.Focus();
                return(false);
            }
            //----
            if (txtNewPassword.Text.Trim() == "")
            {
                MessageBox.Show(this, "请输入新密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNewPassword.Focus();
                return(false);
            }
            if (txtNewPassword2.Text.Trim() == "")
            {
                MessageBox.Show(this, "请确认新密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNewPassword2.Focus();
                return(false);
            }

            if (txtNewPassword.Text.Trim().Length < 6)
            {
                MessageBox.Show(this, "新密码不能少于6个字符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNewPassword.Focus();
                return(false);
            }

            if (txtNewPassword.Text != txtNewPassword2.Text)
            {
                MessageBox.Show(this, "两次输入的新密码不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNewPassword.Focus();
                return(false);
            }
            //----
            var oldPassword = MyUtil.GetLoginPassword();

            if (txtOldPassword.Text.Trim() != oldPassword.Trim())
            {
                MessageBox.Show(this, "旧密码不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtOldPassword.Focus();
                return(false);
            }
            //----
            return(true);
        }
Пример #3
0
        //确定
        private void btnOK_Click(object sender, EventArgs e)
        {
            var password = txtLoginPassword.Text.Trim();

            if (String.IsNullOrWhiteSpace(password))
            {
                txtLoginPassword.Focus();
                return;
            }

            var loginPassword = MyUtil.GetLoginPassword();

            if (password != loginPassword)
            {
                MessageBox.Show(this, "登录口令不正确!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtLoginPassword.Focus();
                return;
            }
            //------------------------
            this.Hide();
            var form = new FormMain();

            form.ShowDialog(this);
        }