using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public class CheckSortBService { public static Model.SGGLDB db = Funs.DB; /// /// 根据月报告主键获取所有月报告HSE检查情况信息 /// /// 月报告主键 /// public static List GetCheckSortsByMonthReportId(string monthReportId) { return (from x in Funs.DB.Manager_CheckSortB where x.MonthReportId == monthReportId select x).ToList(); } public static Model.Manager_CheckSortB GetCheckSortByMonthReportIdAndCheckType(string monthReportId, string checkType) { return (from x in Funs.DB.Manager_CheckSortB where x.MonthReportId == monthReportId && x.CheckType == checkType select x).FirstOrDefault(); } /// /// 根据月报告主键获取总检查次数 /// /// 安全检查类型 /// 月报告主键 /// public static decimal? GetSumCheckNumberByMonthReportId(string monthReportId, string checkType) { return (from x in Funs.DB.Manager_CheckSortB where x.MonthReportId == monthReportId && x.CheckType == checkType select x.CheckNumber).Sum(); } /// /// 根据月报告主键获取总违章数量 /// /// 安全检查类型 /// 月报告主键 /// public static decimal? GetSumViolationNumberByMonthReportId(string monthReportId, string checkType) { return (from x in Funs.DB.Manager_CheckSortB where x.MonthReportId == monthReportId && x.CheckType == checkType select x.ViolationNumber).Sum(); } /// /// 增加月报告HSE检查情况信息 /// /// 月报告HSE检查情况实体 public static void AddCheckSort(Model.Manager_CheckSortB checkSort) { Model.SGGLDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_CheckSortB)); Model.Manager_CheckSortB newCheckSort = new Model.Manager_CheckSortB { CheckSortId = newKeyID, MonthReportId = checkSort.MonthReportId, CheckType = checkSort.CheckType, CheckNumber = checkSort.CheckNumber, TotalCheckNum = checkSort.TotalCheckNum, ViolationNumber = checkSort.ViolationNumber, TotalViolationNum = checkSort.TotalViolationNum }; db.Manager_CheckSortB.InsertOnSubmit(newCheckSort); db.SubmitChanges(); } /// /// 根据月报告主键删除对应的所有月报告HSE检查情况信息 /// /// 月报告主键 public static void DeleteCheckSortsByMonthReportId(string monthReportId) { var q = (from x in db.Manager_CheckSortB where x.MonthReportId == monthReportId select x).ToList(); db.Manager_CheckSortB.DeleteAllOnSubmit(q); db.SubmitChanges(); } } }