UIAndPower.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. using SysBaseLibs;
  6. using SysDataLibs.TableClass;
  7. namespace SysDataLibs
  8. {
  9. public class UIAndPower
  10. {
  11. // Fields
  12. private string _FunctoinId = "";
  13. private bool _IsAdd = false;
  14. private bool _IsBrowse = false;
  15. private bool _IsDelete = false;
  16. private bool _IsAudit = false;
  17. private bool _IsPrint = false;
  18. private bool _IsUpdate = false;
  19. private string _PageName = "";
  20. List<string> _PageNameList = null;
  21. public UIAndPower(DataRow poRow)
  22. {
  23. if (poRow != null)
  24. {
  25. _FunctoinId = UtilStr.StrFromObj(poRow[Sys_Functions_info.cFunctionID]);
  26. _IsAdd = Utils.ObjToBool(poRow[Sys_Functions_info.cIsAdd]);
  27. _IsBrowse = Utils.ObjToBool(poRow[Sys_Functions_info.cIsBrowse]);
  28. _IsDelete = Utils.ObjToBool(poRow[Sys_Functions_info.cIsDelete]);
  29. _IsAudit = Utils.ObjToBool(poRow[Sys_Functions_info.cIsAudit]);
  30. _IsPrint = Utils.ObjToBool(poRow[Sys_Functions_info.cIsPrint]);
  31. _IsUpdate = Utils.ObjToBool(poRow[Sys_Functions_info.cIsUpdate]);
  32. _PageName = UtilStr.StrFromObj(poRow[Sys_Functions_info.cPageName]);
  33. _PageName = UtilStr.UAndT(_PageName);
  34. }
  35. }
  36. public List<string> PageNameList
  37. {
  38. get
  39. {
  40. if (_PageNameList == null)
  41. {
  42. _PageNameList = new List<string>();
  43. Array loArr = UtilStr.StrToArrayEx(_PageName, ";");
  44. if (loArr != null && loArr.Length > 0)
  45. {
  46. foreach (string lcName in loArr)
  47. _PageNameList.Add(lcName);
  48. }
  49. }
  50. return _PageNameList;
  51. }
  52. }
  53. // Properties
  54. public string FunctoinId
  55. {
  56. get
  57. {
  58. return this._FunctoinId;
  59. }
  60. }
  61. public string PageName
  62. {
  63. get { return this._PageName; }
  64. }
  65. public bool ContainsPageName(string pcPageName)
  66. {
  67. pcPageName = UtilStr.UAndT(pcPageName);
  68. return PageNameList.Contains(pcPageName);
  69. }
  70. public bool IsAdd
  71. {
  72. get
  73. {
  74. return this._IsAdd;
  75. }
  76. }
  77. public bool IsUpdate
  78. {
  79. get
  80. {
  81. return this._IsUpdate;
  82. }
  83. }
  84. public bool IsBrowse
  85. {
  86. get
  87. {
  88. return this._IsBrowse;
  89. }
  90. }
  91. public bool IsDelete
  92. {
  93. get
  94. {
  95. return this._IsDelete;
  96. }
  97. }
  98. public bool IsPrint
  99. {
  100. get
  101. {
  102. return this._IsPrint;
  103. }
  104. }
  105. public bool IsAudit
  106. {
  107. get
  108. {
  109. return this._IsAudit;
  110. }
  111. }
  112. }
  113. public class UIAndPowerList : List<UIAndPower>
  114. {
  115. public UIAndPowerList()
  116. {
  117. }
  118. public void SetData(DataTable poDataTable)
  119. {
  120. if (poDataTable != null && poDataTable.Rows != null)
  121. {
  122. foreach (DataRow loRow in poDataTable.Rows)
  123. {
  124. try
  125. {
  126. UIAndPower loPow = new UIAndPower(loRow);
  127. this.Add(loPow);
  128. }
  129. catch (Exception e)
  130. {
  131. ThreadLog.LogException(e);
  132. continue;
  133. }
  134. }
  135. }
  136. }
  137. Dictionary<string, UIAndPower> _PageNameUIAndPowerDic = null;
  138. public Dictionary<string, UIAndPower> PageNameUIAndPowerDic
  139. {
  140. get
  141. {
  142. if (_PageNameUIAndPowerDic == null)
  143. {
  144. _PageNameUIAndPowerDic = new Dictionary<string, UIAndPower>();
  145. foreach (UIAndPower loPower in this)
  146. {
  147. if (loPower.PageNameList.Count > 0)
  148. {
  149. foreach (string lcPageName in loPower.PageNameList)
  150. {
  151. if (_PageNameUIAndPowerDic.ContainsKey(lcPageName))
  152. {
  153. _PageNameUIAndPowerDic[lcPageName] = loPower;
  154. }
  155. else
  156. _PageNameUIAndPowerDic.Add(lcPageName, loPower);
  157. }
  158. }
  159. }
  160. }
  161. return _PageNameUIAndPowerDic;
  162. }
  163. }
  164. public bool ContainFunctionID(string pcFunctionID)
  165. {
  166. bool lbRetVal = false;
  167. foreach (UIAndPower loPower in this)
  168. {
  169. if (loPower.FunctoinId == pcFunctionID)
  170. {
  171. lbRetVal = true;
  172. break;
  173. }
  174. }
  175. return lbRetVal;
  176. }
  177. public bool ContainPageName(string pcPageName)
  178. {
  179. pcPageName = UtilStr.UAndT(pcPageName);
  180. return PageNameUIAndPowerDic.ContainsKey(pcPageName);
  181. }
  182. public UIAndPower getUIAndPowerByPageName(string pcPageName)
  183. {
  184. UIAndPower loRetVal = null;
  185. pcPageName = UtilStr.UAndT(pcPageName);
  186. if (this.PageNameUIAndPowerDic.ContainsKey(pcPageName))
  187. loRetVal = PageNameUIAndPowerDic[pcPageName];
  188. return loRetVal;
  189. }
  190. public string UserFunctionIdList
  191. {
  192. get
  193. {
  194. string lcRetVal = "";
  195. foreach (UIAndPower loUIP in this)
  196. {
  197. lcRetVal += (lcRetVal == "" ? "" : ",") + "'" + loUIP.FunctoinId.Trim() + "'";
  198. }
  199. return lcRetVal;
  200. }
  201. }
  202. public new void Clear()
  203. {
  204. if (_PageNameUIAndPowerDic != null)
  205. {
  206. _PageNameUIAndPowerDic.Clear();
  207. _PageNameUIAndPowerDic = null;
  208. }
  209. base.Clear();
  210. }
  211. }
  212. public enum PowerType
  213. {
  214. IsBrowse = 0,
  215. IsAdd = 1,
  216. IsUpdate = 2,
  217. IsDelete = 3,
  218. IsPrint = 4,
  219. IsAudit = 5
  220. }
  221. }