|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Configuration;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace DAL
|
|
|
{
|
|
|
public class DBFactoryHelper
|
|
|
{
|
|
|
private IDbInterface DBHelper;
|
|
|
public DBFactoryHelper(string dbType, string conStr)
|
|
|
{
|
|
|
if (dbType == "1")
|
|
|
{
|
|
|
DBHelper = new DBHelperSql(conStr);
|
|
|
}
|
|
|
else if (dbType == "2")
|
|
|
{
|
|
|
DBHelper = new DbHelperOra(conStr);
|
|
|
}
|
|
|
else if (dbType == "3")
|
|
|
{
|
|
|
DBHelper = new DBHelperDm(conStr);
|
|
|
}
|
|
|
else if (dbType == "4")
|
|
|
{
|
|
|
this.DBHelper = new DBHelperMySql(conStr);
|
|
|
}
|
|
|
}
|
|
|
public object GetSingle(string SQLString)
|
|
|
{
|
|
|
return DBHelper.GetSingle(SQLString);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="strSql"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool Exists(string strSql)
|
|
|
{
|
|
|
return DBHelper.Exists(strSql);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行多条SQL语句,实现数据库事务。
|
|
|
/// </summary>
|
|
|
/// <param name="SQLStringList">多条SQL语句</param>
|
|
|
public int ExecuteSqlTran(List<String> SQLStringList)
|
|
|
{
|
|
|
return DBHelper.ExecuteSqlTran(SQLStringList);
|
|
|
}
|
|
|
public bool ExecuteSqlTran(List<string> sqlList, List<IDataParameter[]> cmdParamList)
|
|
|
{
|
|
|
return DBHelper.ExecuteSqlTran(sqlList, cmdParamList);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行查询语句,返回DataSet
|
|
|
/// </summary>
|
|
|
/// <param name="SQLString">查询语句</param>
|
|
|
/// <returns>DataSet</returns>
|
|
|
public DataSet Query(string SQLString)
|
|
|
{
|
|
|
return DBHelper.Query(SQLString);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行SQL语句,返回影响的记录数
|
|
|
/// </summary>
|
|
|
/// <param name="SQLString">SQL语句</param>
|
|
|
/// <returns>影响的记录数</returns>
|
|
|
public int ExecuteSql(string SQLString, params IDataParameter[] cmdParms)
|
|
|
{
|
|
|
return DBHelper.ExecuteSql(SQLString, cmdParms);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 执行SQL语句,返回影响的记录数
|
|
|
/// </summary>
|
|
|
/// <param name="SQLString">SQL语句</param>
|
|
|
/// <returns>影响的记录数</returns>
|
|
|
public int ExecuteSql(string SQLString)
|
|
|
{
|
|
|
return DBHelper.ExecuteSql(SQLString);
|
|
|
}
|
|
|
}
|
|
|
}
|