示例#1
0
        private bool Check()
        {
            if (string.IsNullOrEmpty(this.txtUserName.Text.Trim()))
            {
                MessageBox.Show("请选择用户人员!", "提示");
                this.btnSelectUser.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(this.txtAccount.Text.Trim()))
            {
                MessageBox.Show("登录帐户不能为空!", "提示");
                this.txtAccount.Focus();
                return(false);
            }

            if (!FrameWork.Public.String.ValidMaxLengh(this.txtAccount.Text.Trim(), 20))
            {
                MessageBox.Show("登录帐户长度不能超过20个字符!", "提示");
                this.txtAccount.Focus();
                return(false);
            }
            //如果用户没有授权角色,提示
            if (roleOrgDictionary.Count == 0)
            {
                MessageBox.Show("没有给用户授权角色!", "提示");
                return(false);
            }

            //验证帐户是否已经存在
            try
            {
                string userId = "";

                if (currentUser != null)
                {
                    userId = currentUser.Id;
                }
                else if (origin != null)
                {
                    userId = origin.Id;
                }

                PrivilegeService _proxy = Common.Util.CreateProxy();
                using (_proxy as IDisposable)
                {
                    User _user = _proxy.GetUserByAccount(txtAccount.Text.Trim());
                    if (_user != null && _user.Id != userId)
                    {
                        MessageBox.Show("该登录帐户已经存在,请使用其他帐户!", "提示");
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "提示");
                return(false);
            }

            /*if (!Neusoft.Framework.Util.StringHelper.ValidMaxLengh(this.txtPassword.Text.Trim(), 20))
             * {
             *  MessageBox.Show("登录口令长度不能超过20个字符!", "提示");
             *  this.txtPassword.Focus();
             *  return false;
             * }
             *
             * if (txtPassword.Text.Trim() != txtConfirmPass.Text.Trim())
             * {
             *  MessageBox.Show("确认口令和登录口令不符,请重新输入!", "提示");
             *  txtConfirmPass.Focus();
             *  return false;
             * }*/

            if (!FrameWork.Public.String.ValidMaxLengh(this.txtMemo.Text.Trim(), 256))
            {
                MessageBox.Show("备注长度不能超过128个汉字!", "提示");
                this.txtMemo.Focus();
                return(false);
            }

            return(true);
        }