添加项目文件。
This commit is contained in:
100
Epost.DAL/HistoryDataDAL.cs
Normal file
100
Epost.DAL/HistoryDataDAL.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Epost.DAL
|
||||
{
|
||||
public class HistoryDataDAL
|
||||
{
|
||||
DataBaseOpration.OprationSqlDAL db = DB_DLL.GetInstance();
|
||||
|
||||
#region 删除表名
|
||||
public bool DeleteTable(string table)
|
||||
{
|
||||
//执行删除语句
|
||||
string sql = "";
|
||||
if (table == "Ordershis")
|
||||
{
|
||||
sql = "delete from Ordershis where state!=3";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = "delete from {0}";
|
||||
sql = string.Format(sql, table);
|
||||
}
|
||||
|
||||
|
||||
//如果表中数据为空
|
||||
string sql1 = "select count(*) from {0}";
|
||||
sql1 = string.Format(sql1, table);
|
||||
DataTable dt = db.GetsqlForDT(sql1);
|
||||
int y = Convert.ToInt32(dt.Rows[0][0].ToString());
|
||||
if (y == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int x = db.InsertSql(sql);
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 保存删除时间(数据库数据)
|
||||
public bool SaveTime(String table, string date)
|
||||
{
|
||||
int x = -1;
|
||||
string sql = "alter proceduce proceduce_delete " +
|
||||
"as delete from {0} where {1}<DATEADD(DAY,{2} GETDATE()) go " +
|
||||
"Execute proceduce_delete";
|
||||
if (table == "Error")
|
||||
{
|
||||
sql = string.Format(sql, table, "date", Convert.ToInt32(date) * (-1), "GETDATE()");
|
||||
}
|
||||
else if (table == "Orders")
|
||||
{
|
||||
sql = string.Format(sql, table, "downdate", Convert.ToInt32(date) * (-1), "GETDATE()");
|
||||
}
|
||||
//GetsqlForDT
|
||||
x = db.InsertSql(sql);
|
||||
if (x != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 查询历史数据
|
||||
public DataTable HistoryData()
|
||||
{
|
||||
string sql = "exec sys_viewtablespace";
|
||||
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user