void btnOK_Click(object sender, EventArgs e)
        {
            //保存菜单
            if (Check() == -1)
            {
                return;
            }

            Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu = GetValue();

            try
            {
                IPrivilegeService _proxy = Common.Util.CreateProxy();
                using (_proxy as IDisposable)
                {
                    _current = _proxy.SaveMenuItem(_menu);
                }
            }
            catch (Exception ex)
            {
                _current = null;
                MessageBox.Show(ex.Message, "提示");
                return;
            }
            MessageBox.Show("保存成功!", "提示");

            //this.Close();
        }
Beispiel #2
0
        private void ModifyMenu()
        {
            if (lvMenu.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择待修改菜单!", "提示");
                return;
            }

            TreeListViewItem _current = lvMenu.SelectedItems[0];

            ///分类不能修改
            if (_current.Level == 0)
            {
                return;
            }

            ZZZZAddMenuForm _frmAdd = new ZZZZAddMenuForm((_current.Tag as Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem),
                                                          _current.Parent.Tag as Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem);

            _frmAdd.ShowDialog();

            Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu = _frmAdd.Current;
            if (_menu != null)
            {
                AddMenuToList(_menu);

                this.tvMenu_AfterSelect(null, null);
            }
        }
        private Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem GetValue()
        {
            if (_current == null)
            {
                _current = new Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem();
            }

            if (_orig != null)
            {
                _current.Id    = _orig.Id;
                _current.Order = _orig.Order;
            }
            _current.Name        = txtMenuName.Text.Trim();
            _current.ParentId    = _parent.Id;
            _current.Shortcut    = cmbShortcut.Text.Trim();
            _current.Tooltip     = txtTooltips.Text.Trim();
            _current.DllName     = txtDllName.Text.Trim();
            _current.WinName     = txtWinName.Text.Trim();
            _current.TreeDllName = txtTreeDllName.Text.Trim();
            _current.TreeName    = txtTreeName.Text.Trim();
            _current.Param       = txtParam.Text.Trim();
            //_current.ControlType = cmbControlType.Text == "" ? "" : (cmbControlType.Text == "窗体" ? "Form" : (cmbControlType.Text == "控件" ? "Control" : "Report"));
            _current.ShowType = cmbShowType.Text == "" ? "" : (cmbShowType.Text == "模式窗体" ? "ShowDialog" : (cmbShowType.Text == "无模式窗体" ? "Show" : "Web"));
            _current.Enabled  = chbEnabled.Checked;
            _current.UserId   = ((Facade.Context.Operator as NeuPrincipal).Identity as NeuIdentity).User.Id;
            _current.OperDate = Common.Util.GetDateTime();
            _current.Layer    = Convert.ToString(long.Parse(_parent.Layer) + 1);

            return(_current);
        }
        public ZZZZAddMenuForm(Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem parent)
        {
            InitializeComponent();

            _parent = parent;
            Init();
        }
Beispiel #5
0
        private void DisplayMenuItem(Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem parent)
        {
            //清除先
            this.lvMenu.Items.Clear();
            TreeListViewItem _root = new TreeListViewItem(parent.Name + "包含的菜单项", 0);

            _root.Tag = parent;
            _root.Expand();
            this.lvMenu.Items.Add(_root);

            AddSubMenuItem(parent, _root);
        }
Beispiel #6
0
        private int GetMenuIndex(Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem menu)
        {
            for (int i = 0; i < _menus.Count; i++)
            {
                Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu = _menus[i];
                if (_menu.Id == menu.Id)
                {
                    return(i);
                }
            }

            return(-1);
        }
Beispiel #7
0
        private void AddMenuToList(Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem menu)
        {
            //删除先
            int i = RemoveMenuFromList(menu.Id);

            if (i >= 0)
            {
                _menus.Insert(i, menu);
            }
            else
            {
                _menus.Add(menu);
            }
        }
Beispiel #8
0
        private int RemoveMenuFromList(string menuID)
        {
            for (int i = 0; i < _menus.Count; i++)
            {
                Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu = _menus[i];
                if (_menu.Id == menuID)
                {
                    _menus.Remove(_menu);
                    return(i);
                }
            }

            return(-1);
        }
