Exemple #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //  获取数据
            BDictMenu         menu       = this.ucMenu1.GetData();
            List <BDictRole>  roles      = this.ucMenu1.GetRoles();
            List <DataEmpDir> emps       = this.ucMenu1.GetEmps();
            MenuWithRight     menuToSave = new MenuWithRight();

            menuToSave.MenuInfo = menu;
            menuToSave.RoleList = roles;
            menuToSave.EmpList  = emps;

            //  保存数据
            String          str = StringHelper.SerializeObject <MenuWithRight>(menuToSave);
            CustomException ce  = null;

            if (_IsNew)
            {
                HttpDataHelper.HttpPostWithInfo("BASE", "/setup/menuadd", out ce, str);
            }
            else
            {
                HttpDataHelper.HttpPostWithInfo("BASE", "/setup/menuset", out ce, str);
            }


            this.DialogResult = DialogResult.OK;
        }
Exemple #2
0
        /// <summary>
        ///  获取菜单选择的人员
        /// </summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        private List <DataEmpDir> getMenuEmp(BDictMenu menu)
        {
            var parmList = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("menuCode", menu.Code)
            };
            CustomException ce = null;
            //  获取菜单选择的人员
            List <DataEmpDir> emps = HttpDataHelper.GetWithInfo <List <DataEmpDir> >("BASE", "/setup/menuemp", out ce, parmList);

            return(emps);
        }
Exemple #3
0
        /// <summary>
        ///  获取菜单选择的角色
        /// </summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        private List <BDictRole> getMenuRole(BDictMenu menu)
        {
            var parmList = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("menuCode", menu.Code)
            };
            CustomException ce = null;
            //  获取菜单选择的角色
            List <BDictRole> roles = HttpDataHelper.GetWithInfo <List <BDictRole> >("BASE", "/setup/menurole", out ce, parmList);

            return(roles);
        }
Exemple #4
0
 /// <summary>
 ///  自定义控件初始化
 /// </summary>
 /// <param name="isNew">是否新增</param>
 /// <param name="menu">菜单实体</param>
 /// <param name="roleList">选择的角色列表</param>
 /// <param name="empList">选择的人员列表</param>
 public void Init(bool isNew, BDictMenu menu, List <BDictRole> roleList, List <DataEmpDir> empList)
 {
     this._IsNew = isNew;
     if (isNew)
     {
         this.Text = "菜单新增";
     }
     this.ucMenu1.SetStatus(true);
     this.ucMenu1.Init(menu, roleList, empList);
     //按钮不可见
     //btnRole.Visible = false;
     //btnEmp.Visible = false;
 }
Exemple #5
0
        /// <summary>
        ///
        /// 刷新菜单
        /// </summary>
        /// <param name="menu"></param>
        private void FreshMenu(BDictMenu menu)
        {
            if (menu != null)
            {
                //  获取菜单选择的角色与人员
                List <BDictRole>  roles = getMenuRole(menu);
                List <DataEmpDir> emps  = getMenuEmp(menu);

                this.ucMenu1.Init(menu, roles, emps);
                this.ucSystem1.Visible = false;
                this.ucMenu1.Visible   = true;
            }
        }
Exemple #6
0
        /// <summary>
        ///  获取菜单数据
        /// </summary>
        /// <returns></returns>
        public BDictMenu GetData()
        {
            BDictMenu menu = new BDictMenu();

            menu.Code      = this.teCode.Text;
            menu.Title     = this.teTitle.Text;
            menu.Prompt    = this.tePrompt.Text;
            menu.Parameter = this.beParameter.Text;
            menu.Ico       = this.beIco.Text;
            menu.WinState  = Convert.ToInt32(this.icbeOpenFlag.EditValue);

            menu.SystemId   = this.systemId;
            menu.ObjectCode = this.objectCode == null ? "" : this.objectCode;

            return(menu);
        }
Exemple #7
0
 private void tvFunction_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
 {
     if (e.Node != null)
     {
         if (e.Node.Level == 0)
         {
             BDictSystem system = e.Node.Tag as BDictSystem;
             this.FreshSystem(system);
         }
         else
         {
             BDictMenu menu = e.Node.Tag as BDictMenu;
             this.FreshMenu(menu);
         }
     }
 }
