131 lines
4.5 KiB
C#
131 lines
4.5 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FineUIPro;
|
|
|
|
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,
|
|
Type = model.Type,
|
|
Address = model.Address,
|
|
Source = model.Source,
|
|
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.Type = model.Type;
|
|
newModel.Address = model.Address;
|
|
newModel.Source = model.Source;
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 事故类型下拉
|
|
/// </summary>
|
|
/// <param name="dropName"></param>
|
|
/// <param name="isShowPlease"></param>
|
|
public static void InitAccidentTypeDropDownList(DropDownList dropName, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "string";
|
|
dropName.DataTextField = "string";
|
|
dropName.DataSource = GetAccidentTypeDropDownList();
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 事故类型下拉
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<string> GetAccidentTypeDropDownList()
|
|
{
|
|
return (from x in Funs.DB.Accident_Warning select x.Type).Distinct().OrderBy(x => x).ToList();
|
|
}
|
|
}
|
|
} |