Пример #1
0
        private void InitEvent()
        {
            this.Load += new EventHandler(delegate(object sender, EventArgs args) {
                this.tbUserName.Focus();
                if (FirstCreate)
                {
                    this.parentForm.FormTitleText = InputBoxTitle.WizardCreateAdmin;
                }
                this.rbUser.Enabled  = !FirstCreate;
                this.rbAdmin.Checked = FirstCreate;
                this.rbUser.Checked  = !FirstCreate;
            });
            #region username
            this.tbUserName.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                ((TextBox)sender).Text = ((TextBox)sender).Text.Trim();
                if (Common.TextBoxChecked((TextBox)sender))
                {
                    //判断用户名是否使用过
                    UserInfo user = processor.QueryOne <UserInfo>("select * from userinfo where username=@username COLLATE NOCASE", delegate()
                    {
                        Dictionary <string, object> dic = new Dictionary <string, object>();
                        dic.Add("username", tbUserName.Text.Trim().ToLower());
                        return(dic);
                    });
                    if (user.Userid == 0)
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbUserNameTip);
                    }
                    else
                    {
                        Common.SetToolTip(this.wrongTip, this.pbUserNameTip, Messages.UserNameOccupied);
                    }
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbUserNameTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region fullname
            this.tbFullName.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked((TextBox)sender))
                {
                    Common.ClearToolTip(this.wrongTip, this.pbFullNameTip);
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbFullNameTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region desc
            this.tbDescription.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbDescription))
                {
                    Common.ClearToolTip(this.wrongTip, this.pbRoleTip);
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbRoleTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region pwd
            this.tbPwd.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbPwd))
                {
                    //判断密钥长度
                    if (Common.Policy == null)
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbPasswordTip);
                    }
                    else
                    {
                        if (tbPwd.Text.TrimEnd().Length >= Common.Policy.MinPwdSize)
                        {
                            Common.ClearToolTip(this.wrongTip, this.pbPasswordTip);
                        }
                        else
                        {
                            Common.SetToolTip(this.wrongTip, this.pbPasswordTip, string.Format(Messages.PasswordShortThanDefined, Common.Policy.MinPwdSize));
                        }
                    }
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbPasswordTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region confirm
            this.tbConfirm.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbConfirm))
                {
                    if (Common.PasswordConfirmed(tbPwd, tbConfirm))
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbConfirmPasswordTip);
                    }
                    else
                    {
                        Common.SetToolTip(this.wrongTip, this.pbConfirmPasswordTip, Messages.MismatchPassword);
                    }
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbConfirmPasswordTip, Messages.EmptyContentError);
                }
            });
            #endregion

            this.initGroupRadioCheckEvent();
            //非法字符处理事件
            this.tbUserName.TextChanged += new EventHandler((sender, e) => {
                Utils.IsInputTextValid(this.tbUserName);
            });
            this.tbFullName.TextChanged += new EventHandler((sender, e) =>
            {
                Utils.IsInputTextValid(this.tbFullName);
            });
        }
