CeErpPermission.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using Castle.ActiveRecord;
  2. using System;
  3. using System.Data;
  4. using System.Text;
  5. namespace BizCom
  6. {
  7. [ActiveRecord("CE_ErpPermission ")]
  8. public class CeErpPermission : ComBase<CeErpPermission>
  9. {
  10. /// <summary>
  11. /// ÄÚ²¿±àºÅ
  12. /// </summary>
  13. [PrimaryKey(PrimaryKeyType.Native)]
  14. public int ID { get; set; }
  15. private int _orgID = 0;
  16. /// <summary>
  17. ///×éÖ¯±àºÅ
  18. /// </summary>
  19. [Property]
  20. public int OrgID
  21. {
  22. get { return _orgID; }
  23. set { _orgID = value; }
  24. }
  25. private int _postID = 0;
  26. /// <summary>
  27. ///ְλ±àºÅ
  28. /// </summary>
  29. [Property]
  30. public int PostID
  31. {
  32. get { return _postID; }
  33. set { _postID = value; }
  34. }
  35. private int _modularID = 0;
  36. /// <summary>
  37. ///Ä£¿é±àºÅ
  38. /// </summary>
  39. [Property]
  40. public int ModularID
  41. {
  42. get { return _modularID; }
  43. set { _modularID = value; }
  44. }
  45. public static DataTable GetErpPermission(object uid)
  46. {
  47. 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);
  48. return ExecuteDataset(sql).Tables[0];
  49. }
  50. public static DataTable GetErpAllPermission()
  51. {
  52. string sql = string.Format("select ID,Name,Tag,Url,Icon,ParentID,IsOperate from ce_erpmodular where isDel=0 order by sort asc ");
  53. return ExecuteDataset(sql).Tables[0];
  54. }
  55. public static DataTable GetPermission(string pId, string oId)
  56. {
  57. string sql = "select ModularID as ID from view_erppermission where orgid={0} and postID={1} and isDel=0 ";
  58. return DbConn.ExecuteDataset(string.Format(sql, oId, pId)).Tables[0];
  59. }
  60. public static void SaveOrgPermission(string oId, string v)
  61. {
  62. StringBuilder sqlList = new StringBuilder();
  63. sqlList.AppendFormat("delete from Ce_ErpPermission where OrgID={0} and PostID=0 ;", oId);
  64. if (v.Length > 0)
  65. {
  66. //Ä£¿éÖµ
  67. string[] sArr = v.Split(',');
  68. foreach (string arr in sArr)
  69. {
  70. sqlList.AppendFormat("insert into Ce_ErpPermission(OrgID,ModularID) Values({0},{1}); ", oId, arr);
  71. }
  72. }
  73. try
  74. {
  75. DbConn.ExecuteNonQuery(sqlList.ToString());
  76. }
  77. catch (Exception)
  78. {
  79. throw;
  80. }
  81. }
  82. public static void SavePostPermission(string pId, string oId, string v)
  83. {
  84. StringBuilder sqlList = new StringBuilder();
  85. sqlList.AppendFormat("delete from Ce_ErpPermission where OrgID={0} and PostID={1} ;", oId, pId);
  86. if (v.Length > 0)
  87. {
  88. //Ä£¿éÖµ
  89. string[] sArr = v.Split(',');
  90. foreach (string arr in sArr)
  91. {
  92. sqlList.AppendFormat("insert into Ce_ErpPermission(OrgID,PostID,ModularID) Values({0},{1},{2}); ", oId, pId, arr);
  93. }
  94. }
  95. try
  96. {
  97. DbConn.ExecuteNonQuery(sqlList.ToString());
  98. }
  99. catch (Exception)
  100. {
  101. throw;
  102. }
  103. }
  104. }
  105. }