using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BLL { public static class AccidentDetailSortBService { /// /// 根据月报告主键获取所有事故台账信息 /// /// 月报告主键 /// public static List GetAccidentDetailSortsByMonthReportId(string monthReportId) { return (from x in Funs.DB.Manager_AccidentDetailSortB where x.MonthReportId == monthReportId orderby x.AccidentDate select x).ToList(); } /// /// 增加月报告事故台账信息 /// /// 月报告事故台账实体 public static void AddAccidentDetailSort(Model.Manager_AccidentDetailSortB accidentSort) { string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_AccidentDetailSortB)); Model.Manager_AccidentDetailSortB newAccidentSort = new Model.Manager_AccidentDetailSortB { AccidentDetailSortId = newKeyID, MonthReportId = accidentSort.MonthReportId, Abstract = accidentSort.Abstract, AccidentType = accidentSort.AccidentType, PeopleNum = accidentSort.PeopleNum, WorkingHoursLoss = accidentSort.WorkingHoursLoss, EconomicLoss = accidentSort.EconomicLoss, AccidentDate = accidentSort.AccidentDate }; Funs.DB.Manager_AccidentDetailSortB.InsertOnSubmit(newAccidentSort); Funs.DB.SubmitChanges(); } /// /// 根据月报告主键删除对应的所有月报告事故台账信息 /// /// 月报告主键 public static void DeleteAccidentDetailSortsByMonthReportId(string monthReportId) { var q = (from x in Funs.DB.Manager_AccidentDetailSortB where x.MonthReportId == monthReportId select x).ToList(); if (q.Count() > 0) { Funs.DB.Manager_AccidentDetailSortB.DeleteAllOnSubmit(q); Funs.DB.SubmitChanges(); } } /// /// 根据主键删除事故台账信息 /// /// 主键 public static void DeleteAccidentDetailSortByAccidentDetailSortId(string accidentDetailSortId) { var q = Funs.DB.Manager_AccidentDetailSortB.FirstOrDefault(x => x.AccidentDetailSortId == accidentDetailSortId); if (q != null) { Funs.DB.Manager_AccidentDetailSortB.DeleteOnSubmit(q); Funs.DB.SubmitChanges(); } } } }