Пример #2
0
        private void InitEventsForTextBoxValidation()
        {
            this.tbPwd.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbPwd))
                {
                    //判断密钥长度
                    if (Common.Policy == null)
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbPasswordTip);
                    }
                    else
                    {
                        if (tbPwd.Text.TrimEnd().Length >= Common.Policy.MinPwdSize)
                        {
                            Common.ClearToolTip(this.wrongTip, this.pbPasswordTip);
                        }
                        else
                        {
                            this.pbPasswordTip.Visible = true;
                            this.wrongTip.SetToolTip(this.pbPasswordTip, string.Format(Messages.PasswordShortThanDefined, Common.Policy.MinPwdSize));
                        }
                    }
                }
                else
                {
                    this.pbPasswordTip.Visible = true;
                    this.wrongTip.SetToolTip(this.pbPasswordTip, Messages.EmptyContentError);
                }
            });
            /*密码确认*/
            this.tbConfirm.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbConfirm))
                {
                    if (Common.PasswordConfirmed(tbPwd, tbConfirm))
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbConfirmPasswordTip);
                    }
                    else
                    {
                        this.pbConfirmPasswordTip.Visible = true;
                        this.wrongTip.SetToolTip(this.pbConfirmPasswordTip, Messages.MismatchPassword);
                    }
                }
                else
                {
                    this.pbConfirmPasswordTip.Visible = true;
                    this.wrongTip.SetToolTip(this.pbConfirmPasswordTip, Messages.EmptyContentError);
                }
            });

            this.tbFullName.Leave += new EventHandler((sender, args) => {
                if (Common.TextBoxChecked(this.tbFullName))
                {
                    Common.ClearToolTip(this.wrongTip, this.pbFullNameTip);
                }
                else
                {
                    this.pbFullNameTip.Visible = true;
                    this.wrongTip.SetToolTip(this.pbFullNameTip, Messages.EmptyContentError);
                }
            });

            this.tbDescription.Leave += new EventHandler((sender, args) =>
            {
                if (Common.TextBoxChecked(this.tbDescription))
                {
                    Common.ClearToolTip(this.wrongTip, this.pbRoleTip);
                }
                else
                {
                    this.pbRoleTip.Visible = true;
                    this.wrongTip.SetToolTip(this.pbRoleTip, Messages.EmptyContentError);
                }
            });
        }
Пример #3
0
 /// <summary>
 /// 初始化事件
 /// </summary>
 private void InitEvent()
 {
     /*新密码校验*/
     this.tbNewPwd.Leave += new EventHandler(delegate(object sender, EventArgs args)
     {
         if (Common.TextBoxChecked(tbNewPwd))
         {
             //判断密钥长度
             if (Common.Policy == null)
             {
                 Common.ClearToolTip(this.wrongTip, this.pbNewPasswordTip);
             }
             else
             {
                 if (tbNewPwd.Text.TrimEnd().Length >= Common.Policy.MinPwdSize)
                 {
                     if (tbNewPwd.Text.TrimEnd() != Common.User.Pwd)
                     {
                         Common.ClearToolTip(this.wrongTip, this.pbNewPasswordTip);
                     }
                     else
                     {
                         Common.SetToolTip(this.wrongTip, this.pbNewPasswordTip, Messages.NewSameOfOldWhenResetPassword);
                     }
                 }
                 else
                 {
                     Common.SetToolTip(this.wrongTip, this.pbNewPasswordTip, string.Format(Messages.PasswordShortThanDefined, Common.Policy.MinPwdSize));
                 }
             }
         }
         else if (!Common.TextBoxChecked(tbNewPwd))
         {
         }
     });
     /*密码确认*/
     this.tbConfirm.Leave += new EventHandler(delegate(object sender, EventArgs args)
     {
         if (Common.TextBoxChecked(tbConfirm))
         {
             if (Common.PasswordConfirmed(tbNewPwd, tbConfirm))
             {
                 Common.ClearToolTip(this.wrongTip, this.pbConfirmNewPasswordTip);
             }
             else
             {
                 Common.SetToolTip(this.wrongTip, this.pbConfirmNewPasswordTip, Messages.MismatchPassword);
             }
         }
         else
         {
         }
     });
     /*保存修改后的密码*/
     this.btnOK.Click += new EventHandler(delegate(object sender, EventArgs args)
     {
         OK();
     });
     /*确认密码回车*/
     this.tbConfirm.KeyPress += new KeyPressEventHandler(delegate(object sender, KeyPressEventArgs args)
     {
         if (args.KeyChar == 13)
         {
             OK();
         }
     });
     tbNewPwd.KeyPress += new KeyPressEventHandler((sender, args) =>
     {
         if (args.KeyChar == 13)
         {
             tbConfirm.Focus();
         }
     });
 }