Пример #1
0
        async private void DeleteUser(string username)
        {
            var dt = serviceClient.GetUserInfo(username).Tables[0];

            if (dt.Rows.Count < 1)
            {
                return;
            }
            var roleID = dt.Rows[0][0].ToString();

            if (roleID == "0")//admin
            {
                return;
            }
            if (MessageBox.Show($"确认要删除用户【{username}】?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }
            int delV = await serviceClient.DeleteUserAsync(username);

            if (delV == 1)
            {
                SelectAllUser();
                MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            MessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #2
0
        async private void RegisterUser()
        {
            var username = this.tb_username.Text.Trim();
            var userpwd  = this.tb_pwd.Text.Trim();
            var userRpwd = this.tb_repwd.Text.Trim();
            var userType = this.cb_userType.SelectedIndex + 1;

            if (string.IsNullOrEmpty(userType.ToString()))
            {
                MessageBox.Show("用户类型不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrEmpty(username))
            {
                MessageBox.Show("用户名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(userpwd))
            {
                MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(userRpwd))
            {
                MessageBox.Show("确认密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataSet dataSet = serviceClient.GetUserInfo(username);

            if (dataSet.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show("用户已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tb_username.ForeColor = Color.Red;
                return;
            }
            tb_username.ForeColor = Color.Black;
            if (userpwd != userRpwd)
            {
                MessageBox.Show("两次密码不一致?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //校验密码复杂度
            if (!RegexHelper.IsMatchPassword(userpwd))
            {
                //密码复杂度不满足
                MessageBox.Show("密码必须包含数字、字母", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            MesService.RegisterResult registerResult = await serviceClient.RegisterAsync(username, userpwd, userType);

            if (registerResult == MesService.RegisterResult.REGISTER_SUCCESS)
            {
                //注册成功
                MessageBox.Show("注册成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #3
0
        private void SelectUserType()
        {
            var dt = mesService.GetUserInfo(tbx_username.Text).Tables[0];

            if (dt.Rows.Count < 1)
            {
                return;
            }
            CurrentUserType = int.Parse(dt.Rows[0][0].ToString());
        }