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; /// /// 根据主键获取 /// /// /// public static Model.Technique_ProtectionStandards GetProtectionStandardsListById(string ProtectionStandardsId) { return Funs.DB.Technique_ProtectionStandards.FirstOrDefault(e => e.ProtectionStandardsId == ProtectionStandardsId); } /// /// 获取集合 /// /// /// public static List GetProtectionStandardsList(int PageNumber, int PageSize) { List 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; } /// /// 添加 /// /// 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(); } /// /// 修改 /// /// 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(); } } /// ///根据主键删除 /// /// 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 CompileDate { get; set; } public System.Nullable IsPass { get; set; } public string UpState { get; set; } public string Remark { get; set; } } } }