示例#1
0
        /// <summary>
        /// 获取菜单树
        /// </summary>
        /// <returns></returns>
        public List <Tree> GetMenuTree()
        {
            List <Tree> Menus = new List <Tree>();


            TbSysSubSystemDefine        tb   = new TbSysSubSystemDefine();
            List <TbSysSubSystemDefine> list = tb.FetchAll();

            foreach (var item in list)
            {
                Tree head = new Tree()
                {
                    Level = 0, Name = item.SubSystemName, Code = ""
                };
                Menus.Add(head);


                TbSysMenu   child  = new TbSysMenu();
                List <Tree> level2 = child.FindNext(item.SubSystemId);
                head.Childs = level2;

                foreach (var item2 in head.Childs)
                {
                    item2.Childs = GetChildren(item2);
                }
            }
            return(Menus);
        }
示例#2
0
        /// <summary>
        /// 以主键为参数删除一条数据
        /// </summary>
        static public void DeleteBy(string menuCode)
        {
            TbSysMenu tbl;

            tbl = new TbSysMenu();

            tbl.MenuCode = menuCode;

            tbl.Delete();
        }
示例#3
0
        /// <summary>
        /// 以主键为参数获取数据,并创建类的实例
        /// </summary>
        /// <returns>类的实例</returns>
        static public TbSysMenu CreateBy(string menuCode)
        {
            TbSysMenu tbl;
            bool      hasData;

            tbl     = new TbSysMenu();
            hasData = tbl.FetchBy(menuCode);

            if (!hasData)
            {
                return(null);
            }
            else
            {
                return(tbl);
            }
        }
示例#4
0
        /// <summary>
        /// 获取所有子菜单
        /// </summary>
        /// <param name="tb"></param>
        /// <returns></returns>
        public List <Tree> GetChildren(Tree tb)
        {
            List <Tree> menus = new List <Tree>();
            TbSysMenu   child = new TbSysMenu();

            menus = child.FindChildAll(tb.Code);

            if (menus.Count == 0)
            {
                return(null);
            }
            foreach (var item in menus)
            {
                item.Childs = GetChildren(item);
            }

            return(menus);
        }