Esempio n. 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();
        }
        public AddPrivilegeForm(Neusoft.Privilege.BizLogic.Model.Priv parent)
        {
            InitializeComponent();

            _parent = parent;

            this.Init();
        }
        public AddPrivilegeForm(Neusoft.Privilege.BizLogic.Model.Priv parent,
                                Neusoft.Privilege.BizLogic.Model.Priv res)
        {
            InitializeComponent();

            _parent  = parent;
            _orig    = res;
            _current = res as Priv;

            this.Init();
        }
        void btnSave_Click(object sender, EventArgs e)
        {
            if (Check() == -1)
            {
                return;
            }

            Neusoft.Privilege.BizLogic.Model.Priv _res = GetValue();

            int ret;

            try
            {
                PrivilegeService _proxy = Common.Util.CreateProxy();
                NFC.Management.PublicTrans.BeginTransaction();

                if (_current.Id == _current.ParentId)
                {
                    _current = null;
                }
                else
                {
                    using (_proxy as IDisposable)
                    {
                        ret = _proxy.SaveResource((Neusoft.Privilege.BizLogic.Model.Priv)_res);

                        //if (ret == 0)
                        //{
                        //    _current = null;
                        //}
                        //else
                        //{
                        //    _current = _res;
                        //}
                    }
                }
                NFC.Management.PublicTrans.Commit();
            }
            catch (Exception ex)
            {
                _current = null;
                NFC.Management.PublicTrans.RollBack();

                MessageBox.Show(ex.Message, "提示");
                return;
            }
            this.DialogResult = DialogResult.OK;
            base.Close();
            this.txtResId.Enabled = false;
        }
Esempio n. 5
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();
        }
        private Neusoft.Privilege.BizLogic.Model.Priv GetValue()
        {
            if (_current == null)
            {
                _current = new Neusoft.Privilege.BizLogic.Model.Priv();
            }

            if (_orig != null)
            {
                _current.Id = _orig.Id;
            }
            else
            {
                _current.Id = this.txtResId.Text.Trim();
            }

            _current.Name        = txtResName.Text.Trim();
            _current.ParentId    = _parent.Id;
            _current.Type        = _parent.Type;
            _current.Description = txtMemo.Text.Trim();

            return(_current);
        }