using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL; public class ConstructionStandardsService { public static Model.SGGLDB db = Funs.DB; /// /// 根据主键获取 /// /// /// public static Model.Technique_ConstructionStandards GetConstructionStandardsListById(string ConstructionStandardsId) { return Funs.DB.Technique_ConstructionStandards.FirstOrDefault(e => e.ConstructionStandardsId == ConstructionStandardsId); } /// /// 获取集合 /// /// /// public static List GetConstructionStandardsList(int PageNumber, int PageSize) { List getDataLists = (from x in Funs.DB.Technique_ConstructionStandards select new ConstructionStandardsItem { ConstructionStandardsId = x.ConstructionStandardsId, ConstructionStandardsCode = x.ConstructionStandardsCode, ConstructionStandardsName = x.ConstructionStandardsName, 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 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(); } /// /// 修改 /// /// 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(); } } /// ///根据主键删除 /// /// 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(); } } public class ConstructionStandardsItem { public string ConstructionStandardsId { get; set; } public string ConstructionStandardsCode { get; set; } public string ConstructionStandardsName { 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; } } }