Exemple #8
0
        private void bbiDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (tlSysMenu.FocusedNode != null)
            {
                if (tlSysMenu.FocusedNode.HasChildren)
                {
                    MessageHelper.ShowWarning("还有子项不能删除!");
                    return;
                }

                string mess = (tlSysMenu.FocusedNode.Level == 0) ? "系统:" : "菜单:";
                mess = mess + "(" + tlSysMenu.FocusedNode.GetDisplayText(tlcCode) + ")" + tlSysMenu.FocusedNode.GetDisplayText(tlcName);

                if (MessageHelper.ShowYesNoAndInfo("是否真的删除 " + mess + "?") == DialogResult.Yes)
                {
                    CustomException ce = null;

                    if (tlSysMenu.FocusedNode.Level == 0)
                    {
                        BDictSystem system   = tlSysMenu.FocusedNode.Tag as BDictSystem;
                        var         parmList = new List <KeyValuePair <string, string> >
                        {
                            new KeyValuePair <string, string>("systemId", system.Id.ToString())
                        };
                        //  删除子系统
                        HttpDataHelper.HttpPostFormUrlParamWithInfo("BASE", "/setup/systemdelete", out ce, parmList);
                    }
                    else
                    {
                        BDictMenu menu     = tlSysMenu.FocusedNode.Tag as BDictMenu;
                        var       parmList = new List <KeyValuePair <string, string> >
                        {
                            new KeyValuePair <string, string>("systemId", menu.SystemId.ToString()),
                            new KeyValuePair <string, string>("menuCode", menu.Code),
                        };
                        //  删除菜单
                        HttpDataHelper.HttpPostFormUrlParamWithInfo("BASE", "/setup/menudelete", out ce, parmList);
                    }
                    // 处理异常ce
                    if (ce != null)
                    {
                        MessageHelper.ShowError("删除操作失败!\r\n" + ce.Info);
                    }
                    tlSysMenu.FocusedNode.Remove();
                }
            }
        }
Exemple #9
0
        public void Init(BDictMenu menu, List <BDictRole> roleList, List <DataEmpDir> empList)
        {
            this.systemId   = menu.SystemId;
            this.objectCode = menu.ObjectCode;

            this.teCode.Text            = menu.Code;
            this.teTitle.Text           = menu.Title;
            this.tePrompt.Text          = menu.Prompt;
            this.beIco.Text             = menu.Ico;
            this.beParameter.Text       = menu.Parameter;
            this.icbeOpenFlag.EditValue = menu.WinState;
            this.beObjectName.Text      = getObjectName();

            this.changedObject();

            gcRole.DataSource = roleList;
            gcEmp.DataSource  = empList;
            //按钮不可见
            //if (editStatus == true)
            //{
            //    groupControl2.Visible = false;
            //}
        }
Exemple #10
0
        private void tlSysMenu_DragDrop(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.None;
            TreeListNode snode        = GetDragNode(e.Data);
            BDictMenu    menu         = snode.Tag as BDictMenu;
            string       old_code     = menu.Code;
            int          old_systemId = menu.SystemId;

            if (snode == null)
            {
                return;
            }
            TreeListHitInfo info = tlSysMenu.CalcHitInfo(tlSysMenu.PointToClient(new System.Drawing.Point(e.X, e.Y)));

            if (info == null)
            {
                return;
            }
            TreeListNode tnode = info.Node;

            if (snode.ParentNode == tnode)    //  还是同一父节点下
            {
                return;
            }
            if (snode.Level == 0 || tnode.Level == 4)    //  系统不能拖到其他节点下,4级菜单下不能再有子节点
            {
                return;
            }

            if (snode.HasChildren)
            {
                MessageHelper.ShowWarning("有子节点的不能被拖到其他菜单下!");
                return;
            }

            int    new_systemId = 0;
            string new_code     = string.Empty;

            if (tnode.Level > 0)
            {
                if (!string.IsNullOrEmpty((tnode.Tag as BDictMenu).ObjectCode))
                {
                    MessageHelper.ShowWarning("节点有功能不能挂其他菜单!");
                    return;
                }
                new_systemId = (tnode.Tag as BDictMenu).SystemId;
                new_code     = tnode.GetValue(tlcCode).ToString() + "1";
            }
            else
            {
                new_systemId = (tnode.Tag as BDictSystem).Id;
                new_code     = "1";
            }

            //  计算新的代码
            if (tnode.HasChildren)
            {
                new_code = getNextMenuCode(tnode.Nodes[tnode.Nodes.Count - 1].GetValue(this.tlcCode).ToString());
            }
            menu.Code     = new_code;
            menu.SystemId = new_systemId;

            // 拖拽修修改
            List <KeyValuePair <string, string> > parms = new List <KeyValuePair <string, string> >();

            parms.Add(new KeyValuePair <string, string>("oldSystem", old_systemId.ToString()));
            parms.Add(new KeyValuePair <string, string>("oldMenu", old_code));
            parms.Add(new KeyValuePair <string, string>("newSystem", new_systemId.ToString()));
            parms.Add(new KeyValuePair <string, string>("newMenu", new_code));
            CustomException ce = null;

            HttpDataHelper.HttpPostFormUrlParamWithInfo("BASE", "/setup/menumove", out ce, parms);
            if (ce == null)
            {
                snode.Remove();
                TreeListNode cnode = tnode.Nodes.Add(new object[] { menu.Code, menu.Title });
                cnode.Tag             = menu;
                tlSysMenu.FocusedNode = cnode;
            }
            else
            {
                MessageHelper.ShowError("菜单移动调用服务失败!\r\n" + ce.Info);
            }
        }
