Пример #1
0
        void ModifyResource()
        {
            SelectedTreeListViewItemCollection _collect = _resTreeListMap[nTabControl1.SelectedTab.Name].SelectedItems;

            if (_collect == null || _collect.Count == 0 || _collect[0].Level == 0)
            {
                MessageBox.Show("请选择要待修改资源!", "提示");
                return;
            }

            AddPrivilegeForm _modify = new AddPrivilegeForm(_collect[0].Parent.Tag as Priv, _collect[0].Tag as Priv);

            _modify.ShowDialog();

            Neusoft.Privilege.BizLogic.Model.Priv _res = _modify.Current;
            if (_res != null && _collect != null)
            {
                _collect[0].SubItems[0].Text = _res.Name;
                _collect[0].SubItems[1].Text = _res.Id;
                _collect[0].SubItems[2].Text = _res.Description;
                _collect[0].Tag = _res;
            }

            _modify.Dispose();
        }
Пример #2
0
        void AddResource()
        {
            if (IsJudgeOperationForOne(nTabControl1.SelectedTab.Name))
            {
                if (tvRole.SelectedNode != null)
                {
                    if ((tvRole.SelectedNode.Tag as Role).Id != "roleadmin" && (tvRole.SelectedNode.Tag as Role).ParentId != "roleadmin")
                    {
                        MessageBox.Show("请在当前角色的跟结点上添加资源!", "提示");
                        return;
                    }
                }
            }

            SelectedTreeListViewItemCollection _collect = _resTreeListMap[nTabControl1.SelectedTab.Name].SelectedItems;

            if (_collect == null || _collect.Count == 0)
            {
                MessageBox.Show("请先选择要添加资源的父级资源!", "提示");
                return;
            }

            AddPrivilegeForm _add = new AddPrivilegeForm(_collect[0].Tag as Priv);

            _add.ShowDialog();

            Neusoft.Privilege.BizLogic.Model.Priv _res = _add.Current;
            if (_add.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                if (_res != null)
                {
                    TreeListViewItem _item = GetTreeListViewItem((Priv)_res);
                    _collect[0].Items.Add(_item);
                }
                else
                {
                    MessageBox.Show("权限已经存在!");
                    return;
                }
            }
            _add.Dispose();
        }