Exemplo n.º 1
0
        /// <summary>
        /// 初始化功能按钮
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private BarButtonItem initBarButtonItem(MenuNodeInfo node)
        {
            BarButtonItem button = new BarButtonItem();

            button.PaintStyle = BarItemPaintStyle.CaptionGlyph;
            button.Glyph      = LoadIcon(node.Icon);
            button.LargeGlyph = LoadIcon(node.Icon);

            button.Name    = node.ID;
            button.Caption = node.Name;
            button.Tag     = node.WinformType + "|" + node.SystemType_ID; //绑定winformType和系统类型

            button.ItemClick += (sender, e) =>
            {
                if (button.Tag != null && !string.IsNullOrEmpty(button.Tag.ToString()))
                {
                    LoadPlugInForm(button.Tag.ToString(),
                                   new BaseEntity()
                    {
                        Data1 = node.Data1, Data2 = node.Data2, Data3 = node.Data3
                    });
                }
                else
                {
                    MessageDxUtil.ShowTips(button.Caption);
                }
            };
            return(button);
        }
Exemplo n.º 2
0
        /*
         * 在引入和角色多对多的关系后,菜单作为角色的资源之一,和功能模块并立。
         * 因此在处理上和Function表的处理类似,作为角色的资源之一。
         */


        /// <summary>
        /// 根据角色集合和系统标识获取对应的菜单集合
        /// </summary>
        /// <returns></returns>
        public List <MenuNodeInfo> GetMenuNodes(string roleIDs, string typeID)
        {
            string sql = string.Format(@"SELECT * FROM {1} Where ID in(
            SELECT distinct ID FROM {1} 
            INNER JOIN T_ACL_Role_Menu On {1}.ID=T_ACL_Role_Menu.Menu_ID WHERE Role_ID IN ({0}) ) AND Visible > 0", roleIDs, tableName);

            if (!string.IsNullOrWhiteSpace(typeID))
            {
                sql += string.Format(" AND SystemType_ID='{0}' ", typeID);
            }

            List <MenuNodeInfo> arrReturn = new List <MenuNodeInfo>();
            DataTable           dt        = base.SqlTable(sql);
            string sortCode = string.Format("{0} {1}", GetSafeFileName(SortField), IsDescending ? "DESC" : "ASC");

            DataRow[] dataRows = dt.Select(string.Format(" PID = '{0}' ", -1), sortCode);
            for (int i = 0; i < dataRows.Length; i++)
            {
                string       id           = dataRows[i]["ID"].ToString();
                MenuNodeInfo menuNodeInfo = GetNode(id, dt);
                arrReturn.Add(menuNodeInfo);
            }

            return(arrReturn);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增数据操作
        /// </summary>
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            string   selectId   = "";
            string   systemType = "";
            TreeNode node       = this.treeView1.SelectedNode;

            if (node != null)
            {
                if (node.Tag != null)
                {
                    MenuNodeInfo menuInfo = node.Tag as MenuNodeInfo;
                    if (menuInfo != null)
                    {
                        selectId   = menuInfo.ID;
                        systemType = menuInfo.SystemType_ID;
                    }
                }
                else
                {
                    systemType = node.Name;
                }
            }

            FrmEditMenu dlg = new FrmEditMenu();

            dlg.PID           = selectId;
            dlg.SystemType_ID = systemType;
            dlg.OnDataSaved  += new EventHandler(dlg_OnDataSaved);
            if (DialogResult.OK == dlg.ShowDialog())
            {
                BindData();
            }
        }
Exemplo n.º 4
0
 private void SetFileIcon(MenuNodeInfo info, JsTreeData item)
 {
     if (info.Children.Count == 0)
     {
         item.icon = "fa fa-file icon-state-warning icon-lg";
     }
 }
Exemplo n.º 5
0
        private MenuNodeInfo TableToInfo(string string_0, DataTable dataTable_0)
        {
            MenuNodeInfo info2 = new MenuNodeInfo(this.FindByID(string_0));

            DataRow[] rowArray = dataTable_0.Select(string.Format(" PID='{0}'", string_0));
            for (int i = 0; i < rowArray.Length; i++)
            {
                string       str  = rowArray[i]["ID"].ToString();
                MenuNodeInfo item = this.TableToInfo(str, dataTable_0);
                info2.Children.Add(item);
            }
            return(info2);
        }
