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(); }
void frmAddRole_Load(object sender, EventArgs e) { // _unitCollection = GetSubUnit(); //修改角色 if (_origin != null) { this.txtRoleName.Text = _origin.Name;//角色名称 //this.txtUnitName.Text = getUnitByID(_origin.AppId, _origin.UnitId).Name; //this.txtUnitName.Tag = _origin.AppId + "||" + _origin.UnitId; this.txtMemo.Text = _origin.Description; //获得角色包含的用户 try { PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { //用于表更改,修改了SQL语句Security.Org.User.GetByRoleID _userCollection = _proxy.QueryUser(_origin.ID); } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); return; } AddUserOfRole(); } else//新增角色 { ////组织单元默认为上级角色的所属单元 //this.txtUnitName.Text = getUnitByID(_parent.AppId, _parent.UnitId).Name; //this.txtUnitName.Tag = _parent.AppId + "||" + _parent.UnitId; } this.txtParentName.Text = _parent.Name; }