private void ucBtnExt1_BtnClick(object sender, EventArgs e)
        {
            var b1 = validateUserID.Verification(txtUserID);
            var b2 = validatePassword1.Verification(txtPassword1);

            validatePassword2.SetVerificationErrorMsg(txtPassword2, "非法输入");
            validatePassword2.SetVerificationModel(txtPassword2, HZH_Controls.Controls.VerificationModel.Custom);
            validatePassword2.SetVerificationRequired(txtPassword2, true);
            validatePassword2.SetVerificationCustomRegex(txtPassword2, $"^{txtPassword1.Text}$");
            var b3 = validatePassword2.Verification(txtPassword2);
            var b4 = validateNewPassword.Verification(txtNewPassword);

            if (b1 == false || b2 == false || b3 == false || b4 == false)
            {
                return;
            }
            try
            {
                CreateGenericCode cre = new CreateGenericCode();
                var oldPwd            = cre.CreateSHA256Code(txtPassword1.Text);
                //首先验证是否可以登录
                T_UserBll bll = new T_UserBll();
                try
                {
                    var res = bll.ModelOptionLoad(-1, -1, -1, txtUserID.Text, oldPwd);
                    if (res == null)
                    {
                        throw new ArgumentException("账户或密码错误无法登录!");
                    }
                    var newPwd    = cre.CreateSHA256Code(txtNewPassword.Text);
                    var updateRes = bll.UpdatePassword(txtUserID.Text, newPwd);
                    if (updateRes)
                    {
                        FrmDialog.ShowDialog(this, "修改成功请退出重新登陆");
                        Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        Close();
                    }
                    else
                    {
                        throw new ArgumentException("无法保存!");
                    }
                }
                catch
                {
                    throw;
                }
                //修改成功后,立即退出重新启动
            }
            catch (ArgumentException ex)
            {
                FrmDialog.ShowDialog(this, ex.Message);
            }catch (Exception ex)
            {
                FrmDialog.ShowDialog(this, "未知错误");
            }
        }
Esempio n. 2
0
        private void FrmLog_Load(object sender, EventArgs e)
        {
            ICreateValidateCode       genericCode = new CreateGenericCode();
            ISetValidateControlConfig setValidateControlConfig = new ControlSet();
            var code = genericCode.CreateMemoryValidateCode();

            txtMemCode.Text = code;
            setValidateControlConfig.SetValidateControl(txtAcc, verAccountValidate, @"^[0-9]{8,15}$", "请输入正确的用户名");
            verPwdValidate.SetVerificationErrorMsg(txtPwd, "请输入正确的密码");

            setValidateControlConfig.SetValidateControl(txtPwd, verPwdValidate, @"^(?=.*[a-z]).{8,}$", "请输入正确的密码");

            setValidateControlConfig.SetValidateControl(txtValidateCode, verValidateCode, string.Format(@"^({0}|{1})$", code, code.ToLower()), "请输入正确的验证码");
        }
Esempio n. 3
0
        private void ucBtnExt1_BtnClick(object sender, EventArgs e)
        {
            txtValidateCode.InputText = txtValidateCode.InputText.ToLower();
            bool accValResult     = verAccountValidate.Verification(txtAcc);
            bool pwdValResult     = verPwdValidate.Verification(txtPwd);
            bool memValCodeResult = verValidateCode.Verification(txtValidateCode);

            try
            {
                if (accValResult && pwdValResult && memValCodeResult)
                {
                    //输入合法,且验证码正确,此时验证账户密码是否正确
                    //使用T_UserDAl
                    T_UserDAl        dal          = new T_UserDAl();
                    ICreateSha256Pwd createSha256 = new
                                                    CreateGenericCode();
                    string sha256PWD = createSha256.CreateSHA256Code(txtPwd.Text);
                    object obj       = dal.ValidateAccount(txtAcc.InputText, sha256PWD);
                    //obj!=null;表示返回了用户权限,此时我们可以使用Convert.ToInt32(obj);
                    if (obj != null)
                    {
                        user = new T_User(txtAcc.InputText, Convert.ToInt32(obj));
                        //打开主界面窗体
                        FrmMain main = new FrmMain();
                        Hide();
                        main.ShowDialog();
                        Dispose();
                        return;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
            catch {
                ICreateValidateCode       genericCode = new CreateGenericCode();
                ISetValidateControlConfig setValidateControlConfig = new ControlSet();
                var code = genericCode.CreateMemoryValidateCode();
                txtMemCode.Text = code;
                setValidateControlConfig.SetValidateControl(txtValidateCode, verValidateCode, string.Format(@"^({0}|{1})$", code, code.ToLower()), "请输入正确的验证码");
            }
        }