using Castle.ActiveRecord; using System; using System.Data; using System.Text; namespace BizCom { [ActiveRecord("X_Permission")] public class XPermission : 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 _userID = 0; /// ///组织编号 /// [Property] public int UserID { get { return _userID; } set { _userID = value; } } private int _modularID = 0; /// ///模块编号 /// [Property] public int ModularID { get { return _modularID; } set { _modularID = value; } } public static void Del(object id) { StringBuilder sql = new StringBuilder(); sql.AppendFormat("delete from X_Permission where id=" + id); ExecuteNonQuery(sql.ToString()); } //public static DataTable GetPermission(int personId, string postId) //{ // string sql; // if (personId > 0) sql = string.Format("select ModularID as ID,Name,Tag,Url,Icon,ParentID,IsOperate from view_erppermission where PostID={0} and isDel=0 order by sort asc ", postId); // else sql = "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 uid) { string sql = string.Format("select ModularID as ID,Name,Tag,Url,Icon,ParentID,IsOperate from view_permission where UserID={0} and isDel=0 order by sort asc ", uid); return ExecuteDataset(sql).Tables[0]; } public static void SavePermission(string uId, string oId, string v) { StringBuilder sqlList = new StringBuilder(); sqlList.AppendFormat("delete from X_Permission where OrgID={0} and UserID={1} ;", oId, uId); if (v.Length > 0) { //模块值 string[] sArr = v.Split(','); foreach (string arr in sArr) { sqlList.AppendFormat("insert into X_Permission(OrgID,UserID,ModularID) Values({0},{1},{2}); ", oId, uId, arr); } } try { DbConn.ExecuteNonQuery(sqlList.ToString()); } catch (Exception) { throw; } } } }