using System; using System.Collections.Generic; using System.Text; using SysBaseLibs; using SysDataLibs.TableClass; namespace SysDataLibs { public class SysSettingObj { public SysSettingObj() { CreateSysSetting(); } Dictionary _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(); 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; } } }