Files
CleanMachine/CleanMachine.DAL/CM/ShiftCountDAL.cs

97 lines
2.7 KiB
C#
Raw Permalink Normal View History

2022-05-10 15:21:13 +08:00
using LeadDataBaseUtility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CleanMachine.DAL.CM
{
public class ShiftCountDAL
{
public ShiftCountDAL()
{
}
#region 一般方法
/// <summary>
/// 存在
/// </summary>
public bool Exists(DateTime DateTime)
{
string strSql = @"SELECT count(1) from CM_SHIFT_COUNT WHERE DateTime=@DateTime ";
return LeadDbHelperSQLite.ExecuteScalar<int>(strSql, new { DateTime }) > 0;
}
/// <summary>
/// 添加一个数据
/// </summary>
public bool Add(CleanMachine.Model.CM.ShiftCount model)
{
string strSql = $@"INSERT INTO CM_SHIFT_COUNT
2022-05-14 10:46:36 +08:00
(DateTime,count,UserCode)
2022-05-10 15:21:13 +08:00
values
2022-05-14 10:46:36 +08:00
(@DateTime,@Count,@UserCode) ";
2022-05-10 15:21:13 +08:00
return LeadDbHelperSQLite.Execute(strSql, model) > 0;
}
/// <summary>
/// 更新一个数据
/// </summary>
public bool Update(CleanMachine.Model.CM.ShiftCount model)
{
string strSql = $@"UPDATE CM_SHIFT_COUNT SET
2022-05-14 10:46:36 +08:00
count=@Count,UserCode=@UserCode
2022-05-10 15:21:13 +08:00
WHERE DateTime=@DateTime ";
return LeadDbHelperSQLite.Execute(strSql, model) > 0;
}
/// <summary>
/// 删除一个数据
/// </summary>
public bool Delete(string strWhere, object Params = null)
{
string strSql = $@"DELETE FROM CM_SHIFT_COUNT ";
if (strWhere.Trim() != "")
{
strSql += $" WHERE {strWhere}";
}
return LeadDbHelperSQLite.Execute(strSql, Params) > 0;
}
/// <summary>
/// 删除一个数据
/// </summary>
public bool Delete(DateTime DateTime)
{
return this.Delete("DateTime=@DateTime ", new { DateTime });
}
/// <summary>
/// 获得数据列表
/// </summary>
public IEnumerable<CleanMachine.Model.CM.ShiftCount> GetList(string strWhere, object Params = null)
{
string strSql = $@"SELECT * FROM CM_SHIFT_COUNT ";
if (strWhere.Trim() != "")
{
strSql += $" WHERE {strWhere}";
}
return LeadDbHelperSQLite.Query <CleanMachine.Model.CM.ShiftCount> (strSql, Params);
}
/// <summary>
/// 获取一个对象
/// </summary>
public CleanMachine.Model.CM.ShiftCount GetModel(DateTime DateTime)
{
return this.GetList("DateTime=@DateTime", new { DateTime }).FirstOrDefault();
}
#endregion
}
}