using System;
|
using System.Collections.Generic;
|
using System.Configuration;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace HH.AMS.Common
|
{
|
public class DBFunction
|
{
|
public enum DBTYPE
|
{
|
MYSQL,
|
MSSQL,
|
ORACLE,
|
ORTHER
|
}
|
|
public static string dbType = ConfigurationManager.ConnectionStrings["DataType"].ToString();
|
public static DBTYPE Now_dbType
|
{
|
get
|
{
|
if (dbType.Equals("MYSQL"))
|
return DBTYPE.MYSQL;
|
if (dbType.Equals("MSSQL"))
|
return DBTYPE.MSSQL;
|
if (dbType.Equals("ORACLE"))
|
return DBTYPE.ORACLE;
|
return DBTYPE.ORTHER;
|
}
|
}
|
public static string StringToTime(string time)
|
{
|
switch (Now_dbType)
|
{
|
case DBTYPE.MYSQL: return "str_to_date('" + time + "', '%Y-%m-%d %H:%i:%s')";
|
case DBTYPE.MSSQL: return " convert(datetime,'" + time + "') ";
|
//case DBTYPE.ORACLE: return " SYSDATE() ";
|
default: return "";
|
}
|
}
|
|
public static string StringAddDay(string time,int day)
|
{
|
switch (Now_dbType)
|
{
|
case DBTYPE.MYSQL: return "date_add('" + time + "',interval "+day+" day)";
|
case DBTYPE.MSSQL: return " convert(datetime,'" + time + "')+"+day;
|
//case DBTYPE.ORACLE: return " SYSDATE() ";
|
default: return "";
|
}
|
}
|
}
|
}
|