appconfig.cs

来自「基于C/S的医疗卫生管理系统」· CS 代码 · 共 53 行

CS
53
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Qeb.Support
{
    public class AppConfig
    {
        static public string GetDBConnection(string key)
        {
            //调用非托管DLL解密
            return System.Configuration.ConfigurationSettings.AppSettings[key].ToString();
        }

        public static string GetValue(string key)
        {
            return GetValue(key, "");
        }

        public static string GetValue(string key,string defaultValue)
        {
#if DEBUG
            //return defaultValue;
            string value = System.Configuration.ConfigurationSettings.AppSettings[key].ToString();
            if (string.IsNullOrEmpty(value.Trim()))
                value = defaultValue;

            return value;
#else            
                try
                {
                    string value = System.Configuration.ConfigurationSettings.AppSettings[key].ToString();
                    if (string.IsNullOrEmpty(value.Trim()))
                        value = defaultValue;                    
                }
                catch (Exception ex)
                {
                    value = "";
                }

                return value;
#endif
            
        }

        public static void SetDBConnection(string key,string value)
        {
            
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?