/// <summary>
        /// DeleteDirect
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="companyId">companyId</param>
        public void DeleteDirect(int workId, int companyId)
        {
            // Delete WorkFullLengthLiningLateral
            WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null);
            workFullLengthLiningM1Lateral.Delete(workId, companyId);

            // Delete m2 data
            WorkFullLengthLiningM2Gateway workFullLengthLiningM2Gateway = new WorkFullLengthLiningM2Gateway(null);
            workFullLengthLiningM2Gateway.Delete(workId, companyId);
        }
        /// <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);
        }
 /// <summary>
 /// Insert a lateral work
 /// </summary>
 /// <param name="workId">workId</param>
 /// <param name="lateral">lateral</param>
 /// <param name="videoDistance">videoDistance</param>
 /// <param name="clockPosition">clockPosition</param>
 /// <param name="distanceToCentre">distanceToCentre</param>
 /// <param name="timeOpened">timeOpened</param>
 /// <param name="reverseSetup">reverseSetup</param>
 /// <param name="reinstate">reinstate</param>
 /// <param name="comments">comments</param>
 /// <param name="deleted">deleted</param>
 /// <param name="companyId">companyId</param>
 /// <param name="clientInspectionNo">clientInspectionNo</param>
 /// <param name="v1Inspection">v1Inspection</param>
 /// <param name="requiresRoboticPrep">requiresRoboticPrep</param>
 /// <param name="requiresRoboticPrepDate">requiresRoboticPrepDate</param>
 /// <param name="holdClientIssue">holdClientIssue</param>
 /// <param name="holdLFSIssue">holdLFSIssue</param>
 /// <param name="lineLateral">lineLateral</param>
 /// <param name="dyeTestReq">dyeTestReq</param>
 /// <param name="dyeTestComplete">dyeTestComplete</param>
 /// <param name="contractYear">contractYear</param>
 private void InsertFLLLateral(int workId, int lateral, string videoDistance, string clockPosition, string distanceToCentre, string timeOpened, string reverseSetup, DateTime? reinstate, string comments, bool deleted, int companyId, string clientInspectionNo, DateTime? v1Inspection, bool requiresRoboticPrep, DateTime? requiresRoboticPrepDate, bool holdClientIssue, bool holdLFSIssue, bool lineLateral, bool dyeTestReq, DateTime? dyeTestComplete, string contractYear)
 {
     WorkFullLengthLiningM1LateralGateway workFullLengthLiningM2LateralGateway = new WorkFullLengthLiningM1LateralGateway();
     WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(workFullLengthLiningM2LateralGateway.Data);
     workFullLengthLiningM1Lateral.InsertDirect(workId, lateral, videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, comments, false, companyId, clientInspectionNo, v1Inspection, requiresRoboticPrep, requiresRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, dyeTestReq, dyeTestComplete, contractYear);
 }
        /// <summary>
        /// Delete lateral work
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="lateral">lateral</param>
        /// <param name="companyId">companyId</param>
        /// <param name="projectId">projectId</param>
        private void DeleteFLLLateral(int workId, int lateral, int companyId, int projectId)
        {
            // Delete work lateral
            WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null);
            workFullLengthLiningM1Lateral.DeleteDirect(workId, lateral, companyId);

            // Delete section
            LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null);
            bool isDeleted = lfsAssetSewerLateral.DeleteDirect(lateral, companyId);

            if (isDeleted)
            {
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(projectId);
                int clientId = projectGateway.GetClientID(projectId);

                LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                lfsAssetSewerLateralClient.DeleteDirect(lateral, clientId, companyId);
            }
        }
        /// <summary>
        /// SaveFll
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="assetIdLateral">assetIdLateral</param>
        /// <param name="companyId">companyId</param>
        /// <param name="opened">opened</param>
        /// <param name="brushed">brushed</param>
        public void SaveFll(int workId, int assetIdLateral, int companyId, DateTime? opened, DateTime? brushed)
        {
            // ... ... Modifications at M1
            WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway();
            workFullLengthLiningM1LateralGateway.LoadByWorkIdLateral(workId, assetIdLateral, companyId);

            if (workFullLengthLiningM1LateralGateway.Table.Rows.Count > 0)
            {
                // ... .... ... Load original data
                string originalVideoDistance = workFullLengthLiningM1LateralGateway.GetVideoDistance(workId, assetIdLateral);
                string originalClockPosition = workFullLengthLiningM1LateralGateway.GetClockPosition(workId, assetIdLateral);
                string originalDistanceToCentre = workFullLengthLiningM1LateralGateway.GetDistanceToCentre(workId, assetIdLateral);
                string originalTimeOpened = workFullLengthLiningM1LateralGateway.GetTimeOpened(workId, assetIdLateral);
                string originalReverseSetup = workFullLengthLiningM1LateralGateway.GetReverseSetup(workId, assetIdLateral);
                DateTime? originalReinstate = workFullLengthLiningM1LateralGateway.GetReinstate(workId, assetIdLateral);
                string originalComments = workFullLengthLiningM1LateralGateway.GetComments(workId, assetIdLateral);
                bool originalDeleted = workFullLengthLiningM1LateralGateway.GetDeleted(workId, assetIdLateral);
                int originalCompanyId = workFullLengthLiningM1LateralGateway.GetCompanyId(workId, assetIdLateral);
                string originalClientInspectionNo = workFullLengthLiningM1LateralGateway.GetClientInspectionNo(workId, assetIdLateral);
                DateTime? originalV1Inspection = workFullLengthLiningM1LateralGateway.GetV1Inspection(workId, assetIdLateral);
                bool originalRequiresRoboticPrep = workFullLengthLiningM1LateralGateway.GetRequiresRoboticPrep(workId, assetIdLateral);
                DateTime? originalRequiresRoboticPrepDate = workFullLengthLiningM1LateralGateway.GetRequiresRoboticPrepDate(workId, assetIdLateral);
                bool originalHoldClientIssue = workFullLengthLiningM1LateralGateway.GetHoldClientIssue(workId, assetIdLateral);
                bool originalHoldLFSIssue = workFullLengthLiningM1LateralGateway.GetHoldLFSIssue(workId, assetIdLateral);
                bool originalLinelateral = workFullLengthLiningM1LateralGateway.GetLineLateral(workId, assetIdLateral);
                bool originalDyeTestReq = workFullLengthLiningM1LateralGateway.GetDyeTestReq(workId, assetIdLateral);
                DateTime? originalDyeTestComplete = null; if (workFullLengthLiningM1LateralGateway.GetDyeTestComplete(workId, assetIdLateral).HasValue) originalDyeTestComplete = workFullLengthLiningM1LateralGateway.GetDyeTestComplete(workId, assetIdLateral);
                string originalContractYear = workFullLengthLiningM1LateralGateway.GetContractYear(workId, assetIdLateral);

                // New data
                string newTimeOpened = ""; if (opened.HasValue) newTimeOpened = opened.Value.ToString();
                DateTime? newReinstate = null; if (brushed.HasValue) newReinstate = brushed;

                // Update work
                WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null);
                workFullLengthLiningM1Lateral.UpdateDirect(workId, assetIdLateral, originalVideoDistance, originalClockPosition, originalDistanceToCentre, originalTimeOpened, originalReverseSetup, originalReinstate, originalComments, originalDeleted, originalCompanyId, originalClientInspectionNo, originalV1Inspection, originalRequiresRoboticPrep, originalRequiresRoboticPrepDate, originalHoldClientIssue, originalHoldLFSIssue, originalLinelateral, originalDyeTestReq, originalDyeTestComplete, originalContractYear, workId, assetIdLateral, originalVideoDistance, originalClockPosition, originalDistanceToCentre, newTimeOpened, originalReverseSetup, newReinstate, originalComments, originalDeleted, originalCompanyId, originalClientInspectionNo, originalV1Inspection, originalRequiresRoboticPrep, originalRequiresRoboticPrepDate, originalHoldClientIssue, originalHoldLFSIssue, originalLinelateral, originalDyeTestReq, originalDyeTestComplete, originalContractYear);
            }
        }
 /// <summary>
 /// Update lateral work
 /// </summary>
 /// <param name="originalWorkId">originalWorkId</param>
 /// <param name="originalLateral">originalLateral</param>
 /// <param name="originalVideoDistance">originalVideoDistance</param>
 /// <param name="originalClockPosition">originalClockPosition</param>
 /// <param name="originalDistanceToCentre">originalDistanceToCentre</param>
 /// <param name="originalTimeOpened">originalTimeOpened</param>
 /// <param name="originalReverseSetup">originalReverseSetup</param>
 /// <param name="originalReinstate">originalReinstate</param>
 /// <param name="originalComments">originalComments</param>
 /// <param name="originalDeleted">originalDeleted</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// <param name="originalClientInspectionNo">originalClientInspectionNo</param>
 /// <param name="originalV1Inspection">originalV1Inspection</param>
 /// <param name="originalRequiresRoboticPrep">originalRequiresRoboticPrep</param>
 /// <param name="originalRequiresRoboticPrepDate">originalRequiresRoboticPrepDate</param>
 /// <param name="originalHoldClientIssue">originalHoldClientIssue</param>
 /// <param name="originalHoldLFSIssue">originalHoldLFSIssue</param>
 /// <param name="originalLineLateral">originalLineLateral</param>
 /// <param name="originalDyeTestReq">originalDyeTestReq</param>
 /// <param name="originalDyeTestComplete">originalDyeTestComplete</param>
 /// <param name="originalContractYear">originalContractYear</param>
 /// 
 /// <param name="newWorkId">newWorkId</param>
 /// <param name="newLateral">newLateral</param>
 /// <param name="newVideoDistance">newVideoDistance</param>
 /// <param name="newClockPosition">newClockPosition</param>
 /// <param name="newDistanceToCentre">newDistanceToCentre</param>
 /// <param name="newTimeOpened">newTimeOpened</param>
 /// <param name="newReverseSetup">newReverseSetup</param>
 /// <param name="newReinstate">newReinstate</param>
 /// <param name="newComments">newComments</param>
 /// <param name="newDeleted">newDeleted</param>
 /// <param name="newCompanyId">newCompanyId</param>
 /// <param name="newClientInspectionNo">newClientInspectionNo</param>
 /// <param name="newV1Inspection">newV1Inspection</param>
 /// <param name="newRequiresRoboticPrep">newRequiresRoboticPrep</param>
 /// <param name="newRequiresRoboticPrepDate">newRequiresRoboticPrepDate</param>
 /// <param name="newHoldClientIssue">newHoldClientIssue</param>
 /// <param name="newHoldLFSIssue">newHoldLFSIssue</param>
 /// <param name="newLineLateral">newLineLateral</param>
 /// <param name="newDyeTestReq">newDyeTestReq</param>
 /// <param name="newDyeTestComplete">newDyeTestComplete</param>
 /// <param name="newContractYear">newContractYear</param>
 private void UpdateFLLLateral(int originalWorkId, int originalLateral, string originalVideoDistance, string originalClockPosition, string originalDistanceToCentre, string originalTimeOpened, string originalReverseSetup, DateTime? originalReinstate, string originalComments, bool originalDeleted, int originalCompanyId, string originalClientInspectionNo, DateTime? originalV1Inspection, bool originalRequiresRoboticPrep, DateTime? originalRequiresRoboticPrepDate, bool originalHoldClientIssue, bool originalHoldLFSIssue, bool originalLineLateral, bool originalDyeTestReq, DateTime? originalDyeTestComplete, string originalContractYear,  int newWorkId, int newLateral, string newVideoDistance, string newClockPosition, string newDistanceToCentre, string newTimeOpened, string newReverseSetup, DateTime? newReinstate, string newComments, bool newDeleted, int newCompanyId, string newClientInspectionNo, DateTime? newV1Inspection, bool newRequiresRoboticPrep, DateTime? newRequiresRoboticPrepDate, bool newHoldClientIssue, bool newHoldLFSIssue, bool newLineLateral, bool newDyeTestReq, DateTime? newDyeTestComplete, string newContractYear)
 {
     // Update m1 lateral
     WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null);
     workFullLengthLiningM1Lateral.UpdateDirect(originalWorkId, originalLateral, originalVideoDistance, originalClockPosition, originalDistanceToCentre, originalTimeOpened, originalReverseSetup, originalReinstate, originalComments, originalDeleted, originalCompanyId, originalClientInspectionNo, originalV1Inspection, originalRequiresRoboticPrep, originalRequiresRoboticPrepDate, originalHoldClientIssue, originalHoldLFSIssue, originalLineLateral, originalDyeTestReq, originalDyeTestComplete, originalContractYear, newWorkId, newLateral, newVideoDistance, newClockPosition, newDistanceToCentre, newTimeOpened, newReverseSetup, newReinstate, newComments, newDeleted, newCompanyId, newClientInspectionNo, newV1Inspection, newRequiresRoboticPrep, newRequiresRoboticPrepDate, newHoldClientIssue, newHoldLFSIssue, newLineLateral, newDyeTestReq, newDyeTestComplete, newContractYear);
 }
