using System; using System.Collections.Generic; using System.Linq; namespace BLL { /// /// 事故警示 /// public static class AccidentWarningService { /// /// 根据主键获取事故警示 /// /// /// public static Model.Accident_Warning GetAccidentWarningById(string Id) { return Funs.DB.Accident_Warning.FirstOrDefault(e => e.Id == Id); } /// /// 获取历年今日发生的事故 /// /// public static List GetYearsTodayList() { string monthDay = DateTime.Now.ToString("MM-dd"); var list = (from x in Funs.DB.Accident_Warning where x.AccidentMonthDay == monthDay orderby x.AccidentDate descending select x).ToList(); //var list = (from x in Funs.DB.Accident_Warning orderby x.AccidentDate descending select x).ToList(); return list; } /// /// 添加事故警示 /// /// public static void AddAccidentWarning(Model.Accident_Warning model) { Model.CNPCDB db = Funs.DB; Model.Accident_Warning newModel = new Model.Accident_Warning { Id = model.Id, Code = model.Code, Title = model.Title, Content = model.Content, Address = model.Address, ResponsibleUnit = model.ResponsibleUnit, AccidentDate = model.AccidentDate, AccidentMonthDay = model.AccidentMonthDay, Remarks = model.Remarks, CreateTime = model.CreateTime, CompileMan = model.CompileMan, CompileManName = model.CompileManName }; db.Accident_Warning.InsertOnSubmit(newModel); db.SubmitChanges(); } /// /// 修改事故警示 /// /// public static void UpdateAccidentWarning(Model.Accident_Warning model) { Model.CNPCDB db = Funs.DB; Model.Accident_Warning newModel = db.Accident_Warning.FirstOrDefault(e => e.Id == model.Id); if (newModel != null) { newModel.Title = model.Title; newModel.Content = model.Content; newModel.Address = model.Address; newModel.ResponsibleUnit = model.ResponsibleUnit; newModel.AccidentDate = model.AccidentDate; newModel.AccidentMonthDay = model.AccidentMonthDay; newModel.Remarks = model.Remarks; db.SubmitChanges(); } } /// /// 根据主键删除事故警示 /// /// public static void DeleteAccidentWarningById(string Id) { Model.CNPCDB db = Funs.DB; Model.Accident_Warning model = db.Accident_Warning.FirstOrDefault(e => e.Id == Id); if (model != null) { CommonService.DeleteAttachFileById(Id);//删除附件 db.Accident_Warning.DeleteOnSubmit(model); db.SubmitChanges(); } } } }