using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
namespace BLL
{
   public static class SysMenuService
    {
       public static Model.SGGLDB db = Funs.DB;
       /// 
       /// 根据MenuId获取菜单名称项
       /// 
       /// 
       /// 
       public static List GetSupMenuListBySuperMenu(string superMenu)
       {
           var list = (from x in Funs.DB.Sys_Menu where x.SuperMenu == superMenu orderby x.SortIndex select x).ToList();          
           return list;
       }
       /// 
       /// 根据MenuId获取菜单名称项
       /// 
       /// 
       /// 
       public static Model.Sys_Menu GetSupMenuBySuperMenu(string superMenu)
       {
           return Funs.DB.Sys_Menu.FirstOrDefault(x => x.SuperMenu == superMenu);    
       }
       /// 
       /// 根据MenuId获取菜单名称项
       /// 
       /// 
       /// 
       public static Model.Sys_Menu GetSysMenuByMenuId(string menuId)
       {
           return Funs.DB.Sys_Menu.FirstOrDefault(x => x.MenuId == menuId);
       }
       /// 
       /// 根据MenuType获取菜单集合
       /// 
       /// 
       /// 
       public static List GetMenuListByMenuType(string menuType)
       {
           var list = (from x in Funs.DB.Sys_Menu where x.MenuType == menuType orderby x.SortIndex select x).ToList();
           return list;
       }
        /// 
        /// 根据MenuType获取菜单集合
        /// 
        /// 
        /// 
        public static List GetIsUsedMenuListByMenuType(string menuType)
        {
            var list = (from x in Funs.DB.Sys_Menu
                        where (x.MenuType == menuType || menuType == null) && x.IsUsed == true
                        orderby x.SortIndex
                        select x).Distinct().ToList();
            return list;
        }
        /// 
        /// 根据MenuType获取菜单集合
        /// 
        /// 
        /// 
        public static List GetIsUsedMenuListBySupType(string menuType)
        {
            List lists = new List();
            if (menuType == "MenuType_S")
            {
                lists = (from x in Funs.DB.Sys_Menu
                         where x.IsOffice == true && x.IsUsed == true
                         orderby x.SortIndex
                         select x).Distinct().ToList();
            }
            else
            {
                lists = (from x in Funs.DB.Sys_Menu
                         where x.IsOffice == false && x.IsUsed == true
                         orderby x.SortIndex
                         select x).Distinct().ToList();
            }
            
            return lists;
        }       
    }
}