using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public class AccidentSortBService { public static Model.SGGLDB db = Funs.DB; public static Model.Manager_AccidentSortB GetAccidentSortsByMonthReportIdAndAccidentType(string monthReportId, string accidentType) { return (from x in Funs.DB.Manager_AccidentSortB where x.MonthReportId == monthReportId && x.AccidentType == accidentType select x).FirstOrDefault(); } /// /// 根据月报告主键获取所有月报告事故分类信息 /// /// 月报告主键 /// public static List GetAccidentSortsByMonthReportId(string monthReportId) { return (from x in Funs.DB.Manager_AccidentSortB where x.MonthReportId == monthReportId select x).ToList(); } /// /// 根据月报告主键集合及类型获取所有月报告事故分类信息 /// /// 月报告主键 /// public static List GetAccidentSortsByMonthReportIdsAndAccidentType(List monthReportIds, string accidentType) { return (from x in Funs.DB.Manager_AccidentSortB where monthReportIds.Contains(x.MonthReportId) && x.AccidentType == accidentType select x).ToList(); } /// /// 根据月报告主键获取总发生次数 /// /// 事故类型 /// 月报告主键 /// public static int? GetSumNumberByMonthReportId(string monthReportId, string accidentType) { return (from x in Funs.DB.Manager_AccidentSortB where x.MonthReportId == monthReportId && x.AccidentType == accidentType select x.Number).Sum(); } /// /// 根据月报告主键获取总损失工时 /// /// 事故类型 /// 月报告主键 /// public static int? GetSumLoseHoursByMonthReportId(string monthReportId, string accidentType) { return (from x in Funs.DB.Manager_AccidentSortB where x.MonthReportId == monthReportId && x.AccidentType == accidentType select x.LoseHours).Sum(); } /// /// 根据月报告主键获取总损失金额 /// /// 事故类型 /// 月报告主键 /// public static decimal? GetSumLoseMoneyByMonthReportId(string monthReportId, string accidentType) { return (from x in Funs.DB.Manager_AccidentSortB where x.MonthReportId == monthReportId && x.AccidentType == accidentType select x.LoseMoney).Sum(); } /// /// 增加月报告事故分类信息 /// /// 月报告事故分类实体 public static void AddAccidentSort(Model.Manager_AccidentSortB accidentSort) { Model.SGGLDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_AccidentSortB)); Model.Manager_AccidentSortB newAccidentSort = new Model.Manager_AccidentSortB { AccidentSortId = newKeyID, MonthReportId = accidentSort.MonthReportId, AccidentType = accidentSort.AccidentType, TypeFlag = accidentSort.TypeFlag, Number = accidentSort.Number, TotalNum = accidentSort.TotalNum, PersonNum = accidentSort.PersonNum, TotalPersonNum = accidentSort.TotalPersonNum, LoseHours = accidentSort.LoseHours, TotalLoseHours = accidentSort.TotalLoseHours, LoseMoney = accidentSort.LoseMoney, TotalLoseMoney = accidentSort.TotalLoseMoney }; db.Manager_AccidentSortB.InsertOnSubmit(newAccidentSort); db.SubmitChanges(); } /// /// 根据月报告主键删除对应的所有月报告事故分类信息 /// /// 月报告主键 public static void DeleteAccidentSortsByMonthReportId(string monthReportId) { var q = (from x in db.Manager_AccidentSortB where x.MonthReportId == monthReportId select x).ToList(); db.Manager_AccidentSortB.DeleteAllOnSubmit(q); db.SubmitChanges(); } } }