using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { /// /// 施工方案/审查 /// public static class ConstructSolutionService { public static Model.SGGLDB db = Funs.DB; /// /// 根据主键获取施工方案/审查 /// /// /// public static Model.Solution_ConstructSolution GetConstructSolutionById(string constructSolutionId) { return Funs.DB.Solution_ConstructSolution.FirstOrDefault(e => e.ConstructSolutionId == constructSolutionId); } /// /// 获取时间段的方案审查 /// /// /// /// /// public static List GetConstructSolutionListByDate(string p, DateTime startTime, DateTime endTime) { return (from x in Funs.DB.Solution_ConstructSolution where x.ProjectId == p && x.CompileDate >= startTime && x.CompileDate <= endTime select x).ToList(); } /// /// 获取时间段的施工方案审查数量 /// /// /// /// /// public static int GetConstructSolutionCountByDate(string projectId, DateTime startTime, DateTime endTime) { var q = (from x in Funs.DB.Solution_ConstructSolution where x.ProjectId == projectId && x.CompileDate >= startTime && x.CompileDate <= endTime orderby x.CompileDate select x).ToList(); return q.Count(); } /// /// 添加施工方案/审查 /// /// public static void AddConstructSolution(Model.Solution_ConstructSolution constructSolution) { Model.SGGLDB db = Funs.DB; Model.Solution_ConstructSolution newConstructSolution = new Model.Solution_ConstructSolution { ConstructSolutionId = constructSolution.ConstructSolutionId, ProjectId = constructSolution.ProjectId, ConstructSolutionCode = constructSolution.ConstructSolutionCode, ConstructSolutionName = constructSolution.ConstructSolutionName, VersionNo = constructSolution.VersionNo, UnitId = constructSolution.UnitId, InvestigateType = constructSolution.InvestigateType, SolutinType = constructSolution.SolutinType, FileContents = constructSolution.FileContents, Remark = constructSolution.Remark, CompileMan = constructSolution.CompileMan, CompileManName = constructSolution.CompileManName, CompileDate = constructSolution.CompileDate, States = constructSolution.States }; db.Solution_ConstructSolution.InsertOnSubmit(newConstructSolution); db.SubmitChanges(); if (constructSolution.ConstructSolutionCode == BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectConstructSolutionMenuId, constructSolution.ProjectId, null)) { CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectConstructSolutionMenuId, constructSolution.ProjectId, null, constructSolution.ConstructSolutionId, constructSolution.CompileDate); } } public static void AddConstructSolutionForApi(Model.Solution_ConstructSolution constructSolution) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { Model.Solution_ConstructSolution newConstructSolution = new Model.Solution_ConstructSolution { ConstructSolutionId = constructSolution.ConstructSolutionId, ProjectId = constructSolution.ProjectId, ConstructSolutionCode = constructSolution.ConstructSolutionCode, ConstructSolutionName = constructSolution.ConstructSolutionName, VersionNo = constructSolution.VersionNo, UnitId = constructSolution.UnitId, InvestigateType = constructSolution.InvestigateType, SolutinType = constructSolution.SolutinType, FileContents = constructSolution.FileContents, Remark = constructSolution.Remark, CompileMan = constructSolution.CompileMan, CompileManName = constructSolution.CompileManName, CompileDate = constructSolution.CompileDate, States = constructSolution.States }; db.Solution_ConstructSolution.InsertOnSubmit(newConstructSolution); db.SubmitChanges(); if (constructSolution.ConstructSolutionCode == BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectConstructSolutionMenuId, constructSolution.ProjectId, null)) { CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitIdForApi(Const.ProjectConstructSolutionMenuId, constructSolution.ProjectId, null, constructSolution.ConstructSolutionId, constructSolution.CompileDate); } } } /// /// 修改施工方案/审查 /// /// public static void UpdateConstructSolution(Model.Solution_ConstructSolution constructSolution) { Model.SGGLDB db = Funs.DB; Model.Solution_ConstructSolution newConstructSolution = db.Solution_ConstructSolution.FirstOrDefault(e => e.ConstructSolutionId == constructSolution.ConstructSolutionId); if (newConstructSolution != null) { newConstructSolution.ConstructSolutionName = constructSolution.ConstructSolutionName; newConstructSolution.VersionNo = constructSolution.VersionNo; newConstructSolution.UnitId = constructSolution.UnitId; newConstructSolution.InvestigateType = constructSolution.InvestigateType; newConstructSolution.SolutinType = constructSolution.SolutinType; newConstructSolution.FileContents = constructSolution.FileContents; newConstructSolution.Remark = constructSolution.Remark; newConstructSolution.States = constructSolution.States; if(!string.IsNullOrEmpty(constructSolution.QRCodeAttachUrl)) { newConstructSolution.QRCodeAttachUrl = constructSolution.QRCodeAttachUrl; } db.SubmitChanges(); if (constructSolution.ConstructSolutionCode != CodeRecordsService.ReturnCodeByDataId(constructSolution.ConstructSolutionId)) { CodeRecordsService.DeleteCodeRecordsByDataId(constructSolution.ConstructSolutionId);//删除编号 } } } public static void UpdateConstructSolutionForApi(Model.Solution_ConstructSolution constructSolution) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { Model.Solution_ConstructSolution newConstructSolution = db.Solution_ConstructSolution.FirstOrDefault(e => e.ConstructSolutionId == constructSolution.ConstructSolutionId); if (newConstructSolution != null) { newConstructSolution.ConstructSolutionName = constructSolution.ConstructSolutionName; newConstructSolution.VersionNo = constructSolution.VersionNo; newConstructSolution.UnitId = constructSolution.UnitId; newConstructSolution.InvestigateType = constructSolution.InvestigateType; newConstructSolution.SolutinType = constructSolution.SolutinType; newConstructSolution.FileContents = constructSolution.FileContents; newConstructSolution.Remark = constructSolution.Remark; newConstructSolution.States = constructSolution.States; if (!string.IsNullOrEmpty(constructSolution.QRCodeAttachUrl)) { newConstructSolution.QRCodeAttachUrl = constructSolution.QRCodeAttachUrl; } db.SubmitChanges(); string code = string.Empty; var codeRecords = db.Sys_CodeRecords.FirstOrDefault(x => x.DataId == constructSolution.ConstructSolutionId); if (codeRecords != null) { code = codeRecords.Code; } if (constructSolution.ConstructSolutionCode != code) { var codeRecords1 = db.Sys_CodeRecords.FirstOrDefault(x => x.DataId == constructSolution.ConstructSolutionId); if (codeRecords1 != null) { ///删除文件柜A中数据 // BLL.FileCabinetAItemService.DeleteFileCabinetAItemByID(dataId); db.Sys_CodeRecords.DeleteOnSubmit(codeRecords1); db.SubmitChanges(); } } } } } /// /// 根据主键删除施工方案/审查 /// /// public static void DeleteConstructSolutionById(string constructSolutionId) { Model.SGGLDB db = Funs.DB; Model.Solution_ConstructSolution constructSolution = db.Solution_ConstructSolution.FirstOrDefault(e => e.ConstructSolutionId == constructSolutionId); if (constructSolution != null) { ////删除审核流程表 CommonService.DeleteFlowOperateByID(constructSolutionId); CodeRecordsService.DeleteCodeRecordsByDataId(constructSolutionId);//删除编号 CommonService.DeleteAttachFileById(constructSolutionId);//删除附件 db.Solution_ConstructSolution.DeleteOnSubmit(constructSolution); db.SubmitChanges(); } } } }