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