Exemplo n.º 1
0
        private void FrmRoleMgr_Load(object sender, EventArgs e)
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                    var models = roleBll.GetModelList("");
                    this.Invoke(new Action(() =>
                    {
                        foreach (var item in models)
                        {
                            AddModel(item);
                        }
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "加载角色异常:" + ex.Message);
                    log.Error("加载角色异常:", ex);
                }
            });

            waiting.Show(this, 300);
        }
Exemplo n.º 2
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (tbRoleName.Text.Trim() == "")
     {
         WinInfoHelper.ShowInfoWindow(this, "角色名称不能为空!");
         return;
     }
     if (_selectRow != null && dgvData.Rows.Contains(_selectRow))
     {
         Maticsoft.Model.SMT_ROLE_INFO role = (Maticsoft.Model.SMT_ROLE_INFO)_selectRow.Tag;
         role.ROLE_NAME = tbRoleName.Text.Trim();
         role.ROLE_DESC = tbRoleDesc.Text.Trim();
         CtrlWaiting waiting = new CtrlWaiting(() =>
         {
             try
             {
                 Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                 roleBll.Update(role);
                 SmtLog.InfoFormat("用户", "更新角色:ID={0},名称={1}", role.ID, role.ROLE_NAME);
                 this.Invoke(new Action(() =>
                 {
                     _selectRow.Cells[0].Value = role.ROLE_NAME;
                     _selectRow.Cells[1].Value = role.ROLE_DESC;
                 }));
             }
             catch (Exception ex)
             {
                 log.Error("更新角色异常:", ex);
                 WinInfoHelper.ShowInfoWindow(this, "更新角色异常:" + ex.Message);
             }
         });
         waiting.Show(this);
     }
 }
Exemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (tbRoleName.Text.Trim() == "")
            {
                WinInfoHelper.ShowInfoWindow(this, "角色名称不能为空!");
                return;
            }
            Maticsoft.Model.SMT_ROLE_INFO role = new Maticsoft.Model.SMT_ROLE_INFO();
            role.ROLE_NAME = tbRoleName.Text.Trim();
            role.ROLE_DESC = tbRoleName.Text.Trim();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                    role.ID = roleBll.Add(role);
                    SmtLog.InfoFormat("用户", "添加角色:ID={0},名称={1}", role.ID, role.ROLE_NAME);
                    this.Invoke(new Action(() =>
                    {
                        AddModel(role);
                    }));
                }
                catch (Exception ex)
                {
                    log.Error("添加角色异常:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "添加角色异常:" + ex.Message);
                }
            });

            waiting.Show(this);
        }
