XModular.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using Castle.ActiveRecord;
  2. using System.Data;
  3. using System.Text;
  4. namespace BizCom
  5. {
  6. [ActiveRecord("X_Modular")]
  7. public class XModular : DicSysBase
  8. {
  9. public XModular()
  10. {
  11. rootName = "系统模块";
  12. titleName = "系统模块根结点";
  13. tableName = "X_Modular";
  14. }
  15. [Property]
  16. public new string Url
  17. {
  18. get { return _url; }
  19. set { _url = value; }
  20. }
  21. [Property]
  22. public new string Tag
  23. {
  24. get { return _tag; }
  25. set { _tag = value; }
  26. }
  27. /// <summary>
  28. ///是否操作
  29. /// </summary>
  30. [Property]
  31. public new bool isOperate
  32. {
  33. get { return _isOperate; }
  34. set { _isOperate = value; }
  35. }
  36. /// <summary>
  37. ///图标
  38. /// </summary>
  39. [Property]
  40. public new string Icon
  41. {
  42. get { return _icon; }
  43. set { _icon = value; }
  44. }
  45. public static DataTable GetModular()
  46. {
  47. return DbConn.ExecuteDataset("select * from X_Modular where isdel=0 order by sort asc").Tables[0];
  48. }
  49. public static DataTable GetOrgModular(string oId)
  50. {
  51. 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";
  52. return DbConn.ExecuteDataset(sql).Tables[0];
  53. }
  54. public static DataTable GetModularNoOperate()
  55. {
  56. string sql = "select * from X_Modular where isdel=0 and isoperate=0 order by path asc, sort asc";
  57. return DbConn.ExecuteDataset(sql).Tables[0];
  58. }
  59. //public static void TransModular(object id,object pId,int sort)
  60. //{
  61. // StringBuilder sql=new StringBuilder();
  62. // sql.AppendFormat("declare @oldid int;");
  63. // sql.AppendFormat("select @oldid=parentid from X_Modular where id={0} ;",id);
  64. // 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);
  65. // sql.AppendFormat("update X_Modular set parentid={0},sort={1} where id={2} ;", pId,sort,id);
  66. // TransExecuteNonQuery(sql.ToString());
  67. //}
  68. //获取角色模块
  69. public static DataTable GetResourceByRoleID(int roleId)
  70. {
  71. string sql = "select * from X_Modular where Code in(select ResCode from LC_SysRoleToResource where RoleID={0}) and IsDel=0 order by parentid,ordernum ";
  72. return DbConn.ExecuteDataset(string.Format(sql, roleId)).Tables[0];
  73. }
  74. public static void BuilderOperate(string mId)
  75. {
  76. StringBuilder sql = new StringBuilder();
  77. DataTable dt = DbConn.ExecuteDataset("select * from X_Modular where id=" + mId).Tables[0];
  78. if (dt == null || dt.Rows.Count < 1) return;
  79. DataRow dr = dt.Rows[0];
  80. string tag = dr["Tag"].ToString();
  81. string path = dr["Path"] + mId + "|";
  82. sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
  83. mId, "查看", tag + "_view", path, 0);
  84. sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
  85. mId, "添加", tag + "_add", path, 1);
  86. sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
  87. mId, "修改", tag + "_edit", path, 2);
  88. sql.AppendFormat("insert into X_Modular(parentid,name,tag,path,sort,isoperate) Values({0},'{1}','{2}','{3}',{4},1) ;",
  89. mId, "删除", tag + "_del", path, 3);
  90. TransExecuteNonQuery(sql.ToString());
  91. }
  92. }
  93. }