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

185 lines
7.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
namespace BLL
{
public class ProtectionStandardsService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取
/// </summary>
/// <param name="ProtectionStandardsId"></param>
/// <returns></returns>
public static Model.Technique_ProtectionStandards GetProtectionStandardsListById(string ProtectionStandardsId)
{
return Funs.DB.Technique_ProtectionStandards.FirstOrDefault(e =>
e.ProtectionStandardsId == ProtectionStandardsId);
}
/// <summary>
/// 获取集合
/// </summary>
/// <param name="ProtectionStandardsId"></param>
/// <returns></returns>
public static List<ProtectionStandardsItem> GetProtectionStandardsList(int PageNumber, int PageSize)
{
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;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="ProtectionStandardsList"></param>
public static void AddProtectionStandardsList(Model.Technique_ProtectionStandards ProtectionStandardsList)
{
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,
};
newProtectionStandardsList.CompileMan = ProtectionStandardsList.CompileMan;
newProtectionStandardsList.CompileDate = ProtectionStandardsList.CompileDate;
newProtectionStandardsList.IsPass = ProtectionStandardsList.IsPass;
newProtectionStandardsList.UpState = ProtectionStandardsList.UpState;
newProtectionStandardsList.Remark = ProtectionStandardsList.Remark;
db.Technique_ProtectionStandards.InsertOnSubmit(newProtectionStandardsList);
db.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="ProtectionStandardsList"></param>
public static void UpdateProtectionStandardsList(Model.Technique_ProtectionStandards ProtectionStandardsList)
{
Model.SGGLDB db = Funs.DB;
Model.Technique_ProtectionStandards newProtectionStandardsList =
db.Technique_ProtectionStandards.FirstOrDefault(e =>
e.ProtectionStandardsId == ProtectionStandardsList.ProtectionStandardsId);
if (newProtectionStandardsList != null)
{
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();
}
}
/// <summary>
///根据主键删除
/// </summary>
/// <param name="ProtectionStandardsId"></param>
public static void DeleteProtectionStandardsListById(string ProtectionStandardsId)
{
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();
}
}
public class ProtectionStandardsItem
{
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;
}
}
}
}