| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using Castle.ActiveRecord;
- using System.Data;
- using System.Text;
- namespace BizCom
- {
- [ActiveRecord("X_Modular")]
- public class XModular : DicSysBase
- {
- public XModular()
- {
- rootName = "系统模块";
- titleName = "系统模块根结点";
- tableName = "X_Modular";
- }
- [Property]
- public new string Url
- {
- get { return _url; }
- set { _url = value; }
- }
- [Property]
- public new string Tag
- {
- get { return _tag; }
- set { _tag = value; }
- }
- /// <summary>
- ///是否操作
- /// </summary>
- [Property]
- public new bool isOperate
- {
- get { return _isOperate; }
- set { _isOperate = value; }
- }
- /// <summary>
- ///图标
- /// </summary>
- [Property]
- public new string Icon
- {
- get { return _icon; }
- set { _icon = value; }
- }
- public static DataTable GetModular()
- {
- return DbConn.ExecuteDataset("select * from X_Modular where isdel=0 order by sort asc").Tables[0];
- }
- public static DataTable GetOrgModular(string oId)
- {
- string sql = "select * from X_Modular where ID in( select ModularID from ce_erppermission where orgid=" + oId + " and postID=0) and isDel=0 order by sort asc";
- return DbConn.ExecuteDataset(sql).Tables[0];
- }
- public static DataTable GetModularNoOperate()
- {
- string sql = "select * from X_Modular where isdel=0 and isoperate=0 order by path asc, sort asc";
- return DbConn.ExecuteDataset(sql).Tables[0];
- }
- //public static void TransModular(object id,object pId,int sort)
- //{
- // StringBuilder sql=new StringBuilder();
- // sql.AppendFormat("declare @oldid int;");
- // sql.AppendFormat("select @oldid=parentid from X_Modular where id={0} ;",id);
- // sql.AppendFormat("update X_Modular set path=REPLACE(Path,@oldid,'{0}') where path like '%|'+(select Convert(varchar,id) from X_Modular where ID={1})+'%|' or ID={1} ;", pId, id);
- // sql.AppendFormat("update X_Modular set parentid={0},sort={1} where id={2} ;", pId,sort,id);
- // TransExecuteNonQuery(sql.ToString());
- //}
- //获取角色模块
- public static DataTable GetResourceByRoleID(int roleId)
- {
- string sql = "select * from X_Modular where Code in(select ResCode from LC_SysRoleToResource where RoleID={0}) and IsDel=0 order by parentid,ordernum ";
- return DbConn.ExecuteDataset(string.Format(sql, roleId)).Tables[0];
- }
- public static void BuilderOperate(string mId)
- {
- StringBuilder sql = new StringBuilder();
- DataTable dt = DbConn.ExecuteDataset("select * from X_Modular where id=" + mId).Tables[0];
- if (dt == null || dt.Rows.Count < 1) return;
- DataRow dr = dt.Rows[0];
- string tag = dr["Tag"].ToString();
- string path = dr["Path"] + mId + "|";
- sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
- mId, "查看", tag + "_view", path, 0);
- sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
- mId, "添加", tag + "_add", path, 1);
- sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
- mId, "修改", tag + "_edit", path, 2);
- sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
- mId, "删除", tag + "_del", path, 3);
- TransExecuteNonQuery(sql.ToString());
- }
- }
- }
|