SGGL_HBAZ/SGGL/BLL/HSSE/Technique/ConstructionStandardsServic...

96 lines
4.2 KiB
C#
Raw Normal View History

2025-02-19 15:09:13 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL;
public class ConstructionStandardsService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取
/// </summary>
/// <param name="ConstructionStandardsId"></param>
/// <returns></returns>
public static Model.Technique_ConstructionStandards GetConstructionStandardsListById(string ConstructionStandardsId)
{
return Funs.DB.Technique_ConstructionStandards.FirstOrDefault(e =>
e.ConstructionStandardsId == ConstructionStandardsId);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="ConstructionStandardsList"></param>
public static void AddConstructionStandardsList(Model.Technique_ConstructionStandards ConstructionStandardsList)
{
Model.SGGLDB db = Funs.DB;
Model.Technique_ConstructionStandards newConstructionStandardsList = new Model.Technique_ConstructionStandards
{
ConstructionStandardsId = ConstructionStandardsList.ConstructionStandardsId,
ConstructionStandardsCode = ConstructionStandardsList.ConstructionStandardsCode,
ConstructionStandardsName = ConstructionStandardsList.ConstructionStandardsName,
AttachUrl = ConstructionStandardsList.AttachUrl,
CompileMan = ConstructionStandardsList.CompileMan,
CompileDate = ConstructionStandardsList.CompileDate,
};
newConstructionStandardsList.CompileMan = ConstructionStandardsList.CompileMan;
newConstructionStandardsList.CompileDate = ConstructionStandardsList.CompileDate;
newConstructionStandardsList.IsPass = ConstructionStandardsList.IsPass;
newConstructionStandardsList.UpState = ConstructionStandardsList.UpState;
newConstructionStandardsList.Remark = ConstructionStandardsList.Remark;
db.Technique_ConstructionStandards.InsertOnSubmit(newConstructionStandardsList);
db.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="ConstructionStandardsList"></param>
public static void UpdateConstructionStandardsList(Model.Technique_ConstructionStandards ConstructionStandardsList)
{
Model.SGGLDB db = Funs.DB;
Model.Technique_ConstructionStandards newConstructionStandardsList =
db.Technique_ConstructionStandards.FirstOrDefault(e =>
e.ConstructionStandardsId == ConstructionStandardsList.ConstructionStandardsId);
if (newConstructionStandardsList != null)
{
newConstructionStandardsList.ConstructionStandardsCode = ConstructionStandardsList.ConstructionStandardsCode;
newConstructionStandardsList.ConstructionStandardsName = ConstructionStandardsList.ConstructionStandardsName;
newConstructionStandardsList.AttachUrl = ConstructionStandardsList.AttachUrl;
newConstructionStandardsList.CompileMan = ConstructionStandardsList.CompileMan;
newConstructionStandardsList.CompileDate = ConstructionStandardsList.CompileDate;
newConstructionStandardsList.UpState = ConstructionStandardsList.UpState;
newConstructionStandardsList.Remark = ConstructionStandardsList.Remark;
db.SubmitChanges();
}
}
/// <summary>
///根据主键删除
/// </summary>
/// <param name="ConstructionStandardsId"></param>
public static void DeleteConstructionStandardsListById(string ConstructionStandardsId)
{
Model.SGGLDB db = Funs.DB;
Model.Technique_ConstructionStandards ConstructionStandardsList =
db.Technique_ConstructionStandards.FirstOrDefault(e => e.ConstructionStandardsId == ConstructionStandardsId);
if (ConstructionStandardsList != null)
{
if (!string.IsNullOrEmpty(ConstructionStandardsList.AttachUrl))
{
BLL.UploadFileService.DeleteFile(Funs.RootPath, ConstructionStandardsList.AttachUrl);
}
////删除附件表
BLL.CommonService.DeleteAttachFileById(ConstructionStandardsList.ConstructionStandardsId);
db.Technique_ConstructionStandards.DeleteOnSubmit(ConstructionStandardsList);
db.SubmitChanges();
}
}
}