Exemplo n.º 6
0
        public List <MenuNodeInfo> GetTreeByID(string mainMenuID)
        {
            List <MenuNodeInfo> list = new List <MenuNodeInfo>();
            string    sql            = string.Format("Select * From {0} Where Visible > 0 Order By PID, Seq ", base.tableName);
            DataTable table          = this.SqlTable(sql);

            DataRow[] rowArray = table.Select(string.Format(" PID = '{0}'", mainMenuID));
            for (int i = 0; i < rowArray.Length; i++)
            {
                string       str2 = rowArray[i]["ID"].ToString();
                MenuNodeInfo item = this.TableToInfo(str2, table);
                list.Add(item);
            }
            return(list);
        }
Exemplo n.º 7
0
        public List <MenuNodeInfo> GetTreeFunctionByID(string mainMenuID, string Functions)
        {
            List <MenuNodeInfo> list = new List <MenuNodeInfo>();
            string    str            = string.Format("Select * From {0} Where Visible > 0 Order By PID, Seq ", base.tableName);
            DataTable table          = this.SqlTable(str);
            string    sort           = string.Format("{0} {1}", base.GetSafeFileName(base.sortField), base.isDescending ? "DESC" : "ASC");

            DataRow[] rowArray = table.Select(string.Format(" PID = '{0}' and FunctionId in ({1})", mainMenuID, Functions), sort);
            for (int i = 0; i < rowArray.Length; i++)
            {
                string       str3 = rowArray[i]["ID"].ToString();
                MenuNodeInfo item = this.TableToInfo(str3, table);
                list.Add(item);
            }
            return(list);
        }
Exemplo n.º 8
0
        public List <MenuNodeInfo> GetTree(string systemType)
        {
            string str = !string.IsNullOrEmpty(systemType) ? string.Format("AND SystemType_ID='{0}'", systemType) : "";
            List <MenuNodeInfo> list = new List <MenuNodeInfo>();
            string    sql            = string.Format("Select * From {0} Where Visible > 0 {1} Order By PID, Seq ", base.tableName, str);
            DataTable table          = base.SqlTable(sql);

            DataRow[] rowArray = table.Select(string.Format(" PID = '{0}' ", -1));
            for (int i = 0; i < rowArray.Length; i++)
            {
                string       str3 = rowArray[i]["ID"].ToString();
                MenuNodeInfo item = this.TableToInfo(str3, table);
                list.Add(item);
            }
            return(list);
        }
Exemplo n.º 9
0
        private MenuNodeInfo GetNode(string id, DataTable dt)
        {
            MenuInfo     menuInfo     = this.FindByID(id);
            MenuNodeInfo menuNodeInfo = new MenuNodeInfo(menuInfo);

            string sort = string.Format("{0} {1}", GetSafeFileName(sortField), isDescending ? "DESC" : "ASC");

            DataRow[] dChildRows = dt.Select(string.Format(" PID='{0}'", id), sort);

            for (int i = 0; i < dChildRows.Length; i++)
            {
                string       childId       = dChildRows[i]["ID"].ToString();
                MenuNodeInfo childNodeInfo = GetNode(childId, dt);
                menuNodeInfo.Children.Add(childNodeInfo);
            }
            return(menuNodeInfo);
        }
Exemplo n.º 10
0
        private MenuNodeInfo GetNode(string gid, DataTable dt, IsVisable isVisable = IsVisable.是, IsDelete isDelete = IsDelete.否)
        {
            MenuInfo     menuInfo     = this.FindById(gid);
            MenuNodeInfo menuNodeInfo = new MenuNodeInfo(menuInfo);

            string sort = string.Format("{0} {1}", GetSafeFileName(sortField), isDescending ? "DESC" : "ASC");

            DataRow[] dChildRows = dt.Select(string.Format(" Pgid='{0}' and (IsVisable = {1} or 0 = {1}) and (IsDelete = {2} or 0 = {2})", gid, (short)isVisable, (short)isDelete), sort);

            for (int i = 0; i < dChildRows.Length; i++)
            {
                string       childId       = dChildRows[i]["Gid"].ToString();
                MenuNodeInfo childNodeInfo = GetNode(childId, dt, isVisable);
                menuNodeInfo.Children.Add(childNodeInfo);
            }
            return(menuNodeInfo);
        }