Exemplo n.º 4
0
        private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                DataGridViewRow row = dgvData.Rows[e.RowIndex];

                _selectRow = row;
                Maticsoft.Model.SMT_ROLE_INFO role = (Maticsoft.Model.SMT_ROLE_INFO)row.Tag;

                tbRoleName.Text = role.ROLE_NAME;
                tbRoleDesc.Text = role.ROLE_DESC;

                if (e.ColumnIndex >= 0)
                {
                    if (dgvData.Columns[e.ColumnIndex].Name == "ColPrivate")
                    {
                        DoSetPrivate();
                    }
                    else if (dgvData.Columns[e.ColumnIndex].Name == "ColDelete")
                    {
                        if (MessageBox.Show("确定删除该角色?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            CtrlWaiting waiting = new CtrlWaiting(() =>
                            {
                                try
                                {
                                    Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + role.ID);
                                    Maticsoft.BLL.SMT_ROLE_INFO roleInfo = new Maticsoft.BLL.SMT_ROLE_INFO();
                                    roleInfo.Delete(role.ID);
                                    SmtLog.InfoFormat("用户", "删除角色:ID={0},名称={1}", role.ID, role.ROLE_NAME);
                                    this.Invoke(new Action(() =>
                                    {
                                        dgvData.Rows.Remove(row);
                                        _selectRow      = null;
                                        tbRoleName.Text = "";
                                        tbRoleDesc.Text = "";
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    log.Error("删除角色异常:", ex);
                                    WinInfoHelper.ShowInfoWindow(this, "删除角色异常:" + ex.Message);
                                }
                            });
                            waiting.Show(this);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void ShowRoles(decimal orgId)
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                var roles = roleBll.GetModelList("ID IN (SELECT RF.ROLE_ID FROM SMT_ROLE_FUN RF WHERE RF.FUN_ID=" + orgId + " and RF.ROLE_TYPE=2)");
                this.Invoke(new Action(() =>
                {
                    DoShowRolesToGrid(roles);
                }));
            });

            waiting.Show(this);
        }
Exemplo n.º 6
0
        private void FrmRolesSelector_Load(object sender, EventArgs e)
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                    var models = roleBll.GetModelList("");
                    this.Invoke(new Action(() =>
                    {
                        this.advRoleTree.Nodes[0].Nodes.Clear();
                        if (models.Count == 0)
                        {
                            WinInfoHelper.ShowInfoWindow(this, "没有获取到角色列表!");
                            return;
                        }
                        foreach (var item in models)
                        {
                            Node node    = new Node(item.ROLE_NAME);
                            node.Tooltip = item.ROLE_DESC;
                            advRoleTree.Nodes[0].Nodes.Add(node);
                            node.Tag = item;
                            if (_selectedids != null && _selectedids.Count > 0)
                            {
                                if (_selectedids.Contains(item.ID))
                                {
                                    node.Checked = true;
                                }
                            }
                        }
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "加载角色列表异常:" + ex.Message);
                    log.Error("加载角色列表异常:", ex);
                }
            });

            waiting.Show(this);
        }
Exemplo n.º 7
0
        private void Init()
        {
            if (_userInfo != null)
            {
                this.Text = "编辑用户";
                if (_userInfo.USER_NAME == "admin")
                {
                    tbUserName.ReadOnly = true;
                    cboRole.Enabled     = false;
                }
                tbUserName.Text  = _userInfo.USER_NAME;
                tbPwd.Text       = _userInfo.PASS_WORD;
                tbRealName.Text  = _userInfo.REAL_NAME;
                cbEnable.Checked = _userInfo.IS_ENABLE;
                tbTel.Text       = _userInfo.TELEPHONE;
                tbAddress.Text   = _userInfo.ADDRESS;
                tbEmail.Text     = _userInfo.EMAIL;
                tbQQ.Text        = _userInfo.QQ;
            }
            else
            {
                this.Text = "新建用户";
            }
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    var depts = DeptDataHelper.GetDepts(true);
                    this.Invoke(new Action(() =>
                    {
                        var nodes = DeptDataHelper.ToTree(depts);
                        cbtDept.Nodes.AddRange(nodes.ToArray());
                        foreach (DevComponents.AdvTree.Node item in cbtDept.Nodes)
                        {
                            item.ExpandAll();
                        }
                        if (_userInfo != null && _userInfo.ORG_ID != null)
                        {
                            decimal id = (decimal)_userInfo.ORG_ID;
                            if (id >= 0)
                            {
                                var node = FindNode(id);

                                if (node != null)
                                {
                                    cbtDept.SelectedNode = node;
                                }
                            }
                        }
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "加载部门异常!" + ex.Message);
                    log.Error("加载部门异常:", ex);
                }
            });

            waiting.Show(this, 300);

            CtrlWaiting waiting1 = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                    var models = roleBll.GetModelList("");
                    this.Invoke(new Action(() =>
                    {
                        foreach (var item in models)
                        {
                            ComboItem cbi = new ComboItem(item.ROLE_NAME);
                            cbi.Tag       = item;
                            cboRole.Items.Add(cbi);
                            if (_userInfo != null && _userInfo.ROLE_ID != null && _userInfo.ROLE_ID == item.ID)
                            {
                                cboRole.SelectedItem = cbi;
                            }
                        }
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "加载角色异常!" + ex.Message);
                    log.Error("加载角色异常:", ex);
                }
            });

            waiting1.Show(this, 300);
        }