99 lines
3.4 KiB
C#
99 lines
3.4 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 事故警示
|
|
/// </summary>
|
|
public static class AccidentWarningService
|
|
{
|
|
|
|
/// <summary>
|
|
/// 根据主键获取事故警示
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <returns></returns>
|
|
public static Model.Accident_Warning GetAccidentWarningById(string Id)
|
|
{
|
|
return Funs.DB.Accident_Warning.FirstOrDefault(e => e.Id == Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取历年今日发生的事故
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<Model.Accident_Warning> 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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加事故警示
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改事故警示
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
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();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除事故警示
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
} |