/// <summary>
        /// Save a Previous PR work
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="companyId">companyId</param>
        private void SavePreviousPRWork(int projectId, int section_assetId, int companyId)
        {
            // Load Previous work - Point Repairs data (last sections work)
            string workType = "Point Repairs";
            WorkPointRepairsGateway workPointRepairsGateway = new WorkPointRepairsGateway();
            workPointRepairsGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId);

            int workId = workPointRepairsGateway.GetWorkIdTop1();
            string clientId = ""; if (workPointRepairsGateway.GetClientId(workId) != "") clientId = workPointRepairsGateway.GetClientId(workId);
            string measurementTakenBy = ""; if (workPointRepairsGateway.GetMeasurementTakenBy(workId) != "") measurementTakenBy = workPointRepairsGateway.GetMeasurementTakenBy(workId);
            DateTime? repairConfirmationDate = null; if (workPointRepairsGateway.GetRepairConfirmationDate(workId).HasValue) repairConfirmationDate = workPointRepairsGateway.GetRepairConfirmationDate(workId);
            bool bypassRequired = workPointRepairsGateway.GetBypassRequired(workId);
            string roboticDistances = ""; if (workPointRepairsGateway.GetRoboticDistances(workId) != "") roboticDistances = workPointRepairsGateway.GetRoboticDistances(workId);
            DateTime? proposedLiningDate = null; if (workPointRepairsGateway.GetProposedLiningDate(workId).HasValue) proposedLiningDate = workPointRepairsGateway.GetProposedLiningDate(workId);
            DateTime? deadlineLiningDate = null; if (workPointRepairsGateway.GetDeadlineLiningDate(workId).HasValue) deadlineLiningDate = workPointRepairsGateway.GetDeadlineLiningDate(workId);
            DateTime? finalVideoDate = null; if (workPointRepairsGateway.GetFinalVideoDate(workId).HasValue) finalVideoDate = workPointRepairsGateway.GetFinalVideoDate(workId);
            int? estimatedJoints = null; if (workPointRepairsGateway.GetEstimatedJoints(workId).HasValue) estimatedJoints = workPointRepairsGateway.GetEstimatedJoints(workId);
            int? jointsTestSealed = null; if (workPointRepairsGateway.GetJointsTestSealed(workId).HasValue) jointsTestSealed = workPointRepairsGateway.GetJointsTestSealed(workId);
            bool issueIdentified = workPointRepairsGateway.GetIssueIdentified(workId);
            bool issueLfs = workPointRepairsGateway.GetIssueLFS(workId);
            bool issueClient = workPointRepairsGateway.GetIssueClient(workId);
            bool issueSales = workPointRepairsGateway.GetIssueSales(workId);
            bool issueGivenToClient = workPointRepairsGateway.GetIssueGivenToClient(workId);
            bool issueResolved = workPointRepairsGateway.GetIssueResolved(workId);
            bool issueInvestigation = workPointRepairsGateway.GetIssueInvestigation(workId);
            string repairId = ""; if (workPointRepairsGateway.GetRepairID(workId) != "") repairId = workPointRepairsGateway.GetRepairID(workId);

            // Load Previous work - General work data
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);

            int? libraryCategoriesId = null; if (workGateway.GetLibraryCategoriesId(workId).HasValue) libraryCategoriesId = workGateway.GetLibraryCategoriesId(workId);
            string comments = workGateway.GetComments(workId);
            string history = workGateway.GetHistory(workId);

            // Save new work
            WorkPointRepairs workPointRepairs = new WorkPointRepairs(null);
            int newSectionWorkId = workPointRepairs.InsertDirect(projectId, section_assetId, libraryCategoriesId, clientId, measurementTakenBy, repairConfirmationDate, bypassRequired, roboticDistances, proposedLiningDate, deadlineLiningDate, finalVideoDate, estimatedJoints, jointsTestSealed, issueIdentified, issueLfs, issueClient, issueSales, issueGivenToClient, issueResolved, issueInvestigation, repairId, false, companyId, comments, history);

            // Load Previous work  -  Save pr repair
            WorkPointRepairsRepairGateway workPointRepairsRepairGateway = new WorkPointRepairsRepairGateway();
            workPointRepairsRepairGateway.LoadByWorkId(workId, companyId);

            foreach (WorkTDS.LFS_WORK_POINT_REPAIRS_REPAIRRow row in (WorkTDS.LFS_WORK_POINT_REPAIRS_REPAIRDataTable)workPointRepairsRepairGateway.Table)
            {
                string repairPointId = row.RepairPointID;
                string type = ""; if (!row.IsTypeNull()) type = row.Type;
                string reamDistance = ""; if (!row.IsReamDistanceNull()) reamDistance = row.ReamDistance;
                DateTime? reamDate = null; if (!row.IsReamDateNull()) reamDate = row.ReamDate;
                string linerDistance = ""; if (!row.IsLinerDistanceNull()) linerDistance = row.LinerDistance;
                string direction = ""; if (!row.IsDirectionNull()) direction = row.Direction;
                int? reinstates = null; if (!row.IsReinstatesNull()) reinstates = row.Reinstates;
                string ltmh = ""; if (!row.IsLTMHNull()) ltmh = row.LTMH;
                string vtmh = ""; if (!row.IsVTMHNull()) vtmh = row.VTMH;
                string distance = ""; if (!row.IsDistanceNull()) distance = row.Distance;
                string size_ = ""; if (!row.IsSize_Null()) size_ = row.Size_;
                DateTime? installDate = null; if (!row.IsInstallDateNull()) installDate = row.InstallDate;
                string mhShot = ""; if (!row.IsMHShotNull()) mhShot = row.MHShot;
                string groutDistance = ""; if (!row.IsGroutDistanceNull()) groutDistance = row.GroutDistance;
                DateTime? groutDate = null; if (!row.IsGroutDateNull()) groutDate = row.GroutDate;
                string approval = ""; if (!row.IsApprovalNull()) approval = row.Approval;
                bool extraRepair = row.ExtraRepair;
                bool cancelled = row.Cancelled;
                string commentsRepair = ""; if (!row.IsCommentsNull()) commentsRepair = row.Comments;
                string defectQualifier = ""; if (!row.IsDefectQualifierNull()) defectQualifier = row.DefectQualifier;
                string defecDetails = ""; if (!row.IsDefectDetailsNull()) defecDetails = row.DefectDetails;
                string length = ""; if (!row.IsLengthNull()) length = row.Length;
                DateTime? reinstateDate = null; if (!row.IsReinstateDateNull()) reinstateDate = row.ReinstateDate;

                WorkPointRepairsRepair workPointRepairsRepair = new WorkPointRepairsRepair();
                workPointRepairsRepair.InsertDirect(newSectionWorkId, repairPointId, type, reamDistance, reamDate, linerDistance, direction, reinstates, ltmh, vtmh, distance, size_, installDate, mhShot, groutDistance, groutDate, approval, extraRepair, cancelled, commentsRepair, false, companyId, defectQualifier, defectQualifier, length, reinstateDate);
            }

            // Load Previous work  - Comments and History
            SavePreviousComments(workId, workType, companyId, newSectionWorkId);
            SavePreviousHistory(workId, workType, companyId, newSectionWorkId);
        }
        /// <summary>
        /// Save a Previous RA work
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="companyId">companyId</param>
        private void SavePreviousRAWork(int projectId, int section_assetId, int companyId)
        {
            // Load Previous work  - Rehab assessment data (last sections work)
            string workType = "Rehab Assessment";
            WorkRehabAssessmentGateway workRehabAssessmentGateway = new WorkRehabAssessmentGateway();
            workRehabAssessmentGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId);

            int workId = workRehabAssessmentGateway.GetWorkIdTop1();
            DateTime? preFlushDate = null; if (workRehabAssessmentGateway.GetPreFlushDateTop1().HasValue) preFlushDate = workRehabAssessmentGateway.GetPreFlushDateTop1();
            DateTime? preVideoDate = null; if (workRehabAssessmentGateway.GetPreVideoDateTop1().HasValue) preVideoDate = workRehabAssessmentGateway.GetPreVideoDateTop1();

            // Load Previous work  -  General work data
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);
            int? libraryCategoriesId = null; if (workGateway.GetLibraryCategoriesId(workId).HasValue) libraryCategoriesId = workGateway.GetLibraryCategoriesId(workId);
            string comments = workGateway.GetComments(workId);
            string history = workGateway.GetHistory(workId);

            // Save new work
            WorkRehabAssessment workRehabAssessment = new WorkRehabAssessment(null);
            int newSectionWorkId = workRehabAssessment.InsertDirect(projectId, section_assetId, libraryCategoriesId, preFlushDate, preVideoDate, false, companyId, comments, history);

            // Load Previous work  - Comments and History
            SavePreviousComments(workId, workType, companyId, newSectionWorkId);
            SavePreviousHistory(workId, workType, companyId, newSectionWorkId);
        }
        /// <summary>
        /// Save a Previous JL work
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="companyId">companyId</param>
        private void SavePreviousJLWork(int projectId, int section_assetId, int companyId)
        {
            // Load Previous work  -  Junction Lining section data (last sections work)
            string workType = "Junction Lining Section";
            WorkJunctionLiningSectionGateway workJunctionLiningSectionGateway = new WorkJunctionLiningSectionGateway();
            workJunctionLiningSectionGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId);

            int workId = workJunctionLiningSectionGateway.GetWorkIdTop1();
            int numLats = workJunctionLiningSectionGateway.GetNumLats(workId);
            int notLinedYet = workJunctionLiningSectionGateway.GetNotLinedYet(workId);
            Boolean allMeasured = workJunctionLiningSectionGateway.GetAllMeasured(workId);
            string issueWithLaterals = workJunctionLiningSectionGateway.GetIssueWithLaterals(workId);
            int notMeasuredYet = workJunctionLiningSectionGateway.GetNotMeasuredYet(workId);
            int notDeliveredYet = workJunctionLiningSectionGateway.GetNotDeliveredYet(workId);
            string trafficControl = ""; if (workJunctionLiningSectionGateway.GetTrafficControl(workId) != "") trafficControl = workJunctionLiningSectionGateway.GetTrafficControl(workId);
            string trafficControlDetails = ""; if (workJunctionLiningSectionGateway.GetTrafficControlDetails(workId) != "") trafficControlDetails = workJunctionLiningSectionGateway.GetTrafficControlDetails(workId);
            Boolean standardBypass = workJunctionLiningSectionGateway.GetStandardBypass(workId);
            string standardBypassComments = ""; if (workJunctionLiningSectionGateway.GetStandardBypassComments(workId) != "") standardBypassComments = workJunctionLiningSectionGateway.GetStandardBypassComments(workId);
            int availableToLine = workJunctionLiningSectionGateway.GetAvailableToLine(workId);

            // Load Previous work  -  General work data
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);

            int? libraryCategoriesId = null; if (workGateway.GetLibraryCategoriesId(workId).HasValue) libraryCategoriesId = workGateway.GetLibraryCategoriesId(workId);
            string comments = workGateway.GetComments(workId);
            string history = workGateway.GetHistory(workId);

            // Save new work
            WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null);
            int newSectionWorkId = workJunctionLiningSection.InsertDirect(projectId, section_assetId, libraryCategoriesId, numLats, notLinedYet, allMeasured, issueWithLaterals, notMeasuredYet, notDeliveredYet, false, companyId, comments, history, trafficControl, trafficControlDetails, standardBypass, standardBypassComments, availableToLine);

            // Load Previous work  - Junction Lining Lateral data
            WorkJunctionLiningLateralGateway workJunctionLiningLateralGateway = new WorkJunctionLiningLateralGateway();
            workJunctionLiningLateralGateway.LoadBySectionWorkId(workId, companyId);

            foreach (WorkTDS.LFS_WORK_JUNCTIONLINING_LATERALRow lateralRow in (WorkTDS.LFS_WORK_JUNCTIONLINING_LATERALDataTable)workJunctionLiningLateralGateway.Table)
            {
                WorkGateway workGatewayForLateral = new WorkGateway();
                workGatewayForLateral.LoadByWorkId(lateralRow.WorkID, companyId);
                int lateral_assetId = workGatewayForLateral.GetAssetId(lateralRow.WorkID);

                DateTime? pipeLocated = null; if (!lateralRow.IsPipeLocatedNull()) pipeLocated = lateralRow.PipeLocated;
                DateTime? sevicesLocated = null; if (!lateralRow.IsServicesLocatedNull()) sevicesLocated = lateralRow.ServicesLocated;
                DateTime? coInstalled = null; if (!lateralRow.IsCoInstalledNull()) coInstalled = lateralRow.CoInstalled;
                DateTime? backfilledConcrete = null; if (!lateralRow.IsBackfilledConcreteNull()) backfilledConcrete = lateralRow.BackfilledConcrete;
                DateTime? backfilledSoil = null; if (!lateralRow.IsBackfilledSoilNull()) backfilledSoil = lateralRow.BackfilledSoil;
                DateTime? grouted = null; if (!lateralRow.IsGroutedNull()) grouted = lateralRow.Grouted;
                DateTime? cored = null; if (!lateralRow.IsCoredNull()) cored = lateralRow.Cored;
                DateTime? prepped = null; if (!lateralRow.IsPreppedNull()) prepped = lateralRow.Prepped;
                DateTime? measured = null; if (!lateralRow.IsMeasuredNull()) measured = lateralRow.Measured;
                string linerSize = ""; if (!lateralRow.IsLinerSizeNull()) linerSize = lateralRow.LinerSize;
                DateTime? inProcess = null; if (!lateralRow.IsInProcessNull()) inProcess = lateralRow.InProcess;
                DateTime? inStock = null; if (!lateralRow.IsInStockNull()) inStock = lateralRow.InStock;
                DateTime? delivered = null; if (!lateralRow.IsDeliveredNull()) delivered = lateralRow.Delivered;
                int? buildRebuild = null; if (!lateralRow.IsBuildRebuildNull()) buildRebuild = lateralRow.BuildRebuild;
                DateTime? preVideo = null; if (!lateralRow.IsPreVideoNull()) preVideo = lateralRow.PreVideo;
                DateTime? linerInstalled = null; if (!lateralRow.IsLinerInstalledNull()) linerInstalled = lateralRow.LinerInstalled;
                DateTime? finalVideo = null; if (!lateralRow.IsFinalVideoNull()) finalVideo = lateralRow.FinalVideo;
                decimal? cost = null; if (!lateralRow.IsCostNull()) cost = lateralRow.Cost;
                DateTime? videoInspection = null; if (!lateralRow.IsVideoInspectionNull()) videoInspection = lateralRow.VideoInspection;
                bool coRequired = lateralRow.CoRequired;
                bool pitRequired = lateralRow.PitRequired;
                string coPitLocation = ""; if (!lateralRow.IsCoPitLocationNull()) coPitLocation = lateralRow.CoPitLocation;
                bool postContractDigRequired = lateralRow.PostContractDigRequired;
                DateTime? coCutDown = null; if (!lateralRow.IsCoCutDownNull()) coCutDown = lateralRow.CoCutDown;
                DateTime? finalRestoration = null; if (!lateralRow.IsFinalRestorationNull()) finalRestoration = lateralRow.FinalRestoration;
                string videoLengthToPropertyLine = ""; if (!lateralRow.IsVideoLengthToPropertyLineNull()) videoLengthToPropertyLine = lateralRow.VideoLengthToPropertyLine;
                bool liningThruCo = lateralRow.LiningThruCo;
                DateTime? noticeDelivered = null; if (!lateralRow.IsNoticeDeliveredNull()) noticeDelivered = lateralRow.NoticeDelivered;
                string hamiltonInspectionNumber = ""; if (!lateralRow.IsHamiltonInspectionNumberNull()) hamiltonInspectionNumber = lateralRow.HamiltonInspectionNumber;
                string flange = ""; if (!lateralRow.IsFlangeNull()) flange = lateralRow.Flange;
                string gasket = ""; if (!lateralRow.IsGasketNull()) gasket = lateralRow.Gasket;
                string depthOfLocated = ""; if (!lateralRow.IsDepthOfLocatedNull()) depthOfLocated = lateralRow.DepthOfLocated;
                bool digRequiredPriorToLining = lateralRow.DigRequiredPriorToLining;
                DateTime? digRequiredPriorToLiningCompleted = null; if (!lateralRow.IsDigRequiredPriorToLiningCompletedNull()) digRequiredPriorToLiningCompleted = lateralRow.DigRequiredPriorToLiningCompleted;
                bool digRequiredAfterLining = lateralRow.DigRequiredAfterLining;
                DateTime? digRequiredAfterLiningCompleted = null; if (!lateralRow.IsDigRequiredAfterLiningCompletedNull()) digRequiredAfterLiningCompleted = lateralRow.DigRequiredAfterLiningCompleted;
                bool outOfScope = lateralRow.OutOfScope;
                bool holdClientIssue = lateralRow.HoldClientIssue;
                DateTime? holdClientIssueResolved = null; if (!lateralRow.IsHoldClientIssueResolvedNull()) holdClientIssueResolved = lateralRow.HoldClientIssueResolved;
                bool holdLFSIssue = lateralRow.HoldLFSIssue;
                DateTime? holdLFSIssueResolved = null; if (!lateralRow.IsHoldLFSIssueResolvedNull()) holdLFSIssueResolved = lateralRow.HoldLFSIssueResolved;
                bool requiresRoboticPrep = lateralRow.LateralRequiresRoboticPrep;
                DateTime? requiresRoboticPrepCompleted = null; if (!lateralRow.IsLateralRequiresRoboticPrepCompletedNull()) requiresRoboticPrepCompleted = lateralRow.LateralRequiresRoboticPrepCompleted;
                string linerType = ""; if (!lateralRow.IsLinerTypeNull()) linerType = lateralRow.LinerType;
                string prepType = ""; if (!lateralRow.IsPrepTypeNull()) prepType = lateralRow.PrepType;
                bool dyeTestReq = lateralRow.DyeTestReq;
                DateTime? dyeTestComplete = null; if (!lateralRow.IsDyeTestCompleteNull()) dyeTestComplete = lateralRow.DyeTestComplete;
                string contractYear = ""; if (!lateralRow.IsContractYearNull()) contractYear = lateralRow.ContractYear;

                WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null);
                workJunctionLiningLateral.InsertDirect(projectId, lateral_assetId, newSectionWorkId, pipeLocated, sevicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, buildRebuild, preVideo, linerInstalled, finalVideo, cost, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, coCutDown, finalRestoration, false, companyId, comments, history, videoLengthToPropertyLine, liningThruCo, noticeDelivered, hamiltonInspectionNumber, flange, gasket, depthOfLocated, digRequiredPriorToLining, digRequiredPriorToLiningCompleted, digRequiredAfterLining, digRequiredAfterLiningCompleted, outOfScope, holdClientIssue, holdClientIssueResolved, holdLFSIssue, holdLFSIssueResolved, requiresRoboticPrep, requiresRoboticPrepCompleted, linerType, prepType, dyeTestReq, dyeTestComplete, contractYear);
            }

            // Load Previous work  - Comments and History
            SavePreviousComments(workId, workType, companyId, newSectionWorkId);
            SavePreviousHistory(workId, workType, companyId, newSectionWorkId);
        }
        /// <summary>
        /// Save a Previous FL work
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="companyId">companyId</param>
        private void SavePreviousFLWork(int projectId, int section_assetId, int companyId)
        {
            // Load Previous work  -  Full Length Lining data (last sections work)
            string workType = "Full Length Lining";
            WorkFullLengthLiningGateway workFullLengthLiningGateway = new WorkFullLengthLiningGateway();
            workFullLengthLiningGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId);

            int workId = workFullLengthLiningGateway.GetWorkIdTop1();
            string clientId = ""; if (workFullLengthLiningGateway.GetClientId(workId) != "") clientId = workFullLengthLiningGateway.GetClientId(workId);
            DateTime? proposedLiningDate = null; if (workFullLengthLiningGateway.GetProposedLiningDate(workId).HasValue) proposedLiningDate = workFullLengthLiningGateway.GetProposedLiningDate(workId);
            DateTime? deadlineLiningDate = null; if (workFullLengthLiningGateway.GetDeadlineLiningDate(workId).HasValue) deadlineLiningDate = workFullLengthLiningGateway.GetDeadlineLiningDate(workId);
            DateTime? p1Date = null; if (workFullLengthLiningGateway.GetP1Date(workId).HasValue) p1Date = workFullLengthLiningGateway.GetP1Date(workId);
            DateTime? m1Date = null; if (workFullLengthLiningGateway.GetM1Date(workId).HasValue) m1Date = workFullLengthLiningGateway.GetM1Date(workId);
            DateTime? m2Date = null; if (workFullLengthLiningGateway.GetM2Date(workId).HasValue) m2Date = workFullLengthLiningGateway.GetM2Date(workId);
            DateTime? installDate = null; if (workFullLengthLiningGateway.GetInstallDate(workId).HasValue) installDate = workFullLengthLiningGateway.GetInstallDate(workId);
            DateTime? finalVideoDate = null; if (workFullLengthLiningGateway.GetFinalVideoDate(workId).HasValue) finalVideoDate = workFullLengthLiningGateway.GetFinalVideoDate(workId);
            bool issueIdentified = workFullLengthLiningGateway.GetIssueIdentified(workId);
            bool issueLfs = workFullLengthLiningGateway.GetIssueLFS(workId);
            bool issueClient = workFullLengthLiningGateway.GetIssueClient(workId);
            bool issueSales = workFullLengthLiningGateway.GetIssueSales(workId);
            bool issueGivenToClient = workFullLengthLiningGateway.GetIssueGivenToClient(workId);
            bool issueResolved = workFullLengthLiningGateway.GetIssueResolved(workId);
            bool issueInvestigation = workFullLengthLiningGateway.GetIssueInvestigation(workId);

            // Load Previous work  -  Full Length Lining M1 data (last sections work)
            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
            fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workId, section_assetId, companyId);

            string measurementTakenBy = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId) != "") measurementTakenBy = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId);
            string trafficControl = ""; if (fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId) != "") trafficControl = fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId);
            string siteDetails = ""; if (fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId) != "") siteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId);
            string accessType = ""; if (fullLengthLiningWorkDetailsGateway.GetAccessType(workId) != "") accessType = fullLengthLiningWorkDetailsGateway.GetAccessType(workId);
            bool pipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workId);
            bool standardByPass = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workId);
            string standardByPassComments = ""; if (fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId) != "") standardByPassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId);
            string trafficControlDetails = ""; if (fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId) != "") trafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId);
            string measurementType = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId) != "") measurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId);
            string measurementFromMH = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId) != "") measurementFromMH = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
            string videoDoneFromMH = ""; if (fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId) != "") videoDoneFromMH = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
            string videoDoneToMH = ""; if (fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId) != "") videoDoneToMH = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);

            // Load Previous work  -  Full Length Lining M2 data (last sections work)
            string videoLength = ""; if (fullLengthLiningWorkDetailsGateway.GetVideoLength(workId) != "") videoLength = fullLengthLiningWorkDetailsGateway.GetVideoLength(workId);
            string measurementTakenBy2 = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workId) != "") measurementTakenBy2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workId);
            bool dropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipe(workId);
            string dropPipeInvertDepth = ""; if (fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workId) != "") dropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workId);
            int? cappedLaterals = null; if (fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId).HasValue) cappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId);
            string lineWithID = ""; if (fullLengthLiningWorkDetailsGateway.GetLineWithId(workId) != "") lineWithID = fullLengthLiningWorkDetailsGateway.GetLineWithId(workId);
            string hydrantAddress = ""; if (fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workId) != "") hydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workId);
            string hydroWireWithin10FtOfInversionMH = ""; if (fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workId) != "") hydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workId);
            string distanceToInversionMH = ""; if (fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workId) != "") distanceToInversionMH = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workId);
            string surfaceGrade = ""; if (fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId) != "") surfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId);
            bool hydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workId);
            bool fridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workId);
            bool twoPump = fullLengthLiningWorkDetailsGateway.GetTwoPump(workId);
            bool sixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypass(workId);
            bool scaffolding = fullLengthLiningWorkDetailsGateway.GetScaffolding(workId);
            bool winchExtention = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workId);
            bool extraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workId);
            bool greyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workId);
            bool easementMats = fullLengthLiningWorkDetailsGateway.GetEasementMats(workId);
            bool rampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequired(workId);
            bool cameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workId);

            // Load Previous work  -  Full Length Lining P1 data (last sections work)
            int? cxisRemoved = null; if (fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).HasValue) fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId);
            bool roboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workId);
            DateTime? roboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId);
            bool p1Completed = fullLengthLiningWorkDetailsGateway.GetP1Completed(workId);

            // Load Previous work  -  General work data
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);

            int? libraryCategoriesId = null; if (workGateway.GetLibraryCategoriesId(workId).HasValue) libraryCategoriesId = workGateway.GetLibraryCategoriesId(workId);
            string comments = workGateway.GetComments(workId);
            string history = workGateway.GetHistory(workId);

            // Save new work
            WorkFullLengthLining workFullLengthLining = new WorkFullLengthLining(null);
            int newSectionWorkId = workFullLengthLining.InsertDirectFullWork(projectId, section_assetId, libraryCategoriesId, clientId, proposedLiningDate, deadlineLiningDate, p1Date, m1Date, m2Date, installDate, finalVideoDate, issueIdentified, issueLfs, issueClient, issueSales, issueGivenToClient, issueResolved, false, companyId, issueInvestigation, comments, history, cxisRemoved, roboticPrepCompleted, roboticPrepCompletedDate, measurementTakenBy, trafficControl, siteDetails, pipeSizeChange, standardByPass, standardByPassComments, trafficControlDetails, measurementType, measurementFromMH, videoDoneFromMH, videoDoneToMH, videoLength, measurementTakenBy2, dropPipe, dropPipeInvertDepth, cappedLaterals, lineWithID, hydrantAddress, hydroWireWithin10FtOfInversionMH, distanceToInversionMH, surfaceGrade, hydroPulley, fridgeCart, twoPump, sixBypass, scaffolding, winchExtention, extraGenerator, greyCableExtension, easementMats, rampRequired, cameraSkid, accessType, p1Completed);

            // Load Previous work  -  Save fl laterals
            WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway();
            workFullLengthLiningM1LateralGateway.LoadByWorkId(workId, companyId);

            foreach (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALRow lateralRow in (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALDataTable)workFullLengthLiningM1LateralGateway.Table)
            {
                int lateral = lateralRow.Lateral;
                string videoDistance = ""; if (!lateralRow.IsVideoDistanceNull()) videoDistance = lateralRow.VideoDistance;
                string clockPosition = ""; if (!lateralRow.IsClockPositionNull()) clockPosition = lateralRow.ClockPosition;
                string distanceToCentre = ""; if (!lateralRow.IsDistanceToCentreNull()) distanceToCentre = lateralRow.DistanceToCentre;
                string timeOpened = ""; if (!lateralRow.IsTimeOpenedNull()) timeOpened = lateralRow.TimeOpened;
                string reverseSetup = ""; if (!lateralRow.IsReverseSetupNull()) reverseSetup = lateralRow.ReverseSetup;
                DateTime? reinstate = null; if (!lateralRow.IsReinstateNull()) reinstate = lateralRow.Reinstate;
                string lateralComments = ""; if (!lateralRow.IsCommentsNull()) lateralComments = lateralRow.Comments;
                string clientInspectionNo = ""; if (!lateralRow.IsClientInspectionNoNull()) clientInspectionNo = lateralRow.ClientInspectionNo;
                DateTime? v1Inspection = null; if (!lateralRow.IsV1InspectionNull()) v1Inspection = lateralRow.V1Inspection;
                bool requiresRoboticPrep = lateralRow.RequiresRoboticPrep;
                DateTime? requiresRoboticPrepDate = null; if (!lateralRow.IsRequiresRoboticPrepDateNull()) requiresRoboticPrepDate = lateralRow.RequiresRoboticPrepDate;
                bool holdClientIssue = lateralRow.HoldClientIssue;
                bool holdLFSIssue = lateralRow.HoldLFSIssue;
                bool lineLateral = lateralRow.LineLateral;
                bool dyeTestReq = lateralRow.DyeTestReq;
                DateTime? dyeTestComplete = null; if (!lateralRow.IsDyeTestCompleteNull()) dyeTestComplete = lateralRow.DyeTestComplete;
                string contractYear = lateralRow.ContractYear;

                WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral();
                workFullLengthLiningM1Lateral.InsertDirect(newSectionWorkId, lateral, videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, lateralComments, false, companyId, clientInspectionNo, v1Inspection, requiresRoboticPrep, requiresRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, dyeTestReq, dyeTestComplete, contractYear);
            }

            // Load Previous work  - Comments and History
            SavePreviousComments(workId, workType, companyId, newSectionWorkId);
            SavePreviousHistory(workId, workType, companyId, newSectionWorkId);
        }
