예제 #1
0
        private void btnSelectUser_Click(object sender, EventArgs e)
        {
            SelectItemForm <IPerson> frmSelect = new SelectItemForm <IPerson>();

            frmSelect.Id          = "Id";
            frmSelect.Value       = "Name";
            frmSelect.Description = "Remark";
            frmSelect.SecondKey   = "AppId";
            frmSelect.InitItem(persons);
            frmSelect.ShowDialog();

            if (frmSelect.DialogResult == DialogResult.OK)
            {
                IPerson person = frmSelect.SelectedItem;
                this.txtUserName.Text = person.Name;

                ///判断该用户是否已经增加,如果增加检索出该用户
                IUser user = IsExistUser(person.AppId, person.Id);

                if (user != null)
                {
                    ModifyUser(user);
                    origin = user;

                    //获得用户所属角色
                    GetRoleOrgMapping();
                    //初始化角色树的Checked属性
                    InitRoleTreeChecked();
                }
                else
                {
                    origin = null;

                    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();
        }
예제 #2
0
        void btnSelectUser_Click(object sender, EventArgs e)
        {
            SelectItemForm <IPerson> _frmSelect = new SelectItemForm <IPerson>();

            _frmSelect.Id          = "Id";
            _frmSelect.Value       = "Name";
            _frmSelect.Description = "Remark";
            _frmSelect.SecondKey   = "AppId";
            _frmSelect.InitItem(_persons);

            if (_frmSelect.ShowDialog() == DialogResult.OK)
            {
                IPerson _person = _frmSelect.SelectedItem;
                this.txtUserName.Text = _person.Name;

                ///判断该用户是否已经增加,如果增加检索出该用户
                ///
                IUser _user = IsExistUser(_person.AppId, _person.Id);

                if (_user != null)
                {
                    ModifyUser(_user);
                    _origin = _user;
                }
                else
                {
                    _origin = null;

                    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          = "";

                    //新用户,默认一个角色
                    NewRole();

                    this.txtAccount.Focus();
                    this.txtAccount.SelectAll();
                }
            }

            _frmSelect.Dispose();
        }