Exemple #1
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 #2
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();
        }