using Castle.ActiveRecord; using System; using System.Data; using System.Text; namespace BizCom { [ActiveRecord("CE_ErpPermission ")] public class CeErpPermission : ComBase { /// /// 内部编号 /// [PrimaryKey(PrimaryKeyType.Native)] public int ID { get; set; } private int _orgID = 0; /// ///组织编号 /// [Property] public int OrgID { get { return _orgID; } set { _orgID = value; } } private int _postID = 0; /// ///职位编号 /// [Property] public int PostID { get { return _postID; } set { _postID = value; } } private int _modularID = 0; /// ///模块编号 /// [Property] public int ModularID { get { return _modularID; } set { _modularID = value; } } public static DataTable GetErpPermission(object uid) { string sql = string.Format("select ModularID as ID,Name,code,Tag,Url,Icon,ParentID,IsOperate from view_erppermission where PostID={0} and isDel=0 order by sort asc ", uid); return ExecuteDataset(sql).Tables[0]; } public static DataTable GetErpAllPermission() { string sql = string.Format("select ID,Name,Tag,Url,Icon,ParentID,IsOperate from ce_erpmodular where isDel=0 order by sort asc "); return ExecuteDataset(sql).Tables[0]; } public static DataTable GetPermission(string pId, string oId) { string sql = "select ModularID as ID from view_erppermission where orgid={0} and postID={1} and isDel=0 "; return DbConn.ExecuteDataset(string.Format(sql, oId, pId)).Tables[0]; } public static void SaveOrgPermission(string oId, string v) { StringBuilder sqlList = new StringBuilder(); sqlList.AppendFormat("delete from Ce_ErpPermission where OrgID={0} and PostID=0 ;", oId); if (v.Length > 0) { //模块值 string[] sArr = v.Split(','); foreach (string arr in sArr) { sqlList.AppendFormat("insert into Ce_ErpPermission(OrgID,ModularID) Values({0},{1}); ", oId, arr); } } try { DbConn.ExecuteNonQuery(sqlList.ToString()); } catch (Exception) { throw; } } public static void SavePostPermission(string pId, string oId, string v) { StringBuilder sqlList = new StringBuilder(); sqlList.AppendFormat("delete from Ce_ErpPermission where OrgID={0} and PostID={1} ;", oId, pId); if (v.Length > 0) { //模块值 string[] sArr = v.Split(','); foreach (string arr in sArr) { sqlList.AppendFormat("insert into Ce_ErpPermission(OrgID,PostID,ModularID) Values({0},{1},{2}); ", oId, pId, arr); } } try { DbConn.ExecuteNonQuery(sqlList.ToString()); } catch (Exception) { throw; } } } }