Beispiel #1
0
        private void Strip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var strip = (ContextMenuStrip)sender;

            strip.Close();
            var tree = this.tv_menu.SelectedNode;//当前选择树节点

            if (tree == null)
            {
                MessageBox.Show("没选到树节点");
                return;
            }
            var code = tree.Tag;//功能对应的菜单code
            //获取选中的数据
            var selected = this.dgv_funclist.SelectedRows;

            if (selected.Count == 0)
            {
                return;
            }
            var row      = selected[0];
            var id       = row.Cells[0].Value;
            var codeName = row.Cells[3].Value.ToString();

            AddFunc func = null;

            switch (e.ClickedItem.Text)
            {
            case "修改":
                func = new AddFunc(Convert.ToDecimal(id));
                break;

            case "删除":
                //if (codeName == "Read")
                //{
                //    MessageBox.Show("系统功能,禁止操作");
                //    return;
                //}
                RemoveFunc(id);
                break;

            case "查看":
                func = new AddFunc(Convert.ToDecimal(id), true);
                break;

            default:
                break;
            }
            if (func != null)
            {
                func.StartPosition = FormStartPosition.CenterScreen;
                var result = func.ShowDialog();
            }
            LoadFuncList(code);
        }
Beispiel #2
0
        /// <summary>
        /// 动态右键菜单,选择菜单之后执行对应功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var now = (ContextMenuStrip)sender;

            now.Close();
            var node = this.tv_menu.SelectedNode;

            if (node == null)
            {
                MessageBox.Show("请选择菜单");
                return;
            }
            var stripText  = e.ClickedItem.Text.GetEunmInDesciption(typeof(NodeMenu));
            var descrition = node.Text; //描述
            var code       = node.Tag;  //code编码
            var codeParent = node.Name; //父级编号
            Add add        = null;
            var _code      = code == null ? null : code.ToString();

            switch ((NodeMenu)stripText)
            {
            case NodeMenu.addchildren:
                add = new Add(_code, NodeMenu.addchildren);
                break;

            case NodeMenu.update:
                add = new Add(_code);
                break;

            case NodeMenu.remove:
                Remove(code);
                break;

            case NodeMenu.add:
                add = new Add(codeParent == null ? null : codeParent.ToString(), NodeMenu.add);
                break;

            case NodeMenu.addFunc:
                AddFunc addFunc = new AddFunc(_code);
                addFunc.StartPosition = FormStartPosition.CenterScreen;
                var result = addFunc.ShowDialog();
                addFunc.Dispose();
                break;

            case NodeMenu.initFunc:
                MenuStripFactory.InItFunc(_code);
                MessageBox.Show("操作成功");
                break;

            default:
                break;
            }
            if (add != null)
            {
                add.StartPosition = FormStartPosition.CenterScreen;
                var result = add.ShowDialog();
                add.Dispose();
            }
            LoadTree();
            LoadMenuList(code);
            this.tv_menu.SelectedNode = node;
        }