using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public class Project_RoleButtonPowerService { /// /// 获取按钮权限集合 /// /// 角色ID /// 菜单ID /// 项目ID /// 按钮集合 public static string[] GetProject_RoleButtonPowerList(string roleId, string menuId,string projectId) { Model.SGGLDB db = Funs.DB; var q = from x in db.Project_RoleButtonPower where x.RoleId == roleId && x.MenuId == menuId && x.ProjectId == projectId 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 DeleteProject_RoleButtonPower(string roleId, string systemValue, string projectId) { Model.SGGLDB db = Funs.DB; var bt = from x in db.Project_RoleButtonPower join y in db.Sys_Menu on x.MenuId equals y.MenuId where x.RoleId == roleId && y.MenuModule == systemValue && x.ProjectId == projectId select x; if (bt.Count() > 0) { db.Project_RoleButtonPower.DeleteAllOnSubmit(bt); } db.SubmitChanges(); } /// /// 增加按钮权限 /// /// public static void SaveProject_RoleButtonPower(Model.Project_RoleButtonPower btn) { Model.SGGLDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Project_RoleButtonPower)); Model.Project_RoleButtonPower button = new Model.Project_RoleButtonPower(); button.ButtonPowerID = newKeyID; button.RoleId = btn.RoleId; button.MenuId = btn.MenuId; button.ButtonToMenuId = btn.ButtonToMenuId; button.ProjectId = btn.ProjectId; db.Project_RoleButtonPower.InsertOnSubmit(button); db.SubmitChanges(); } } }