using System; using System.Collections.Generic; using System.Data; using BP.DA; using BP.Sys; namespace BP.En { /// /// 访问控制 /// public class UAC { #region 常用方法 public void Readonly() { this.IsUpdate = false; this.IsDelete = false; this.IsInsert = false; this.IsAdjunct = false; this.IsView = true; } /// /// 全部开放 /// public void OpenAll() { this.IsUpdate = true; this.IsDelete = true; this.IsInsert = true; this.IsAdjunct = false; this.IsView = true; } /// /// 为一个角色设置全部的权限 /// /// public void OpenAllForStation(string fk_station) { Paras ps = new Paras(); ps.Add("FK_Emp",BP.Web.WebUser.No); ps.Add("st", fk_station); bool bl; bl = DBAccess.IsExits("SELECT FK_Emp FROM Port_DeptEmpStation WHERE FK_Emp=" + BP.Difference.SystemConfig.AppCenterDBVarStr + "FK_Emp AND FK_Station=" + BP.Difference.SystemConfig.AppCenterDBVarStr + "st", ps); if (bl) this.OpenAll(); else this.Readonly(); } /// /// 仅仅对管理员 /// public UAC OpenForSysAdmin() { // if (BP.Web.WebUser.No.Equals("admin") == true) if (BP.Web.WebUser.IsAdmin) this.OpenAll(); return this; } public UAC OpenForAppAdmin() { /*if (BP.Web.WebUser.No != null && BP.Web.WebUser.No.Contains("admin") == true)*/ if (BP.Web.WebUser.IsAdmin) { this.OpenAll(); } return this; } public UAC OpenForAdmin() { /*if (BP.Web.WebUser.No != null && BP.Web.WebUser.IsAdmin == true)*/ if (BP.Web.WebUser.IsAdmin) { this.OpenAll(); } else { this.Readonly(); } return this; } #endregion #region 控制属性 /// /// 是否插入 /// public bool IsInsert = false; /// /// 是否删除 /// public bool IsDelete = false; /// /// 是否更新 /// public bool IsUpdate = false; /// /// 是否查看 /// public bool IsView = true; /// /// 附件 /// public bool IsAdjunct = false; /// /// 是否可以导出 /// 注意:要启用导出权限控制,请使用uac.IsExp = UserRegedit.HaveRoleForExp(this.ToString()); /// public bool IsExp = false; /// /// 是否可以导入 /// 注意:要启用导入权限控制,请使用uac.IsImp = UserRegedit.HaveRoleForImp(this.ToString()); /// public bool IsImp = false; #endregion #region 构造 /// /// 用户访问 /// public UAC() { } #endregion } }