/// <summary>
        /// UpdateDirect
        /// </summary>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="projectId">projectId</param>
        /// <param name="sectionAssetId">sectionAssetId</param>
        /// <param name="companyId">companyId</param>
        public void Save(Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int projectId, int sectionAssetId, int companyId)
        {
            PointRepairsTDS pointRepairsChanges = (PointRepairsTDS)Data.GetChanges();

            if (pointRepairsChanges.WorkDetails.Rows.Count > 0)
            {
                PointRepairsWorkDetailsGateway pointRepairsWorkDetailsGateway = new PointRepairsWorkDetailsGateway(pointRepairsChanges);

                // Update sections
                foreach (PointRepairsTDS.WorkDetailsRow workDetailsRow in (PointRepairsTDS.WorkDetailsDataTable)pointRepairsChanges.WorkDetails)
                {
                    // Unchanged values
                    int workId = workDetailsRow.WorkID;

                    // Original values
                    string originalClientId = pointRepairsWorkDetailsGateway.GetClientIdOriginal(workId);
                    string originalMeasurementTakenBy = pointRepairsWorkDetailsGateway.GetMeasurementTakenByOriginal(workId);
                    DateTime? originalRepairConfirmationDate = pointRepairsWorkDetailsGateway.GetRepairConfirmationDateOriginal(workId);
                    bool originalBypassRequired = pointRepairsWorkDetailsGateway.GetBypassRequiredOriginal(workId);
                    string originalRoboticDistances = pointRepairsWorkDetailsGateway.GetRoboticDistancesOriginal(workId);
                    DateTime? originalProposedLiningDate = pointRepairsWorkDetailsGateway.GetProposedLiningDateOriginal(workId);
                    DateTime? originalDeadlineLiningDate = pointRepairsWorkDetailsGateway.GetDeadlineLiningDateOriginal(workId);
                    DateTime? originalFinalVideoDate = pointRepairsWorkDetailsGateway.GetFinalVideoDateOriginal(workId);
                    int? originalEstimatedJoints = pointRepairsWorkDetailsGateway.GetEstimatedJointsOriginal(workId);
                    int? originalJointsTestSealed = pointRepairsWorkDetailsGateway.GetJointsTestSealedOriginal(workId);
                    bool originalIssueIdentified = pointRepairsWorkDetailsGateway.GetIssueIdentifiedOriginal(workId);
                    bool originalIssueLFS = pointRepairsWorkDetailsGateway.GetIssueLFSOriginal(workId);
                    bool originalIssueClient = pointRepairsWorkDetailsGateway.GetIssueClientOriginal(workId);
                    bool originalIssueSales = pointRepairsWorkDetailsGateway.GetIssueSalesOriginal(workId);
                    bool originalIssueGivenToClient = pointRepairsWorkDetailsGateway.GetIssueGivenToClientOriginal(workId);
                    bool originalIssueResolved = pointRepairsWorkDetailsGateway.GetIssueResolvedOriginal(workId);
                    bool originalIssueInvestigation = pointRepairsWorkDetailsGateway.GetIssueInvestigationOriginal(workId);

                    // New variables
                    string newClientId = pointRepairsWorkDetailsGateway.GetClientId(workId);
                    string newMeasurementTakenBy = pointRepairsWorkDetailsGateway.GetMeasurementTakenBy(workId);
                    DateTime? newRepairConfirmationDate = pointRepairsWorkDetailsGateway.GetRepairConfirmationDate(workId);
                    bool newBypassRequired = pointRepairsWorkDetailsGateway.GetBypassRequired(workId);
                    string newRoboticDistances = pointRepairsWorkDetailsGateway.GetRoboticDistances(workId);
                    DateTime? newProposedLiningDate = pointRepairsWorkDetailsGateway.GetProposedLiningDate(workId);
                    DateTime? newDeadlineLiningDate = pointRepairsWorkDetailsGateway.GetDeadlineLiningDate(workId);
                    DateTime? newFinalVideoDate = pointRepairsWorkDetailsGateway.GetFinalVideoDate(workId);
                    int? newEstimatedJoints = pointRepairsWorkDetailsGateway.GetEstimatedJoints(workId);
                    int? newJointsTestSealed = pointRepairsWorkDetailsGateway.GetJointsTestSealed(workId);
                    bool newIssueIdentified = pointRepairsWorkDetailsGateway.GetIssueIdentified(workId);
                    bool newIssueLFS = pointRepairsWorkDetailsGateway.GetIssueLFS(workId);
                    bool newIssueClient = pointRepairsWorkDetailsGateway.GetIssueClient(workId);
                    bool newIssueSales = pointRepairsWorkDetailsGateway.GetIssueSales(workId);
                    bool newIssueGivenToClient = pointRepairsWorkDetailsGateway.GetIssueGivenToClient(workId);
                    bool newIssueResolved = pointRepairsWorkDetailsGateway.GetIssueResolved(workId);
                    bool newIssueInvestigation = pointRepairsWorkDetailsGateway.GetIssueInvestigation(workId);

                    // ... RA
                    DateTime? originalPreFlushDate = pointRepairsWorkDetailsGateway.GetPreFlushDateOriginal(workId);
                    DateTime? originalPreVideoDate = pointRepairsWorkDetailsGateway.GetPreVideoDateOriginal(workId);

                    // ... FLL P1
                    DateTime? originalP1Date = pointRepairsWorkDetailsGateway.GetP1DateOriginal(workId);
                    int? originalCxisRemoved = pointRepairsWorkDetailsGateway.GetCxisRemovedOriginal(workId);

                    // ... FLL M1
                    string originalTrafficControl = pointRepairsWorkDetailsGateway.GetTrafficControlOriginal(workId);
                    string originalMaterial = pointRepairsWorkDetailsGateway.GetMaterialOriginal(workId);

                    // ... FLL M2
                    string originalVideoLength = pointRepairsWorkDetailsGateway.GetVideoLengthOriginal(workId);

                    // ... P1
                    DateTime? newP1Date = pointRepairsWorkDetailsGateway.GetP1Date(workId);
                    int? newCxisRemoved = pointRepairsWorkDetailsGateway.GetCxisRemoved(workId);
                    string newTrafficControl = pointRepairsWorkDetailsGateway.GetTrafficControl(workId);
                    string newMaterial = pointRepairsWorkDetailsGateway.GetMaterial(workId);

                    // ... M2
                    string newVideoLength = pointRepairsWorkDetailsGateway.GetVideoLength(workId);

                    // ... RA
                    DateTime? newPreFlushDate = pointRepairsWorkDetailsGateway.GetPreFlushDate(workId);
                    DateTime? newPreVideoDate = pointRepairsWorkDetailsGateway.GetPreVideoDate(workId);

                    // ... FLL WorkID
                    int workIdFll = 0; if (!workDetailsRow.IsWorkIDFLLNull()) workIdFll = workDetailsRow.WorkIDFLL;
                    int workIdRa = 0; if (!workDetailsRow.IsWorkIDRANull()) workIdRa = workDetailsRow.WorkIDRA;

                    if (workIdFll != 0) // ... Has Fll work
                    {
                        FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                        fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workIdFll, sectionAssetId, companyId);

                        // Original values
                        string originalClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientIdOriginal(workIdFll);
                        DateTime? originalProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDateOriginal(workIdFll);
                        DateTime? originalDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDateOriginal(workIdFll);
                        DateTime? originalM1Date = fullLengthLiningWorkDetailsGateway.GetM1DateOriginal(workIdFll);
                        DateTime? originalM2Date = fullLengthLiningWorkDetailsGateway.GetM2DateOriginal(workIdFll);
                        DateTime? originalInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDateOriginal(workIdFll);
                        DateTime? originalFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDateOriginal(workIdFll);
                        bool originalIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentifiedOriginal(workIdFll);
                        bool originalIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFSOriginal(workIdFll);
                        bool originalIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClientOriginal(workIdFll);
                        bool originalIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSalesOriginal(workIdFll);
                        bool originalIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClientOriginal(workIdFll);
                        bool originalIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolvedOriginal(workIdFll);
                        bool originalIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigationOriginal(workIdFll);
                        bool originalRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedOriginal(workIdFll);
                        DateTime? originalRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDateOriginal(workIdFll);
                        bool originalP1Completed = fullLengthLiningWorkDetailsGateway.GetP1CompletedOriginal(workIdFll);

                        // M1 data
                        string originalMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByOriginal(workIdFll);
                        string originalSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetailsOriginal(workIdFll);
                        bool originalPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChangeOriginal(workIdFll);
                        bool originalStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypassOriginal(workIdFll);
                        string originalStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassCommentsOriginal(workIdFll);
                        string originalTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetailsOriginal(workIdFll);
                        string originalMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementTypeOriginal(workIdFll);
                        string originalMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMhOriginal(workIdFll);
                        string originalVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMhOriginal(workIdFll);
                        string originalVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMhOriginal(workIdFll);
                        string originalAccessType = fullLengthLiningWorkDetailsGateway.GetAccessTypeOriginal(workIdFll);

                        // M2 data
                        string originalMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2Original(workIdFll);
                        bool originalDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipeOriginal(workIdFll);
                        string originalDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepthOriginal(workIdFll);
                        int? originalCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLateralsOriginal(workIdFll);
                        string originalLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithIdOriginal(workIdFll);
                        string originalHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddressOriginal(workIdFll);
                        string originalHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMHOriginal(workIdFll);
                        string originalDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMhOriginal(workIdFll);
                        string originalSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGradeOriginal(workIdFll);
                        bool originalHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulleyOriginal(workIdFll);
                        bool originalFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCartOriginal(workIdFll);
                        bool originalTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPumpOriginal(workIdFll);
                        bool originalSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypassOriginal(workIdFll);
                        bool originalScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffoldingOriginal(workIdFll);
                        bool originalWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtensionOriginal(workIdFll);
                        bool originalExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGeneratorOriginal(workIdFll);
                        bool originalGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtensionOriginal(workIdFll);
                        bool originalEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMatsOriginal(workIdFll);
                        bool originalRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequiredOriginal(workIdFll);
                        bool originalCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkidOriginal(workIdFll);

                        // Comments
                        string originalComments = fullLengthLiningWorkDetailsGateway.GetCommentsOriginal(workIdFll);

                        // New variables
                        string newClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientId(workIdFll);
                        DateTime? newProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workIdFll);
                        DateTime? newDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workIdFll);
                        DateTime? newM1Date = fullLengthLiningWorkDetailsGateway.GetM1Date(workIdFll);
                        DateTime? newM2Date = fullLengthLiningWorkDetailsGateway.GetM2Date(workIdFll);
                        DateTime? newInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDate(workIdFll);
                        DateTime? newFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workIdFll);
                        bool newIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentified(workIdFll);
                        bool newIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFS(workIdFll);
                        bool newIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClient(workIdFll);
                        bool newIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSales(workIdFll);
                        bool newIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClient(workIdFll);
                        bool newIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolved(workIdFll);
                        bool newIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigation(workIdFll);
                        bool newRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workIdFll);
                        DateTime? newRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workIdFll);
                        bool newP1Completed = fullLengthLiningWorkDetailsGateway.GetP1Completed(workIdFll);

                        // M1
                        string newMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workIdFll);
                        string newSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workIdFll);
                        bool newPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workIdFll);
                        bool newStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workIdFll);
                        string newStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workIdFll);
                        string newTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workIdFll);
                        string newMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workIdFll);
                        string newMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll);
                        string newVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workIdFll);
                        string newVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workIdFll);
                        string newAccessType = fullLengthLiningWorkDetailsGateway.GetAccessType(workIdFll);

                        // M2
                        string newMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workIdFll);
                        bool newDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipe(workIdFll);
                        string newDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workIdFll);
                        int? newCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workIdFll);
                        string newLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithId(workIdFll);
                        string newHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workIdFll);
                        string newHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workIdFll);
                        string newDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workIdFll);
                        string newSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workIdFll);
                        bool newHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workIdFll);
                        bool newFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workIdFll);
                        bool newTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPump(workIdFll);
                        bool newSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypass(workIdFll);
                        bool newScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffolding(workIdFll);
                        bool newWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workIdFll);
                        bool newExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workIdFll);
                        bool newGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workIdFll);
                        bool newEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMats(workIdFll);
                        bool newRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequired(workIdFll);
                        bool newCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workIdFll);

                        // comments
                        string newComments = fullLengthLiningWorkDetailsGateway.GetComments(workIdFll);

                        // ... Update work
                        UpdateFllWork(sectionAssetId, countryId, provinceId, countyId, cityId, workIdFll, originalClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, originalP1Date, originalM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, originalCxisRemoved, originalRoboticPrepCompleted, originalRoboticPrepCompletedDate, originalMeasurementTakenByFLL, originalTrafficControl, originalSiteDetails, originalPipeSizeChange, originalStandardBypass, originalStandardBypassComments, originalTrafficControlDetails, originalMeasurementType, originalMeasurementFromMh, originalVideoDoneFromMh, originalVideoDoneToMh, originalVideoLength, originalComments, false, companyId, originalMaterial, originalAccessType, originalP1Completed, newClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, newP1Date, newM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, newCxisRemoved, newRoboticPrepCompleted, newRoboticPrepCompletedDate, newMeasurementTakenByFLL, newMaterial, newTrafficControl, newSiteDetails, newPipeSizeChange, newStandardBypass, newStandardBypassComments, newTrafficControlDetails, newMeasurementType, newMeasurementFromMh, newVideoDoneFromMh, newVideoDoneToMh, newVideoLength, newComments, false, companyId, newAccessType, newP1Completed);
                    }
                    else
                    {
                        if (newP1Date.HasValue || newCxisRemoved.HasValue || newMaterial != "" || newTrafficControl != "" || newVideoLength != "") // Insert Fll work
                        {
                            WorkFullLengthLining workFullLengthLining = new WorkFullLengthLining(null);
                            workIdFll = workFullLengthLining.InsertDirectEmptyWorks(projectId, sectionAssetId, null, "", null, null, null, null, null, null, null, false, false, false, false, false, false, false, companyId, false, "", "");

                            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                            fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workIdFll, sectionAssetId, companyId);

                            // Original values
                            string originalClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientIdOriginal(workIdFll);
                            DateTime? originalProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDateOriginal(workIdFll);
                            DateTime? originalDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDateOriginal(workIdFll);
                            DateTime? originalM1Date = fullLengthLiningWorkDetailsGateway.GetM1DateOriginal(workIdFll);
                            DateTime? originalM2Date = fullLengthLiningWorkDetailsGateway.GetM2DateOriginal(workIdFll);
                            DateTime? originalInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDateOriginal(workIdFll);
                            DateTime? originalFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDateOriginal(workIdFll);
                            bool originalIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentifiedOriginal(workIdFll);
                            bool originalIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFSOriginal(workIdFll);
                            bool originalIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClientOriginal(workIdFll);
                            bool originalIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSalesOriginal(workIdFll);
                            bool originalIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClientOriginal(workIdFll);
                            bool originalIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolvedOriginal(workIdFll);
                            bool originalIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigationOriginal(workIdFll);
                            bool originalRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedOriginal(workIdFll);
                            DateTime? originalRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDateOriginal(workIdFll);
                            bool originalP1Completed = fullLengthLiningWorkDetailsGateway.GetP1CompletedOriginal(workIdFll);

                            // M1 data
                            string originalMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByOriginal(workIdFll);
                            string originalSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetailsOriginal(workIdFll);
                            bool originalPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChangeOriginal(workIdFll);
                            bool originalStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypassOriginal(workIdFll);
                            string originalStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassCommentsOriginal(workIdFll);
                            string originalTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetailsOriginal(workIdFll);
                            string originalMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementTypeOriginal(workIdFll);
                            string originalMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMhOriginal(workIdFll);
                            string originalVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMhOriginal(workIdFll);
                            string originalVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMhOriginal(workIdFll);
                            string originalAccessType = fullLengthLiningWorkDetailsGateway.GetAccessTypeOriginal(workIdFll);

                            // M2 data
                            string originalMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2Original(workIdFll);
                            bool originalDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipeOriginal(workIdFll);
                            string originalDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepthOriginal(workIdFll);
                            int? originalCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLateralsOriginal(workIdFll);
                            string originalLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithIdOriginal(workIdFll);
                            string originalHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddressOriginal(workIdFll);
                            string originalHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMHOriginal(workIdFll);
                            string originalDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMhOriginal(workIdFll);
                            string originalSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGradeOriginal(workIdFll);
                            bool originalHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulleyOriginal(workIdFll);
                            bool originalFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCartOriginal(workIdFll);
                            bool originalTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPumpOriginal(workIdFll);
                            bool originalSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypassOriginal(workIdFll);
                            bool originalScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffoldingOriginal(workIdFll);
                            bool originalWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtensionOriginal(workIdFll);
                            bool originalExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGeneratorOriginal(workIdFll);
                            bool originalGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtensionOriginal(workIdFll);
                            bool originalEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMatsOriginal(workIdFll);
                            bool originalRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequiredOriginal(workIdFll);
                            bool originalCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkidOriginal(workIdFll);

                            // Comments
                            string originalComments = fullLengthLiningWorkDetailsGateway.GetCommentsOriginal(workIdFll);

                            // New variables
                            string newClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientId(workIdFll);
                            DateTime? newProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workIdFll);
                            DateTime? newDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workIdFll);
                            DateTime? newM1Date = fullLengthLiningWorkDetailsGateway.GetM1Date(workIdFll);
                            DateTime? newM2Date = fullLengthLiningWorkDetailsGateway.GetM2Date(workIdFll);
                            DateTime? newInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDate(workIdFll);
                            DateTime? newFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workIdFll);
                            bool newIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentified(workIdFll);
                            bool newIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFS(workIdFll);
                            bool newIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClient(workIdFll);
                            bool newIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSales(workIdFll);
                            bool newIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClient(workIdFll);
                            bool newIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolved(workIdFll);
                            bool newIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigation(workIdFll);
                            bool newRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workIdFll);
                            DateTime? newRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workIdFll);
                            bool newP1Completed = fullLengthLiningWorkDetailsGateway.GetP1Completed(workIdFll);

                            // M1
                            string newMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workIdFll);
                            string newSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workIdFll);
                            bool newPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workIdFll);
                            bool newStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workIdFll);
                            string newStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workIdFll);
                            string newTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workIdFll);
                            string newMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workIdFll);
                            string newMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll);
                            string newVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workIdFll);
                            string newVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workIdFll);
                            string newAccessType = fullLengthLiningWorkDetailsGateway.GetAccessType(workIdFll);

                            // M2
                            string newMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workIdFll);
                            bool newDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipe(workIdFll);
                            string newDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workIdFll);
                            int? newCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workIdFll);
                            string newLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithId(workIdFll);
                            string newHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workIdFll);
                            string newHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workIdFll);
                            string newDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workIdFll);
                            string newSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workIdFll);
                            bool newHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workIdFll);
                            bool newFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workIdFll);
                            bool newTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPump(workIdFll);
                            bool newSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypass(workIdFll);
                            bool newScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffolding(workIdFll);
                            bool newWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workIdFll);
                            bool newExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workIdFll);
                            bool newGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workIdFll);
                            bool newEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMats(workIdFll);
                            bool newRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequired(workIdFll);
                            bool newCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workIdFll);

                            // comments
                            string newComments = fullLengthLiningWorkDetailsGateway.GetComments(workIdFll);

                            // ... Update work
                            UpdateFllWork(sectionAssetId, countryId, provinceId, countyId, cityId, workIdFll, originalClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, originalP1Date, originalM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, originalCxisRemoved, originalRoboticPrepCompleted, originalRoboticPrepCompletedDate, originalMeasurementTakenByFLL, originalTrafficControl, originalSiteDetails, originalPipeSizeChange, originalStandardBypass, originalStandardBypassComments, originalTrafficControlDetails, originalMeasurementType, originalMeasurementFromMh, originalVideoDoneFromMh, originalVideoDoneToMh, originalVideoLength, originalComments, false, companyId, originalMaterial, originalAccessType, originalP1Completed, newClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, newP1Date, newM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, newCxisRemoved, newRoboticPrepCompleted, newRoboticPrepCompletedDate, newMeasurementTakenByFLL, newMaterial, newTrafficControl, newSiteDetails, newPipeSizeChange, newStandardBypass, newStandardBypassComments, newTrafficControlDetails, newMeasurementType, newMeasurementFromMh, newVideoDoneFromMh, newVideoDoneToMh, newVideoLength, newComments, false, companyId, newAccessType, newP1Completed);
                        }
                    }

                    if (workIdRa != 0) // ... Has Fll work
                    {
                        UpdateRaWork(workIdRa, originalPreFlushDate, originalPreVideoDate, newPreFlushDate, newPreVideoDate, companyId);
                    }
                    else
                    {
                        if (newPreFlushDate.HasValue || newPreVideoDate.HasValue) // Insert RA work
                        {
                            WorkRehabAssessment workRehabAssessment = new WorkRehabAssessment(null);
                            workIdRa = workRehabAssessment.InsertDirect(projectId, sectionAssetId, null, newPreFlushDate, newPreVideoDate, false, companyId, "", "");

                            UpdateRaWork(workIdRa, originalPreFlushDate, originalPreVideoDate, newPreFlushDate, newPreVideoDate, companyId);
                        }
                    }

                    // Update work
                    WorkPointRepairs workPointRepairs = new WorkPointRepairs(null);
                    workPointRepairs.UpdateDirect(sectionAssetId, workId, originalClientId, originalMeasurementTakenBy, originalRepairConfirmationDate, originalBypassRequired, originalRoboticDistances, originalProposedLiningDate, originalDeadlineLiningDate, originalFinalVideoDate, originalEstimatedJoints, originalJointsTestSealed, originalIssueIdentified, originalIssueLFS, originalIssueClient, originalIssueSales, originalIssueGivenToClient, originalIssueResolved, originalIssueInvestigation, "", false, companyId, workId, newClientId, newMeasurementTakenBy, newRepairConfirmationDate, newBypassRequired, newRoboticDistances, newProposedLiningDate, newDeadlineLiningDate, newFinalVideoDate, newEstimatedJoints, newJointsTestSealed, newIssueIdentified, newIssueLFS, newIssueClient, newIssueSales, newIssueGivenToClient, newIssueResolved, newIssueInvestigation, "", false, companyId);

                    // Get original variables
                    WorkGateway workGateway = new WorkGateway();
                    workGateway.LoadByWorkId(workId, companyId);

                    string originalWorkType = workGateway.GetWorkTypeOriginal(workId);
                    int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(workId);
                    string originalComment = workGateway.GetCommentsOriginal(workId);
                    string originalHistory = workGateway.GetHistoryOriginal(workId);

                    //Get new comment
                    WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway();
                    workCommentsGateway.LoadByAssetIdWorkTypeProjectId(sectionAssetId, companyId, "Point Repairs", projectId);
                    WorkComments workComments = new WorkComments(workCommentsGateway.Data);
                    string newComment = workComments.GetCommentsSummary(companyId, workCommentsGateway.Table.Rows.Count, "\n");

                    Work work = new Work(null);
                    work.UpdateDirect(workId, projectId, sectionAssetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, workId, projectId, sectionAssetId, originalWorkType, originalLibraryCategoriesId, false, companyId, newComment, originalHistory);
                }
            }
        }
        private void LoadWorkData(int workId, int assetId)
        {
            PointRepairsWorkDetailsGateway pointRepairsWorkDetailsGateway = new PointRepairsWorkDetailsGateway(pointRepairsTDS);

            if (pointRepairsWorkDetailsGateway.Table.Rows.Count > 0)
            {
                // For Header
                tbxVideoLength.Text = pointRepairsWorkDetailsGateway.GetVideoLength(workId);

                // For PR general data
                tbxGeneralDataClientId.Text = pointRepairsWorkDetailsGateway.GetClientId(workId);
                tbxGeneralDataMeasurementsTakenBy.Text = pointRepairsWorkDetailsGateway.GetMeasurementTakenBy(workId);

                // For RA data
                tbxGeneralDataPreFlushDate.Text = "";
                if (pointRepairsWorkDetailsGateway.GetPreFlushDate(workId).HasValue)
                {
                    DateTime preFlushDate = (DateTime)pointRepairsWorkDetailsGateway.GetPreFlushDate(workId);
                    tbxGeneralDataPreFlushDate.Text = preFlushDate.Month.ToString() + "/" + preFlushDate.Day.ToString() + "/" + preFlushDate.Year.ToString();
                }

                tbxGeneralDataPreVideoDate.Text = "";
                if (pointRepairsWorkDetailsGateway.GetPreVideoDate(workId).HasValue)
                {
                    DateTime preVideoDate = (DateTime)pointRepairsWorkDetailsGateway.GetPreVideoDate(workId);
                    tbxGeneralDataPreVideoDate.Text = preVideoDate.Month.ToString() + "/" + preVideoDate.Day.ToString() + "/" + preVideoDate.Year.ToString();
                }
                // For FLL data
                tbxGeneralDataP1Date.Text = "";
                if (pointRepairsWorkDetailsGateway.GetP1Date(workId).HasValue)
                {
                    DateTime p1Date = (DateTime)pointRepairsWorkDetailsGateway.GetP1Date(workId);
                    tbxGeneralDataP1Date.Text = p1Date.Month.ToString() + "/" + p1Date.Day.ToString() + "/" + p1Date.Year.ToString();
                }

                tbxGeneralDataRepairConfirmationDate.Text = "";
                if (pointRepairsWorkDetailsGateway.GetRepairConfirmationDate(workId).HasValue)
                {
                    DateTime confirmationDate = (DateTime)pointRepairsWorkDetailsGateway.GetRepairConfirmationDate(workId);
                    tbxGeneralDataRepairConfirmationDate.Text = confirmationDate.Month.ToString() + "/" + confirmationDate.Day.ToString() + "/" + confirmationDate.Year.ToString();
                }

                // For FLL M1 data
                tbxGeneralDataTrafficControl.Text = pointRepairsWorkDetailsGateway.GetTrafficControl(workId);
                tbxGeneralDataMaterial.Text = pointRepairsWorkDetailsGateway.GetMaterial(workId);

                // For FLL P1 data
                tbxGeneralDataCXIsRemoved.Text = ""; if (pointRepairsWorkDetailsGateway.GetCxisRemoved(workId).HasValue) tbxGeneralDataCXIsRemoved.Text = pointRepairsWorkDetailsGateway.GetCxisRemoved(workId).ToString();

                ckbxGeneralDataBypassRequired.Checked = pointRepairsWorkDetailsGateway.GetBypassRequired(workId);
                tbxGeneralDataRoboticDistances.Text = pointRepairsWorkDetailsGateway.GetRoboticDistances(workId);
                tbxGeneralDataProposedLiningDate.Text = "";
                if (pointRepairsWorkDetailsGateway.GetProposedLiningDate(workId).HasValue)
                {
                    DateTime proposedLiningDate = (DateTime)pointRepairsWorkDetailsGateway.GetProposedLiningDate(workId);
                    tbxGeneralDataProposedLiningDate.Text = proposedLiningDate.Month.ToString() + "/" + proposedLiningDate.Day.ToString() + "/" + proposedLiningDate.Year.ToString();
                }

                tbxGeneralDataDeadlineLiningDate.Text = "";
                if (pointRepairsWorkDetailsGateway.GetDeadlineLiningDate(workId).HasValue)
                {
                    DateTime deadlineLiningDate = (DateTime)pointRepairsWorkDetailsGateway.GetDeadlineLiningDate(workId);
                    tbxGeneralDataDeadlineLiningDate.Text = deadlineLiningDate.Month.ToString() + "/" + deadlineLiningDate.Day.ToString() + "/" + deadlineLiningDate.Year.ToString();
                }

                tbxGeneralDataFinalVideo.Text = "";
                if (pointRepairsWorkDetailsGateway.GetFinalVideoDate(workId).HasValue)
                {
                    DateTime finalVideo = (DateTime)pointRepairsWorkDetailsGateway.GetFinalVideoDate(workId);
                    tbxGeneralDataFinalVideo.Text = finalVideo.Month.ToString() + "/" + finalVideo.Day.ToString() + "/" + finalVideo.Year.ToString();
                }

                tbxGeneralDataEstimatedJoints.Text = ""; if (pointRepairsWorkDetailsGateway.GetEstimatedJoints(workId).HasValue) tbxGeneralDataEstimatedJoints.Text = pointRepairsWorkDetailsGateway.GetEstimatedJoints(workId).ToString();
                tbxGeneralDataJointsTestSealed.Text = ""; if (pointRepairsWorkDetailsGateway.GetJointsTestSealed(workId).HasValue) tbxGeneralDataJointsTestSealed.Text = pointRepairsWorkDetailsGateway.GetJointsTestSealed(workId).ToString();

                ckbxGeneralDataIssueIdentified.Checked = pointRepairsWorkDetailsGateway.GetIssueIdentified(workId);
                ckbxGeneralDataLfsIssue.Checked = pointRepairsWorkDetailsGateway.GetIssueLFS(workId);
                ckbxGeneralDataClientIssue.Checked = pointRepairsWorkDetailsGateway.GetIssueClient(workId);
                ckbxGeneralDataSalesIssue.Checked = pointRepairsWorkDetailsGateway.GetIssueSales(workId);
                ckbxGeneralDataIssueGivenToClient.Checked = pointRepairsWorkDetailsGateway.GetIssueGivenToClient(workId);
                ckbxGeneralDataIssueInvestigation.Checked = pointRepairsWorkDetailsGateway.GetIssueInvestigation(workId);
                ckbxGeneralDataIssueResolved.Checked = pointRepairsWorkDetailsGateway.GetIssueResolved(workId);
            }
        }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadByWorkIdAssetId
 /// </summary>
 /// <param name="workId">workId</param>
 /// <param name="assetId">assetId</param>
 /// <param name="companyId">companyId</param>
 public void LoadByWorkIdAssetId(int workId, int assetId, int companyId)
 {
     PointRepairsWorkDetailsGateway pointRepairsWorkDetailsGateway = new PointRepairsWorkDetailsGateway(Data);
     pointRepairsWorkDetailsGateway.LoadByWorkIdAssetId(workId, assetId, companyId);
 }