using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BLL { public static class ProjectChemicalReportService { /// /// 化工行业能源节约与生态环境保护汇总表 /// /// 化工行业能源节约与生态环境保护汇总表Id /// 化工行业能源节约与生态环境保护汇总表 public static Model.Environmental_ProjectChemicalReport GetChemicalReportByChemicalReportId(string ChemicalReportId) { return Funs.DB.Environmental_ProjectChemicalReport.FirstOrDefault(e => e.ChemicalReportId == ChemicalReportId); } /// /// 化工行业能源节约与生态环境保护汇总表 /// /// 单位Id /// 年度 /// 月份 /// 化工行业能源节约与生态环境保护汇总表 public static Model.Environmental_ProjectChemicalReport GetChemicalReportByProjectIdAndYearAndMonth(string projectId, int year, int month) { return Funs.DB.Environmental_ProjectChemicalReport.FirstOrDefault(e => e.ProjectId == projectId && e.Month == month && e.Year == year); } /// /// 增加化工行业能源节约与生态环境保护汇总表 /// /// 化工行业能源节约与生态环境保护汇总表实体 public static void AddChemicalReport(Model.Environmental_ProjectChemicalReport ChemicalReport) { Model.Environmental_ProjectChemicalReport newChemicalReport = new Model.Environmental_ProjectChemicalReport { ChemicalReportId = ChemicalReport.ChemicalReportId, Year = ChemicalReport.Year, Month = ChemicalReport.Month, ProjectId = ChemicalReport.ProjectId, FillingDate = ChemicalReport.FillingDate, DutyPerson = ChemicalReport.DutyPerson, FillingMan = ChemicalReport.FillingMan, UpState = ChemicalReport.UpState, }; Funs.DB.Environmental_ProjectChemicalReport.InsertOnSubmit(newChemicalReport); Funs.DB.SubmitChanges(); } /// /// 修改化工行业能源节约与生态环境保护汇总表 /// /// 化工行业能源节约与生态环境保护汇总表实体 public static void UpdateChemicalReport(Model.Environmental_ProjectChemicalReport ChemicalReport) { Model.Environmental_ProjectChemicalReport newChemicalReport = Funs.DB.Environmental_ProjectChemicalReport.FirstOrDefault(e => e.ChemicalReportId == ChemicalReport.ChemicalReportId); if (newChemicalReport != null) { newChemicalReport.Year = ChemicalReport.Year; newChemicalReport.Month = ChemicalReport.Month; newChemicalReport.ProjectId = ChemicalReport.ProjectId; newChemicalReport.FillingDate = ChemicalReport.FillingDate; newChemicalReport.DutyPerson = ChemicalReport.DutyPerson; newChemicalReport.UpState = ChemicalReport.UpState; Funs.DB.SubmitChanges(); } } /// /// 根据Id获取数据 /// /// public static void DeleteChemicalReportByChemicalReportId(string ChemicalReportId) { Model.Environmental_ProjectChemicalReport newChemicalReport = Funs.DB.Environmental_ProjectChemicalReport.FirstOrDefault(e => e.ChemicalReportId == ChemicalReportId); if (newChemicalReport != null) { Funs.DB.Environmental_ProjectChemicalReport.DeleteOnSubmit(newChemicalReport); Funs.DB.SubmitChanges(); } } /// /// 根据报表单位,报表时间判断是否存在 /// /// Id /// public static Model.Environmental_ProjectChemicalReport GetChemicalReportByProjectIdDate(string projectId, int year, int Month) { return Funs.DB.Environmental_ProjectChemicalReport.FirstOrDefault(e => e.ProjectId == projectId && e.Year == year && e.Month == Month); } /// /// 根据报表单位,报表年份获取对应集合 /// /// Id /// public static List GetChemicalReportByProjectIdYear(string projectId, int year) { return (from x in Funs.DB.Environmental_ProjectChemicalReport where x.ProjectId == projectId && x.Year == year select x).ToList(); } } }