using FineUIPro; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public static class SyhsedataHiddendangercheckService { public static Model.SGGLDB db = Funs.DB; #region 获取列表 /// /// 记录数 /// public static int count { get; set; } public static List GetSYHSEData_HiddenDangerCheckByModle(Model.SYHSEData_HiddenDangerCheck table) { var q = from x in db.SYHSEData_HiddenDangerCheck where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && (string.IsNullOrEmpty(table.FactoryId) || x.FactoryId.Contains(table.FactoryId)) && (string.IsNullOrEmpty(table.HiddenDangerName) || x.HiddenDangerName.Contains(table.HiddenDangerName)) select x ; return q.ToList(); } /// 获取分页列表 /// /// 页码 /// 每页数量 /// public static IEnumerable getListData(Model.SYHSEData_HiddenDangerCheck table, Grid Grid1) { var q = GetSYHSEData_HiddenDangerCheckByModle(table); count = q.Count(); if (count == 0) { return null; } // q= q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList(); // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); return from x in q select new { x.Id, x.FactoryId, x.HiddenDangerName, x.TotalNum, x.OKNum, x.ReportDate, }; } #endregion public static Model.SYHSEData_HiddenDangerCheck GetSYHSEData_HiddenDangerCheckById(string Id) { return db.SYHSEData_HiddenDangerCheck.FirstOrDefault(x => x.Id == Id); } public static void AddSYHSEData_HiddenDangerCheck(Model.SYHSEData_HiddenDangerCheck newtable) { Model.SYHSEData_HiddenDangerCheck table = new Model.SYHSEData_HiddenDangerCheck { Id = newtable.Id, FactoryId = newtable.FactoryId, HiddenDangerName = newtable.HiddenDangerName, TotalNum = newtable.TotalNum, OKNum = newtable.OKNum, ReportDate = newtable.ReportDate, }; db.SYHSEData_HiddenDangerCheck.InsertOnSubmit(table); db.SubmitChanges(); } public static void AddBulkSYHSEData_HiddenDangerCheck(List newtables) { db.SYHSEData_HiddenDangerCheck.InsertAllOnSubmit(newtables); db.SubmitChanges(); } public static void UpdateSYHSEData_HiddenDangerCheck(Model.SYHSEData_HiddenDangerCheck newtable) { Model.SYHSEData_HiddenDangerCheck table = db.SYHSEData_HiddenDangerCheck.FirstOrDefault(x => x.Id == newtable.Id); if (table != null) { table.Id = newtable.Id; table.FactoryId = newtable.FactoryId; table.HiddenDangerName = newtable.HiddenDangerName; table.TotalNum = newtable.TotalNum; table.OKNum = newtable.OKNum; table.ReportDate = newtable.ReportDate; db.SubmitChanges(); } } public static void DeleteSYHSEData_HiddenDangerCheckById(string Id) { Model.SYHSEData_HiddenDangerCheck table = db.SYHSEData_HiddenDangerCheck.FirstOrDefault(x => x.Id == Id); if (table != null) { db.SYHSEData_HiddenDangerCheck.DeleteOnSubmit(table); db.SubmitChanges(); } } public static void DeleteALLSYHSEData_HiddenDangerCheck() { if (db.SYHSEData_HiddenDangerCheck != null) { db.SYHSEData_HiddenDangerCheck.DeleteAllOnSubmit(db.SYHSEData_HiddenDangerCheck); db.SubmitChanges(); } } public static List GetSYHSEData_HiddenDangerCheckByDate(DateTime? reportDate) { var q = from x in db.SYHSEData_HiddenDangerCheck where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 select x; return q.ToList(); } public static void DeleteSYHSEData_HiddenDangerCheckByDate(DateTime? reportDate) { var table = db.SYHSEData_HiddenDangerCheck.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); if (table != null) { db.SYHSEData_HiddenDangerCheck.DeleteAllOnSubmit(table); db.SubmitChanges(); } } } }