using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public class Sys_ButtonPowerService { ///// ///// 获取按钮权限集合 ///// ///// 角色ID ///// 菜单ID ///// 按钮集合 //public static string[] GetButtonPowerList(string roleId, string menuId) //{ // Model.EProject db = Funs.DB; // var q = from x in db.Sys_ButtonPower where x.RoleId == roleId && x.MenuId == menuId select x; // if (q != null) // { // string[] button = new string[q.Count()]; // int i = 0; // foreach (var b in q) // { // Model.ButtonToMenu btn = db.ButtonToMenu.FirstOrDefault(e => e.ButtonToMenuId == b.ButtonToMenuId); // button[i] = btn.ButtonName; // i++; // } // return button; // } // else // { // return null; // } //} /// /// 删除权限 /// /// public static void DeleteButtonPower(string roleId) { //Model.EProjectDB db = Funs.DB; var bt = from x in Funs.DB.Sys_ButtonPower join y in Funs.DB.Sys_Menu on x.MenuId equals y.MenuId where x.RoleId == roleId select x; if (bt.Count() > 0) { Funs.DB.Sys_ButtonPower.DeleteAllOnSubmit(bt); } Funs.DB.SubmitChanges(); } /// /// 增加按钮权限 /// /// public static void SaveButtonPower(Model.Sys_ButtonPower btn) { //Model.EProjectDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Sys_ButtonPower)); Model.Sys_ButtonPower button = new Model.Sys_ButtonPower(); button.ButtonPowerID = newKeyID; button.RoleId = btn.RoleId; button.MenuId = btn.MenuId; button.ButtonToMenuId = btn.ButtonToMenuId; Funs.DB.Sys_ButtonPower.InsertOnSubmit(button); Funs.DB.SubmitChanges(); } /// /// 判断菜单是否存在 /// /// /// public static bool IsExistMenu(string menuId) { Model.Sys_Menu m = Funs.DB.Sys_Menu.FirstOrDefault(e => e.MenuId == menuId); if (m != null) { return true; } else { return false; } } /// /// 判断按键对应菜单是否存在 /// /// /// public static bool isExistButtonToMenu(string buttonToMenuId) { //Model.Sys_ButtonToMenu b = Funs.DB.Sys_ButtonToMenu.FirstOrDefault(e => e.ButtonToMenuId == buttonToMenuId); //if (b != null) //{ // return true; //} //else //{ return false; //} } } }