Esempio n. 7
0
        /// <summary>
        /// UpdateFLLaterals
        /// </summary>
        /// <param name="currentProjectId">currentProjectId</param>
        /// <param name="lateral_assetId">lateral_assetId</param>
        /// <param name="companyId">companyId</param>
        /// <param name="v1Inspection">v1Inspection</param>
        /// <param name="clientInspectionNo">clientInspectionNo</param>
        /// <param name="section_">section_</param>
        /// <param name="requiresRoboticPrep">requiresRoboticPrep</param>
        /// <param name="requiresRoboticPrepCompleted">requiresRoboticPrepCompleted</param>
        /// <param name="holdClientIssue">holdClientIssue</param>
        /// <param name="holdLFSIssue">holdLFSIssue</param>
        /// <param name="dyeTestReq">dyeTestReq</param>
        /// <param name="dyeTestComplete">dyeTestComplete</param>
        private void UpdateFLLaterals(int currentProjectId, int lateral_assetId, int companyId, DateTime? v1Inspection, string clientInspectionNo, int section_, bool requiresRoboticPrep, DateTime? requiresRoboticPrepCompleted, bool holdClientIssue, bool holdLFSIssue, bool dyeTestReq, DateTime? dyeTestComplete, string contractYear)
        {
            // Load work id
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByProjectIdAssetIdWorkType(currentProjectId, section_, "Full Length Lining", companyId);
            if (workGateway.Table.Rows.Count > 0)
            {
                // ... ... Get WorkId for Full Length Lining
                int workIdFll = workGateway.GetWorkId(section_, "Full Length Lining", currentProjectId);

                // ... ... Modifications at M1
                WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway();
                workFullLengthLiningM1LateralGateway.LoadByWorkIdLateral(workIdFll, lateral_assetId, companyId);
                if (workFullLengthLiningM1LateralGateway.Table.Rows.Count > 0)
                {
                    // ... .... ... Load original data
                    string originalVideoDistance = workFullLengthLiningM1LateralGateway.GetVideoDistance(workIdFll, lateral_assetId);
                    string originalClockPosition = workFullLengthLiningM1LateralGateway.GetClockPosition(workIdFll, lateral_assetId);
                    string originalDistanceToCentre = workFullLengthLiningM1LateralGateway.GetDistanceToCentre(workIdFll, lateral_assetId);
                    string originalTimeOpened = workFullLengthLiningM1LateralGateway.GetTimeOpened(workIdFll, lateral_assetId);
                    string originalReverseSetup = workFullLengthLiningM1LateralGateway.GetReverseSetup(workIdFll, lateral_assetId);
                    DateTime? originalReinstate = workFullLengthLiningM1LateralGateway.GetReinstate(workIdFll, lateral_assetId);
                    string originalComments = workFullLengthLiningM1LateralGateway.GetComments(workIdFll, lateral_assetId);
                    bool originalDeleted = workFullLengthLiningM1LateralGateway.GetDeleted(workIdFll, lateral_assetId);
                    int originalCompanyId = workFullLengthLiningM1LateralGateway.GetCompanyId(workIdFll, lateral_assetId);
                    string originalClientInspectionNo = workFullLengthLiningM1LateralGateway.GetClientInspectionNo(workIdFll, lateral_assetId);
                    DateTime? originalV1Inspection = workFullLengthLiningM1LateralGateway.GetV1Inspection(workIdFll, lateral_assetId);
                    bool originalRequiresRoboticPrep = workFullLengthLiningM1LateralGateway.GetRequiresRoboticPrep(workIdFll, lateral_assetId);
                    DateTime? originalRequiresRoboticPrepDate = workFullLengthLiningM1LateralGateway.GetRequiresRoboticPrepDate(workIdFll, lateral_assetId);
                    bool originalHoldClientIssue = workFullLengthLiningM1LateralGateway.GetHoldClientIssue(workIdFll, lateral_assetId);
                    bool originalHoldLFSIssue = workFullLengthLiningM1LateralGateway.GetHoldLFSIssue(workIdFll, lateral_assetId);
                    bool originalLinelateral = workFullLengthLiningM1LateralGateway.GetLineLateral(workIdFll, lateral_assetId);
                    bool originalDyeTestReq = workFullLengthLiningM1LateralGateway.GetDyeTestReq(workIdFll, lateral_assetId);
                    DateTime? originalDyeTestComplete = null; if (workFullLengthLiningM1LateralGateway.GetDyeTestComplete(workIdFll, lateral_assetId).HasValue) originalDyeTestComplete = workFullLengthLiningM1LateralGateway.GetDyeTestComplete(workIdFll, lateral_assetId);
                    string originalContractYear = workFullLengthLiningM1LateralGateway.GetContractYear(workIdFll, lateral_assetId);

                    // New data
                    DateTime? newV1Inspection = v1Inspection;
                    string newClientInspectionNo = clientInspectionNo;
                    bool newRequiresRoboticPrep = requiresRoboticPrep;
                    bool newHoldClientIssue = holdClientIssue;
                    bool newHoldLFSIssue = holdLFSIssue;
                    DateTime? newRequiresRoboticPrepCompleted = null; if (requiresRoboticPrepCompleted.HasValue) newRequiresRoboticPrepCompleted = requiresRoboticPrepCompleted;
                    bool newDyeTestReq = dyeTestReq;
                    DateTime? newDyeTestComplete = null; if (dyeTestComplete.HasValue) newDyeTestComplete = dyeTestComplete;
                    string newContractYear = contractYear;

                    // Update work
                    WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null);
                    workFullLengthLiningM1Lateral.UpdateDirect(workIdFll, lateral_assetId, originalVideoDistance, originalClockPosition, originalDistanceToCentre, originalTimeOpened, originalReverseSetup, originalReinstate, originalComments, originalDeleted, originalCompanyId, originalClientInspectionNo, originalV1Inspection, originalRequiresRoboticPrep, originalRequiresRoboticPrepDate, originalHoldClientIssue, originalHoldLFSIssue, originalLinelateral, originalDyeTestReq, originalDyeTestComplete, originalContractYear, workIdFll, lateral_assetId, originalVideoDistance, originalClockPosition, originalDistanceToCentre, originalTimeOpened, originalReverseSetup, originalReinstate, originalComments, originalDeleted, originalCompanyId, newClientInspectionNo, newV1Inspection, newRequiresRoboticPrep, newRequiresRoboticPrepCompleted, newHoldClientIssue, newHoldLFSIssue, originalLinelateral, newDyeTestReq, newDyeTestComplete, newContractYear);
                }
            }
        }
        /// <summary>
        /// Delete lateral work
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="lateral">lateral</param>
        /// <param name="companyId">companyId</param>
        /// <param name="clientId">clientId</param>
        private void DeleteFLLLateral(int workId, int lateral, int companyId, int clientId)
        {
            // Delete work lateral
            WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null);
            workFullLengthLiningM1Lateral.DeleteDirect(workId, lateral, companyId);

            // Delete section
            LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null);
            bool isDeleted = lfsAssetSewerLateral.DeleteDirect(lateral, companyId);

            if (isDeleted)
            {
                LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                lfsAssetSewerLateralClient.DeleteDirect(lateral, clientId, companyId);
            }
        }