using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
///
/// 中央企业安全生产治本攻坚三年行动工作台账
///
public static class ActionWorkLedgerService
{
///
/// 根据主键获取中央企业安全生产治本攻坚三年行动工作台账
///
///
///
public static Model.Information_ActionWorkLedger GetActionWorkLedgerById(string ActionWorkLedgerId)
{
return Funs.DB.Information_ActionWorkLedger.FirstOrDefault(e => e.ActionWorkLedgerId == ActionWorkLedgerId);
}
///
/// 中央企业安全生产治本攻坚三年行动工作台账
///
/// 单位Id
/// 年度
/// 季度
/// 中央企业安全生产治本攻坚三年行动工作台账
public static Model.Information_ActionWorkLedger GetActionWorkLedgerByUnitIdAndYearAndQuarters(string unitId, int year, int quarters)
{
return Funs.DB.Information_ActionWorkLedger.FirstOrDefault(e => e.UnitId == unitId && e.Quarter == quarters && e.YearId == year);
}
///
/// 根据单位Id获取安全生产数据季报集合
///
/// 单位Id
/// 安全生产数据季报集合
public static List GetActionWorkLedgersByUnitId(string UnitId)
{
return (from x in Funs.DB.View_Information_ActionWorkLedger where x.UnitId == UnitId orderby x.ReportDate descending select x).ToList();
}
///
/// 添加中央企业安全生产治本攻坚三年行动工作台账
///
///
public static void AddActionWorkLedger(Model.Information_ActionWorkLedger ActionWorkLedger)
{
Model.Information_ActionWorkLedger newActionWorkLedger = new Model.Information_ActionWorkLedger
{
ActionWorkLedgerId = ActionWorkLedger.ActionWorkLedgerId,
UnitId = ActionWorkLedger.UnitId,
ReportDate = ActionWorkLedger.ReportDate,
YearId = ActionWorkLedger.YearId,
Quarter = ActionWorkLedger.Quarter,
CompileMan = ActionWorkLedger.CompileMan,
UpState = ActionWorkLedger.UpState,
HandleState = ActionWorkLedger.HandleState,
HandleMan = ActionWorkLedger.HandleMan
};
Funs.DB.Information_ActionWorkLedger.InsertOnSubmit(newActionWorkLedger);
Funs.DB.SubmitChanges();
}
///
/// 修改中央企业安全生产治本攻坚三年行动工作台账
///
///
public static void UpdateActionWorkLedger(Model.Information_ActionWorkLedger ActionWorkLedger)
{
Model.Information_ActionWorkLedger newActionWorkLedger = Funs.DB.Information_ActionWorkLedger.FirstOrDefault(e => e.ActionWorkLedgerId == ActionWorkLedger.ActionWorkLedgerId);
if (newActionWorkLedger != null)
{
newActionWorkLedger.UnitId = ActionWorkLedger.UnitId;
newActionWorkLedger.ReportDate = ActionWorkLedger.ReportDate;
newActionWorkLedger.YearId = ActionWorkLedger.YearId;
newActionWorkLedger.Quarter = ActionWorkLedger.Quarter;
newActionWorkLedger.UpState = ActionWorkLedger.UpState;
newActionWorkLedger.HandleState = ActionWorkLedger.HandleState;
newActionWorkLedger.HandleMan = ActionWorkLedger.HandleMan;
Funs.DB.SubmitChanges();
}
}
///
/// 根据主键删除中央企业安全生产治本攻坚三年行动工作台账
///
///
public static void DeleteActionWorkLedgerById(string ActionWorkLedgerId)
{
Model.Information_ActionWorkLedger ActionWorkLedger = Funs.DB.Information_ActionWorkLedger.FirstOrDefault(e => e.ActionWorkLedgerId == ActionWorkLedgerId);
if (ActionWorkLedger != null)
{
Funs.DB.Information_ActionWorkLedger.DeleteOnSubmit(ActionWorkLedger);
Funs.DB.SubmitChanges();
}
}
///
/// 根据单位、季度获取中央企业安全生产治本攻坚三年行动工作台账
///
///
///
///
public static Model.Information_ActionWorkLedger GetActionWorkLedgerByUnitIdDate(string unitId, int yearId, int quarter, string ActionWorkLedgerId)
{
return Funs.DB.Information_ActionWorkLedger.FirstOrDefault(e => e.UnitId == unitId && e.YearId == yearId && e.Quarter == quarter && ((ActionWorkLedgerId == null && e.ActionWorkLedgerId != null) || e.ActionWorkLedgerId != ActionWorkLedgerId));
}
}
}