110,539
社区成员
发帖
与我相关
我的任务
分享
//有以下几个对象:
//1、业务窗体
public partial class FrmBranch : BaseDock
{
private PermissionsController Permissions { get; set; }
public FrmBranch()
{
InitializeComponent();
Permissions = new PermissionsController(this); //权限控制类
//根据权限屏蔽功能对象
InitAutothorizedUI();
}
}
//2、权限类
public class PermissionsController
{
private BaseDock Basedock { get; set; }
private BaseForm Baseform { get; set; }
/// <summary>
/// 功能模块名称
/// </summary>
public string Itemno { get; set; }
public PermissionsController(BaseDock frm)
{
Basedock = frm;
GetItemno();
}
public PermissionsController(BaseForm frm)
{
Baseform = frm;
GetItemno();
}
/// <summary>
/// 检查用户功能级权限
/// </summary>
/// <param name="itemno"></param>
public bool CheckUserFuncAuth()
{
//是否具备功能模块权限
bool IsAuthorization = false;
//判断查询权限
if (Basedock != null)
if (!Basedock.GetLiminf(Portal.gc.UserInfo.Logno, Itemno, "aaaa"))
{
IsAuthorization = true;
MessageDxUtil.ShowWarning("当前账户【" + Portal.gc.UserInfo.Logno + "】没有查询权限,请联系系统管理员!");
}
if (Baseform != null)
if (!Baseform.GetLiminf(Portal.gc.UserInfo.Logno, Itemno, "brow"))
{
IsAuthorization = true;
throw new ArgumentException("当前账户【" + Portal.gc.UserInfo.Logno + "】没有查询权限,请联系系统管理员!");
}
return IsAuthorization;
}
/// <summary>
/// 获取当前类模块名称
/// </summary>
/// <returns></returns>
private void GetItemno()
{
if (Basedock != null)
Itemno = BusinessHelper.GetRemovePrefixString(Basedock.Name, "Frm");
if (Baseform != null)
Itemno = BusinessHelper.GetRemovePrefixString(Baseform.Name, "Frm");
}
}