SGGL_HBAZ/SGGL/BLL/HSSE/Technique/ProtectionStandardsService.cs

185 lines
7.1 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;
2025-02-20 17:21:35 +08:00
using Model;
2025-02-19 15:09:13 +08:00
2025-03-05 18:22:54 +08:00
namespace BLL
2025-02-19 15:09:13 +08:00
{
2025-03-05 18:22:54 +08:00
public class ProtectionStandardsService
2025-02-20 17:21:35 +08:00
{
2025-03-05 18:22:54 +08:00
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取
/// </summary>
/// <param name="ProtectionStandardsId"></param>
/// <returns></returns>
public static Model.Technique_ProtectionStandards GetProtectionStandardsListById(string ProtectionStandardsId)
2025-02-20 17:55:00 +08:00
{
2025-03-05 18:22:54 +08:00
return Funs.DB.Technique_ProtectionStandards.FirstOrDefault(e =>
e.ProtectionStandardsId == ProtectionStandardsId);
2025-02-20 17:55:00 +08:00
}
2025-02-19 15:09:13 +08:00
2025-03-05 18:22:54 +08:00
/// <summary>
/// 获取集合
/// </summary>
/// <param name="ProtectionStandardsId"></param>
/// <returns></returns>
public static List<ProtectionStandardsItem> GetProtectionStandardsList(int PageNumber, int PageSize)
2025-02-19 15:09:13 +08:00
{
2025-03-05 18:22:54 +08:00
List<ProtectionStandardsItem> getDataLists = (from x in Funs.DB.Technique_ProtectionStandards
select new ProtectionStandardsItem
{
ProtectionStandardsId = x.ProtectionStandardsId,
ProtectionStandardsCode = x.ProtectionStandardsCode,
ProtectionStandardsName = x.ProtectionStandardsName,
AttachUrl = x.AttachUrl,
CompileMan = x.CompileMan,
CompileDate = x.CompileDate,
IsPass = x.IsPass,
UpState = x.UpState,
Remark = x.Remark
}).ToList();
if (PageNumber > 0 && PageSize > 0)
{
getDataLists = getDataLists.Skip((PageNumber - 1) * PageSize).Take(PageSize).ToList();
}
return getDataLists;
}
2025-02-19 15:09:13 +08:00
2025-03-05 18:22:54 +08:00
/// <summary>
/// 添加
/// </summary>
/// <param name="ProtectionStandardsList"></param>
public static void AddProtectionStandardsList(Model.Technique_ProtectionStandards ProtectionStandardsList)
2025-02-19 15:09:13 +08:00
{
2025-03-05 18:22:54 +08:00
Model.SGGLDB db = Funs.DB;
Model.Technique_ProtectionStandards newProtectionStandardsList = new Model.Technique_ProtectionStandards
{
ProtectionStandardsId = ProtectionStandardsList.ProtectionStandardsId,
ProtectionStandardsCode = ProtectionStandardsList.ProtectionStandardsCode,
ProtectionStandardsName = ProtectionStandardsList.ProtectionStandardsName,
AttachUrl = ProtectionStandardsList.AttachUrl,
CompileMan = ProtectionStandardsList.CompileMan,
CompileDate = ProtectionStandardsList.CompileDate,
};
2025-02-19 15:09:13 +08:00
newProtectionStandardsList.CompileMan = ProtectionStandardsList.CompileMan;
newProtectionStandardsList.CompileDate = ProtectionStandardsList.CompileDate;
2025-03-05 18:22:54 +08:00
newProtectionStandardsList.IsPass = ProtectionStandardsList.IsPass;
2025-02-19 15:09:13 +08:00
newProtectionStandardsList.UpState = ProtectionStandardsList.UpState;
newProtectionStandardsList.Remark = ProtectionStandardsList.Remark;
2025-03-05 18:22:54 +08:00
db.Technique_ProtectionStandards.InsertOnSubmit(newProtectionStandardsList);
2025-02-19 15:09:13 +08:00
db.SubmitChanges();
}
2025-03-05 18:22:54 +08:00
/// <summary>
/// 修改
/// </summary>
/// <param name="ProtectionStandardsList"></param>
public static void UpdateProtectionStandardsList(Model.Technique_ProtectionStandards ProtectionStandardsList)
2025-02-19 15:09:13 +08:00
{
2025-03-05 18:22:54 +08:00
Model.SGGLDB db = Funs.DB;
Model.Technique_ProtectionStandards newProtectionStandardsList =
db.Technique_ProtectionStandards.FirstOrDefault(e =>
e.ProtectionStandardsId == ProtectionStandardsList.ProtectionStandardsId);
if (newProtectionStandardsList != null)
2025-02-19 15:09:13 +08:00
{
2025-03-05 18:22:54 +08:00
newProtectionStandardsList.ProtectionStandardsCode = ProtectionStandardsList.ProtectionStandardsCode;
newProtectionStandardsList.ProtectionStandardsName = ProtectionStandardsList.ProtectionStandardsName;
newProtectionStandardsList.AttachUrl = ProtectionStandardsList.AttachUrl;
newProtectionStandardsList.CompileMan = ProtectionStandardsList.CompileMan;
newProtectionStandardsList.CompileDate = ProtectionStandardsList.CompileDate;
newProtectionStandardsList.UpState = ProtectionStandardsList.UpState;
newProtectionStandardsList.Remark = ProtectionStandardsList.Remark;
db.SubmitChanges();
2025-02-19 15:09:13 +08:00
}
2025-03-05 18:22:54 +08:00
}
2025-02-19 15:09:13 +08:00
2025-03-05 18:22:54 +08:00
/// <summary>
///根据主键删除
/// </summary>
/// <param name="ProtectionStandardsId"></param>
public static void DeleteProtectionStandardsListById(string ProtectionStandardsId)
2025-02-20 17:21:35 +08:00
{
2025-03-05 18:22:54 +08:00
Model.SGGLDB db = Funs.DB;
Model.Technique_ProtectionStandards ProtectionStandardsList =
db.Technique_ProtectionStandards.FirstOrDefault(e => e.ProtectionStandardsId == ProtectionStandardsId);
if (ProtectionStandardsList != null)
{
if (!string.IsNullOrEmpty(ProtectionStandardsList.AttachUrl))
{
BLL.UploadFileService.DeleteFile(Funs.RootPath, ProtectionStandardsList.AttachUrl);
}
////删除附件表
BLL.CommonService.DeleteAttachFileById(ProtectionStandardsList.ProtectionStandardsId);
db.Technique_ProtectionStandards.DeleteOnSubmit(ProtectionStandardsList);
db.SubmitChanges();
}
2025-02-20 17:21:35 +08:00
}
2025-03-05 18:22:54 +08:00
public class ProtectionStandardsItem
2025-02-20 17:21:35 +08:00
{
2025-03-05 18:22:54 +08:00
public string ProtectionStandardsId
{
get;
set;
}
public string ProtectionStandardsCode
{
get;
set;
}
public string ProtectionStandardsName
{
get;
set;
}
public string AttachUrl
{
get;
set;
}
public string CompileMan
{
get;
set;
}
public System.Nullable<System.DateTime> CompileDate
{
get;
set;
}
public System.Nullable<bool> IsPass
{
get;
set;
}
public string UpState
{
get;
set;
}
public string Remark
{
get;
set;
}
2025-02-20 17:21:35 +08:00
}
}
2025-02-19 15:09:13 +08:00
}