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; } public static Model.Sys_Menu GetSys_MenuById(string MenuId) { return Funs.DB.Sys_Menu.FirstOrDefault(e => e.MenuId == MenuId); } /// /// 根据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; } public static void UpdateSys_Menu(Model.Sys_Menu newtable) { Model.Sys_Menu table = Funs.DB.Sys_Menu.FirstOrDefault(e => e.MenuId == newtable.MenuId); if (table != null) { table.MenuId = newtable.MenuId; table.IsUsed = newtable.IsUsed; table.MenuName = newtable.MenuName; table.Icon = newtable.Icon; table.Url = newtable.Url; table.SortIndex = newtable.SortIndex; table.SuperMenu = newtable.SuperMenu; table.MenuType = newtable.MenuType; table.IsOffice = newtable.IsOffice; table.IsEnd = newtable.IsEnd; Funs.DB.SubmitChanges(); } } public static void SetAllIsUsed(string MenuType) { var q = from x in Funs.DB.Sys_Menu where x.MenuType == MenuType select x; foreach (var p in q) { p.IsUsed = false; } db.SubmitChanges(); } } }