コード例 #1
0
ファイル: UserEdit.cs プロジェクト: s1366560/hrd_bio
        private void ButSave_Click(object sender, EventArgs e)
        {
            string OldPsw = EncryptionText.EncryptDES(TxtOldPassword.Text.Trim(), KeyManager.PWDKey);

            if (OldPsw != userInfo.UserPassword)
            {
                this.LabOldPswDisplay.Text      = "* 该密码与您之前使用的密码不一致!";
                this.LabOldPswDisplay.ForeColor = c;
                this.TxtOldPassword.Focus();
                return;
            }
            if (TxtPassword.Text.Trim().Length >= 23)
            {
                this.LabUserPassword.Text      = "* 新密码长度不能超过22位!";
                this.LabUserPassword.ForeColor = c;
                this.TxtPassword.Focus();
                return;
            }
            else if (TxtPassword.Text.Trim().Length < 6)
            {
                this.LabUserPassword.Text      = "* 新密码长度不能少于6位!";
                this.LabUserPassword.ForeColor = c;
                this.TxtPassword.Focus();
                return;
            }
            if (TxtAffirmPassword.Text.Trim() != TxtPassword.Text.Trim())
            {
                this.LabAffirmPassw.Text      = "* 密码不匹配,请新输入!";
                this.LabAffirmPassw.ForeColor = c;
                this.TxtAffirmPassword.Focus();
                return;
            }
            else
            {
                this.LabAffirmPassw.Text = "";
            }

            userInfo.UserID       = TxtAccount.Text.Trim();
            userInfo.UserName     = TxtName.Text.Trim();
            userInfo.UserPassword = EncryptionText.EncryptDES(TxtPassword.Text.Trim(), KeyManager.PWDKey);
            int iCount = new SystemUserManagement().IUpdateCommonUserInfo(userInfo);

            if (iCount > 0)
            {
                PassUserInfoEditEvent(userInfo);
                this.Invoke(new EventHandler(delegate
                {
                    UserLoginInfo.SetUserLogInfo(userInfo);
                    MessageBox.Show("用户修改成功!");
                    this.Close(); this.Dispose();
                }));
            }
            else
            {
                this.Invoke(new EventHandler(delegate { MessageBox.Show("用户修改失败!"); this.Close(); this.Dispose(); }));
            }
        }
コード例 #2
0
ファイル: UserCommon.cs プロジェクト: s1366560/hrd_bio
        private void ButSave_Click(object sender, EventArgs e)
        {
            UserInfo u = userInfoList.SingleOrDefault(t => t.UserID == TxtAccount.Text.Trim());

            if (u != null)
            {
                if (u.UserID.Contains(TxtAccount.Text.Trim()))
                {
                    this.LabAccountPropmt.Text = "* 该账号已被使用,请重新输入!";
                    this.LabName.ForeColor     = c;
                    this.TxtAccount.Focus();
                    return;
                }
            }
            if (System.Text.Encoding.Default.GetBytes(TxtName.Text).Length < 2)
            {
                this.LabName.Text      = "* 账号名称长度不能小于4位!";
                this.LabName.ForeColor = c;
                this.TxtName.Focus();
                return;
            }
            if (System.Text.Encoding.Default.GetBytes(TxtName.Text).Length >= 15)
            {
                this.LabName.Text      = "* 账号名称长度不能超过14位!";
                this.LabName.ForeColor = c;
                this.TxtName.Focus();
                return;
            }
            if (System.Text.Encoding.Default.GetBytes(TxtAccount.Text.Trim()).Length < 4)
            {
                this.LabAccountPropmt.Text      = "* 账号长度不能小于4位!";
                this.LabAccountPropmt.ForeColor = c;
                this.TxtAccount.Focus();
                return;
            }
            if (TxtAccount.Text.Trim().Length >= 19)
            {
                this.LabAccountPropmt.Text      = "* 账号长度不能超过18位!";
                this.LabAccountPropmt.ForeColor = c;
                this.TxtAccount.Focus();
                return;
            }
            if (TxtPassword.Text.Trim().Length >= 23)
            {
                this.LabUserPassword.Text      = "* 密码长度不能超过22位!";
                this.LabUserPassword.ForeColor = c;
                this.TxtPassword.Focus();
                return;
            }
            else if (TxtPassword.Text.Trim().Length < 6)
            {
                this.LabUserPassword.Text      = "* 密码长度不能少于6位!";
                this.LabUserPassword.ForeColor = c;
                this.TxtPassword.Focus();
                return;
            }
            if (TxtAffirmPassword.Text.Trim() != TxtPassword.Text.Trim())
            {
                this.LabAffirmPassw.Text      = "* 密码不匹配,请新输入!";
                this.LabAffirmPassw.ForeColor = c;
                this.TxtAffirmPassword.Focus();
                return;
            }
            else
            {
                this.LabAffirmPassw.Text = "";
            }

            UserInfo userInfo = new UserInfo();

            userInfo.UserID       = TxtAccount.Text.Trim();
            userInfo.UserName     = TxtName.Text.Trim();
            userInfo.UserPassword = EncryptionText.EncryptDES(TxtPassword.Text.Trim(), KeyManager.PWDKey);
            int iCount = new SystemUserManagement().AddUserInfo("AddUserInfo", userInfo);

            if (iCount > 0)
            {
                PassUserInfoEvent(userInfo);
                this.Invoke(new EventHandler(delegate
                {
                    MessageBox.Show("用户创建成功!");
                    this.Close(); this.Dispose();
                }));
            }
            else
            {
                this.Invoke(new EventHandler(delegate { MessageBox.Show("用户创建失败!"); this.Close(); this.Dispose(); }));
            }
        }