Esempio n. 1
0
        private void DoSave()
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                decimal?old = _userInfo.ROLE_ID;
                try
                {
                    _userInfo.ROLE_ID = SELECT_ROLE.ID;
                    Maticsoft.BLL.SMT_USER_INFO userBll = new Maticsoft.BLL.SMT_USER_INFO();
                    userBll.Update(_userInfo);
                    SmtLog.InfoFormat("用户", "修改用户:{0},角色:{1}成功.", _userInfo.USER_NAME, _userInfo.ROLE_ID + ":" + SELECT_ROLE.ROLE_NAME);
                    this.Invoke(new Action(() =>
                    {
                        _userInfo.ROLE_NAME = SELECT_ROLE.ROLE_NAME + "(点击修改)";
                        this.DialogResult   = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    _userInfo.ROLE_ID = old;
                    WinInfoHelper.ShowInfoWindow(this, "保存失败:" + ex.Message);
                    log.Error("保存授权角色失败:", ex);
                }
            });

            waiting.Show(this);
        }
Esempio n. 2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (tbUserName.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空!");
                return;
            }
            if (_userInfo == null)
            {
                _userInfo    = new Maticsoft.Model.SMT_USER_INFO();
                _userInfo.ID = -1;
            }
            string oldUser = _userInfo.USER_NAME;

            _userInfo.USER_NAME = tbUserName.Text.Trim();
            _userInfo.PASS_WORD = tbPwd.Text;
            if (_userInfo.PASS_WORD == "123456")
            {
                _userInfo.PASS_WORD = "e10adc3949ba59abbe56e057f20f883e";
            }
            _userInfo.REAL_NAME = tbRealName.Text.Trim();
            _userInfo.IS_ENABLE = cbEnable.Checked;
            _userInfo.TELEPHONE = tbTel.Text.Trim();
            _userInfo.ADDRESS   = tbAddress.Text.Trim();
            _userInfo.EMAIL     = tbEmail.Text.Trim();
            _userInfo.QQ        = tbQQ.Text.Trim();
            _userInfo.KEY_VAL   = "";
            _userInfo.IS_DELETE = false;
            if (cboRole.SelectedItem != null)
            {
                ComboItem cboItem = (ComboItem)cboRole.SelectedItem;
                Maticsoft.Model.SMT_ROLE_INFO roleInfo = (Maticsoft.Model.SMT_ROLE_INFO)cboItem.Tag;
                _userInfo.ROLE_ID   = roleInfo.ID;
                _userInfo.ROLE_NAME = roleInfo.ROLE_NAME;
            }
            else
            {
                _userInfo.ROLE_ID = -1;
            }
            if (cbtDept.SelectedNode != null)
            {
                Maticsoft.Model.SMT_ORG_INFO orgInfo = (Maticsoft.Model.SMT_ORG_INFO)cbtDept.SelectedNode.Tag;
                _userInfo.ORG_ID    = orgInfo.ID;
                _userInfo.DEPT_NAME = orgInfo.ORG_NAME;
            }
            else
            {
                _userInfo.ORG_ID = -1;
            }
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_USER_INFO userBll = new Maticsoft.BLL.SMT_USER_INFO();
                    if (_userInfo.ID == -1)
                    {
                        userBll.Add(_userInfo);
                        SmtLog.InfoFormat("用户", "添加用户:用户名={0},状态={1}", _userInfo.USER_NAME, _userInfo.IS_ENABLE);
                    }
                    else
                    {
                        userBll.Update(_userInfo);
                        SmtLog.InfoFormat("用户", "更新用户:用户名={0},状态={1},原始用户名={2}", _userInfo.USER_NAME, _userInfo.IS_ENABLE, oldUser);
                    }
                    this.BeginInvoke(new Action(() =>
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存用户异常:" + ex.Message);
                    log.Error("保存用户异常:", ex);
                }
            });

            waiting.Show(this);
        }