Exemple #11
0
        private void bbiEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (tlSysMenu.FocusedNode != null)
            {
                if (tlSysMenu.FocusedNode.Level == 0)
                {
                    //  系统修改
                    BDictSystem   system = tlSysMenu.FocusedNode.Tag as BDictSystem;
                    FrmSystemEdit frm    = new FrmSystemEdit();
                    if (this.roleList == null)
                    {
                        //  获取全部可用角色列表
                        this.roleList = CommonDataHelper.GetRoleAll();
                    }
                    if (this.empList == null)
                    {
                        //  获取全部可用员工列表
                        this.empList = CommonDataHelper.GetEmpAll();
                    }

                    frm.SetRefData(this.roleList, this.empList);
                    frm.Init(false, system, this.ucSystem1.GetRoles(), this.ucSystem1.GetEmps());
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        system = frm.GetData();
                        this.tlSysMenu.FocusedNode.SetValue(this.tlcCode, system.Code);
                        this.tlSysMenu.FocusedNode.SetValue(this.tlcName, system.Name);
                        this.tlSysMenu.FocusedNode.Tag = system;
                        this.ucSystem1.Init(system, frm.GetRoles(), frm.GetEmps());
                    }
                    frm.Dispose();
                }
                else
                {
                    //  菜单修改
                    BDictMenu   menu = tlSysMenu.FocusedNode.Tag as BDictMenu;
                    FrmMenuEdit frm  = new FrmMenuEdit();
                    if (this.roleList == null)
                    {
                        //  获取全部可用角色列表
                        this.roleList = CommonDataHelper.GetRoleAll();
                    }
                    if (this.empList == null)
                    {
                        //  获取全部可用员工列表
                        this.empList = CommonDataHelper.GetEmpAll();
                    }

                    frm.SetRefData(this.moduleList, this.objectList, this.roleList, this.empList);
                    frm.Init(false, menu, this.ucMenu1.GetRoles(), this.ucMenu1.GetEmps());
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        menu = frm.GetData();
                        this.tlSysMenu.FocusedNode.SetValue(this.tlcName, menu.Title);
                        this.tlSysMenu.FocusedNode.Tag = menu;
                        this.ucMenu1.Init(menu, frm.GetRoles(), frm.GetEmps());
                    }
                    frm.Dispose();
                }
            }
        }
Exemple #12
0
        private void bbiAddMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (tlSysMenu.FocusedNode == null)
            {
                return;
            }
            if ((tlSysMenu.FocusedNode.Tag as BDictMenu).ObjectCode != null)
            {
                MessageHelper.ShowWarning("该节点有对象,不能下挂菜单!");
                return;
            }
            if (tlSysMenu.FocusedNode.Level == 4)
            {
                MessageHelper.ShowWarning("菜单的层级目前至多为4级!");
                return;
            }

            //  计算下一个代码编号
            string code = string.Empty;

            if (tlSysMenu.FocusedNode.Nodes.Count > 0)
            {
                //  已经有节点,在最后节点编号基础上加1
                code = getNextMenuCode(tlSysMenu.FocusedNode.Nodes[tlSysMenu.FocusedNode.Nodes.Count - 1].GetValue(this.tlcCode).ToString());
            }
            else
            {
                if (tlSysMenu.FocusedNode.Level == 0)
                {
                    code = "1";
                }
                else
                {
                    code = tlSysMenu.FocusedNode.GetValue(this.tlcCode).ToString() + "1";
                }
            }

            //  获取系统ID
            int systemId = 0;

            if (tlSysMenu.FocusedNode.Level == 0)
            {
                systemId = (tlSysMenu.FocusedNode.Tag as BDictSystem).Id;
            }
            else
            {
                systemId = (tlSysMenu.FocusedNode.Tag as BDictMenu).SystemId;
            }

            BDictMenu menu = new BDictMenu();

            menu.Code     = code;
            menu.SystemId = systemId;
            menu.WinState = 1;

            FrmMenuEdit frm = new FrmMenuEdit();

            if (this.roleList == null)
            {
                //  获取全部可用角色列表
                this.roleList = CommonDataHelper.GetRoleAll();
            }
            if (this.empList == null)
            {
                //  获取全部可用员工列表
                this.empList = CommonDataHelper.GetEmpAll();
            }

            frm.SetRefData(this.moduleList, this.objectList, this.roleList, this.empList);
            frm.Init(true, menu, new List <BDictRole>(), new List <DataEmpDir>());
            if (frm.ShowDialog() == DialogResult.OK)
            {
                menu = frm.GetData();

                TreeListNode cnode = this.tlSysMenu.FocusedNode.Nodes.Add(new object[] { menu.Code, menu.Title });
                cnode.Tag             = menu;
                tlSysMenu.FocusedNode = cnode;
            }
            frm.Dispose();
        }