120 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			120 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Threading.Tasks;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     public static class ChemicalReportService
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 化工行业能源节约与生态环境保护汇总表
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReportId">化工行业能源节约与生态环境保护汇总表Id</param>
 | |
|         /// <returns>化工行业能源节约与生态环境保护汇总表</returns>
 | |
|         public static Model.Environmental_ChemicalReport GetChemicalReportByChemicalReportId(string ChemicalReportId)
 | |
|         {
 | |
|             return Funs.DB.Environmental_ChemicalReport.FirstOrDefault(e => e.ChemicalReportId == ChemicalReportId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 化工行业能源节约与生态环境保护汇总表
 | |
|         /// </summary>
 | |
|         /// <param name="unitId">单位Id</param>
 | |
|         /// <param name = "year" > 年度 </ param >
 | |
|         /// <param name="month">月份</param>
 | |
|         /// <returns>化工行业能源节约与生态环境保护汇总表</returns>
 | |
|         public static Model.Environmental_ChemicalReport GetChemicalReportByUnitIdAndYearAndMonth(string unitId, int year, int month)
 | |
|         {
 | |
|             return Funs.DB.Environmental_ChemicalReport.FirstOrDefault(e => e.UnitId == unitId && e.Month == month && e.Year == year);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据单位Id获取化工行业能源节约与生态环境保护汇总表集合
 | |
|         /// </summary>
 | |
|         /// <param name="UnitId">单位Id</param>
 | |
|         /// <returns>化工行业能源节约与生态环境保护汇总表集合</returns>
 | |
|         public static List<Model.View_Environmental_ChemicalReport> GetChemicalReportsByUnitId(string UnitId)
 | |
|         {
 | |
|             return (from x in Funs.DB.View_Environmental_ChemicalReport where x.UnitId == UnitId orderby x.FillingDate descending select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 增加化工行业能源节约与生态环境保护汇总表
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReport">化工行业能源节约与生态环境保护汇总表实体</param>
 | |
|         public static void AddChemicalReport(Model.Environmental_ChemicalReport ChemicalReport)
 | |
|         {
 | |
|             Model.Environmental_ChemicalReport newChemicalReport = new Model.Environmental_ChemicalReport
 | |
|             {
 | |
|                 ChemicalReportId = ChemicalReport.ChemicalReportId,
 | |
|                 Year = ChemicalReport.Year,
 | |
|                 Month = ChemicalReport.Month,
 | |
|                 UnitId = ChemicalReport.UnitId,
 | |
|                 FillingDate = ChemicalReport.FillingDate,
 | |
|                 DutyPerson = ChemicalReport.DutyPerson,
 | |
|                 FillingMan = ChemicalReport.FillingMan,
 | |
|                 UpState = ChemicalReport.UpState,
 | |
|             };
 | |
| 
 | |
|             Funs.DB.Environmental_ChemicalReport.InsertOnSubmit(newChemicalReport);
 | |
|             Funs.DB.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改化工行业能源节约与生态环境保护汇总表
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReport">化工行业能源节约与生态环境保护汇总表实体</param>
 | |
|         public static void UpdateChemicalReport(Model.Environmental_ChemicalReport ChemicalReport)
 | |
|         {
 | |
|             Model.Environmental_ChemicalReport newChemicalReport = Funs.DB.Environmental_ChemicalReport.FirstOrDefault(e => e.ChemicalReportId == ChemicalReport.ChemicalReportId);
 | |
|             if (newChemicalReport != null)
 | |
|             {
 | |
|                 newChemicalReport.Year = ChemicalReport.Year;
 | |
|                 newChemicalReport.Month = ChemicalReport.Month;
 | |
|                 newChemicalReport.UnitId = ChemicalReport.UnitId;
 | |
|                 newChemicalReport.FillingDate = ChemicalReport.FillingDate;
 | |
|                 newChemicalReport.DutyPerson = ChemicalReport.DutyPerson;
 | |
|                 newChemicalReport.UpState = ChemicalReport.UpState;
 | |
| 
 | |
|                 Funs.DB.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据Id获取数据
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReportId"></param>
 | |
|         public static void DeleteChemicalReportByChemicalReportId(string ChemicalReportId)
 | |
|         {
 | |
|             Model.Environmental_ChemicalReport newChemicalReport = Funs.DB.Environmental_ChemicalReport.FirstOrDefault(e => e.ChemicalReportId == ChemicalReportId);
 | |
|             if (newChemicalReport != null)
 | |
|             {
 | |
|                 Funs.DB.Environmental_ChemicalReport.DeleteOnSubmit(newChemicalReport);
 | |
|                 Funs.DB.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据报表单位,报表时间判断是否存在
 | |
|         /// </summary>
 | |
|         /// <param name="Id">Id</param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.Environmental_ChemicalReport GetChemicalReportByUnitIdDate(string unitId, int year, int Month)
 | |
|         {
 | |
|             return Funs.DB.Environmental_ChemicalReport.FirstOrDefault(e => e.UnitId == unitId && e.Year == year && e.Month == Month);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据报表单位,报表年份获取对应集合
 | |
|         /// </summary>
 | |
|         /// <param name="Id">Id</param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.Environmental_ChemicalReport> GetChemicalReportByUnitIdYear(string unitId, int year)
 | |
|         {
 | |
|             return (from x in Funs.DB.Environmental_ChemicalReport where x.UnitId == unitId && x.Year == year select x).ToList();
 | |
|         }
 | |
|     }
 | |
| }
 |