Exemplo n.º 11
0
        public List <MenuNodeInfo> GetTreeFunction(string systemType, string Functions)
        {
            string str = !string.IsNullOrEmpty(systemType) ? string.Format("AND SystemType_ID='{0}'", systemType) : "";
            List <MenuNodeInfo> list = new List <MenuNodeInfo>();
            string    str2           = string.Format("Select * From {0} Where Visible > 0 {1} Order By PID, Seq ", base.tableName, str);
            DataTable table          = base.SqlTable(str2);
            string    sort           = string.Format("{0} {1}", base.GetSafeFileName(base.sortField), base.isDescending ? "DESC" : "ASC");

            DataRow[] rowArray = table.Select(string.Format(" PID = '{0}' and FunctionId in ({1})", -1, Functions), sort);
            for (int i = 0; i < rowArray.Length; i++)
            {
                string       str4 = rowArray[i]["ID"].ToString();
                MenuNodeInfo item = this.TableToInfo(str4, table);
                list.Add(item);
            }
            return(list);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取指定菜单下面的树形列表
        /// </summary>
        /// <param name="mainMenuID">指定菜单ID</param>
        public List <MenuNodeInfo> GetTreeById(string mainMenuId, IsVisable isVisable = IsVisable.是, IsDelete isDelete = IsDelete.否)
        {
            List <MenuNodeInfo> arrReturn = new List <MenuNodeInfo>();
            string sql = string.Format("Select * From {0} Where (IsVisable = {1} or 0 = {1}) Order By Pgid, Seq ", tableName, (short)isVisable);

            DataTable dt   = SqlTable(sql);
            string    sort = string.Format("{0} {1}", GetSafeFileName(sortField), isDescending ? "DESC" : "ASC");

            DataRow[] dataRows = dt.Select(string.Format(" Pgid = '{0}' and (IsVisable = {1} or 0 = {1}) and (IsDelete = {2} or 0 = {2})", mainMenuId, (short)isVisable, (short)isDelete), sort);
            for (int i = 0; i < dataRows.Length; i++)
            {
                string       id           = dataRows[i]["Gid"].ToString();
                MenuNodeInfo menuNodeInfo = GetNode(id, dt);
                arrReturn.Add(menuNodeInfo);
            }

            return(arrReturn);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 获取指定菜单下面的树形列表
        /// </summary>
        /// <param name="mainMenuID">指定菜单ID</param>
        public List <MenuNodeInfo> GetTreeByID(string mainMenuID)
        {
            List <MenuNodeInfo> arrReturn = new List <MenuNodeInfo>();
            string sql = string.Format("Select * From {0} Where Visible > 0 Order By PID, Seq ", tableName);

            DataTable dt   = SqlTable(sql);
            string    sort = string.Format("{0} {1}", GetSafeFileName(sortField), isDescending ? "DESC" : "ASC");

            DataRow[] dataRows = dt.Select(string.Format(" PID = '{0}'", mainMenuID), sort);
            for (int i = 0; i < dataRows.Length; i++)
            {
                string       id           = dataRows[i]["ID"].ToString();
                MenuNodeInfo menuNodeInfo = GetNode(id, dt);
                arrReturn.Add(menuNodeInfo);
            }

            return(arrReturn);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 获取树形结构的菜单列表
        /// </summary>
        public List <MenuNodeInfo> GetTree(string systemtypeId, IsVisable isVisable = IsVisable.是, IsDelete isDelete = IsDelete.否)
        {
            string condition = !string.IsNullOrEmpty(systemtypeId) ? string.Format("AND SystemtypeId='{0}'", systemtypeId) : "";
            List <MenuNodeInfo> arrReturn = new List <MenuNodeInfo>();
            string sql = string.Format("Select * From {0} Where (IsVisable = {2} or 0 = {2}) {1} Order By Pgid, Seq ", tableName, condition, (short)isVisable);

            DataTable dt   = base.SqlTable(sql);
            string    sort = string.Format("{0} {1}", GetSafeFileName(sortField), isDescending ? "DESC" : "ASC");

            DataRow[] dataRows = dt.Select(string.Format(" Pgid = '{0}' ", -1), sort);
            for (int i = 0; i < dataRows.Length; i++)
            {
                string       id           = dataRows[i]["Gid"].ToString();
                MenuNodeInfo menuNodeInfo = GetNode(id, dt);
                arrReturn.Add(menuNodeInfo);
            }

            return(arrReturn);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取树形结构的菜单列表
        /// </summary>
        public List <MenuNodeInfo> GetTree(string systemType)
        {
            string condition = !string.IsNullOrEmpty(systemType) ? string.Format("AND SystemType_ID='{0}'", systemType) : "";
            List <MenuNodeInfo> arrReturn = new List <MenuNodeInfo>();
            string sql = string.Format("Select * From {0} Where Visible > 0 {1} Order By PID, Seq ", tableName, condition);

            DataTable dt   = base.SqlTable(sql);
            string    sort = string.Format("{0} {1}", GetSafeFileName(sortField), isDescending ? "DESC" : "ASC");

            DataRow[] dataRows = dt.Select(string.Format(" PID = '{0}' ", -1), sort);
            for (int i = 0; i < dataRows.Length; i++)
            {
                string       id           = dataRows[i]["ID"].ToString();
                MenuNodeInfo menuNodeInfo = GetNode(id, dt);
                arrReturn.Add(menuNodeInfo);
            }

            return(arrReturn);
        }
Exemplo n.º 16
0
        private TreeNode FindNode(TreeNodeCollection nodes, string menuId)
        {
            foreach (TreeNode node in nodes)
            {
                if (node.Tag != null)
                {
                    MenuNodeInfo info = node.Tag as MenuNodeInfo;
                    if (info != null && info.ID == menuId)
                    {
                        return(node);
                    }
                }

                TreeNode candidate = FindNode(node.Nodes, menuId);
                if (candidate != null)
                {
                    return(candidate);
                }
            }

            return(null);
        }
Exemplo n.º 17
0
        private void AddPages()
        {
            // 约定菜单共有3级,第一级为大的类别,第二级为小模块分组,第三级为具体的菜单
            //List<MenuNodeInfo> menuList = BLLFactory<Menus>.Instance.GetTree(Portal.gc.SYSTEMTYPEID);
            string firguid    = "7b5ea040-563b-40aa-a560-170ac9374f56";
            string secguid    = "4314381b-fbff-43cf-b727-f72d53e21264";
            string thirdguid1 = "402d58c4-d536-4213-8d35-cbf5164ed8eb";
            string thirdguid2 = "8ff8c148-3675-409d-b80d-22043edcc151";

            List <MenuNodeInfo> menuList          = new List <MenuNodeInfo>();
            MenuNodeInfo        firstmenuNodeInfo = new MenuNodeInfo();

            firstmenuNodeInfo.Pgid           = "-1";
            firstmenuNodeInfo.Gid            = firguid;
            firstmenuNodeInfo.CreatorId      = 1;
            firstmenuNodeInfo.CreatorTime    = DateTime.Now;
            firstmenuNodeInfo.Icon           = @"images\MenuIcon\020.ico";
            firstmenuNodeInfo.IsDelete       = 0;
            firstmenuNodeInfo.IsVisable      = 1;
            firstmenuNodeInfo.LastUpdateTime = DateTime.Now;
            firstmenuNodeInfo.Name           = "主菜单";
            firstmenuNodeInfo.Seq            = "1";
            firstmenuNodeInfo.WinformClass   = "#";
            menuList.Add(firstmenuNodeInfo);

            List <MenuNodeInfo> secondmenuList     = new List <MenuNodeInfo>();
            MenuNodeInfo        secondmenuNodeInfo = new MenuNodeInfo();

            secondmenuNodeInfo.Pgid           = firguid;
            secondmenuNodeInfo.Gid            = firguid;
            secondmenuNodeInfo.CreatorId      = 1;
            secondmenuNodeInfo.CreatorTime    = DateTime.Now;
            secondmenuNodeInfo.Icon           = @"images\MenuIcon\020.ico";
            secondmenuNodeInfo.IsDelete       = 0;
            secondmenuNodeInfo.IsVisable      = 1;
            secondmenuNodeInfo.LastUpdateTime = DateTime.Now;
            secondmenuNodeInfo.Name           = "代销数据工具";
            secondmenuNodeInfo.Seq            = "1";
            secondmenuNodeInfo.WinformClass   = "";
            secondmenuList.Add(secondmenuNodeInfo);
            firstmenuNodeInfo.Children = secondmenuList;

            List <MenuNodeInfo> thirdmenuList      = new List <MenuNodeInfo>();
            MenuNodeInfo        third1menuNodeInfo = new MenuNodeInfo();

            third1menuNodeInfo.Pgid           = firguid;
            third1menuNodeInfo.Gid            = firguid;
            third1menuNodeInfo.CreatorId      = 1;
            third1menuNodeInfo.CreatorTime    = DateTime.Now;
            third1menuNodeInfo.Icon           = @"images\MenuIcon\009.ico";
            third1menuNodeInfo.IsDelete       = 0;
            third1menuNodeInfo.IsVisable      = 1;
            third1menuNodeInfo.LastUpdateTime = DateTime.Now;
            third1menuNodeInfo.Name           = "配置代销数据";
            third1menuNodeInfo.Seq            = "1";
            third1menuNodeInfo.WinformClass   = "JCodes.Framework.TestWinForm.FrmConsignment;JCodes.Framework.TestWinForm.exe";
            thirdmenuList.Add(third1menuNodeInfo);

            MenuNodeInfo third2menuNodeInfo = new MenuNodeInfo();

            third2menuNodeInfo.Pgid           = firguid;
            third2menuNodeInfo.Gid            = firguid;
            third2menuNodeInfo.CreatorId      = 1;
            third2menuNodeInfo.CreatorTime    = DateTime.Now;
            third2menuNodeInfo.Icon           = @"images\MenuIcon\028.ico";
            third2menuNodeInfo.IsDelete       = 0;
            third2menuNodeInfo.IsVisable      = 1;
            third2menuNodeInfo.LastUpdateTime = DateTime.Now;
            third2menuNodeInfo.Name           = "代销处理";
            third2menuNodeInfo.Seq            = "2";
            third2menuNodeInfo.WinformClass   = "JCodes.Framework.TestWinForm.ZsDaixiao.FrmDealConsignment;JCodes.Framework.TestWinForm.exe";
            thirdmenuList.Add(third2menuNodeInfo);
            secondmenuNodeInfo.Children = thirdmenuList;

            /*List<MenuNodeInfo> secondmenuList = new List<MenuNodeInfo>();
             * MenuNodeInfo secondmenuNodeInfo = new MenuNodeInfo();
             * secondmenuNodeInfo.Pgid = firguid;
             * secondmenuNodeInfo.Gid = firguid;
             * secondmenuNodeInfo.CreatorId = 1;
             * secondmenuNodeInfo.CreatorTime = DateTime.Now;
             * secondmenuNodeInfo.Icon = @"images\MenuIcon\020.ico";
             * secondmenuNodeInfo.IsDelete = 0;
             * secondmenuNodeInfo.IsVisable = 1;
             * secondmenuNodeInfo.LastUpdateTime = DateTime.Now;
             * secondmenuNodeInfo.Name = "浩天网络";
             * secondmenuNodeInfo.Seq = "1";
             * secondmenuNodeInfo.WinformClass = "";
             * secondmenuList.Add(secondmenuNodeInfo);
             * firstmenuNodeInfo.Children = secondmenuList;
             *
             * List<MenuNodeInfo> thirdmenuList = new List<MenuNodeInfo>();
             * MenuNodeInfo third1menuNodeInfo = new MenuNodeInfo();
             * third1menuNodeInfo.Pgid = firguid;
             * third1menuNodeInfo.Gid = firguid;
             * third1menuNodeInfo.CreatorId = 1;
             * third1menuNodeInfo.CreatorTime = DateTime.Now;
             * third1menuNodeInfo.Icon = @"images\MenuIcon\009.ico";
             * third1menuNodeInfo.IsDelete = 0;
             * third1menuNodeInfo.IsVisable = 1;
             * third1menuNodeInfo.LastUpdateTime = DateTime.Now;
             * third1menuNodeInfo.Name = "XLS数据处理";
             * third1menuNodeInfo.Seq = "1";
             * third1menuNodeInfo.WinformClass = "JCodes.Framework.TestWinForm.Haotian.FrmHackVote;JCodes.Framework.TestWinForm.exe";
             * thirdmenuList.Add(third1menuNodeInfo);
             * secondmenuNodeInfo.Children = thirdmenuList;*/

            if (menuList.Count == 0)
            {
                return;
            }

            int i = 0;

            foreach (MenuNodeInfo firstInfo in menuList)
            {
                //添加页面(一级菜单)
                RibbonPage page = new RibbonPage();
                page.Text = firstInfo.Name;
                page.Name = firstInfo.Gid;
                this.ribbonControl.Pages.Insert(i++, page);

                if (firstInfo.Children.Count == 0)
                {
                    continue;
                }
                foreach (MenuNodeInfo secondInfo in firstInfo.Children)
                {
                    //添加RibbonPageGroup(二级菜单)
                    RibbonPageGroup group = new RibbonPageGroup();
                    group.Text       = secondInfo.Name;
                    group.Name       = secondInfo.Gid;
                    group.Glyph      = LoadIcon(secondInfo.Icon);
                    group.ImageIndex = 0;
                    page.Groups.Add(group);

                    if (secondInfo.Children.Count == 0)
                    {
                        continue;
                    }
                    foreach (MenuNodeInfo thirdInfo in secondInfo.Children)
                    {
                        // 判断 WinformType 如果是 RgbiSkins 则表示皮肤
                        if (thirdInfo.WinformClass == Const.RgbiSkins)
                        {
                            RibbonGalleryBarItem rgbi = new RibbonGalleryBarItem();
                            var galleryItemGroup1     = new GalleryItemGroup();
                            rgbi.Name    = thirdInfo.Gid;
                            rgbi.Caption = thirdInfo.Name;
                            rgbi.Gallery.Groups.AddRange(new DevExpress.XtraBars.Ribbon.GalleryItemGroup[] { galleryItemGroup1 });
                            group.ItemLinks.Add(rgbi);
                            DevExpress.XtraBars.Helpers.SkinHelper.InitSkinGallery(rgbi, true);
                        }
                        else
                        {
                            //添加功能按钮(三级菜单)
                            BarButtonItem button = new BarButtonItem();
                            button.PaintStyle = BarItemPaintStyle.CaptionGlyph;
                            button.LargeGlyph = LoadIcon(thirdInfo.Icon);
                            button.Glyph      = LoadIcon(thirdInfo.Icon);

                            button.Name       = thirdInfo.Gid;
                            button.Caption    = thirdInfo.Name;
                            button.Tag        = thirdInfo.WinformClass;
                            button.ItemClick += (sender, e) =>
                            {
                                if (button.Tag != null && !string.IsNullOrEmpty(button.Tag.ToString()))
                                {
                                    Portal.gc._waitBeforeLogin = new WaitDialogForm("正则加载 " + button.Caption + " 窗体中...", "加载窗体");
                                    LoadPlugInForm(button.Tag.ToString());
                                    if (Portal.gc._waitBeforeLogin != null)
                                    {
                                        Portal.gc._waitBeforeLogin.Invoke((EventHandler) delegate
                                        {
                                            if (Portal.gc._waitBeforeLogin != null)
                                            {
                                                Portal.gc._waitBeforeLogin.Close(); Portal.gc._waitBeforeLogin = null;
                                            }
                                        });
                                    }
                                }
                                else
                                {
                                    MessageDxUtil.ShowTips(button.Caption);
                                }
                            };
                            if (thirdInfo.WinformClass.Contains(Const.BeginGroup))
                            {
                                group.ItemLinks.Add(button, true);
                            }
                            else
                            {
                                group.ItemLinks.Add(button);
                            }
                        }
                    }
                }
            }
        }