123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using SysBaseLibs;
- using SysDataLibs.TableClass;
- namespace SysDataLibs
- {
- public class SysSettingObj
- {
- public SysSettingObj()
- {
- CreateSysSetting();
- }
- Dictionary<string, string> _DiscList = null;
- private void CreateSysSetting()
- {
- DBConnSql loConn = new DBConnSql();
- if (loConn.Open())
- {
- string lcSql = " select " + Sys_Setting_info.cSysSetCode + "," + Sys_Setting_info.cSysSetValue + " from " + Tn.Sys_Setting;
- rsQuery loQuery = loConn.OpenQuery(lcSql);
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- {
- _DiscList = new Dictionary<string, string>();
- loQuery.MoveFirst();
- for (int i = 0; i < loQuery.RecCount; i++)
- {
- string lcCode = loQuery.GetString(Sys_Setting_info.cSysSetCode);
- lcCode = UtilStr.UAndT(lcCode);
- if (!_DiscList.ContainsKey(lcCode))
- _DiscList.Add(lcCode, loQuery.GetString(Sys_Setting_info.cSysSetValue));
- loQuery.MoveNext();
- }
- }
- loConn.Close();
- }
- }
- public string GetRealString(string pcCode)
- {
- return SysSecLibs.SysSecurity.Decrypt(GetString(pcCode));
- }
- public bool GetBool(string pcCode)
- {
- return Utils.ObjToBool(GetString(pcCode));
- }
- public int GetInt(string pcCode)
- {
- return Utils.ValI( GetString(pcCode));
- }
- public void Refresh()
- {
- _DiscList.Clear();
- _DiscList = null;
- CreateSysSetting();
- }
- public string GetString(string pcCode)
- {
- string lcRetVal = "";
- pcCode = UtilStr.UAndT(pcCode);
- if (_DiscList == null)
- {
- CreateSysSetting();
- }
- if (_DiscList != null && _DiscList.ContainsKey(pcCode))
- lcRetVal = _DiscList[pcCode];
- return lcRetVal;
- }
- public bool SetString(string pcCode, string pcValue)
- {
- bool lbRetval = false;
- DBConnSql loConn = new DBConnSql();
- try
- {
- if (loConn.Open())
- {
- Sys_Setting_info loSet = new Sys_Setting_info(pcCode, loConn);
- loSet.SysSetValue = pcValue;
- if (loConn.ExecuteSql(loSet.UpdateSql()))
- {
- lbRetval = true;
- Refresh();
- }
- }
- }
- catch
- {
- lbRetval = false;
- }
- finally
- {
- loConn.Close();
- }
- return lbRetval;
- }
- }
- }
|