using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
public class HazardCService
{
private static Model.SGGLDB db = Funs.DB;
///
/// 根据月报Id获取危险源动态识别及控制
///
///
///
public static List GetHazardByMonthReportId(string monthReportId)
{
return (from x in Funs.DB.Manager_Month_HazardC where x.MonthReportId == monthReportId orderby x.SortIndex select x).ToList();
}
///
/// 添加危险源动态识别及控制
///
///
public static void AddHazard(Model.Manager_Month_HazardC hazard)
{
Model.SGGLDB db = Funs.DB;
Model.Manager_Month_HazardC newHazard = new Model.Manager_Month_HazardC
{
HazardId = SQLHelper.GetNewID(typeof(Model.Manager_Month_HazardC)),
MonthReportId = hazard.MonthReportId,
WorkArea = hazard.WorkArea,
Subcontractor = hazard.Subcontractor,
DangerousSource = hazard.DangerousSource,
ControlMeasures = hazard.ControlMeasures,
SortIndex = hazard.SortIndex
};
db.Manager_Month_HazardC.InsertOnSubmit(newHazard);
db.SubmitChanges();
}
///
/// 根据月报Id删除所有相关危险源动态识别及控制
///
/// 月报Id
public static void DeleteHazardByMonthReportId(string monthReportId)
{
Model.SGGLDB db = Funs.DB;
var q = (from x in db.Manager_Month_HazardC where x.MonthReportId == monthReportId select x).ToList();
if (q != null)
{
db.Manager_Month_HazardC.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
}
}