using FineUIPro;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
public static class HSSEData_HiddenDangerDetailService
{
public static Model.SGGLDB db = Funs.DB;
#region 获取列表
///
/// 记录数
///
public static int count
{
get;
set;
}
public static List GetHSSEData_HiddenDangerDetailByModle(Model.HSSEData_HiddenDangerDetail table)
{
var q = from x in db.HSSEData_HiddenDangerDetail
where
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
(string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) &&
(string.IsNullOrEmpty(table.CollCropCode) || x.CollCropCode.Contains(table.CollCropCode)) &&
(string.IsNullOrEmpty(table.UnitName) || x.UnitName.Contains(table.UnitName)) &&
(string.IsNullOrEmpty(table.TypeName) || x.TypeName.Contains(table.TypeName))
select x
;
return q.ToList();
}
/// 获取分页列表
///
/// 页码
/// 每页数量
///
public static IEnumerable getListData(Model.HSSEData_HiddenDangerDetail table, Grid Grid1)
{
var q = GetHSSEData_HiddenDangerDetailByModle(table);
count = q.Count();
if (count == 0)
{
return null;
}
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
x.Id,
x.UnitId,
x.CollCropCode,
x.UnitName,
x.ReportDate,
x.TypeName,
x.TotalNum,
x.NeedRectifyNum,
};
}
#endregion
public static Model.HSSEData_HiddenDangerDetail GetHSSEData_HiddenDangerDetailById(string Id)
{
return db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id);
}
public static List GetHSSEData_HiddenDangerDetailByDate(DateTime? reportDate)
{
var q = from x in db.HSSEData_HiddenDangerDetail
where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0
select x;
return q.ToList();
}
public static void AddHSSEData_HiddenDangerDetail(Model.HSSEData_HiddenDangerDetail newtable)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.HSSEData_HiddenDangerDetail table = new Model.HSSEData_HiddenDangerDetail
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
TypeName = newtable.TypeName,
TotalNum = newtable.TotalNum,
NeedRectifyNum = newtable.NeedRectifyNum,
};
db.HSSEData_HiddenDangerDetail.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void UpdateHSSEData_HiddenDangerDetail(Model.HSSEData_HiddenDangerDetail newtable)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.TypeName = newtable.TypeName;
table.TotalNum = newtable.TotalNum;
table.NeedRectifyNum = newtable.NeedRectifyNum;
db.SubmitChanges();
}
}
}
public static void DeleteHSSEData_HiddenDangerDetailById(string Id)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
db.HSSEData_HiddenDangerDetail.DeleteOnSubmit(table);
db.SubmitChanges();
}
}
}
public static void DeleteHSSEData_HiddenDangerDetailByDate(DateTime? reportDate)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var table = db.HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
{
db.HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
}
}
}
}