110 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			110 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using System.Threading.Tasks;
 | 
						|
 | 
						|
namespace BLL
 | 
						|
{
 | 
						|
    public static class ProjectChemicalReportService
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 化工行业能源节约与生态环境保护汇总表
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="ChemicalReportId">化工行业能源节约与生态环境保护汇总表Id</param>
 | 
						|
        /// <returns>化工行业能源节约与生态环境保护汇总表</returns>
 | 
						|
        public static Model.Environmental_ProjectChemicalReport GetChemicalReportByChemicalReportId(string ChemicalReportId)
 | 
						|
        {
 | 
						|
            return Funs.DB.Environmental_ProjectChemicalReport.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_ProjectChemicalReport GetChemicalReportByProjectIdAndYearAndMonth(string projectId, int year, int month)
 | 
						|
        {
 | 
						|
            return Funs.DB.Environmental_ProjectChemicalReport.FirstOrDefault(e => e.ProjectId == projectId && e.Month == month && e.Year == year);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 增加化工行业能源节约与生态环境保护汇总表
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="ChemicalReport">化工行业能源节约与生态环境保护汇总表实体</param>
 | 
						|
        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();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 修改化工行业能源节约与生态环境保护汇总表
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="ChemicalReport">化工行业能源节约与生态环境保护汇总表实体</param>
 | 
						|
        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();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据Id获取数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="ChemicalReportId"></param>
 | 
						|
        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();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据报表单位,报表时间判断是否存在
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="Id">Id</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        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);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据报表单位,报表年份获取对应集合
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="Id">Id</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static List<Model.Environmental_ProjectChemicalReport> GetChemicalReportByProjectIdYear(string projectId, int year)
 | 
						|
        {
 | 
						|
            return (from x in Funs.DB.Environmental_ProjectChemicalReport where x.ProjectId == projectId && x.Year == year select x).ToList();
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |