84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
public class HazardAdministerService
|
|
{
|
|
public static bool Insert(Model.Report_HazardAdminister model)
|
|
{
|
|
try
|
|
{
|
|
Funs.DB.Report_HazardAdminister.InsertOnSubmit(model);
|
|
Funs.DB.SubmitChanges();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"插入数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static bool Update(Model.Report_HazardAdminister model)
|
|
{
|
|
try
|
|
{
|
|
var result = Funs.DB.Report_HazardAdminister.FirstOrDefault(a => a.Id == model.Id);
|
|
if (result != null)
|
|
{
|
|
result.Unitid = model.Unitid;
|
|
result.Months = model.Months;
|
|
result.States = model.States;
|
|
result.ProjectId = model.ProjectId;
|
|
result.TrobleDate = model.TrobleDate;
|
|
result.Description = model.Description;
|
|
result.HazTypes = model.HazTypes;
|
|
result.Severity = model.Severity;
|
|
result.HazNumber = model.HazNumber;
|
|
result.Hazlocation = model.Hazlocation;
|
|
result.Measure = model.Measure;
|
|
result.CheckMan = model.CheckMan;
|
|
result.RecDate = model.RecDate;
|
|
result.HeadMan = model.HeadMan;
|
|
result.ClosedType = model.ClosedType;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"更新表数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static bool Delete(string newId)
|
|
{
|
|
try
|
|
{
|
|
var result = Funs.DB.Report_HazardAdminister.Where(a => a.Id == newId).ToList();
|
|
if (result.Count > 0)
|
|
{
|
|
Funs.DB.Report_HazardAdminister.DeleteAllOnSubmit(result);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"删除数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static Model.Report_HazardAdminister Detail(string newId)
|
|
{
|
|
var result = Funs.DB.Report_HazardAdminister.FirstOrDefault(a => a.Id == newId);
|
|
return result;
|
|
}
|
|
}
|
|
}
|