Exemplo n.º 1
0
        private void btnAddNewUser_Click(object sender, EventArgs e)
        {
            AddNewUserForm addForm = new AddNewUserForm();

            if (addForm.ShowDialog() == DialogResult.OK)
            {
                LoadData();
            }
        }
Exemplo n.º 2
0
        private void addNewUserButton_Click(object sender, EventArgs e)
        {
            using (var form = new AddNewUserForm())
            {
                DialogResult result = form.ShowDialog(this);
                if (result != DialogResult.OK)
                {
                    return;
                }

                if (userManager.UserNameExists(form.UserName))
                {
                    Util.ShowErrorMessage("该用户名已经存在!");
                    return;
                }

                var user = new User(form.UserName, form.PassWord);
                user.Roles.Add("Users");

                this.userManager.AddUser(user);
                this.usersIsDirty = true;
            }
        }