📄 config.cs
字号:
using System;
using System.Data;
using System.Configuration;
namespace HouseSystem.Components
{
/// <summary>
/// Config 的摘要说明。
/// </summary>
public class Config
{
private static int dbType;
public Config()
{
Config.dbType =DbType.SQLServer;
}
public static int GetDbType
{
get
{
return Config.dbType;
}
}
public static string GetConnectionString()
{
Config.GetConfig();
string text1 = null;
switch (Config.dbType)
{
case 0://DbType.Access
{
string text2 = ConfigurationSettings.AppSettings["CONNSTR_Access"];
int num1 = text2.IndexOf("fullpath:");
if (num1 == -1)
{
return ("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory.ToString() + text2);
}
text2 = text2.Substring(9);
return ("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + text2);
}
case 1://DbType.SQLServer
{
return ConfigurationSettings.AppSettings["CONNSTR_SQL"];
}
}
return text1;
}
public static void GetConfig()
{
string text1 = ConfigurationSettings.AppSettings["My_DBType"].ToLower();
if (text1 == "access")
{
Config.dbType = DbType.Access;
}
else
{
if (text1 == "sqlserver")
{
throw new Exception("\u9519\u8bef\uff0c\u514d\u8d39\u7248\u4e0d\u652f\u6301Sql Server\u6570\u636e\u5e93\uff01");
}
throw new Exception("\u914d\u7f6e\u6587\u4ef6\u9519\u8bef!");
}
}
public static DataRow GetWebConfigInfo()
{
string text1 = "SELECT [weburl],[webname],[webemail],[weblinkman],[webtel1],[webtel2],[webexpire],[webtype] FROM [Config] WHERE [ID]=0";
return SQLDAL.SQLHelper.ExecuteDataRow(text1);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -