private void btnSelectUser_Click(object sender, EventArgs e) { SelectItemForm <Person> frmSelect = new SelectItemForm <Person>(); frmSelect.Id = "Id"; frmSelect.Value = "Name"; frmSelect.Description = "Remark"; frmSelect.SecondKey = "AppId"; frmSelect.InitItem(persons); frmSelect.ShowDialog(); if (frmSelect.DialogResult == DialogResult.OK) { Person person = frmSelect.SelectedItem; this.txtUserName.Text = person.Name; ///判断该用户是否已经增加,如果增加检索出该用户 User user = IsExistUser(person.AppId, person.Id); if (user != null) { ModifyUser(user); origin = user; //获得用户所属角色 GetRoleOrgMapping(); //初始化角色树的Checked属性 InitRoleTreeChecked(); } else { origin = null; //获得用户所属角色 roleOrgDictionary = new Dictionary <string, List <string> >(); //初始化角色树的Checked属性 InitRoleTreeChecked(); this.txtUserName.Text = person.Name; this.txtUserName.Tag = person.AppId + "||" + person.Id; this.txtAccount.Text = person.Id; this.chbOriginPass.Checked = true; this.chbLock.Checked = false; this.txtMemo.Text = ""; ////新用户,默认一个角色,把当前角色传过来作为默认角色 //allRolesOfUser.Add(currentRole); this.txtAccount.Focus(); this.txtAccount.SelectAll(); } } frmSelect.Dispose(); }
void btnAdd_Click(object sender, EventArgs e) { SelectItemForm <User> _frmSelect = new SelectItemForm <User>(); _frmSelect.Id = "Id"; _frmSelect.Value = "Name"; _frmSelect.Description = "Description"; IList <User> _users = null; try { PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { _users = _proxy.QueryUser(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); return; } _frmSelect.InitItem(_users); if (_frmSelect.ShowDialog() == DialogResult.OK) { User _user = _frmSelect.SelectedItem; if (_user == null) { return; } //存在该用户,提示返回 if (IsExistUser(_user)) { MessageBox.Show("角色下面已经存在该用户,不能重复添加!", "提示"); return; } //添加用户 AddUserToList(_user); _newUserID.Add(_user.Id); } _frmSelect.Dispose(); }