Ejemplo n.º 5
0
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        private void UpdateForReport(string unitType)
        {
            // Load comments
            foreach (FlM1ReportTDS.M1ReportByClientRow row in (FlM1ReportTDS.M1ReportByClientDataTable)Table)
            {
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(row.WorkID, row.COMPANY_ID);
                row.M1Comments = workGateway.GetComments(row.WorkID);
            }

            // Update for unit type
            FlM1LateralReportGateway flM1LateralReportGateway = new FlM1LateralReportGateway(Data);
            flM1LateralReportGateway.ClearBeforeFill = false;
            FlM1LateralReport flM1LateralReport = new FlM1LateralReport(Data);

            foreach (FlM1ReportTDS.M1ReportByClientRow row in (FlM1ReportTDS.M1ReportByClientDataTable)Table)
            {
                if (!row.IsM1CommentsNull())
                {
                    row.M1Comments = row.M1Comments.Replace("<br>", "\n");
                }

                Distance d;

                if (unitType == "Metric")
                {
                    if (!row.IsSize_Null())
                    {
                        if (Distance.IsValidDistance(row.Size_))
                        {
                            d = new Distance(row.Size_);
                            row.Size_ = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsLengthNull())
                    {
                        if (Distance.IsValidDistance(row.Length))
                        {
                            d = new Distance(row.Length);
                            row.Length = d.ToStringInMet2();
                        }
                    }

                    if (!row.IsUSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.USMHDepth))
                        {
                            d = new Distance(row.USMHDepth);
                            row.USMHDepth = d.ToStringInMet2();
                        }
                    }

                    if (!row.IsDSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.DSMHDepth))
                        {
                            d = new Distance(row.DSMHDepth);
                            row.DSMHDepth = d.ToStringInMet2();
                        }
                    }

                    if (!row.IsUSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth12))
                        {
                            d = new Distance(row.USMHMouth12);
                            row.USMHMouth12 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth1))
                        {
                            d = new Distance(row.USMHMouth1);
                            row.USMHMouth1 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth2))
                        {
                            d = new Distance(row.USMHMouth2);
                            row.USMHMouth2 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth3))
                        {
                            d = new Distance(row.USMHMouth3);
                            row.USMHMouth3 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth4))
                        {
                            d = new Distance(row.USMHMouth4);
                            row.USMHMouth4 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth5))
                        {
                            d = new Distance(row.USMHMouth5);
                            row.USMHMouth5 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth12))
                        {
                            d = new Distance(row.DSMHMouth12);
                            row.DSMHMouth12 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth1))
                        {
                            d = new Distance(row.DSMHMouth1);
                            row.DSMHMouth1 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth2))
                        {
                            d = new Distance(row.DSMHMouth2);
                            row.DSMHMouth2 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth3))
                        {
                            d = new Distance(row.DSMHMouth3);
                            row.DSMHMouth3 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth4))
                        {
                            d = new Distance(row.DSMHMouth4);
                            row.DSMHMouth4 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth5))
                        {
                            d = new Distance(row.DSMHMouth5);
                            row.DSMHMouth5 = d.ToStringInMil2();
                        }
                    }
                }

                if (unitType == "Imperial")
                {
                    if (!row.IsSize_Null())
                    {
                        if (Distance.IsValidDistance(row.Size_))
                        {
                            Distance distance = new Distance(row.Size_);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.Size_) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.Size_) * 0.03937;
                                            row.Size_ = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.Size_ = row.Size_ + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsLengthNull())
                    {
                        d = new Distance(row.Length);
                        row.Length = d.ToStringInEng1();
                    }

                    if (!row.IsUSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.USMHDepth))
                        {
                            Distance distance = new Distance(row.USMHDepth);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHDepth = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.Size_) > 99)
                                        {
                                            double newUSMHDepth = 0;
                                            newUSMHDepth = Convert.ToDouble(row.Size_) * 0.03937;
                                            row.USMHDepth = Convert.ToString(Math.Ceiling(newUSMHDepth)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHDepth = row.USMHDepth + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHDepth = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHDepth = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.DSMHDepth))
                        {
                            Distance distance = new Distance(row.DSMHDepth);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHDepth = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.Size_) > 99)
                                        {
                                            double newDSMHDepth = 0;
                                            newDSMHDepth = Convert.ToDouble(row.Size_) * 0.03937;
                                            row.DSMHDepth = Convert.ToString(Math.Ceiling(newDSMHDepth)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHDepth = row.USMHDepth + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHDepth = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHDepth = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth12))
                        {
                            Distance distance = new Distance(row.USMHMouth12);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth12) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth12) * 0.03937;
                                            row.USMHMouth12 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth12 = row.USMHMouth12 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth12 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth1))
                        {
                            Distance distance = new Distance(row.USMHMouth1);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth1) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth1) * 0.03937;
                                            row.USMHMouth1 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth1 = row.USMHMouth1 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth1 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth2))
                        {
                            Distance distance = new Distance(row.USMHMouth2);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth2) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth2) * 0.03937;
                                            row.USMHMouth2 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth2 = row.USMHMouth2 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth2 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth3))
                        {
                            Distance distance = new Distance(row.USMHMouth3);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth3) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth3) * 0.03937;
                                            row.USMHMouth3 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth3 = row.USMHMouth3 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth3 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth4))
                        {
                            Distance distance = new Distance(row.USMHMouth4);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth4) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth4) * 0.03937;
                                            row.USMHMouth4 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth4 = row.USMHMouth4 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth4 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth5))
                        {
                            Distance distance = new Distance(row.USMHMouth5);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth5) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth5) * 0.03937;
                                            row.USMHMouth5 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth5 = row.USMHMouth5 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth5 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth12))
                        {
                            Distance distance = new Distance(row.DSMHMouth12);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth12) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth12) * 0.03937;
                                            row.DSMHMouth12 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth12 = row.DSMHMouth12 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth12 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth1))
                        {
                            Distance distance = new Distance(row.DSMHMouth1);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth1) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth1) * 0.03937;
                                            row.DSMHMouth1 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth1 = row.DSMHMouth1 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth1 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth2))
                        {
                            Distance distance = new Distance(row.DSMHMouth2);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth2) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth2) * 0.03937;
                                            row.DSMHMouth2 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth2 = row.DSMHMouth2 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth2 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth3))
                        {
                            Distance distance = new Distance(row.DSMHMouth3);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth3) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth3) * 0.03937;
                                            row.DSMHMouth3 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth3 = row.DSMHMouth3 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth3 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth4))
                        {
                            Distance distance = new Distance(row.DSMHMouth4);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth4) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth4) * 0.03937;
                                            row.DSMHMouth4 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth4 = row.DSMHMouth4 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth4 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth5))
                        {
                            Distance distance = new Distance(row.DSMHMouth5);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth5) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth5) * 0.03937;
                                            row.DSMHMouth5 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth5 = row.DSMHMouth5 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth5 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }
                }

                flM1LateralReportGateway.LoadByAssetId(row.AssetID, row.COMPANY_ID);
                flM1LateralReport.UpdateForReport(row.FlowOrderID, unitType);
            }
        }
