using FineUIPro; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public static class EnergyReportService { public static Model.SGGLDB db = Funs.DB; #region 获取列表 /// /// 记录数 /// public static int count { get; set; } public static List GetEnvironmental_EnergyReportByModle(Model.Environmental_EnergyReport table) { var q = from x in db.Environmental_EnergyReport where (string.IsNullOrEmpty(table.EnergyReportId) || x.EnergyReportId.Contains(table.EnergyReportId)) && (string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) && (string.IsNullOrEmpty(table.FillingMan) || x.FillingMan.Contains(table.FillingMan)) && (string.IsNullOrEmpty(table.DutyPerson) || x.DutyPerson.Contains(table.DutyPerson)) && (string.IsNullOrEmpty(table.UpState) || x.UpState.Contains(table.UpState)) select x ; return q.ToList(); } /// 获取分页列表 /// /// 页码 /// 每页数量 /// public static IEnumerable getListData(Model.Environmental_EnergyReport table, Grid Grid1) { var q = GetEnvironmental_EnergyReportByModle(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.EnergyReportId, x.UnitId, x.Year, x.Quarters, x.FillingMan, x.FillingDate, x.DutyPerson, x.UpState, }; } #endregion public static Model.Environmental_EnergyReport GetEnvironmental_EnergyReportById(string EnergyReportId) { return db.Environmental_EnergyReport.FirstOrDefault(x => x.EnergyReportId == EnergyReportId); } public static Model.Environmental_EnergyReport GetEnvironmental_EnergyReportByUnitIdAndYearAndQuarters(string unitId, int year, int Quarters) { return Funs.DB.Environmental_EnergyReport.FirstOrDefault(e => e.UnitId == unitId && e.Quarters == Quarters && e.Year == year); } public static void AddEnvironmental_EnergyReport(Model.Environmental_EnergyReport newtable) { Model.Environmental_EnergyReport table = new Model.Environmental_EnergyReport { EnergyReportId = newtable.EnergyReportId, UnitId = newtable.UnitId, Year = newtable.Year, Quarters = newtable.Quarters, FillingMan = newtable.FillingMan, FillingDate = newtable.FillingDate, DutyPerson = newtable.DutyPerson, UpState = newtable.UpState, }; db.Environmental_EnergyReport.InsertOnSubmit(table); db.SubmitChanges(); } public static void AddBulkEnvironmental_EnergyReport(List newtables) { db.Environmental_EnergyReport.InsertAllOnSubmit(newtables); db.SubmitChanges(); } /// /// 根据报表单位,报表时间判断是否存在 /// /// Id /// public static Model.Environmental_EnergyReport GetEnergyReportByUnitIdDate(string unitId, int year, int Quarters) { return Funs.DB.Environmental_EnergyReport.FirstOrDefault(e => e.UnitId == unitId && e.Year == year && e.Quarters == Quarters); } /// /// 根据报表单位,报表年份获取对应集合 /// /// Id /// public static List GetEnergyReportByUnitIdYear(string unitId, int year) { return (from x in Funs.DB.Environmental_EnergyReport where x.UnitId == unitId && x.Year == year select x).ToList(); } public static void UpdateEnvironmental_EnergyReport(Model.Environmental_EnergyReport newtable) { Model.Environmental_EnergyReport table = db.Environmental_EnergyReport.FirstOrDefault(x => x.EnergyReportId == newtable.EnergyReportId); if (table != null) { table.EnergyReportId = newtable.EnergyReportId; table.UnitId = newtable.UnitId; table.Year = newtable.Year; table.Quarters = newtable.Quarters; table.FillingMan = newtable.FillingMan; table.FillingDate = newtable.FillingDate; table.DutyPerson = newtable.DutyPerson; table.UpState = newtable.UpState; db.SubmitChanges(); } } public static void DeleteEnvironmental_EnergyReportById(string EnergyReportId) { Model.Environmental_EnergyReport table = db.Environmental_EnergyReport.FirstOrDefault(x => x.EnergyReportId == EnergyReportId); if (table != null) { db.Environmental_EnergyReport.DeleteOnSubmit(table); db.SubmitChanges(); } } public static void DeleteALLEnvironmental_EnergyReport() { if (db.Environmental_EnergyReport != null) { db.Environmental_EnergyReport.DeleteAllOnSubmit(db.Environmental_EnergyReport); db.SubmitChanges(); } } } }