Beispiel #9
0
        void DownItem_Click(object sender, EventArgs e)
        {
            if (lvMenu.SelectedItems.Count == 0)
            {
                return;
            }
            TreeListViewItem _current = lvMenu.SelectedItems[0];
            TreeListViewItem _next    = GetNextItem(_current);

            if (_next == null)
            {
                return;
            }

            IPrivilegeService _proxy = Common.Util.CreateProxy();

            try
            {
                Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu     = (Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem)_current.Tag;
                Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _nextMenu = (Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem)_next.Tag;

                int _order = _menu.Order;
                _menu.Order     = _nextMenu.Order;
                _nextMenu.Order = _order;

                //using (TransactionScope _scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    using (_proxy as IDisposable)
                    {
                        _menu     = _proxy.SaveMenuItem(_menu);
                        _nextMenu = _proxy.SaveMenuItem(_nextMenu);
                    }
                }

                int _index = GetMenuIndex(_menu);
                RemoveMenuFromList(_nextMenu.Id);
                _menus.Insert(_index, _nextMenu);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示");
                return;
            }

            tvMenu_AfterSelect(null, null);
        }
Beispiel #10
0
        private void AddSubMenuItem(Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem parent, TreeListViewItem parentItem)
        {
            foreach (Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu in _menus)
            {
                if (_menu.ParentId == parent.Id)
                {
                    TreeListViewItem _lvItem = new TreeListViewItem(_menu.Name, 1);
                    _lvItem.SubItems.AddRange(new string[] {
                        _menu.Shortcut, _menu.DllName, _menu.WinName, _menu.ControlType, _menu.ShowType,
                        _menu.Param, (_menu.Enabled?"是":"否")
                    });

                    _lvItem.Tag = _menu;
                    parentItem.Items.Add(_lvItem);

                    AddSubMenuItem(_menu, _lvItem);
                }
            }
        }
Beispiel #11
0
        void tvMenu_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            //保存编辑信息
            Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu = (Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem)e.Node.Tag;

            if (e.Label == null || e.Label.Trim() == "")
            {
                e.CancelEdit = true;
                return;
            }

            if (!Neusoft.Framework.Util.StringHelper.ValidMaxLengh(e.Label, 60))
            {
                e.CancelEdit = true;
                MessageBox.Show("分类的名称不能超过30个汉字!", "提示");
                e.Node.BeginEdit();
                return;
            }

            _menu.Name = e.Label;
            //保存分类信息
            try
            {
                IPrivilegeService _proxy = Common.Util.CreateProxy();
                using (_proxy as IDisposable)
                {
                    _menu = _proxy.SaveMenuItem(_menu);
                }

                if (_menu == null)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            AddMenuToList(_menu);
        }
Beispiel #12
0
        /// <summary>
        /// 增加分类
        /// </summary>
        private void AddType()
        {
            Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem _menu = new Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem();
            _menu.ParentId = "ROOT";
            _menu.Type     = "Menu";
            _menu.Enabled  = true;
            _menu.Layer    = "1";
            _menu.UserId   = ((Facade.Context.Operator as NeuPrincipal).Identity as NeuIdentity).User.Id;
            _menu.OperDate = Common.Util.GetDateTime();
            _menu.Name     = "新分类";

            //保存分类信息
            try
            {
                IPrivilegeService _proxy = Common.Util.CreateProxy();
                using (_proxy as IDisposable)
                {
                    _menu = _proxy.SaveMenuItem(_menu);
                }

                if (_menu == null)
                {
                    return;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }

            TreeNode _node = new TreeNode(_menu.Name);

            _node.ImageIndex         = 0;
            _node.SelectedImageIndex = 0;
            _node.Tag = _menu;
            this.tvMenu.Nodes.Add(_node);
            this.tvMenu.SelectedNode = _node;
            AddMenuToList(_menu);

            _node.BeginEdit();
        }
 public Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem SaveMenuItem(Neusoft.Privilege.ServiceContracts.Model.Impl.MenuItem menuItem)
 {
     return(this.Channel.SaveMenuItem(menuItem));
 }