using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
public static class ChemicalReportService
{
///
/// 化工行业能源节约与生态环境保护汇总表
///
/// 化工行业能源节约与生态环境保护汇总表Id
/// 化工行业能源节约与生态环境保护汇总表
public static Model.Environmental_ChemicalReport GetChemicalReportByChemicalReportId(string ChemicalReportId)
{
return Funs.DB.Environmental_ChemicalReport.FirstOrDefault(e => e.ChemicalReportId == ChemicalReportId);
}
///
/// 化工行业能源节约与生态环境保护汇总表
///
/// 单位Id
/// 年度 param >
/// 月份
/// 化工行业能源节约与生态环境保护汇总表
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);
}
///
/// 根据单位Id获取化工行业能源节约与生态环境保护汇总表集合
///
/// 单位Id
/// 化工行业能源节约与生态环境保护汇总表集合
public static List GetChemicalReportsByUnitId(string UnitId)
{
return (from x in Funs.DB.View_Environmental_ChemicalReport where x.UnitId == UnitId orderby x.FillingDate descending select x).ToList();
}
///
/// 增加化工行业能源节约与生态环境保护汇总表
///
/// 化工行业能源节约与生态环境保护汇总表实体
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();
}
///
/// 修改化工行业能源节约与生态环境保护汇总表
///
/// 化工行业能源节约与生态环境保护汇总表实体
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();
}
}
///
/// 根据Id获取数据
///
///
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();
}
}
///
/// 根据报表单位,报表时间判断是否存在
///
/// Id
///
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);
}
///
/// 根据报表单位,报表年份获取对应集合
///
/// Id
///
public static List GetChemicalReportByUnitIdYear(string unitId, int year)
{
return (from x in Funs.DB.Environmental_ChemicalReport where x.UnitId == unitId && x.Year == year select x).ToList();
}
}
}