114 lines
3.4 KiB
C#
114 lines
3.4 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace BLL
|
|||
|
{
|
|||
|
public class Sys_ButtonPowerService
|
|||
|
{
|
|||
|
///// <summary>
|
|||
|
///// 获取按钮权限集合
|
|||
|
///// </summary>
|
|||
|
///// <param name="roleId">角色ID</param>
|
|||
|
///// <param name="menuId">菜单ID</param>
|
|||
|
///// <returns>按钮集合</returns>
|
|||
|
//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;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 删除权限
|
|||
|
/// </summary>
|
|||
|
/// <param name="roleId"></param>
|
|||
|
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();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 增加按钮权限
|
|||
|
/// </summary>
|
|||
|
/// <param name="power"></param>
|
|||
|
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();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 判断菜单是否存在
|
|||
|
/// </summary>
|
|||
|
/// <param name="postId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 判断按键对应菜单是否存在
|
|||
|
/// </summary>
|
|||
|
/// <param name="postId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
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;
|
|||
|
//}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|