SysSettingObj.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using SysBaseLibs;
  5. using SysDataLibs.TableClass;
  6. namespace SysDataLibs
  7. {
  8. public class SysSettingObj
  9. {
  10. public SysSettingObj()
  11. {
  12. CreateSysSetting();
  13. }
  14. Dictionary<string, string> _DiscList = null;
  15. private void CreateSysSetting()
  16. {
  17. DBConnSql loConn = new DBConnSql();
  18. if (loConn.Open())
  19. {
  20. string lcSql = " select " + Sys_Setting_info.cSysSetCode + "," + Sys_Setting_info.cSysSetValue + " from " + Tn.Sys_Setting;
  21. rsQuery loQuery = loConn.OpenQuery(lcSql);
  22. if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  23. {
  24. _DiscList = new Dictionary<string, string>();
  25. loQuery.MoveFirst();
  26. for (int i = 0; i < loQuery.RecCount; i++)
  27. {
  28. string lcCode = loQuery.GetString(Sys_Setting_info.cSysSetCode);
  29. lcCode = UtilStr.UAndT(lcCode);
  30. if (!_DiscList.ContainsKey(lcCode))
  31. _DiscList.Add(lcCode, loQuery.GetString(Sys_Setting_info.cSysSetValue));
  32. loQuery.MoveNext();
  33. }
  34. }
  35. loConn.Close();
  36. }
  37. }
  38. public string GetRealString(string pcCode)
  39. {
  40. return SysSecLibs.SysSecurity.Decrypt(GetString(pcCode));
  41. }
  42. public bool GetBool(string pcCode)
  43. {
  44. return Utils.ObjToBool(GetString(pcCode));
  45. }
  46. public int GetInt(string pcCode)
  47. {
  48. return Utils.ValI( GetString(pcCode));
  49. }
  50. public void Refresh()
  51. {
  52. _DiscList.Clear();
  53. _DiscList = null;
  54. CreateSysSetting();
  55. }
  56. public string GetString(string pcCode)
  57. {
  58. string lcRetVal = "";
  59. pcCode = UtilStr.UAndT(pcCode);
  60. if (_DiscList == null)
  61. {
  62. CreateSysSetting();
  63. }
  64. if (_DiscList != null && _DiscList.ContainsKey(pcCode))
  65. lcRetVal = _DiscList[pcCode];
  66. return lcRetVal;
  67. }
  68. public bool SetString(string pcCode, string pcValue)
  69. {
  70. bool lbRetval = false;
  71. DBConnSql loConn = new DBConnSql();
  72. try
  73. {
  74. if (loConn.Open())
  75. {
  76. Sys_Setting_info loSet = new Sys_Setting_info(pcCode, loConn);
  77. loSet.SysSetValue = pcValue;
  78. if (loConn.ExecuteSql(loSet.UpdateSql()))
  79. {
  80. lbRetval = true;
  81. Refresh();
  82. }
  83. }
  84. }
  85. catch
  86. {
  87. lbRetval = false;
  88. }
  89. finally
  90. {
  91. loConn.Close();
  92. }
  93. return lbRetval;
  94. }
  95. }
  96. }