210 lines
6.7 KiB
C#
210 lines
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
public class RiskIdentificationService
|
|
{
|
|
/// <summary>
|
|
/// 添加主表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static bool Insert(Model.Report_RiskIdentification model)
|
|
{
|
|
try
|
|
{
|
|
Funs.DB.Report_RiskIdentification.InsertOnSubmit(model);
|
|
Funs.DB.SubmitChanges();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"插入数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加子表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static bool InsertC(Model.Report_RiskIdentification_c model)
|
|
{
|
|
try
|
|
{
|
|
Funs.DB.Report_RiskIdentification_c.InsertOnSubmit(model);
|
|
Funs.DB.SubmitChanges();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"插入数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改主表信息
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static bool Update(Model.Report_RiskIdentification model)
|
|
{
|
|
try
|
|
{
|
|
var result = Funs.DB.Report_RiskIdentification.FirstOrDefault(a => a.Id == model.Id);
|
|
if (result != null)
|
|
{
|
|
result.WorkModuleA = model.WorkModuleA;
|
|
result.WorkModuleB = model.WorkModuleB;
|
|
result.Unitid = model.Unitid;
|
|
result.Months = model.Months;
|
|
result.States = model.States;
|
|
result.ProjectId = model.ProjectId;
|
|
result.CreateDate = model.CreateDate;
|
|
result.SignPerson = model.SignPerson;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"更新表数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改子表信息
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static bool UpdateC(Model.Report_RiskIdentification_c model)
|
|
{
|
|
try
|
|
{
|
|
var result = Funs.DB.Report_RiskIdentification_c.FirstOrDefault(a => a.Id == model.Id);
|
|
if (result != null)
|
|
{
|
|
result.HazardText = model.HazardText;
|
|
result.Accident = model.Accident;
|
|
result.NodelL = model.NodelL;
|
|
result.NodelE = model.NodelE;
|
|
result.NodelC = model.NodelC;
|
|
result.NodelD = model.NodelD;
|
|
result.RiskLevel = model.RiskLevel;
|
|
result.Measures = model.Measures;
|
|
result.ControlLevel = model.ControlLevel;
|
|
result.ResPerson = model.ResPerson;
|
|
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"更新表数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id删除主表
|
|
/// </summary>
|
|
/// <param name="newId"></param>
|
|
/// <returns></returns>
|
|
public static bool Delete(string newId)
|
|
{
|
|
try
|
|
{
|
|
var result = Funs.DB.Report_RiskIdentification.Where(a => a.Id == newId).ToList();
|
|
if (result.Count > 0)
|
|
{
|
|
Funs.DB.Report_RiskIdentification.DeleteAllOnSubmit(result);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"删除数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id删除子表
|
|
/// </summary>
|
|
/// <param name="newId"></param>
|
|
/// <returns></returns>
|
|
public static bool DeleteC(string newId)
|
|
{
|
|
try
|
|
{
|
|
var resultc = Funs.DB.Report_RiskIdentification_c.Where(a => a.Id == newId).ToList();
|
|
if (resultc.Count > 0)
|
|
{
|
|
Funs.DB.Report_RiskIdentification_c.DeleteAllOnSubmit(resultc);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"删除数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主表id删除子表
|
|
/// </summary>
|
|
/// <param name="newId"></param>
|
|
/// <returns></returns>
|
|
public static bool DeleteCbyRiskId(string newId)
|
|
{
|
|
try
|
|
{
|
|
var resultc = Funs.DB.Report_RiskIdentification_c.Where(a => a.RiskId == newId).ToList();
|
|
if (resultc.Count > 0)
|
|
{
|
|
Funs.DB.Report_RiskIdentification_c.DeleteAllOnSubmit(resultc);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"删除数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主表明细
|
|
/// </summary>
|
|
/// <param name="newId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Report_RiskIdentification Detail(string newId)
|
|
{
|
|
var result = Funs.DB.Report_RiskIdentification.FirstOrDefault(a => a.Id == newId);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 子表明细
|
|
/// </summary>
|
|
/// <param name="newId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Report_RiskIdentification_c DetailC(string newId)
|
|
{
|
|
var result = Funs.DB.Report_RiskIdentification_c.FirstOrDefault(a => a.Id == newId);
|
|
return result;
|
|
}
|
|
}
|
|
}
|