111
cjs
2025-06-06 03e67373c4c3bef21936ec1f9037f2ebcd434583
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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 "";
            }
        }
    }
}