Ejemplo n.º 6
0
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        public void UpdateForReport(string unitType)
        {
            // Load comments
            foreach (FlM1ReportTDS.M2_SECTIONRow row in (FlM1ReportTDS.M2_SECTIONDataTable)Table)
            {
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(row.WorkID, row.COMPANY_ID);

                row.Comments = workGateway.GetComments(row.WorkID);

                Distance d;

                if (unitType == "Metric")
                {
                    if (!row.IsSize_Null())
                    {
                        d = new Distance(row.Size_);
                        row.Size_ = d.ToStringInMet2();
                    }

                    if (!row.IsVideoLengthNull())
                    {
                        d = new Distance(row.VideoLength);
                        row.VideoLength = d.ToStringInMet2();
                    }

                    if (!row.IsSurfaceGradeNull())
                    {
                        if (row.SurfaceGrade == "0-3 ft")
                        {
                            row.SurfaceGrade = "0-0.91 m";
                        }

                        if (row.SurfaceGrade == "3-6 ft")
                        {
                            row.SurfaceGrade = "0.91-1.83 m";
                        }

                        if (row.SurfaceGrade == "6 ft +")
                        {
                            row.SurfaceGrade = "1.83 m +";
                        }
                    }
                }

                if (unitType == "Imperial")
                {
                    if (!row.IsSize_Null())
                    {
                        if (Distance.IsValidDistance(row.Size_))
                        {
                            Distance distance = new Distance(row.Size_);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    if (Convert.ToDouble(row.Size_) > 99)
                                    {
                                        double newSize_ = 0;
                                        newSize_ = Convert.ToDouble(row.Size_) * 0.03937;
                                        row.Size_ = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                    }
                                    else
                                    {
                                        row.Size_ = row.Size_ + "\"";
                                    }
                                    break;
                                case 4:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsVideoLengthNull())
                    {
                        d = new Distance(row.VideoLength);
                        row.VideoLength = d.ToStringInEng1();
                    }
                }
            }

            // Update for unit type
            //foreach (FlM1ReportTDS.M2_SECTIONRow row in (FlM1ReportTDS.M2_SECTIONDataTable)Table)
            //{
                //Distance d;

                //if (unitType == "Metric")
                //{
                //    if (!row.IsSize_Null())
                //    {
                //        d = new Distance(row.Size_);
                //        row.Size_ = d.ToStringInMet2();
                //    }

                //    if (!row.IsVideoLengthNull())
                //    {
                //        d = new Distance(row.VideoLength);
                //        row.VideoLength = d.ToStringInMet2();
                //    }

                //    if (!row.IsSurfaceGradeNull())
                //    {
                //        if (row.SurfaceGrade == "0-3 ft")
                //        {
                //            row.SurfaceGrade = "0-0.91 m";
                //        }

                //        if (row.SurfaceGrade == "3-6 ft")
                //        {
                //            row.SurfaceGrade = "0.91-1.83 m";
                //        }

                //        if (row.SurfaceGrade == "6 ft +")
                //        {
                //            row.SurfaceGrade = "1.83 m +";
                //        }
                //    }
                //}

                //if (unitType == "Imperial")
                //{
                //    if (!row.IsSize_Null())
                //    {
                //        if (Distance.IsValidDistance(row.Size_))
                //        {
                //            Distance distance = new Distance(row.Size_);

                //            switch (distance.DistanceType)
                //            {
                //                case 2:
                //                    row.Size_ = distance.ToStringInEng1();
                //                    break;
                //                case 3:
                //                    if (Convert.ToDouble(row.Size_) > 99)
                //                    {
                //                        double newSize_ = 0;
                //                        newSize_ = Convert.ToDouble(row.Size_) * 0.03937;
                //                        row.Size_ = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                //                    }
                //                    else
                //                    {
                //                        row.Size_ = row.Size_ + "\"";
                //                    }
                //                    break;
                //                case 4:
                //                    row.Size_ = distance.ToStringInEng1();
                //                    break;
                //                case 5:
                //                    row.Size_ = distance.ToStringInEng1();
                //                    break;
                //            }
                //        }
                //    }

                //    if (!row.IsVideoLengthNull())
                //    {
                //        d = new Distance(row.VideoLength);
                //        row.VideoLength = d.ToStringInEng1();
                //    }
                //}
            //}
        }
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        private void UpdateForReport(string unitType)
        {
            // Load comments
            foreach (FlM1LateralReportTDS.M1ReportByClientRow row in (FlM1LateralReportTDS.M1ReportByClientDataTable)Table)
            {
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(row.WorkID, row.COMPANY_ID);
                row.M1Comments = workGateway.GetComments(row.WorkID);
            }

            // Update for unit type
            FlM1LateralLateralReportGateway flM1LateralReportGateway = new FlM1LateralLateralReportGateway(Data);
            flM1LateralReportGateway.ClearBeforeFill = false;
            FlM1LateralLateralReport flM1LateralReport = new FlM1LateralLateralReport(Data);

            foreach (FlM1LateralReportTDS.M1ReportByClientRow row in (FlM1LateralReportTDS.M1ReportByClientDataTable)Table)
            {
                flM1LateralReportGateway.LoadByAssetId(row.AssetID, row.COMPANY_ID);
                flM1LateralReport.UpdateForReport(row.FlowOrderID, unitType);
            }
        }