using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public class AccidentSortCService { public static Model.SGGLDB db = Funs.DB; public static Model.Manager_AccidentSortC GetAccidentSortsByMonthReportIdAndAccidentType(string monthReportId, string accidentType) { return (from x in Funs.DB.Manager_AccidentSortC where x.MonthReportId == monthReportId && x.AccidentType == accidentType select x).FirstOrDefault(); } /// /// 根据月报告主键获取所有月报告事故分类信息 /// /// 月报告主键 /// public static List GetAccidentSortsByMonthReportId(string monthReportId) { return (from x in Funs.DB.Manager_AccidentSortC where x.MonthReportId == monthReportId select x).ToList(); } /// /// 根据月报告主键获取总发生次数 /// /// 事故类型 /// 月报告主键 /// public static int? GetSumNumberByMonthReportId(string monthReportId, string accidentType) { return (from x in Funs.DB.Manager_AccidentSortC 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_AccidentSortC 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_AccidentSortC where x.MonthReportId == monthReportId && x.AccidentType == accidentType select x.LoseMoney).Sum(); } /// /// 增加月报告事故分类信息 /// /// 月报告事故分类实体 public static void AddAccidentSort(Model.Manager_AccidentSortC accidentSort) { Model.SGGLDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_AccidentSortC)); Model.Manager_AccidentSortC newAccidentSort = new Model.Manager_AccidentSortC { AccidentSortId = newKeyID, MonthReportId = accidentSort.MonthReportId, AccidentType = accidentSort.AccidentType, TypeFlag = accidentSort.TypeFlag, Number = accidentSort.Number, TotalNum = accidentSort.TotalNum, LoseHours = accidentSort.LoseHours, TotalLoseHours = accidentSort.TotalLoseHours, LoseMoney = accidentSort.LoseMoney, TotalLoseMoney = accidentSort.TotalLoseMoney }; db.Manager_AccidentSortC.InsertOnSubmit(newAccidentSort); db.SubmitChanges(); } /// /// 根据月报告主键删除对应的所有月报告事故分类信息 /// /// 月报告主键 public static void DeleteAccidentSortsByMonthReportId(string monthReportId) { var q = (from x in db.Manager_AccidentSortC where x.MonthReportId == monthReportId select x).ToList(); db.Manager_AccidentSortC.DeleteAllOnSubmit(q); db.SubmitChanges(); } } }