// ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadByWorkId
 /// </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)
 {
     FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(Data);
     fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workId, assetId, companyId);
 }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <param name="companyId">companyId</param>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        private void ProcessDataForProject(int companyId)
        {
            ArrayList al = new ArrayList();
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;
            int linersAcum = 0;
            double totalHrsAcum = 0;

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepRow row1 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepDataTable)Table)
            {
                if (row1.Phase.Contains("Prep"))
                {
                    int workIdFll = GetWorkId(row1.ProjectID, row1.AssetID, "Full Length Lining", companyId);

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

                    if (fullLengthLiningWorkDetailsGateway.Table.Rows.Count > 0)
                    {
                        string totalFt = fullLengthLiningWorkDetailsGateway.GetVideoLength(workIdFll);
                        if (totalFt != "")
                        {
                            Distance distOriginal = new Distance(totalFt);
                            row1.TotalFtDouble = distOriginal.ToDoubleInEng3();
                            row1.RealFt = distOriginal.ToDoubleInEng3();
                        }
                        else
                        {
                            row1.TotalFtDouble = 0;
                            row1.RealFt = 0;
                        }
                    }
                    else
                    {
                        row1.TotalFtDouble = 0;
                        row1.RealFt = 0;
                    }
                }

                if (!alDays.Contains(row1.Date))
                {
                    alDays.Add(row1.Date);
                    totalHrsAcum = totalHrsAcum + row1.Hrs;
                }
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepRow row2 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepDataTable)Table)
            {
                if (row2.Phase.Contains("Prep"))
                {
                    rateAcum = rateAcum + row2.RealFt / row2.Hrs;
                }
                else
                {
                    if (row2.Phase.Contains("Install"))
                    {
                        linersAcum = linersAcum + row2.LinersInstalled;
                        rateAcum = rateAcum + (row2.Hrs / row2.LinersInstalled);
                        //row2.TotalHrs = totalHrsAcum;
                    }
                    else
                    {
                        linersAcum = linersAcum + row2.LinersReinstated;
                        rateAcum = rateAcum + (row2.Hrs / row2.LinersReinstated);
                        //row2.TotalHrs = totalHrsAcum;
                    }
                }

                row2.NumPeriods = alDays.Count;
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepRow row3 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepDataTable)Table)
            {
                if (row3.Phase.Contains("Prep"))
                {
                    row3.AverageRate = rateAcum / alDays.Count;
                }
                else
                {
                    row3.AverageRate = totalHrsAcum / linersAcum;
                }
            }
        }
Пример #3
0
        private void LoadWorkData(int workId, int assetId)
        {
            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningTDS);

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

                // Load full length lining general data
                tbxGeneralClientId.Text = fullLengthLiningWorkDetailsGateway.GetClientId(workId);
                ckbxGeneralIssueIdentified.Checked = fullLengthLiningWorkDetailsGateway.GetIssueIdentified(workId);
                ckbxGeneralLfsIssue.Checked = fullLengthLiningWorkDetailsGateway.GetIssueLFS(workId);
                ckbxGeneralClientIssue.Checked = fullLengthLiningWorkDetailsGateway.GetIssueClient(workId);
                ckbxGeneralSalesIssue.Checked = fullLengthLiningWorkDetailsGateway.GetIssueSales(workId);
                ckbxGeneralIssueGivenToClient.Checked = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClient(workId);
                ckbxGeneralIssueResolved.Checked = fullLengthLiningWorkDetailsGateway.GetIssueResolved(workId);
                ckbxGeneralIssueInvestigation.Checked = fullLengthLiningWorkDetailsGateway.GetIssueInvestigation(workId);

                // ... Load Dates
                if (fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId).HasValue)
                {
                    tkrdpGeneralProposedLiningDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workId).HasValue)
                {
                    tkrdpGeneralDeadlineLiningDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetP1Date(workId).HasValue)
                {
                    tkrdpPrepDataP1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetP1Date(workId);
                    tkrdpGeneralP1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetP1Date(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetM1Date(workId).HasValue)
                {
                    tkrdpM1DataM1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM1Date(workId);
                    tkrdpGeneralM1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM1Date(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetM2Date(workId).HasValue)
                {
                    tkrdpGeneralM2Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM2Date(workId);
                    tkrdpM2DataM2Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM2Date(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetInstallDate(workId).HasValue)
                {
                    tkrdpGeneralInstallDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetInstallDate(workId);
                    tkrdpInstallDataInstallDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetInstallDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId).HasValue)
                {
                    tkrdpGeneralFinalVideo.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId);
                    tkrdpInstallDataFinalVideoDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId);
                }

                // ... for RA data
                if (fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId).HasValue)
                {
                    tkrdpGeneralPreFlushDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId);
                    tkrdpGeneralPreFlushDateReadOnly.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId).HasValue)
                {
                    tkrdpGeneralPreVideoDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId);
                    tkrdpGeneralPreVideoDateReadOnly.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId);
                }

                // For FullLengthLiningP1 data
                tbxPrepDataCXIsRemoved.Text = ""; if (fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).HasValue) tbxPrepDataCXIsRemoved.Text = fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).ToString();
                ckbxPrepDataRoboticPrepCompleted.Checked = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workId);
                if (fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId).HasValue)
                {
                    tkrdpPrepDataRoboticPrepCompletedDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId);
                }
                ckbxPrepDataP1Completed.Checked = fullLengthLiningWorkDetailsGateway.GetP1Completed(workId);

                // For FullLengthLiningM1 data
                // ... for material
                ddlM1DataMaterial.SelectedValue = fullLengthLiningWorkDetailsGateway.GetMaterial(workId);

                // ... form m1 data
                tbxM1DataMeasurementsTakenBy.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId);
                ddlM1DataTrafficControl.SelectedValue = fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId);
                if(fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId) == "") ddlM1DataSiteDetails.SelectedIndex = 0; else ddlM1DataSiteDetails.SelectedValue = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId);
                if (fullLengthLiningWorkDetailsGateway.GetAccessType(workId) == "") ddlM1DataAccessType.SelectedIndex = 0; else ddlM1DataAccessType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetAccessType(workId);
                ckbxM1DataPipeSizeChange.Checked = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workId);
                ckbxM1DataStandardBypass.Checked = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workId);
                tbxM1DataStandardBypassComments.Text = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId);
                tbxM1DataTrafficControlDetails.Text = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId);
                ddlM1DataMeasurementType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId);
                ddlM1DataMeasuredFromMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                tbxM1DataMeasuredFromMh.Text = ""; fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                ddlM1DataVideoDoneFromMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
                tbxM1DataVideoDoneFromMh.Text = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
                ddlM1DataVideoDoneToMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);
                tbxM1DataVideoDoneToMh.Text = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);

                // For FullLengthLiningM2 data
                tbxM2DataMeasurementsTakenBy.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workId);
                ckbxM2DataDropPipe.Checked = fullLengthLiningWorkDetailsGateway.GetDropPipe(workId);
                tbxM2DataDropPipeInvertdepth.Text = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workId);
                tbxM2DataCappedLaterals.Text = ""; if (fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId).HasValue) tbxM2DataCappedLaterals.Text = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId).ToString();
                tbxM2DataLineWidthId.Text = fullLengthLiningWorkDetailsGateway.GetLineWithId(workId);
                tbxM2DataHydrantAddress.Text = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workId);
                ddlM2DataHydroWireWithin10FtOfInversionMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workId);
                tbxM2DataDistanceToInversionMH.Text = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workId);
                if (fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId) == "") ddlM2DataSurfaceGrade.SelectedIndex = 0; else ddlM2DataSurfaceGrade.SelectedValue = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId);
                cbxM2DataHydroPulley.Checked = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workId);
                cbxM2DataFridgeCart.Checked = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workId);
                cbxM2DataTwoPump.Checked = fullLengthLiningWorkDetailsGateway.GetTwoPump(workId);
                cbxM2DataSixBypass.Checked = fullLengthLiningWorkDetailsGateway.GetSixBypass(workId);
                cbxM2DataScaffolding.Checked = fullLengthLiningWorkDetailsGateway.GetScaffolding(workId);
                cbxM2DataWinchExtension.Checked = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workId);
                cbxM2DataExtraGenerator.Checked = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workId);
                cbxM2DataGreyCableExtension.Checked = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workId);
                cbxM2DataEasementMats.Checked = fullLengthLiningWorkDetailsGateway.GetEasementMats(workId);
                cbxM2DataRampsRequired.Checked = fullLengthLiningWorkDetailsGateway.GetRampRequired(workId);
                cbxM2DataCameraSkid.Checked = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workId);

                // For FullLengthLiningWetOut data
                int companyId = Int32.Parse(hdfCompanyId.Value);

                // ... ... tube size = confirmed Size
                Distance confirmedSizeDistance = new Distance(tbxConfirmedSize.Text);
                double confirmedSize = 0;
                string[] confirmedSizeString = confirmedSizeDistance.ToStringInEng1().Split('\"');

                if (!confirmedSizeDistance.ToStringInEng1().Contains("'"))
                {
                    if (Validator.IsValidDouble(tbxConfirmedSize.Text))
                    {
                        confirmedSize = double.Parse(tbxConfirmedSize.Text);
                    }
                    else
                    {
                        confirmedSize = double.Parse(confirmedSizeString[0]);
                    }
                }
                else
                {
                    confirmedSize = Math.Ceiling(confirmedSizeDistance.ToDoubleInEng3()*12);
                    tbxConfirmedSize.Text = confirmedSize.ToString();
                }

                // ... Verify if work has wet out information
                WorkFullLengthLiningWetOutGateway workFullLengthLiningWetOutGateway = new WorkFullLengthLiningWetOutGateway();
                workFullLengthLiningWetOutGateway.LoadByWorkId(workId, companyId);

                if (workFullLengthLiningWetOutGateway.Table.Rows.Count > 0)
                {
                    // ... setup data
                    ddlWetOutDataLinerTube.SelectedValue = fullLengthLiningWorkDetailsGateway.GetLinerTube(workId);
                    if (ddlWetOutDataLinerTube.SelectedValue != "(Select)")
                    {
                        ckbxWetOutDataIncludeWetOutInformation.Checked = true;
                    }
                    else
                    {
                        ckbxWetOutDataIncludeWetOutInformation.Checked = false;
                    }

                    ddlWetOutDataResins.SelectedValue = fullLengthLiningWorkDetailsGateway.GetResinId(workId).ToString();
                    tbxWetOutDataExcessResin.Text = fullLengthLiningWorkDetailsGateway.GetExcessResin(workId).ToString();
                    ddlWetOutDataPoundsDrums.SelectedValue = fullLengthLiningWorkDetailsGateway.GetPoundsDrums(workId);
                    tbxWetOutDataDrumDiameter.Text = fullLengthLiningWorkDetailsGateway.GetDrumDiameter(workId).ToString();
                    tbxWetOutDataHoistMaximumHeight.Text = fullLengthLiningWorkDetailsGateway.GetHoistMaximumHeight(workId).ToString();
                    tbxWetOutDataHoistMinimumHeight.Text = fullLengthLiningWorkDetailsGateway.GetHoistMinimumHeight(workId).ToString();
                    tbxWetOutDataDownDropTubeLength.Text = fullLengthLiningWorkDetailsGateway.GetDownDropTubeLenght(workId).ToString();
                    tbxWetOutDataPumpHeightAboveGround.Text = fullLengthLiningWorkDetailsGateway.GetPumpHeightAboveGround(workId).ToString();
                    tbxWetOutDataTubeResinToFeltFactor.Text = fullLengthLiningWorkDetailsGateway.GetTubeResinToFeltFactor(workId).ToString();

                    // ... wet out sheet
                    DateTime wetOutDataDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheet(workId);
                    tbxWetOutDataDateOfSheet.Text = wetOutDataDateOfSheet.Month.ToString() + "/" + wetOutDataDateOfSheet.Day.ToString() + "/" + wetOutDataDateOfSheet.Year.ToString();
                    ddlWetOutDataMadeBy.SelectedValue = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId).ToString();
                    hdfRunDetails.Value = fullLengthLiningWorkDetailsGateway.GetRunDetails(workId);
                    ddlWetOutDataRunDetails2.SelectedValue = fullLengthLiningWorkDetailsGateway.GetRunDetails2(workId);
                    tkrdpWetOutDataWetOutDate.SelectedDate = fullLengthLiningWorkDetailsGateway.GetWetOutDate(workId);

                    tbxWetOutDataInstallDate.Text = "";
                    if (fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId).HasValue)
                    {
                        DateTime? wetOutDataInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);
                        DateTime wetOutDataInstallDateDateTime = (DateTime)wetOutDataInstallDate;
                        tbxWetOutDataInstallDate.Text = wetOutDataInstallDateDateTime.Month.ToString() + "/" + wetOutDataInstallDateDateTime.Day.ToString() + "/" + wetOutDataInstallDateDateTime.Year.ToString();
                    }

                    tbxWetOutDataTubeThickness.Text = fullLengthLiningWorkDetailsGateway.GetInversionThickness(workId);
                    tbxWetOutDataLengthToLine.Text = decimal.Round(decimal.Parse(fullLengthLiningWorkDetailsGateway.GetLengthToLine(workId).ToString()), 1).ToString();
                    tbxWetOutDataPlusExtra.Text = fullLengthLiningWorkDetailsGateway.GetPlusExtra(workId).ToString();
                    tbxWetOutDataForTurnOffset.Text = fullLengthLiningWorkDetailsGateway.GetForTurnOffset(workId).ToString();
                    tbxWetOutDataLengthtToWetOut.Text = fullLengthLiningWorkDetailsGateway.GetLengthToWetOut(workId).ToString();

                    tbxWetOutDataTubeMaxColdHead.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHead(workId).ToString();
                    tbxWetOutDataTubeMaxColdHeadPSI.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHeadPsi(workId).ToString();
                    tbxWetOutDataTubeMaxHotHead.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHead(workId).ToString();
                    tbxWetOutDataTubeMaxHotHeadPSI.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHeadPsi(workId).ToString();
                    tbxWetOutDataTubeIdealHead.Text = fullLengthLiningWorkDetailsGateway.GetTubeIdealHead(workId).ToString();
                    tbxWetOutDataTubeIdealHeadPSI.Text = fullLengthLiningWorkDetailsGateway.GetTubeIdealHeadPsi(workId).ToString();

                    tbxWetOutDataNetResinForTube.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTube(workId).ToString();
                    tbxWetOutDataNetResinForTubeUsgals.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgals(workId).ToString();
                    tbxWetOutDataNetResinForTubeDrumsIns.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeDrumsIns(workId);
                    tbxWetOutDataNetResinForTubeLbsFt.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeLbsFt(workId).ToString();
                    tbxWetOutDataNetResinForTubeUsgFt.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgFt(workId).ToString();

                    tbxWetOutDataExtraResinForMix.Text = fullLengthLiningWorkDetailsGateway.GetExtraResinForMix(workId).ToString();
                    tbxWetOutDataExtraLbsForMix.Text = fullLengthLiningWorkDetailsGateway.GetExtraLbsForMix(workId).ToString();
                    tbxWetOutDataTotalMixQuantity.Text = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantity(workId).ToString();
                    tbxWetOutDataTotalMixQuantityUsgals.Text = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityUsgals(workId).ToString();
                    tbxWetOutDataTotalMixQuantityDrumsIns.Text = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityDrumsIns(workId);

                    ddlWetOutDataInversionType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetInversionType(workId);
                    tbxWetOutDataDepthOfInversionMH.Text = fullLengthLiningWorkDetailsGateway.GetDepthOfInversionMH(workId).ToString();
                    tbxWetOutDataTubeForColumn.Text = fullLengthLiningWorkDetailsGateway.GetTubeForColumn(workId).ToString();
                    tbxWetOutDataTubeForStartDry.Text = fullLengthLiningWorkDetailsGateway.GetTubeForStartDry(workId).ToString();
                    tbxWetOutDataTotalTube.Text = fullLengthLiningWorkDetailsGateway.GetTotalTube(workId).ToString();
                    tbxWetOutDataDropTubeConnects.Text = fullLengthLiningWorkDetailsGateway.GetDropTubeConnects(workId);
                    tbxWetOutDataAllowsHeadTo.Text = fullLengthLiningWorkDetailsGateway.GetAllowsHeadTo(workId).ToString();
                    tbxWetOutDataRollerGap.Text = fullLengthLiningWorkDetailsGateway.GetRollerGap(workId).ToString();

                    tbxWetOutDataHeightNeeded.Text = fullLengthLiningWorkDetailsGateway.GetHeightNeeded(workId).ToString();
                    tbxWetOutDataAvailable.Text = fullLengthLiningWorkDetailsGateway.GetAvailable(workId);
                    tbxWetOutDataHoistHeight.Text = fullLengthLiningWorkDetailsGateway.GetHoistHeight(workId);
                    hdfResinId.Value = fullLengthLiningWorkDetailsGateway.GetResinId(workId).ToString();
                    hdfMadeBy.Value = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId).ToString();
                    tbxWetOutDataNotes.Text = fullLengthLiningWorkDetailsGateway.GetCommentsCipp(workId);

                    lblWetOutDataResinGray.Text = fullLengthLiningWorkDetailsGateway.GetResinsLabel(workId);
                    lblWetOutDataDrumContainsGray.Text = fullLengthLiningWorkDetailsGateway.GetDrumContainsLabel(workId);
                    lblWetOutDataLinerTubeGray.Text = fullLengthLiningWorkDetailsGateway.GetLinerTubeLabel(workId);
                    lblWetOutDataLbDrumsGrey.Text = fullLengthLiningWorkDetailsGateway.GetForLbDrumsLabel(workId);
                    lblWetOutDataNetResinGrey.Text = fullLengthLiningWorkDetailsGateway.GetNetResinLabel(workId);
                    lblWetOutDataCatalystGrey.Text = fullLengthLiningWorkDetailsGateway.GetCatalystLabel(workId);

                    // ... ... graphic labels
                    lblWetOutDataDimensionLabel.Text = confirmedSize + " ins x " + ddlThickness.SelectedValue + " mm Tube";
                    lblWetOutDataTotalTubeLengthlabel.Text = "Total Tube Length " + tbxWetOutDataTotalTube.Text + " ft";
                    lblWetOutDataForColumnLabel.Text = tbxWetOutDataTubeForColumn.Text + " ft  for Column";
                    lblWetOutDataDryFtLabel.Text = "Dry " + tbxWetOutDataTubeForStartDry.Text + " ft";
                    lblWetOutDataWetOutLengthlabel.Text = "Wet-Out Length " + tbxWetOutDataLengthtToWetOut.Text + " ft";
                    lblWetOutDataDryFtEndLabel.Text = "Dry " + tbxWetOutDataTubeForColumn.Text + " ft";
                    lblWetOutDataTailEndlabel.Text = "Tail End";
                    lblWetOutDataColumnEndlabel.Text = "Column End";
                    lblWetOutDataRollerGapLabel.Text = "Roller Gap " + tbxWetOutDataRollerGap.Text + " mm";
                }
                else
                {
                    //  Wet Out Data
                    // ... Show current day for new sheets
                    DateTime sheetDate = DateTime.Now;
                    tbxWetOutDataDateOfSheet.Text = sheetDate.Month.ToString() + "/" + sheetDate.Day.ToString() + "/" + sheetDate.Year.ToString();

                    // Set default values.
                    tbxWetOutDataExcessResin.Text = "0.0";
                    ddlWetOutDataPoundsDrums.SelectedIndex = 1;
                    tbxWetOutDataDrumDiameter.Text = "22.5";
                    tbxWetOutDataHoistMaximumHeight.Text = "24";
                    tbxWetOutDataHoistMinimumHeight.Text = "5";
                    tbxWetOutDataDownDropTubeLength.Text = "19";
                    tbxWetOutDataPumpHeightAboveGround.Text = "6";
                    tbxWetOutDataTubeResinToFeltFactor.Text = "87";

                    tbxWetOutDataPlusExtra.Text = "3";
                    tbxWetOutDataForTurnOffset.Text = "0";

                    tbxWetOutDataExtraResinForMix.Text = "0";
                    tbxWetOutDataTubeForColumn.Text = "16";
                    tbxWetOutDataTubeForStartDry.Text = "3";
                    if (ddlWetOutDataInversionType.SelectedValue == "Top")
                    {
                        Distance usmhDepthDistance = new Distance(tbxM1DataUsmhDepth.Text);
                        tbxWetOutDataDepthOfInversionMH.Text = decimal.Round(decimal.Parse(usmhDepthDistance.ToStringInEng3()), 1).ToString();
                    }
                    else
                    {
                        if (ddlWetOutDataInversionType.SelectedValue == "Bottom")
                        {
                            Distance dsmhDepthDistance = new Distance(tbxM1DataDsmhDepth.Text);
                            tbxWetOutDataDepthOfInversionMH.Text = decimal.Round(decimal.Parse(dsmhDepthDistance.ToStringInEng3()), 1).ToString();
                        }
                        else
                        {
                            tbxWetOutDataDepthOfInversionMH.Text = "0";
                        }
                    }

                    tbxWetOutDataRollerGap.Text = "13";
                    tbxWetOutDataNotes.Text = fullLengthLiningWorkDetailsGateway.GetCommentsCipp(workId);

                    // ...Section values
                    // ... ... Length To Line = Steel Tape Length, the first section to consider is the work one in Xft Yin
                    Distance steelTapeLength = new Distance(tbxSteelTapeLength.Text);
                    tbxWetOutDataLengthToLine.Text = decimal.Round(decimal.Parse(steelTapeLength.ToStringInEng3()), 1).ToString();
                    tbxInversionDataRunLength.Text = decimal.Round(decimal.Parse(steelTapeLength.ToStringInEng3()),1).ToString();
                    double lengthToLine = double.Parse(steelTapeLength.ToStringInEng3());

                    // ... Run details
                    if (cbxlSectionId.Items.Count > 1)
                    {
                        hdfRunDetails.Value = hdfSectionId.Value;
                    }

                    // .... Install Date
                    tbxWetOutDataInstallDate.Text = "";
                    if (tkrdpInstallDataInstallDate.SelectedDate.ToString() != "")
                    {
                        DateTime? inversionDataInstalledOn = tkrdpInstallDataInstallDate.SelectedDate;
                        DateTime installedOnDateTime = (DateTime)inversionDataInstalledOn;

                        tbxWetOutDataInstallDate.Text = installedOnDateTime.Month.ToString() + "/" + installedOnDateTime.Day.ToString() + "/" + installedOnDateTime.Year.ToString();
                    }
                }

                // ... Verify if work has inversion information
                WorkFullLengthLiningInversionGateway workFullLengthLiningInversionGateway = new WorkFullLengthLiningInversionGateway();
                workFullLengthLiningInversionGateway.LoadByWorkId(workId, companyId);

                // ... Verify if work has inversion information
                if (workFullLengthLiningInversionGateway.Table.Rows.Count > 0)
                {
                    // ... Inversion data
                    lblInversionDataSubtitle.Text = fullLengthLiningWorkDetailsGateway.GetLinerTube(workId);

                    DateTime inversionDataDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheet(workId);
                    tbxInversionDataDateOfSheet.Text = inversionDataDateOfSheet.Month.ToString() + "/" + inversionDataDateOfSheet.Day.ToString() + "/" + inversionDataDateOfSheet.Year.ToString();

                    int employeeId = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId);
                    EmployeeGateway employeeGateway = new EmployeeGateway();
                    employeeGateway.LoadByEmployeeId(employeeId);
                    tbxInversionDataMadeBy.Text = employeeGateway.GetLastName(employeeId) + " " + employeeGateway.GetFirstName(employeeId);

                    tbxInversionDataInstalledOn.Text = "";
                    if (fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId).HasValue)
                    {
                        DateTime? inversionDataInstalledOn = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);
                        DateTime inversionDataInstalledOnDateTime = (DateTime)inversionDataInstalledOn;
                        tbxInversionDataInstalledOn.Text = inversionDataInstalledOnDateTime.Month.ToString() + "/" + inversionDataInstalledOnDateTime.Day.ToString() + "/" + inversionDataInstalledOnDateTime.Year.ToString();
                    }

                    tbxInversionDataRunDetails2.Text = fullLengthLiningWorkDetailsGateway.GetRunDetails2(workId);
                    tbxInversionDataCommentsEdit.Text = fullLengthLiningWorkDetailsGateway.GetInversionComment(workId);
                    tbxInversionDataLinerSize.Text = confirmedSizeString + " ins x" + fullLengthLiningWorkDetailsGateway.GetInversionThickness(workId);
                    tbxInversionDataRunLength.Text = decimal.Round(decimal.Parse(fullLengthLiningWorkDetailsGateway.GetLengthToLine(workId).ToString()), 1).ToString();
                    tbxInversionDataWetOutLenght.Text = fullLengthLiningWorkDetailsGateway.GetLengthToWetOut(workId).ToString();

                    ddlInversionDataInversionPipeType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetPipeType(workId);
                    if (ddlInversionDataInversionPipeType.SelectedValue != "(Select)")
                    {
                        ckbxInversionDataIncludeInversionInformation.Checked = true;
                    }
                    else
                    {
                        ckbxInversionDataIncludeInversionInformation.Checked = false;
                    }

                    ddlInversionDataPipeCondition.SelectedValue = fullLengthLiningWorkDetailsGateway.GetPipeCondition(workId);
                    ddlInversionDataGroundMoisture.SelectedValue = fullLengthLiningWorkDetailsGateway.GetGroundMoisture(workId);
                    tbxInversionDataBoilerSize.Text = fullLengthLiningWorkDetailsGateway.GetBoilerSize(workId).ToString();
                    tbxInversionDataPumpsTotalCapacity.Text = fullLengthLiningWorkDetailsGateway.GetPumpTotalCapacity(workId).ToString();
                    tbxInversionDataLayflatSize.Text = fullLengthLiningWorkDetailsGateway.GetLayFlatSize(workId).ToString();
                    tbxInversionDataLayflatQuantityTotal.Text = fullLengthLiningWorkDetailsGateway.GetLayFlatQuantityTotal(workId).ToString();

                    tbxInversionDataWaterStartTempTs.Text = fullLengthLiningWorkDetailsGateway.GetWaterStartTemp(workId).ToString();
                    tbxInversionDataTempT1.Text = fullLengthLiningWorkDetailsGateway.GetTemp1(workId).ToString();
                    tbxInversionDataHoldAtT1For.Text = fullLengthLiningWorkDetailsGateway.GetHoldAtT1(workId).ToString();
                    tbxInversionDataTempT2.Text = fullLengthLiningWorkDetailsGateway.GetTempT2(workId).ToString();
                    tbxInversionDataCookAtT2For.Text = fullLengthLiningWorkDetailsGateway.GetCookAtT2(workId).ToString();
                    tbxInversionDataCoolDownFor.Text = fullLengthLiningWorkDetailsGateway.GetCoolDownFor(workId).ToString();

                    tbxInversionDataCoolToTemp.Text = fullLengthLiningWorkDetailsGateway.GetCoolToTemp(workId).ToString();
                    tbxInversionDataDropInPipeRun.Text = fullLengthLiningWorkDetailsGateway.GetDropInPipeRun(workId).ToString();
                    tbxInversionDataPipeSlopeOf.Text = fullLengthLiningWorkDetailsGateway.GetPipeSlopOf(workId).ToString();

                    lblInversionData45F120F.Text = tbxInversionDataWaterStartTempTs.Text + "°F-" + tbxInversionDataTempT1.Text + "°F (hr)";
                    tbxInversionData45F120F.Text = fullLengthLiningWorkDetailsGateway.GetF45F120(workId).ToString();
                    tbxInversionDataHold.Text = fullLengthLiningWorkDetailsGateway.GetHold(workId).ToString();
                    lblInversionData120F185F.Text = tbxInversionDataTempT1.Text + "°F-" + tbxInversionDataTempT2.Text + "°F (hr)";
                    tbxInversionData120F185F.Text = fullLengthLiningWorkDetailsGateway.GetF120F185(workId).ToString();
                    tbxInversionDataCookTime.Text = fullLengthLiningWorkDetailsGateway.GetCookTime(workId).ToString();
                    tbxInversionDataCoolTime.Text = fullLengthLiningWorkDetailsGateway.GetCoolTime(workId).ToString();
                    tbxInversionDataAproxTotal.Text = fullLengthLiningWorkDetailsGateway.GetAproxTotal(workId).ToString();

                    tbxInversionDataWaterChangesPerHour.Text = fullLengthLiningWorkDetailsGateway.GetWaterChangesPerHour(workId).ToString();
                    tbxInversionDataReturnWaterVelocity.Text = fullLengthLiningWorkDetailsGateway.GetReturnWaterVelocity(workId).ToString();
                    tbxInversionDataLayflatBackPressure.Text = fullLengthLiningWorkDetailsGateway.GetLayflatBackPressure(workId).ToString();
                    tbxInversionDataPumpLiftAtIdealHead.Text = fullLengthLiningWorkDetailsGateway.GetPumpLiftAtIdealHead(workId).ToString();
                    tbxInversionDataWaterToFillLinerColumn.Text = fullLengthLiningWorkDetailsGateway.GetWaterToFillLinerColumn(workId).ToString();
                    tbxInversionDataWaterPerFit.Text = fullLengthLiningWorkDetailsGateway.GetWaterPerFit(workId).ToString();

                    tbxInversionDataNotesAndInstallationResults.Text = fullLengthLiningWorkDetailsGateway.GetInstallationResults(workId);

                    lblInversionDataLinerInfoGrey.Text = fullLengthLiningWorkDetailsGateway.GetInversionLinerTubeLabel(workId);
                    lblInversionDataHeadsGrey.Text = fullLengthLiningWorkDetailsGateway.GetHeadsIdealLabel(workId);
                    lblInversionDataPumpingCirculationSubtitle.Text = fullLengthLiningWorkDetailsGateway.GetPumpingAndCirculationLabel(workId);

                    // ... ... graphic labels
                    lblInversionDataMaxColdForTubeLabel.Text = tbxWetOutDataTubeMaxColdHead.Text + " ft = Max Cold for tube";
                    lblInversionDataMaxHotForTubeLabel.Text = tbxWetOutDataTubeMaxHotHead.Text + " ft = Max Hot for tube";
                    lblInversionDataIdelForTubeLabel.Text = tbxWetOutDataTubeIdealHead.Text + " ft = Ideal for tube";

                    double maxColdForTubeEnd = double.Parse(tbxWetOutDataTubeMaxColdHead.Text) + double.Parse(tbxInversionDataDropInPipeRun.Text);
                    lblInversionDataMaxColdForTubeEndLabel.Text = decimal.Round(decimal.Parse(maxColdForTubeEnd.ToString()), 1).ToString() + " ft";

                    double maxHotForTubeEnd = double.Parse(tbxWetOutDataTubeMaxHotHead.Text) + double.Parse(tbxInversionDataDropInPipeRun.Text);
                    lblInversionDataMaxHotForTubeEndLabel.Text = decimal.Round(decimal.Parse(maxHotForTubeEnd.ToString()), 1).ToString() + " ft";

                    double idealForTubeEnd = double.Parse(tbxWetOutDataTubeIdealHead.Text) + double.Parse(tbxInversionDataDropInPipeRun.Text);
                    lblInversionDataIdelForTubeEndLabel.Text = decimal.Round(decimal.Parse(idealForTubeEnd.ToString()), 1).ToString() + " ft";

                    lblInversionDataPumpHeightLabel.Text = "   " + tbxWetOutDataPumpHeightAboveGround.Text + " ft";
                    lblInversionDataLinerSizeLabel.Text = confirmedSize.ToString() + " ins x" + fullLengthLiningWorkDetailsGateway.GetInversionThickness(workId) + " Liner";

                    lblInversionDataRunLengthLabel.Text = "Run Length: " + tbxInversionDataRunLength.Text + " ft; Fall: " + tbxInversionDataDropInPipeRun.Text + " ft";
                    lblInversionDataDepthOfInversionMHLabel.Text = "   " + tbxWetOutDataDepthOfInversionMH.Text + " ft";
                    lblInversionDataEndLabel.Text = "End";
                }
                else
                {
                    //  Wet Out Data
                    // ... Show current day for new sheets
                    DateTime sheetDate = DateTime.Now;
                    tbxInversionDataDateOfSheet.Text = sheetDate.Month.ToString() + "/" + sheetDate.Day.ToString() + "/" + sheetDate.Year.ToString();

                    // Set default values.
                    lblInversionData45F120F.Text = "";
                    lblInversionData120F185F.Text = "";
                    tbxInversionDataBoilerSize.Text = "7000000";
                    tbxInversionDataPumpsTotalCapacity.Text = "300";
                    tbxInversionDataLayflatSize.Text = "4";
                    tbxInversionDataLayflatQuantityTotal.Text = "1";

                    tbxInversionDataWaterStartTempTs.Text = "45";
                    tbxInversionDataTempT1.Text = "120";
                    tbxInversionDataHoldAtT1For.Text = "0.5";
                    tbxInversionDataTempT2.Text = "185";
                    tbxInversionDataCookAtT2For.Text = "2";
                    tbxInversionDataCoolDownFor.Text = "1";
                    tbxInversionDataCoolToTemp.Text = "85";

                    // ...Section values
                    // ... ... Length To Line = Steel Tape Length, the first section to consider is the work one in Xft Yin
                    Distance steelTapeLength = new Distance(tbxSteelTapeLength.Text);
                    tbxInversionDataRunLength.Text = decimal.Round(decimal.Parse(steelTapeLength.ToStringInEng3()), 1).ToString();
                    double lengthToLine = double.Parse(steelTapeLength.ToStringInEng3());

                    // ... Run details
                    if (cbxlSectionId.Items.Count > 1)
                    {
                        hdfRunDetails.Value = hdfSectionId.Value;
                    }

                    // .... Install Date
                    tbxInversionDataInstalledOn.Text = "";
                    if (tkrdpInstallDataInstallDate.SelectedDate.ToString() != "")
                    {
                        DateTime? inversionDataInstalledOn = tkrdpInstallDataInstallDate.SelectedDate;
                        DateTime installedOnDateTime = (DateTime)inversionDataInstalledOn;

                        tbxInversionDataInstalledOn.Text = installedOnDateTime.Month.ToString() + "/" + installedOnDateTime.Day.ToString() + "/" + installedOnDateTime.Year.ToString();
                    }
                 }

                // ... Show FLL Comments + RA Comments
                int flWorkId = workId;

                // ... ... Get raWorkId
                int raWorkId = 0;
                int projectId = Int32.Parse(hdfCurrentProjectId.Value);
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByProjectIdAssetIdWorkType(projectId, assetId, "Rehab Assessment", companyId);
                if (workGateway.Table.Rows.Count > 0)
                {
                    raWorkId = workGateway.GetWorkId(assetId, "Rehab Assessment", projectId);
                }

                // ... ... Get comments
                FullLengthLiningAllComments fullLengthLiningAllComments = new FullLengthLiningAllComments(fullLengthLiningTDS);
                fullLengthLiningAllComments.LoadAllByFlWorkIdRaWorkId(flWorkId, raWorkId, companyId);

                // ... ... Store datasets
                Session["fullLengthLiningTDS"] = fullLengthLiningTDS;

                // ... ... Show comments
                tbxCommentsDataComments.Text = fullLengthLiningAllComments.GetFLOrRAComments(companyId, fullLengthLiningAllComments.Table.Rows.Count, "\n");
            }
        }
        /// <summary>
        /// Save
        /// </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>
        /// <param name="includeWetOutInformation">includeWetOutInformation</param>
        /// <param name="includeInversionInformation">includeInversionInformation</param>
        public void Save(Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int projectId, int sectionAssetId, int companyId, bool includeWetOutInformation, bool includeInversionInformation)
        {
            FullLengthLiningTDS fullLengthLiningChanges = (FullLengthLiningTDS)Data.GetChanges();

            if (fullLengthLiningChanges.WorkDetails.Rows.Count > 0)
            {
                FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningChanges);

                // Update sections
                foreach (FullLengthLiningTDS.WorkDetailsRow row in (FullLengthLiningTDS.WorkDetailsDataTable)fullLengthLiningChanges.WorkDetails)
                {
                    // Unchanged values
                    int workId = row.WorkID;

                    // Original values
                    string originalClientId = fullLengthLiningWorkDetailsGateway.GetClientIdOriginal(workId);
                    DateTime? originalProposedLiningDate = fullLengthLiningWorkDetailsGateway.GetProposedLiningDateOriginal(workId);
                    DateTime? originalDeadlineLiningDate = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDateOriginal(workId);
                    DateTime? originalP1Date = fullLengthLiningWorkDetailsGateway.GetP1DateOriginal(workId);
                    DateTime? originalM1Date = fullLengthLiningWorkDetailsGateway.GetM1DateOriginal(workId);
                    DateTime? originalM2Date = fullLengthLiningWorkDetailsGateway.GetM2DateOriginal(workId);
                    DateTime? originalInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDateOriginal(workId);
                    DateTime? originalFinalVideoDate = fullLengthLiningWorkDetailsGateway.GetFinalVideoDateOriginal(workId);
                    bool originalIssueIdentified = fullLengthLiningWorkDetailsGateway.GetIssueIdentifiedOriginal(workId);
                    bool originalIssueLFS = fullLengthLiningWorkDetailsGateway.GetIssueLFSOriginal(workId);
                    bool originalIssueClient = fullLengthLiningWorkDetailsGateway.GetIssueClientOriginal(workId);
                    bool originalIssueSales = fullLengthLiningWorkDetailsGateway.GetIssueSalesOriginal(workId);
                    bool originalIssueGivenToClient = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClientOriginal(workId);
                    bool originalIssueResolved = fullLengthLiningWorkDetailsGateway.GetIssueResolvedOriginal(workId);
                    bool originalIssueInvestigation = fullLengthLiningWorkDetailsGateway.GetIssueInvestigationOriginal(workId);
                    int? originalCxisRemoved = fullLengthLiningWorkDetailsGateway.GetCxisRemovedOriginal(workId);
                    bool originalRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedOriginal(workId);
                    DateTime? originalRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDateOriginal(workId);
                    DateTime? originalPreFlushDate = fullLengthLiningWorkDetailsGateway.GetPreFlushDateOriginal(workId);
                    DateTime? originalPreVideoDate = fullLengthLiningWorkDetailsGateway.GetPreVideoDateOriginal(workId);
                    int originalRaWorkId = fullLengthLiningWorkDetailsGateway.GetRaWorkIdOriginal(workId);
                    bool originalP1Completed = fullLengthLiningWorkDetailsGateway.GetP1CompletedOriginal(workId);

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

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

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

                    // New variables
                    string newClientId = fullLengthLiningWorkDetailsGateway.GetClientId(workId);
                    DateTime? newProposedLiningDate = fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId);
                    DateTime? newDeadlineLiningDate = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workId);
                    DateTime? newP1Date = fullLengthLiningWorkDetailsGateway.GetP1Date(workId);
                    DateTime? newM1Date = fullLengthLiningWorkDetailsGateway.GetM1Date(workId);
                    DateTime? newM2Date = fullLengthLiningWorkDetailsGateway.GetM2Date(workId);
                    DateTime? newInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDate(workId);
                    DateTime? newFinalVideoDate = fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId);
                    bool newIssueIdentified = fullLengthLiningWorkDetailsGateway.GetIssueIdentified(workId);
                    bool newIssueLFS = fullLengthLiningWorkDetailsGateway.GetIssueLFS(workId);
                    bool newIssueClient = fullLengthLiningWorkDetailsGateway.GetIssueClient(workId);
                    bool newIssueSales = fullLengthLiningWorkDetailsGateway.GetIssueSales(workId);
                    bool newIssueGivenToClient = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClient(workId);
                    bool newIssueResolved = fullLengthLiningWorkDetailsGateway.GetIssueResolved(workId);
                    bool newIssueInvestigation = fullLengthLiningWorkDetailsGateway.GetIssueInvestigation(workId);
                    int? newCxisRemoved = fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId);
                    bool newRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workId);
                    DateTime? newRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId);
                    DateTime? newPreFlushDate = fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId);
                    DateTime? newPreVideoDate = fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId);
                    int newRaWorkId = fullLengthLiningWorkDetailsGateway.GetRaWorkId(workId);
                    bool newP1Completed = fullLengthLiningWorkDetailsGateway.GetP1Completed(workId);

                    // M1
                    string newMeasurementTakenBy = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId);
                    string newMaterial = fullLengthLiningWorkDetailsGateway.GetMaterial(workId);
                    string newTrafficControl = fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId);
                    string newSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId);
                    bool newPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workId);
                    bool newStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workId);
                    string newStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId);
                    string newTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId);
                    string newMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId);
                    string newMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                    string newVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
                    string newVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);
                    string newAccessType = fullLengthLiningWorkDetailsGateway.GetAccessType(workId);

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

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

                    // Update work
                    UpdateWork(countryId, provinceId, countyId, cityId, workId, originalClientId, originalProposedLiningDate, originalDeadlineLiningDate, originalP1Date, originalM1Date, originalM2Date, originalInstallDate, originalFinalVideoDate, originalIssueIdentified, originalIssueLFS, originalIssueClient, originalIssueSales, originalIssueGivenToClient, originalIssueResolved, originalIssueInvestigation, originalCxisRemoved, originalRoboticPrepCompleted, originalRoboticPrepCompletedDate, originalMeasurementTakenBy, originalTrafficControl, originalSiteDetails, originalPipeSizeChange, originalStandardBypass, originalStandardBypassComments, originalTrafficControlDetails, originalMeasurementType, originalMeasurementFromMh, originalVideoDoneFromMh, originalVideoDoneToMh, originalMeasurementTakenByM2, originalDropPipe, originalDropPipeInvertDepth, originalCappedLaterals, originalLineWithId, originalHydrantAddress, originalHydroWireWithin10FtOfInversionMH, originalDistanceToInversionMh, originalSurfaceGrade, originalHydroPulley, originalFridgeCart, originalTwoPump, originalSixBypass, originalScaffolding, originalWinchExtension, originalExtraGenerator, originalGreyCableExtension, originalEasementMats, originalRampRequired, originalVideoLength, originalComments, originalPreFlushDate, originalPreVideoDate, originalRaWorkId, false, companyId, originalMaterial, originalCameraSkid, originalAccessType, originalP1Completed, newClientId, newProposedLiningDate, newDeadlineLiningDate, newP1Date, newM1Date, newM2Date, newInstallDate, newFinalVideoDate, newIssueIdentified, newIssueLFS, newIssueClient, newIssueSales, newIssueGivenToClient, newIssueResolved, newIssueInvestigation, newCxisRemoved, newRoboticPrepCompleted, newRoboticPrepCompletedDate, newMeasurementTakenBy, newMaterial, newTrafficControl, newSiteDetails, newPipeSizeChange, newStandardBypass, newStandardBypassComments, newTrafficControlDetails, newMeasurementType, newMeasurementFromMh, newVideoDoneFromMh, newVideoDoneToMh, newMeasurementTakenByM2, newDropPipe, newDropPipeInvertDepth, newCappedLaterals, newLineWithId, newHydrantAddress, newHydroWireWithin10FtOfInversionMH, newDistanceToInversionMh, newSurfaceGrade, newHydroPulley, newFridgeCart, newTwoPump, newSixBypass, newScaffolding, newWinchExtension, newExtraGenerator, newGreyCableExtension, newEasementMats, newRampRequired, newVideoLength, newComments, newPreFlushDate, newPreVideoDate, newRaWorkId, sectionAssetId, false, companyId, newCameraSkid, newAccessType, newP1Completed);

                    // For wet out information
                    if (includeWetOutInformation)
                    {
                        // Update data
                        WorkFullLengthLiningWetOutGateway workFullLengthLiningWetOutGateway = new WorkFullLengthLiningWetOutGateway();
                        workFullLengthLiningWetOutGateway.LoadByWorkId(workId, companyId);

                        // ... Verify if work has wet out data information
                        if (workFullLengthLiningWetOutGateway.Table.Rows.Count > 0)
                        {
                            // Wet Out data original values
                            string originalLinerTube = fullLengthLiningWorkDetailsGateway.GetLinerTubeOriginal(workId);
                            int originalResinID = fullLengthLiningWorkDetailsGateway.GetResinIdOriginal(workId);
                            decimal originalExcessResin = fullLengthLiningWorkDetailsGateway.GetExcessResinOriginal(workId);
                            string originalPoundsDrums = fullLengthLiningWorkDetailsGateway.GetPoundsDrumsOriginal(workId);
                            decimal originalDrumDiameter = fullLengthLiningWorkDetailsGateway.GetDrumDiameterOriginal(workId);
                            decimal originalHoistMaximumHeight = fullLengthLiningWorkDetailsGateway.GetHoistMaximumHeightOriginal(workId);
                            decimal originalHoistMinimumHeight = fullLengthLiningWorkDetailsGateway.GetHoistMinimumHeightOriginal(workId);
                            decimal originalDownDropTubeLenght = fullLengthLiningWorkDetailsGateway.GetDownDropTubeLenghtOriginal(workId);
                            decimal originalPumpHeightAboveGround = fullLengthLiningWorkDetailsGateway.GetPumpHeightAboveGroundOriginal(workId);
                            int originalTubeResinToFeltFactor = fullLengthLiningWorkDetailsGateway.GetTubeResinToFeltFactorOriginal(workId);
                            DateTime originalDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheetOriginal(workId);
                            int originalEmployeeID = fullLengthLiningWorkDetailsGateway.GetEmployeeIdOriginal(workId);
                            string originalRunDetails = fullLengthLiningWorkDetailsGateway.GetRunDetailsOriginal(workId);
                            string originalRunDetails2 = fullLengthLiningWorkDetailsGateway.GetRunDetails2Original(workId);
                            DateTime originalWetOutDate = fullLengthLiningWorkDetailsGateway.GetWetOutDateOriginal(workId);
                            DateTime? originalWetOutInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDateOriginal(workId);
                            string originalThickness = fullLengthLiningWorkDetailsGateway.GetInversionThicknessOriginal(workId);
                            decimal originalLengthToLine = fullLengthLiningWorkDetailsGateway.GetLengthToLineOriginal(workId);
                            decimal originalPlusExtra = fullLengthLiningWorkDetailsGateway.GetPlusExtraOriginal(workId);
                            decimal originalForTurnOffset = fullLengthLiningWorkDetailsGateway.GetForTurnOffsetOriginal(workId);
                            decimal originalLengthToWetOut = fullLengthLiningWorkDetailsGateway.GetLengthToWetOutOriginal(workId);
                            decimal originalTubeMaxColdHead = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHeadOriginal(workId);
                            decimal originalTubeMaxColdHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHeadPsiOriginal(workId);
                            decimal originalTubeMaxHotHead = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHeadOriginal(workId);
                            decimal originalTubeMaxHotHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHeadPsiOriginal(workId);
                            decimal originalTubeIdealHead = fullLengthLiningWorkDetailsGateway.GetTubeIdealHeadOriginal(workId);
                            decimal originalTubeIdealHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeIdealHeadPsiOriginal(workId);
                            decimal originalNetResinForTube = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeOriginal(workId);
                            decimal originalNetResinForTubeUsgals = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgalsOriginal(workId);
                            string originalNetResinForTubeDrumsIns = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeDrumsInsOriginal(workId);
                            decimal originalNetResinForTubeLbsFt = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeLbsFtOriginal(workId);
                            decimal originalNetResinForTubeUsgFt = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgFtOriginal(workId);
                            int originalExtraResinForMix = fullLengthLiningWorkDetailsGateway.GetExtraResinForMixOriginal(workId);
                            decimal originalExtraLbsForMix = fullLengthLiningWorkDetailsGateway.GetExtraLbsForMixOriginal(workId);
                            decimal originalTotalMixQuantity = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityOriginal(workId);
                            decimal originalTotalMixQuantityUsgals = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityUsgalsOriginal(workId);
                            string originalTotalMixQuantityDrumsIns = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityDrumsInsOriginal(workId);
                            string originalInversionType = fullLengthLiningWorkDetailsGateway.GetInversionTypeOriginal(workId);
                            decimal originalDepthOfInversionMH = fullLengthLiningWorkDetailsGateway.GetDepthOfInversionMHOriginal(workId);
                            decimal originalTubeForColumn = fullLengthLiningWorkDetailsGateway.GetTubeForColumnOriginal(workId);
                            decimal originalTubeForStartDry = fullLengthLiningWorkDetailsGateway.GetTubeForStartDryOriginal(workId);
                            decimal originalTotalTube = fullLengthLiningWorkDetailsGateway.GetTotalTubeOriginal(workId);
                            string originalDropTubeConnects = fullLengthLiningWorkDetailsGateway.GetDropTubeConnectsOriginal(workId);
                            decimal originalAllowsHeadTo = fullLengthLiningWorkDetailsGateway.GetAllowsHeadToOriginal(workId);
                            decimal originalRollerGap = fullLengthLiningWorkDetailsGateway.GetRollerGapOriginal(workId);
                            decimal originalHeightNeeded = fullLengthLiningWorkDetailsGateway.GetHeightNeededOriginal(workId);
                            string originalAvailable = fullLengthLiningWorkDetailsGateway.GetAvailableOriginal(workId);
                            string originalHoistHeight = fullLengthLiningWorkDetailsGateway.GetHoistHeightOriginal(workId);
                            string originalCommentsCipp = fullLengthLiningWorkDetailsGateway.GetCommentsCippOriginal(workId);
                            string originalResinLabel = fullLengthLiningWorkDetailsGateway.GetResinsLabelOriginal(workId);
                            string originalDrumContainsLabel = fullLengthLiningWorkDetailsGateway.GetDrumContainsLabelOriginal(workId);
                            string originalLinerTubeLabel = fullLengthLiningWorkDetailsGateway.GetLinerTubeLabelOriginal(workId);
                            string originalForLbDrumsLabel = fullLengthLiningWorkDetailsGateway.GetForLbDrumsLabelOriginal(workId);
                            string originalNetResinLabel = fullLengthLiningWorkDetailsGateway.GetNetResinLabelOriginal(workId);
                            string originalCatalystLabel = fullLengthLiningWorkDetailsGateway.GetCatalystLabelOriginal(workId);

                            // Wet Out new data
                            string newLinerTube = fullLengthLiningWorkDetailsGateway.GetLinerTube(workId);
                            int newResinID = fullLengthLiningWorkDetailsGateway.GetResinId(workId);
                            decimal newExcessResin = fullLengthLiningWorkDetailsGateway.GetExcessResin(workId);
                            string newPoundsDrums = fullLengthLiningWorkDetailsGateway.GetPoundsDrums(workId);
                            decimal newDrumDiameter = fullLengthLiningWorkDetailsGateway.GetDrumDiameter(workId);
                            decimal newHoistMaximumHeight = fullLengthLiningWorkDetailsGateway.GetHoistMaximumHeight(workId);
                            decimal newHoistMinimumHeight = fullLengthLiningWorkDetailsGateway.GetHoistMinimumHeight(workId);
                            decimal newDownDropTubeLenght = fullLengthLiningWorkDetailsGateway.GetDownDropTubeLenght(workId);
                            decimal newPumpHeightAboveGround = fullLengthLiningWorkDetailsGateway.GetPumpHeightAboveGround(workId);
                            int newTubeResinToFeltFactor = fullLengthLiningWorkDetailsGateway.GetTubeResinToFeltFactor(workId);
                            DateTime newDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheet(workId);
                            int newEmployeeID = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId);
                            string newRunDetails = fullLengthLiningWorkDetailsGateway.GetRunDetails(workId);
                            string newRunDetails2 = fullLengthLiningWorkDetailsGateway.GetRunDetails2(workId);
                            DateTime newWetOutDate = fullLengthLiningWorkDetailsGateway.GetWetOutDate(workId);
                            DateTime? newWetOutInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);
                            string newThickness = fullLengthLiningWorkDetailsGateway.GetInversionThickness(workId);
                            decimal newLengthToLine = fullLengthLiningWorkDetailsGateway.GetLengthToLine(workId);
                            decimal newPlusExtra = fullLengthLiningWorkDetailsGateway.GetPlusExtra(workId);
                            decimal newForTurnOffset = fullLengthLiningWorkDetailsGateway.GetForTurnOffset(workId);
                            decimal newLengthToWetOut = fullLengthLiningWorkDetailsGateway.GetLengthToWetOut(workId);
                            decimal newTubeMaxColdHead = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHead(workId);
                            decimal newTubeMaxColdHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHeadPsi(workId);
                            decimal newTubeMaxHotHead = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHead(workId);
                            decimal newTubeMaxHotHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHeadPsi(workId);
                            decimal newTubeIdealHead = fullLengthLiningWorkDetailsGateway.GetTubeIdealHead(workId);
                            decimal newTubeIdealHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeIdealHeadPsi(workId);
                            decimal newNetResinForTube = fullLengthLiningWorkDetailsGateway.GetNetResinForTube(workId);
                            decimal newNetResinForTubeUsgals = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgals(workId);
                            string newNetResinForTubeDrumsIns = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeDrumsIns(workId);
                            decimal newNetResinForTubeLbsFt = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeLbsFt(workId);
                            decimal newNetResinForTubeUsgFt = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgFt(workId);
                            int newExtraResinForMix = fullLengthLiningWorkDetailsGateway.GetExtraResinForMix(workId);
                            decimal newExtraLbsForMix = fullLengthLiningWorkDetailsGateway.GetExtraLbsForMix(workId);
                            decimal newTotalMixQuantity = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantity(workId);
                            decimal newTotalMixQuantityUsgals = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityUsgals(workId);
                            string newTotalMixQuantityDrumsIns = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityDrumsIns(workId);
                            string newInversionType = fullLengthLiningWorkDetailsGateway.GetInversionType(workId);
                            decimal newDepthOfInversionMH = fullLengthLiningWorkDetailsGateway.GetDepthOfInversionMH(workId);
                            decimal newTubeForColumn = fullLengthLiningWorkDetailsGateway.GetTubeForColumn(workId);
                            decimal newTubeForStartDry = fullLengthLiningWorkDetailsGateway.GetTubeForStartDry(workId);
                            decimal newTotalTube = fullLengthLiningWorkDetailsGateway.GetTotalTube(workId);
                            string newDropTubeConnects = fullLengthLiningWorkDetailsGateway.GetDropTubeConnects(workId);
                            decimal newAllowsHeadTo = fullLengthLiningWorkDetailsGateway.GetAllowsHeadTo(workId);
                            decimal newRollerGap = fullLengthLiningWorkDetailsGateway.GetRollerGap(workId);
                            decimal newHeightNeeded = fullLengthLiningWorkDetailsGateway.GetHeightNeeded(workId);
                            string newAvailable = fullLengthLiningWorkDetailsGateway.GetAvailable(workId);
                            string newHoistHeight = fullLengthLiningWorkDetailsGateway.GetHoistHeight(workId);
                            string newCommentsCipp = fullLengthLiningWorkDetailsGateway.GetCommentsCipp(workId);
                            string newResinLabel = fullLengthLiningWorkDetailsGateway.GetResinsLabel(workId);
                            string newDrumContainsLabel = fullLengthLiningWorkDetailsGateway.GetDrumContainsLabel(workId);
                            string newLinerTubeLabel = fullLengthLiningWorkDetailsGateway.GetLinerTubeLabel(workId);
                            string newForLbDrumsLabel = fullLengthLiningWorkDetailsGateway.GetForLbDrumsLabel(workId);
                            string newNetResinLabel = fullLengthLiningWorkDetailsGateway.GetNetResinLabel(workId);
                            string newCatalystLabel = fullLengthLiningWorkDetailsGateway.GetCatalystLabel(workId);

                            string originalInversionComment = "";
                            string originalPipeType = "";
                            string originalPipeCondition = "";
                            string originalGroundMoisture = "";
                            decimal originalBoilerSize = 0m;
                            decimal originalPumpTotalCapacity = 0m;
                            decimal originalLayFlatSize = 0m;
                            decimal originalLayFlatQuantityTotal = 0m;
                            decimal originalWaterStartTemp = 0m;
                            decimal originalTemp1 =  0m;
                            decimal originalHoldAtT1 = 0m;
                            decimal originalTempT2 = 0m;
                            decimal originalCookAtT2 = 0m;
                            decimal originalCoolDownFor = 0m;
                            decimal originalCoolToTemp = 0m;
                            decimal originalDropInPipeRun = 0m;
                            decimal originalPipeSlopOf = 0m;
                            decimal originalF45F120 = 0m;
                            decimal originalHold = 0m;
                            decimal originalF120F185 = 0m;
                            decimal originalCookTime = 0m;
                            decimal originalCoolTime = 0m;
                            decimal originalAproxTotal = 0m;
                            decimal originalWaterChangesPerHour = 0m;
                            decimal originalReturnWaterVelocity = 0m;
                            decimal originalLayflatBackPressure = 0m;
                            decimal originalPumpLiftAtIdealHead = 0m;
                            decimal originalWaterToFillLinerColumn = 0m;
                            decimal originalWaterPerFit = 0m;
                            string originalInstallationResults = "";
                            string originalInversionLinerTubeLabel = "";
                            string originalHeadsIdealLabel = "";
                            string originalPumpingAndCirculationLabel = "";

                            // Inversion new Data
                            string newInversionComment = "";
                            string newPipeType = "";
                            string newPipeCondition = "";
                            string newGroundMoisture = "";
                            decimal newBoilerSize = 0m;
                            decimal newPumpTotalCapacity = 0m;
                            decimal newLayFlatSize = 0m;
                            decimal newLayFlatQuantityTotal = 0m;
                            decimal newWaterStartTemp = 0m;
                            decimal newTemp1 = 0m;
                            decimal newHoldAtT1 = 0m;
                            decimal newTempT2 = 0m;
                            decimal newCookAtT2 = 0m;
                            decimal newCoolDownFor = 0m;
                            decimal newCoolToTemp = 0m;
                            decimal newDropInPipeRun = 0m;
                            decimal newPipeSlopOf = 0m;
                            decimal newF45F120 = 0m;
                            decimal newHold = 0m;
                            decimal newF120F185 = 0m;
                            decimal newCookTime = 0m;
                            decimal newCoolTime = 0m;
                            decimal newAproxTotal = 0m;
                            decimal newWaterChangesPerHour = 0m;
                            decimal newReturnWaterVelocity = 0m;
                            decimal newLayflatBackPressure = 0m;
                            decimal newPumpLiftAtIdealHead = 0m;
                            decimal newWaterToFillLinerColumn = 0m;
                            decimal newWaterPerFit = 0m;
                            string newInstallationResults = "";
                            string newInversionLinerTubeLabel = "";
                            string newHeadsIdealLabel = "";
                            string newPumpingAndCirculationLabel = "";

                            if (includeInversionInformation)
                            {
                                // InversionData original values
                                originalInversionComment = fullLengthLiningWorkDetailsGateway.GetInversionCommentOriginal(workId);
                                originalPipeType = fullLengthLiningWorkDetailsGateway.GetPipeTypeOriginal(workId);
                                originalPipeCondition = fullLengthLiningWorkDetailsGateway.GetPipeConditionOriginal(workId);
                                originalGroundMoisture = fullLengthLiningWorkDetailsGateway.GetGroundMoistureOriginal(workId);
                                originalBoilerSize = fullLengthLiningWorkDetailsGateway.GetBoilerSizeOriginal(workId);
                                originalPumpTotalCapacity = fullLengthLiningWorkDetailsGateway.GetPumpTotalCapacityOriginal(workId);
                                originalLayFlatSize = fullLengthLiningWorkDetailsGateway.GetLayFlatSizeOriginal(workId);
                                originalLayFlatQuantityTotal = fullLengthLiningWorkDetailsGateway.GetLayFlatQuantityTotalOriginal(workId);
                                originalWaterStartTemp = fullLengthLiningWorkDetailsGateway.GetWaterStartTempOriginal(workId);
                                originalTemp1 = fullLengthLiningWorkDetailsGateway.GetTemp1Original(workId);
                                originalHoldAtT1 = fullLengthLiningWorkDetailsGateway.GetHoldAtT1Original(workId);
                                originalTempT2 = fullLengthLiningWorkDetailsGateway.GetTempT2Original(workId);
                                originalCookAtT2 = fullLengthLiningWorkDetailsGateway.GetCookAtT2Original(workId);
                                originalCoolDownFor = fullLengthLiningWorkDetailsGateway.GetCoolDownForOriginal(workId);
                                originalCoolToTemp = fullLengthLiningWorkDetailsGateway.GetCoolToTempOriginal(workId);
                                originalDropInPipeRun = fullLengthLiningWorkDetailsGateway.GetDropInPipeRunOriginal(workId);
                                originalPipeSlopOf = fullLengthLiningWorkDetailsGateway.GetPipeSlopOfOriginal(workId);
                                originalF45F120 = fullLengthLiningWorkDetailsGateway.GetF45F120Original(workId);
                                originalHold = fullLengthLiningWorkDetailsGateway.GetHoldOriginal(workId);
                                originalF120F185 = fullLengthLiningWorkDetailsGateway.GetF120F185Original(workId);
                                originalCookTime = fullLengthLiningWorkDetailsGateway.GetCookTimeOriginal(workId);
                                originalCoolTime = fullLengthLiningWorkDetailsGateway.GetCoolTimeOriginal(workId);
                                originalAproxTotal = fullLengthLiningWorkDetailsGateway.GetAproxTotalOriginal(workId);
                                originalWaterChangesPerHour = fullLengthLiningWorkDetailsGateway.GetWaterChangesPerHourOriginal(workId);
                                originalReturnWaterVelocity = fullLengthLiningWorkDetailsGateway.GetReturnWaterVelocityOriginal(workId);
                                originalLayflatBackPressure = fullLengthLiningWorkDetailsGateway.GetLayflatBackPressureOriginal(workId);
                                originalPumpLiftAtIdealHead = fullLengthLiningWorkDetailsGateway.GetPumpLiftAtIdealHeadOriginal(workId);
                                originalWaterToFillLinerColumn = fullLengthLiningWorkDetailsGateway.GetWaterToFillLinerColumnOriginal(workId);
                                originalWaterPerFit = fullLengthLiningWorkDetailsGateway.GetWaterPerFitOriginal(workId);
                                originalInstallationResults = fullLengthLiningWorkDetailsGateway.GetInstallationResultsOriginal(workId);
                                originalInversionLinerTubeLabel = fullLengthLiningWorkDetailsGateway.GetInversionLinerTubeLabelOriginal(workId);
                                originalHeadsIdealLabel = fullLengthLiningWorkDetailsGateway.GetHeadsIdealLabelOriginal(workId);
                                originalPumpingAndCirculationLabel = fullLengthLiningWorkDetailsGateway.GetPumpingAndCirculationLabelOriginal(workId);

                                // Inversion new Data
                                newInversionComment = fullLengthLiningWorkDetailsGateway.GetInversionComment(workId);
                                newPipeType = fullLengthLiningWorkDetailsGateway.GetPipeType(workId);
                                newPipeCondition = fullLengthLiningWorkDetailsGateway.GetPipeCondition(workId);
                                newGroundMoisture = fullLengthLiningWorkDetailsGateway.GetGroundMoisture(workId);
                                newBoilerSize = fullLengthLiningWorkDetailsGateway.GetBoilerSize(workId);
                                newPumpTotalCapacity = fullLengthLiningWorkDetailsGateway.GetPumpTotalCapacity(workId);
                                newLayFlatSize = fullLengthLiningWorkDetailsGateway.GetLayFlatSize(workId);
                                newLayFlatQuantityTotal = fullLengthLiningWorkDetailsGateway.GetLayFlatQuantityTotal(workId);
                                newWaterStartTemp = fullLengthLiningWorkDetailsGateway.GetWaterStartTemp(workId);
                                newTemp1 = fullLengthLiningWorkDetailsGateway.GetTemp1(workId);
                                newHoldAtT1 = fullLengthLiningWorkDetailsGateway.GetHoldAtT1(workId);
                                newTempT2 = fullLengthLiningWorkDetailsGateway.GetTempT2(workId);
                                newCookAtT2 = fullLengthLiningWorkDetailsGateway.GetCookAtT2(workId);
                                newCoolDownFor = fullLengthLiningWorkDetailsGateway.GetCoolDownFor(workId);
                                newCoolToTemp = fullLengthLiningWorkDetailsGateway.GetCoolToTemp(workId);
                                newDropInPipeRun = fullLengthLiningWorkDetailsGateway.GetDropInPipeRun(workId);
                                newPipeSlopOf = fullLengthLiningWorkDetailsGateway.GetPipeSlopOf(workId);
                                newF45F120 = fullLengthLiningWorkDetailsGateway.GetF45F120(workId);
                                newHold = fullLengthLiningWorkDetailsGateway.GetHold(workId);
                                newF120F185 = fullLengthLiningWorkDetailsGateway.GetF120F185(workId);
                                newCookTime = fullLengthLiningWorkDetailsGateway.GetCookTime(workId);
                                newCoolTime = fullLengthLiningWorkDetailsGateway.GetCoolTime(workId);
                                newAproxTotal = fullLengthLiningWorkDetailsGateway.GetAproxTotal(workId);
                                newWaterChangesPerHour = fullLengthLiningWorkDetailsGateway.GetWaterChangesPerHour(workId);
                                newReturnWaterVelocity = fullLengthLiningWorkDetailsGateway.GetReturnWaterVelocity(workId);
                                newLayflatBackPressure = fullLengthLiningWorkDetailsGateway.GetLayflatBackPressure(workId);
                                newPumpLiftAtIdealHead = fullLengthLiningWorkDetailsGateway.GetPumpLiftAtIdealHead(workId);
                                newWaterToFillLinerColumn = fullLengthLiningWorkDetailsGateway.GetWaterToFillLinerColumn(workId);
                                newWaterPerFit = fullLengthLiningWorkDetailsGateway.GetWaterPerFit(workId);
                                newInstallationResults = fullLengthLiningWorkDetailsGateway.GetInstallationResults(workId);
                                newInversionLinerTubeLabel = fullLengthLiningWorkDetailsGateway.GetInversionLinerTubeLabel(workId);
                                newHeadsIdealLabel = fullLengthLiningWorkDetailsGateway.GetHeadsIdealLabel(workId);
                                newPumpingAndCirculationLabel = fullLengthLiningWorkDetailsGateway.GetPumpingAndCirculationLabel(workId);
                            }

                            // Get All sectionIds for insert
                            string runDetails = row.RunDetails;
                            string[] runDetailsList = runDetails.Split('>');

                            for (int i = 0; i < runDetailsList.Length; i++)
                            {
                                AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                                string sectionId = runDetailsList[i].ToString();
                                assetSewerSectionGateway.LoadBySectionId(sectionId, companyId);
                                int assetId = assetSewerSectionGateway.GetAssetID(sectionId);

                                WorkGateway workGateway = new WorkGateway();
                                int newWorkId = 0;
                                workGateway.LoadByProjectIdAssetIdWorkType(projectId, assetId, "Full Length Lining", companyId);
                                if (workGateway.Table.Rows.Count > 0)
                                {
                                    newWorkId = workGateway.GetWorkId(assetId, "Full Length Lining", projectId);
                                }

                                WorkFullLengthLiningWetOutGateway workFullLengthLiningWetOutGatewayForReview = new WorkFullLengthLiningWetOutGateway();
                                workFullLengthLiningWetOutGatewayForReview.LoadByWorkId(newWorkId, companyId);
                                if (workFullLengthLiningWetOutGatewayForReview.Table.Rows.Count > 0)
                                {
                                    // Update work with cipp information
                                    UpdateWorkWetOutInformation(newWorkId, originalLinerTube, originalResinID, originalExcessResin, originalPoundsDrums, originalDrumDiameter, originalHoistMaximumHeight, originalHoistMinimumHeight, originalDownDropTubeLenght, originalPumpHeightAboveGround, originalTubeResinToFeltFactor, originalDateOfSheet, originalEmployeeID, originalRunDetails, originalRunDetails2, originalWetOutDate, originalWetOutInstallDate, originalThickness, originalLengthToLine, originalPlusExtra, originalForTurnOffset, originalLengthToWetOut, originalTubeMaxColdHead, originalTubeMaxColdHeadPsi, originalTubeMaxHotHead, originalTubeMaxHotHeadPsi, originalTubeIdealHead, originalTubeIdealHeadPsi, originalNetResinForTube, originalNetResinForTubeUsgals, originalNetResinForTubeDrumsIns, originalNetResinForTubeLbsFt, originalNetResinForTubeUsgFt, originalExtraResinForMix, originalExtraLbsForMix, originalTotalMixQuantity, originalTotalMixQuantityUsgals, originalTotalMixQuantityDrumsIns, originalInversionType, originalDepthOfInversionMH, originalTubeForColumn, originalTubeForStartDry, originalTotalTube, originalDropTubeConnects, originalAllowsHeadTo, originalRollerGap, originalHeightNeeded, originalAvailable, originalHoistHeight, originalCommentsCipp, originalResinLabel, originalDrumContainsLabel, originalLinerTubeLabel, originalForLbDrumsLabel, originalNetResinLabel, originalCatalystLabel, originalInversionComment, originalPipeType, originalPipeCondition, originalGroundMoisture, originalBoilerSize, originalPumpTotalCapacity, originalLayFlatSize, originalLayFlatQuantityTotal, originalWaterStartTemp, originalTemp1, originalHoldAtT1, originalTempT2, originalCookAtT2, originalCoolDownFor, originalCoolToTemp, originalDropInPipeRun, originalPipeSlopOf, originalF45F120, originalHold, originalF120F185, originalCookTime, originalCoolTime, originalAproxTotal, originalWaterChangesPerHour, originalReturnWaterVelocity, originalLayflatBackPressure, originalPumpLiftAtIdealHead, originalWaterToFillLinerColumn, originalWaterPerFit, originalInstallationResults, originalInversionLinerTubeLabel, originalHeadsIdealLabel, originalPumpingAndCirculationLabel, false, companyId, newLinerTube, newResinID, newExcessResin, newPoundsDrums, newDrumDiameter, newHoistMaximumHeight, newHoistMinimumHeight, newDownDropTubeLenght, newPumpHeightAboveGround, newTubeResinToFeltFactor, newDateOfSheet, newEmployeeID, newRunDetails, newRunDetails2, newWetOutDate, newWetOutInstallDate, newThickness, newLengthToLine, newPlusExtra, newForTurnOffset, newLengthToWetOut, newTubeMaxColdHead, newTubeMaxColdHeadPsi, newTubeMaxHotHead, newTubeMaxHotHeadPsi, newTubeIdealHead, newTubeIdealHeadPsi, newNetResinForTube, newNetResinForTubeUsgals, newNetResinForTubeDrumsIns, newNetResinForTubeLbsFt, newNetResinForTubeUsgFt, newExtraResinForMix, newExtraLbsForMix, newTotalMixQuantity, newTotalMixQuantityUsgals, newTotalMixQuantityDrumsIns, newInversionType, newDepthOfInversionMH, newTubeForColumn, newTubeForStartDry, newTotalTube, newDropTubeConnects, newAllowsHeadTo, newRollerGap, newHeightNeeded, newAvailable, newHoistHeight, newCommentsCipp, newResinLabel, newDrumContainsLabel, newLinerTubeLabel, newForLbDrumsLabel, newNetResinLabel, newCatalystLabel, newInversionComment, newPipeType, newPipeCondition, newGroundMoisture, newBoilerSize, newPumpTotalCapacity, newLayFlatSize, newLayFlatQuantityTotal, newWaterStartTemp, newTemp1, newHoldAtT1, newTempT2, newCookAtT2, newCoolDownFor, newCoolToTemp, newDropInPipeRun, newPipeSlopOf, newF45F120, newHold, newF120F185, newCookTime, newCoolTime, newAproxTotal, newWaterChangesPerHour, newReturnWaterVelocity, newLayflatBackPressure, newPumpLiftAtIdealHead, newWaterToFillLinerColumn, newWaterPerFit, newInstallationResults, newInversionLinerTubeLabel, newHeadsIdealLabel, newPumpingAndCirculationLabel, false, companyId, includeWetOutInformation, includeInversionInformation);
                                }
                                else
                                {
                                    // ... Insert wet out data
                                    string inversionComment = fullLengthLiningWorkDetailsGateway.GetInversionComment(workId);
                                    string installationResults = fullLengthLiningWorkDetailsGateway.GetInstallationResults(workId);
                                    DateTime? wetOutInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);

                                    InsertWorkWetOutInformation(newWorkId, row.LinerTube, row.ResinID, row.ExcessResin, row.PoundsDrums, row.DrumDiameter, row.HoistMaximumHeight, row.HoistMinimumHeight, row.DownDropTubeLenght, row.PumpHeightAboveGround, row.TubeResinToFeltFactor, row.DateOfSheet, row.EmployeeID, row.RunDetails, row.RunDetails2, row.WetOutDate, wetOutInstallDate, row.Thickness, row.LengthToLine, row.PlusExtra, row.ForTurnOffset, row.LengthToWetOut, row.TubeMaxColdHead, row.TubeMaxColdHeadPsi, row.TubeMaxHotHead, row.TubeMaxHotHeadPsi, row.TubeIdealHead, row.TubeIdealHeadPsi, row.NetResinForTube, row.NetResinForTubeUsgals, row.NetResinForTubeDrumsIns, row.NetResinForTubeLbsFt, row.NetResinForTubeUsgFt, row.ExtraResinForMix, row.ExtraLbsForMix, row.TotalMixQuantity, row.TotalMixQuantityUsgals, row.TotalMixQuantityDrumsIns, row.InversionType, row.DepthOfInversionMH, row.TubeForColumn, row.TubeForStartDry, row.TotalTube, row.DropTubeConnects, row.AllowsHeadTo, row.RollerGap, row.HeightNeeded, row.Available, row.HoistHeight, row.CommentsCipp, row.ResinsLabel, row.DrumContainsLabel, row.LinerTubeLabel, row.ForLbDrumsLabel, row.NetResinLabel, row.CatalystLabel, inversionComment, row.PipeType, row.PipeCondition, row.GroundMoisture, row.BoilerSize, row.PumpTotalCapacity, row.LayFlatSize, row.LayFlatQuantityTotal, row.WaterStartTemp, row.Temp1, row.HoldAtT1, row.TempT2, row.CookAtT2, row.CoolDownFor, row.CoolToTemp, row.DropInPipeRun, row.PipeSlopOf, row.F45F120, row.Hold, row.F120F185, row.CookTime, row.CoolTime, row.AproxTotal, row.WaterChangesPerHour, row.ReturnWaterVelocity, row.LayflatBackPressure, row.PumpLiftAtIdealHead, row.WaterToFillLinerColumn, row.WaterPerFit, installationResults, row.InversionLinerTubeLabel, row.HeadsIdealLabel, row.PumpingAndCirculationLabel, row.Deleted, row.COMPANY_ID, includeWetOutInformation, includeInversionInformation);
                                }
                            }
                        }
                        else
                        {
                            // Get All sectionIds for insert
                            string runDetails = row.RunDetails;
                            string[] runDetailsList = runDetails.Split('>');

                            for (int i = 0; i < runDetailsList.Length; i++)
                            {
                                AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                                string sectionId = runDetailsList[i].ToString();
                                assetSewerSectionGateway.LoadBySectionId(sectionId, companyId);
                                int assetId = assetSewerSectionGateway.GetAssetID(sectionId);

                                WorkGateway workGateway = new WorkGateway();
                                workGateway.LoadByProjectIdAssetIdWorkType(projectId, assetId, "Full Length Lining", companyId);
                                if (workGateway.Table.Rows.Count > 0)
                                {
                                    int newWorkId = workGateway.GetWorkId(assetId, "Full Length Lining", projectId);

                                    // ... Insert wet out data
                                    string inversionComment = fullLengthLiningWorkDetailsGateway.GetInversionComment(workId);
                                    string installationResults = fullLengthLiningWorkDetailsGateway.GetInstallationResults(workId);
                                    DateTime? wetOutInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);

                                    InsertWorkWetOutInformation(newWorkId, row.LinerTube, row.ResinID, row.ExcessResin, row.PoundsDrums, row.DrumDiameter, row.HoistMaximumHeight, row.HoistMinimumHeight, row.DownDropTubeLenght, row.PumpHeightAboveGround, row.TubeResinToFeltFactor, row.DateOfSheet, row.EmployeeID, row.RunDetails, row.RunDetails2, row.WetOutDate, wetOutInstallDate, row.Thickness, row.LengthToLine, row.PlusExtra, row.ForTurnOffset, row.LengthToWetOut, row.TubeMaxColdHead, row.TubeMaxColdHeadPsi, row.TubeMaxHotHead, row.TubeMaxHotHeadPsi, row.TubeIdealHead, row.TubeIdealHeadPsi, row.NetResinForTube, row.NetResinForTubeUsgals, row.NetResinForTubeDrumsIns, row.NetResinForTubeLbsFt, row.NetResinForTubeUsgFt, row.ExtraResinForMix, row.ExtraLbsForMix, row.TotalMixQuantity, row.TotalMixQuantityUsgals, row.TotalMixQuantityDrumsIns, row.InversionType, row.DepthOfInversionMH, row.TubeForColumn, row.TubeForStartDry, row.TotalTube, row.DropTubeConnects, row.AllowsHeadTo, row.RollerGap, row.HeightNeeded, row.Available, row.HoistHeight, row.CommentsCipp, row.ResinsLabel, row.DrumContainsLabel, row.LinerTubeLabel, row.ForLbDrumsLabel, row.NetResinLabel, row.CatalystLabel, inversionComment, row.PipeType, row.PipeCondition, row.GroundMoisture, row.BoilerSize, row.PumpTotalCapacity, row.LayFlatSize, row.LayFlatQuantityTotal, row.WaterStartTemp, row.Temp1, row.HoldAtT1, row.TempT2, row.CookAtT2, row.CoolDownFor, row.CoolToTemp, row.DropInPipeRun, row.PipeSlopOf, row.F45F120, row.Hold, row.F120F185, row.CookTime, row.CoolTime, row.AproxTotal, row.WaterChangesPerHour, row.ReturnWaterVelocity, row.LayflatBackPressure, row.PumpLiftAtIdealHead, row.WaterToFillLinerColumn, row.WaterPerFit, installationResults, row.InversionLinerTubeLabel, row.HeadsIdealLabel, row.PumpingAndCirculationLabel, row.Deleted, row.COMPANY_ID, includeWetOutInformation, includeInversionInformation);
                                }
                            }
                        }
                    }

                    // Update JL Section WorkID
                    int sectionWorkId = 0;
                    WorkGateway workGatewayForJL = new WorkGateway();
                    workGatewayForJL.LoadByProjectIdAssetIdWorkType(projectId, sectionAssetId, "Junction Lining Section", companyId);

                    if (workGatewayForJL.Table.Rows.Count > 0)
                    {
                        sectionWorkId = workGatewayForJL.GetWorkId(sectionAssetId, "Junction Lining Section", projectId);
                        WorkJunctionLiningSectionGateway workJunctionLiningSectionGateway = new WorkJunctionLiningSectionGateway();
                        workJunctionLiningSectionGateway.LoadByWorkId(sectionWorkId, companyId);

                        // get old values of section
                        int numLats = workJunctionLiningSectionGateway.GetNumLats(sectionWorkId);
                        int notLinedYet = workJunctionLiningSectionGateway.GetNotLinedYet(sectionWorkId);
                        bool allMeasured = workJunctionLiningSectionGateway.GetAllMeasured(sectionWorkId);
                        bool deleted = workJunctionLiningSectionGateway.GetDeleted(sectionWorkId);
                        string issueWithLaterals = workJunctionLiningSectionGateway.GetIssueWithLaterals(sectionWorkId);
                        int notMeasuredYet = workJunctionLiningSectionGateway.GetNotMeasuredYet(sectionWorkId);
                        int notDeliveredYet = workJunctionLiningSectionGateway.GetNotDeliveredYet(sectionWorkId);
                        string trafficControl = workJunctionLiningSectionGateway.GetTrafficControl(sectionWorkId);
                        string trafficControlDetails = workJunctionLiningSectionGateway.GetTrafficControlDetails(sectionWorkId);
                        bool standardBypass = workJunctionLiningSectionGateway.GetStandardBypass(sectionWorkId);
                        string standardBypassComments = workJunctionLiningSectionGateway.GetStandardBypassComments(sectionWorkId);
                        int availableToLine = workJunctionLiningSectionGateway.GetAvailableToLine(sectionWorkId);

                        WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null);
                        workJunctionLiningSection.UpdateDirect(sectionWorkId, numLats, notLinedYet, allMeasured, deleted, issueWithLaterals, notMeasuredYet, notDeliveredYet, companyId, trafficControl, trafficControlDetails, standardBypass, standardBypassComments, availableToLine, numLats, notLinedYet, allMeasured, issueWithLaterals, notMeasuredYet, notDeliveredYet, newTrafficControl, newTrafficControlDetails, newStandardBypass, newStandardBypassComments, availableToLine);
                    }
                }
            }
        }
        /// <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);
        }
Пример #6
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            // Set active toolbar
            mForm8 master = (mForm8)this.Master;
            master.ActiveToolbar = "eSewers";

            // For error message
            hdfErrorFieldList.Value = "";
            if ((tbxWetOutDataHoistHeight.Text == "OK")|| (tbxWetOutDataHoistHeight.Text == ""))
            {
                lblWetOutDataWarning.Visible = false;
            }
            else
            {
                lblWetOutDataWarning.Visible = true;
            }

            // For Video Done From MH and Measured From MH
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int assetId = Int32.Parse(hdfAssetId.Value);
            int workId = Int32.Parse(hdfWorkId.Value);
            int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());

            // set visible VideoDoneFromMh and Measured From and To
            FullLengthLiningWorkDetailsGateway flWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
            flWorkDetailsGateway.LoadByWorkIdAssetId(workId, assetId, companyId);

            FullLengthLiningLateralDetails flLateralDetails = new FullLengthLiningLateralDetails();
            flLateralDetails.LoadForEdit(workId, assetId, companyId, currentProjectId);

            if (Int32.Parse(tbxLaterals.Text) > 0)
            {
                ddlM1DataVideoDoneFromMh.Visible = false;
                tbxM1DataVideoDoneFromMh.Visible = true;
                tbxM1DataVideoDoneFromMh.Text = ddlM1DataVideoDoneFromMh.SelectedValue;

                ddlM1DataVideoDoneToMh.Visible = false;
                tbxM1DataVideoDoneToMh.Visible = true;
                tbxM1DataVideoDoneToMh.Text = ddlM1DataVideoDoneToMh.SelectedValue;

                ddlM1DataMeasuredFromMh.Visible = false;
                tbxM1DataMeasuredFromMh.Visible = true;
                tbxM1DataMeasuredFromMh.Text = ddlM1DataMeasuredFromMh.SelectedValue;

                btnClear.Visible = false;
            }
            else
            {
                ddlM1DataVideoDoneFromMh.Visible = true;
                tbxM1DataVideoDoneFromMh.Visible = false;

                ddlM1DataVideoDoneToMh.Visible = true;
                tbxM1DataVideoDoneToMh.Visible = false;

                ddlM1DataMeasuredFromMh.Visible = true;
                tbxM1DataMeasuredFromMh.Visible = false;

                btnClear.Visible = true;
            }

            // For materials (m1)
            MaterialInformationGateway materialInformationGateway = new MaterialInformationGateway();
            materialInformationGateway.LoadLastMaterialByAssetId(assetId, companyId);

            if (materialInformationGateway.Table.Rows.Count > 0)
            {
                ddlM1DataMaterial.SelectedValue = materialInformationGateway.GetLastMaterialType(assetId);
            }

            // For PreFlush Date and PreVideo Date
            int projectId = Int32.Parse(hdfCurrentProjectId.Value);
            FullLengthLiningWorkDetailsGateway  fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
            fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workId, assetId, companyId);

            int? raProjectId = fullLengthLiningWorkDetailsGateway.GetRaProjectId(workId);
            if ((raProjectId.HasValue) && (raProjectId == projectId))
            {
                // ... if ra data is from the same project
                tkrdpGeneralPreFlushDate.Visible = true;
                tkrdpGeneralPreVideoDate.Visible = true;
                tkrdpGeneralPreFlushDateReadOnly.Visible = false;
                tkrdpGeneralPreVideoDateReadOnly.Visible = false;
            }
            else
            {
                tkrdpGeneralPreFlushDate.Visible = false;
                tkrdpGeneralPreVideoDate.Visible = false;
                tkrdpGeneralPreFlushDateReadOnly.Visible = true;
                tkrdpGeneralPreVideoDateReadOnly.Visible = true;
            }
            // ... if there is no data
            if (tkrdpGeneralPreFlushDate.SelectedDate.HasValue)
            {
                tkrdpGeneralPreFlushDate.Calendar.Enabled = false;
                tkrdpGeneralPreFlushDate.DateInput.ReadOnly = true;
            }
            else
            {
                tkrdpGeneralPreFlushDate.Calendar.Enabled = true;
                tkrdpGeneralPreFlushDate.DateInput.ReadOnly = false;
            }

            if (tkrdpGeneralPreVideoDate.SelectedDate.HasValue)
            {
                tkrdpGeneralPreVideoDate.Calendar.Enabled = false;
                tkrdpGeneralPreVideoDate.DateInput.ReadOnly = true;
            }
            else
            {
                tkrdpGeneralPreVideoDate.Calendar.Enabled = true;
                tkrdpGeneralPreVideoDate.DateInput.ReadOnly = false;
            }

            // Hide or show the Old CWP ID field
            if (tbxOldCwpId.Text == "")
            {
                lblOldCwpId.Visible = false;
                tbxOldCwpId.Visible = false;
            }

            if (tbxFlowSectionId.Text == "")
            {
                LoadFullLengthLiningData(currentProjectId, assetId, companyId);
            }

            // Validate tools
            if (Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_ADMIN"]))
            {
                tkrpbLeftMenuTools.Items[0].Items[1].Visible = true; // Resins option
                tkrpbLeftMenuTools.Items[0].Items[2].Visible = true; // Catalyst option

                tkrdpInstallDataInstallDate.Enabled = true;
                tkrdpInstallDataFinalVideoDate.Enabled = true;
            }
            else
            {
                tkrpbLeftMenuTools.Items[0].Items[1].Visible = false; // Resins option
                tkrpbLeftMenuTools.Items[0].Items[2].Visible = false; // Catalyst option

                tkrdpInstallDataInstallDate.Enabled = false;
                tkrdpInstallDataFinalVideoDate.Enabled = false;
            }
        }
        /// <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 METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        private void UpdateForReport(string unitType)
        {
            FlReinstateLateralReportGateway flReinstateLateralReportGateway = new FlReinstateLateralReportGateway(Data);
            flReinstateLateralReportGateway.ClearBeforeFill = false;
            FlReinstateLateralReport flReinstateLateralReport = new FlReinstateLateralReport(Data);

            foreach (FlReinstateReportTDS.ReinstateSectionRow row in (FlReinstateReportTDS.ReinstateSectionDataTable)Table)
            {
                int workId = row.WorkID;
                FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workId, row.AssetID, row.COMPANY_ID);
                string measurementFromMH = "USMH"; if (fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId) != "") measurementFromMH = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);

                Distance d;

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

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

                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.IsLengthNull())
                    {
                        d = new Distance(row.Length);
                        row.Length = d.ToStringInEng2();
                    }
                }

                flReinstateLateralReportGateway.LoadByAssetId(row.AssetID, row.COMPANY_ID);
                flReinstateLateralReport.UpdateForReport(row.FlowOrderID, unitType, measurementFromMH);
            }
        }
        private void workUpdate()
        {
            // Get general variables
            int workId = Int32.Parse(hdfWorkId.Value.Trim());
            int assetId = Int32.Parse(hdfAssetId.Value.Trim());
            int originalCompanyId = Int32.Parse(hdfCompanyId.Value.Trim());
            string workType = hdfWorkType.Value.Trim();
            bool originalDeleted = false;

            // Get original variables
            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
            fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workId, assetId, originalCompanyId);

            // ... Verify if work has cipp information
            if (fullLengthLiningWorkDetailsGateway.Table.Rows.Count > 0)
            {
                // Wet Out data original values
                string originalLinerTube = fullLengthLiningWorkDetailsGateway.GetLinerTubeOriginal(workId);
                int originalResinId = fullLengthLiningWorkDetailsGateway.GetResinIdOriginal(workId);
                decimal originalExcessResin = fullLengthLiningWorkDetailsGateway.GetExcessResinOriginal(workId);
                string originalPoundsDrums = fullLengthLiningWorkDetailsGateway.GetPoundsDrumsOriginal(workId);
                decimal originalDrumDiameter = fullLengthLiningWorkDetailsGateway.GetDrumDiameterOriginal(workId);
                decimal originalHoistMaximumHeight = fullLengthLiningWorkDetailsGateway.GetHoistMaximumHeightOriginal(workId);
                decimal originalHoistMinimumHeight = fullLengthLiningWorkDetailsGateway.GetHoistMinimumHeightOriginal(workId);
                decimal originalDownDropTubeLenght = fullLengthLiningWorkDetailsGateway.GetDownDropTubeLenghtOriginal(workId);
                decimal originalPumpHeightAboveGround = fullLengthLiningWorkDetailsGateway.GetPumpHeightAboveGroundOriginal(workId);
                int originalTubeResinToFeltFactor = fullLengthLiningWorkDetailsGateway.GetTubeResinToFeltFactorOriginal(workId);
                DateTime originalDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheetOriginal(workId);
                int originalEmployeeId = fullLengthLiningWorkDetailsGateway.GetEmployeeIdOriginal(workId);
                string originalRunDetails = fullLengthLiningWorkDetailsGateway.GetRunDetailsOriginal(workId);
                string originalRunDetails2 = fullLengthLiningWorkDetailsGateway.GetRunDetails2Original(workId);
                DateTime originalWetOutDate = fullLengthLiningWorkDetailsGateway.GetWetOutDateOriginal(workId);
                DateTime? originalWetOutInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDateOriginal(workId);
                string originalThickness = fullLengthLiningWorkDetailsGateway.GetInversionThicknessOriginal(workId);
                decimal originalLengthToLine = fullLengthLiningWorkDetailsGateway.GetLengthToLineOriginal(workId);
                decimal originalPlusExtra = fullLengthLiningWorkDetailsGateway.GetPlusExtraOriginal(workId);
                decimal originalForTurnOffset = fullLengthLiningWorkDetailsGateway.GetForTurnOffsetOriginal(workId);
                decimal originalLengthToWetOut = fullLengthLiningWorkDetailsGateway.GetLengthToWetOutOriginal(workId);
                decimal originalTubeMaxColdHead = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHeadOriginal(workId);
                decimal originalTubeMaxColdHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHeadPsiOriginal(workId);
                decimal originalTubeMaxHotHead = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHeadOriginal(workId);
                decimal originalTubeMaxHotHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHeadPsiOriginal(workId);
                decimal originalTubeIdealHead = fullLengthLiningWorkDetailsGateway.GetTubeIdealHeadOriginal(workId);
                decimal originalTubeIdealHeadPsi = fullLengthLiningWorkDetailsGateway.GetTubeIdealHeadPsiOriginal(workId);
                decimal originalNetResinForTube = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeOriginal(workId);
                decimal originalNetResinForTubeUsgals = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgalsOriginal(workId);
                string originalNetResinForTubeDrumsIns = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeDrumsInsOriginal(workId);
                decimal originalNetResinForTubeLbsFt = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeLbsFtOriginal(workId);
                decimal originalNetResinForTubeUsgFt = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgFtOriginal(workId);
                int originalExtraResinForMix = fullLengthLiningWorkDetailsGateway.GetExtraResinForMixOriginal(workId);
                decimal originalExtraLbsForMix = fullLengthLiningWorkDetailsGateway.GetExtraLbsForMixOriginal(workId);
                decimal originalTotalMixQuantity = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityOriginal(workId);
                decimal originalTotalMixQuantityUsgals = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityUsgalsOriginal(workId);
                string originalTotalMixQuantityDrumsIns = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityDrumsInsOriginal(workId);
                string originalInversionType = fullLengthLiningWorkDetailsGateway.GetInversionTypeOriginal(workId);
                decimal originalDepthOfInversionMH = fullLengthLiningWorkDetailsGateway.GetDepthOfInversionMHOriginal(workId);
                decimal originalTubeForColumn = fullLengthLiningWorkDetailsGateway.GetTubeForColumnOriginal(workId);
                decimal originalTubeForStartDry = fullLengthLiningWorkDetailsGateway.GetTubeForStartDryOriginal(workId);
                decimal originalTotalTube = fullLengthLiningWorkDetailsGateway.GetTotalTubeOriginal(workId);
                string originalDropTubeConnects = fullLengthLiningWorkDetailsGateway.GetDropTubeConnectsOriginal(workId);
                decimal originalAllowsHeadTo = fullLengthLiningWorkDetailsGateway.GetAllowsHeadToOriginal(workId);
                decimal originalRollerGap = fullLengthLiningWorkDetailsGateway.GetRollerGapOriginal(workId);
                decimal originalHeightNeeded = fullLengthLiningWorkDetailsGateway.GetHeightNeededOriginal(workId);
                string originalAvailable = fullLengthLiningWorkDetailsGateway.GetAvailableOriginal(workId);
                string originalHoistHeight = fullLengthLiningWorkDetailsGateway.GetHoistHeightOriginal(workId);
                string originalCommentsCipp = fullLengthLiningWorkDetailsGateway.GetCommentsCippOriginal(workId);
                string originalResinsLabel = fullLengthLiningWorkDetailsGateway.GetResinsLabelOriginal(workId);
                string originalDrumContainsLabel = fullLengthLiningWorkDetailsGateway.GetDrumContainsLabelOriginal(workId);
                string originalLinerTubeLabel = fullLengthLiningWorkDetailsGateway.GetLinerTubeLabelOriginal(workId);
                string originalForLbDrumsLabel = fullLengthLiningWorkDetailsGateway.GetForLbDrumsLabelOriginal(workId);
                string originalNetResinLabel = fullLengthLiningWorkDetailsGateway.GetNetResinLabelOriginal(workId);
                string originalCatalystLabel = fullLengthLiningWorkDetailsGateway.GetCatalystLabelOriginal(workId);

                // Wet Out new data
                // ... Get new comment
                WorkFullLengthLiningWetOutCommentsGateway workFullLengthLiningWetOutCommentsGateway = new WorkFullLengthLiningWetOutCommentsGateway();
                workFullLengthLiningWetOutCommentsGateway.LoadAllByWorkIdWorkType(workId, originalCompanyId, workType);

                WorkFullLengthLiningWetOutComments workFullLengthLiningWetOutComments = new WorkFullLengthLiningWetOutComments(workFullLengthLiningWetOutCommentsGateway.Data);
                string newComments = workFullLengthLiningWetOutComments.GetCommentsSummary(originalCompanyId, workFullLengthLiningWetOutCommentsGateway.Table.Rows.Count, "\n");

                // Update work with cipp information
                WorkFullLengthLiningWetOut workFullLengthLiningWetOut = new WorkFullLengthLiningWetOut(null);
                workFullLengthLiningWetOut.UpdateDirect(workId, originalLinerTube, originalResinId, originalExcessResin, originalPoundsDrums, originalDrumDiameter, originalHoistMaximumHeight, originalHoistMinimumHeight, originalDownDropTubeLenght, originalPumpHeightAboveGround, originalTubeResinToFeltFactor, originalDateOfSheet, originalEmployeeId, originalRunDetails, originalRunDetails2, originalWetOutDate, originalWetOutInstallDate, originalThickness, originalLengthToLine, originalPlusExtra, originalForTurnOffset, originalLengthToWetOut, originalTubeMaxColdHead, originalTubeMaxColdHeadPsi, originalTubeMaxHotHead, originalTubeMaxHotHeadPsi, originalTubeIdealHead, originalTubeIdealHeadPsi, originalNetResinForTube, originalNetResinForTubeUsgals, originalNetResinForTubeDrumsIns, originalNetResinForTubeLbsFt, originalNetResinForTubeUsgFt, originalExtraResinForMix, originalExtraLbsForMix, originalTotalMixQuantity, originalTotalMixQuantityUsgals, originalTotalMixQuantityDrumsIns, originalInversionType, originalDepthOfInversionMH, originalTubeForColumn, originalTubeForStartDry, originalTotalTube, originalDropTubeConnects, originalAllowsHeadTo, originalRollerGap, originalHeightNeeded, originalAvailable, originalHoistHeight, originalCommentsCipp, originalResinsLabel, originalDrumContainsLabel, originalLinerTubeLabel, originalForLbDrumsLabel, originalNetResinLabel, originalCatalystLabel, originalDeleted, originalCompanyId, workId, originalLinerTube, originalResinId, originalExcessResin, originalPoundsDrums, originalDrumDiameter, originalHoistMaximumHeight, originalHoistMinimumHeight, originalDownDropTubeLenght, originalPumpHeightAboveGround, originalTubeResinToFeltFactor, originalDateOfSheet, originalEmployeeId, originalRunDetails, originalRunDetails2, originalWetOutDate, originalWetOutInstallDate, originalThickness, originalLengthToLine, originalPlusExtra, originalForTurnOffset, originalLengthToWetOut, originalTubeMaxColdHead, originalTubeMaxColdHeadPsi, originalTubeMaxHotHead, originalTubeMaxHotHeadPsi, originalTubeIdealHead, originalTubeIdealHeadPsi, originalNetResinForTube, originalNetResinForTubeUsgals, originalNetResinForTubeDrumsIns, originalNetResinForTubeLbsFt, originalNetResinForTubeUsgFt, originalExtraResinForMix, originalExtraLbsForMix, originalTotalMixQuantity, originalTotalMixQuantityUsgals, originalTotalMixQuantityDrumsIns, originalInversionType, originalDepthOfInversionMH, originalTubeForColumn, originalTubeForStartDry, originalTotalTube, originalDropTubeConnects, originalAllowsHeadTo, originalRollerGap, originalHeightNeeded, originalAvailable, originalHoistHeight, newComments, originalResinsLabel, originalDrumContainsLabel, originalLinerTubeLabel, originalForLbDrumsLabel, originalNetResinLabel, originalCatalystLabel, originalDeleted, originalCompanyId);
            }
        }
        protected void btnPrintLateralLocationSheet_Click(object sender, EventArgs e)
        {
            mForm7 master = (mForm7)this.Master;
            ScriptManager scriptManager = (ScriptManager)master.FindControl("ScriptManagerMaster7");

            if (!scriptManager.IsInAsyncPostBack)
            {
                string url = "";
                string client = "";
                string name = "";
                string project = "";
                string title = "Full Length Lining Search Results";

                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());
                int companyId = Int32.Parse(hdfCompanyId.Value);
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                client += "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                project = projectGateway.GetName(currentProjectId);
                name = client + " > Project: " + project + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")";

                // ... for title view
                if (hdfBtnOrigin.Value == "Go")
                {
                    int viewId = Int32.Parse(ddlView.SelectedValue.Trim());

                    // ... Load name view
                    WorkViewGateway workViewGateway = new WorkViewGateway();
                    workViewGateway.LoadByViewId(viewId, companyId);

                    title = workViewGateway.GetName(viewId);
                }

                // Report call
                Page.Validate();
                if (Page.IsValid)
                {
                    PostPageChanges();

                    int assetId = GetAssetId();
                    if (assetId > 0)
                    {
                        WorkGateway workGateway = new WorkGateway();
                        workGateway.LoadByProjectIdAssetIdWorkType(Int32.Parse(hdfCurrentProjectId.Value), assetId, "Full Length Lining", Int32.Parse(hdfCompanyId.Value));
                        int workId = workGateway.GetWorkId(assetId, "Full Length Lining", Int32.Parse(hdfCurrentProjectId.Value));

                        FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                        fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));
                        string measuredFrom = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);

                        Response.Write("<script language='javascript'> {window.open('./../../CWP/Common/lateral_location_sheet_report.aspx?source_page=lm&project_id=" + hdfCurrentProjectId.Value + "&client_id=" + hdfCurrentClientId.Value + "&work_id=" + workId.ToString() + "&measured_from=" + measuredFrom + "&asset_id=" + assetId.ToString() + "', '_blank', 'toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=800, height=680');}</script>");
                    }
                    else
                    {
                        cvSelection.IsValid = false;
                    }
                }

                if (url != "") Response.Redirect(url);
            }
        }
Пример #11
0
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateFieldsForSections
        /// </summary>
        private void UpdateFieldsForSections()
        {
            // Distance Validation
            foreach (JltoBuildReportTDS.JLToBuildRow row in ((JltoBuildReportTDS.JLToBuildDataTable)Table))
            {
                if (!row.IsMainSizeNull())
                {
                    if (Distance.IsValidDistance(row.MainSize))
                    {
                        Distance distance = new Distance(row.MainSize);

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

            foreach (JltoBuildReportTDS.JLToBuildRow row in ((JltoBuildReportTDS.JLToBuildDataTable)Table))
            {
                // Validate RoboticPrepCompleted
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByProjectIdAssetIdWorkType(row.ProjectID, row.Section_, "Full Length Lining", row.COMPANY_ID);
                if (workGateway.Table.Rows.Count > 0)
                {
                    // ... Get WorkId for Full Length Lining
                    int workIdFll = workGateway.GetWorkId(row.Section_, "Full Length Lining", row.ProjectID);

                    // ... Load if there is robotic prep completed
                    FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                    fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workIdFll, row.AssetID, row.COMPANY_ID);

                    bool roboticPrepCompleted = false;
                    DateTime? roboticPrepCompletedDate = null;

                    roboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workIdFll);
                    roboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workIdFll);

                    if ((roboticPrepCompleted) && (!roboticPrepCompletedDate.HasValue))
                    {
                        row.Delete();
                    }
                }
            }
        }
Пример #12
0
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForProcess
        /// </summary>
        /// <param name="companyId">companyId</param>
        private void UpdateForReport(int companyId)
        {
            WorkJunctionLiningCoPitLocationListGateway workJunctionLiningCoPitLocationListGateway = new WorkJunctionLiningCoPitLocationListGateway();

            foreach (JlOverviewReportTDS.JlOverviewRow row in (JlOverviewReportTDS.JlOverviewDataTable)Table)
            {
                if (!row.IsCoPitLocationNull())
                {
                    row.Abbreviation = workJunctionLiningCoPitLocationListGateway.GetAbbreviation(row.CoPitLocation, companyId);
                }

                if (!row.IsCommentsNull())
                {
                    row.Comments = row.Comments.Replace("<br>", "\n");
                }

                int workIdFll = GetWorkId(row.ProjectID, row.AssetID, "Full Length Lining", companyId);

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

                if (fullLengthLiningWorkDetailsGateway.Table.Rows.Count > 0)
                {
                    string measurementFromMH = "USMH"; if (fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll) != "") measurementFromMH = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll);

                    if (measurementFromMH == "DSMH")
                    {
                        string auxDistanceFromUSMH = row.DistanceFromUSMH;
                        row.DistanceFromUSMH = row.DistanceFromDSMH;
                        row.DistanceFromDSMH = auxDistanceFromUSMH;
                    }
                }
            }
        }
        /// <summary>
        /// LoadByProjectIdJlNavigatorTDS
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="jlNavigatorTDS">jlNavigatorTDS</param>
        /// <param name="companyId">companyId</param>
        public void LoadByProjectIdJlNavigatorTDS(int projectId, JlNavigatorTDS jlNavigatorTDS, int companyId)
        {
            ArrayList sections = new ArrayList();
            LateralLocationSheetReportGateway lateralLocationSheetReportGateway = new LateralLocationSheetReportGateway(Data);

            lateralLocationSheetReportGateway.ClearBeforeFill = false;

            foreach (JlNavigatorTDS.JlNavigatorRow jlNavigatorRow in jlNavigatorTDS.JlNavigator)
            {
                if (jlNavigatorRow.Selected)
                {
                    if (!sections.Contains(jlNavigatorRow.AssetID))
                    {
                        sections.Add(jlNavigatorRow.AssetID);
                        int assetId = jlNavigatorRow.AssetID;

                        int workIdFll = GetWorkId(projectId, assetId, "Full Length Lining", companyId);
                        string measuredFrom = "USMH";
                        if (workIdFll > 0)
                        {
                            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                            fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workIdFll, assetId, companyId);
                            measuredFrom = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll);
                        }

                        // Get Data
                        lateralLocationSheetReportGateway.LoadByAssetId(assetId, companyId);
                        UpdateForReportForJunctionLining(assetId, workIdFll, projectId, measuredFrom, companyId);
                    }
                }
            }

            lateralLocationSheetReportGateway.ClearBeforeFill = true;
        }
Пример #14
0
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateFieldsForSections
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="companyId">companyId</param>
        private void UpdateFieldsForSections(int projectId, int companyId)
        {
            foreach (JlNavigatorTDS.JlNavigatorRow row in (JlNavigatorTDS.JlNavigatorDataTable)Table)
            {
                if (row.IsPitRequiredNull())
                    row.PitRequired = false;

                if (row.IsCoRequiredNull())
                    row.CoRequired = false;

                if (row.IsPostContractDigRequiredNull())
                    row.PostContractDigRequired = false;

                if (row.IsLiningThruCoNull())
                    row.LiningThruCo = false;

                if (!row.IsFlowOrderIDNull())
                {
                    row.LateralID = row.FlowOrderID + "-JL-" + row.LateralID;
                }
                else
                {
                    row.LateralID = "JL-" + row.LateralID;
                }

                if (!row.IsMainSizeNull())
                {
                    try
                    {
                        if (Distance.IsValidDistance(row.MainSize))
                        {
                            Distance distance = new Distance(row.MainSize);

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

                row.Selected = false;

                int workIdFll = GetWorkId(projectId, row.AssetID, "Full Length Lining", companyId);

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

                if (fullLengthLiningWorkDetailsGateway.Table.Rows.Count > 0)
                {
                    string measurementFromMH = "USMH";
                    if (fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll) != "") measurementFromMH = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll);

                    if (measurementFromMH == "DSMH")
                    {
                        string auxDistanceFromUSMH = row.DistanceFromUSMH;
                        row.DistanceFromUSMH = row.DistanceFromDSMH;
                        row.DistanceFromDSMH = auxDistanceFromUSMH;
                    }
                }
            }
        }
        private void UpdateDatabase()
        {
            try
            {
                TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDSToSave);
                teamProjectTime2Gateway.Update(projectTime2TDS);

                teamProjectTime2TDSToSave.AcceptChanges();
                teamProjectTime2TDS.AcceptChanges();
                projectTime2TDS.AcceptChanges();
                Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
            }
            catch (Exception ex)
            {
                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }

            DB.Open();
            DB.BeginTransaction();
            try
            {
                if (ddlTypeOfWork.SelectedValue == "MH Rehab")
                {
                    int companyId = Int32.Parse(hdfCompanyId.Value);

                    // Get ids & location
                    int projectId = Int32.Parse(ddlProject.SelectedValue);
                    ProjectGateway projectGateway = new ProjectGateway();
                    projectGateway.LoadByProjectId(projectId);

                    Int64 countryId = projectGateway.GetCountryID(projectId);
                    Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId);
                    Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId);
                    Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId);

                    manholeRehabilitationTDS = new ManholeRehabilitationTDS();
                    ManholeRehabilitationWorkDetails manholeRehabilitationWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                    ManholeRehabilitationWorkDetailsGateway manholeRehabilitationWorkDetailsGateway = new ManholeRehabilitationWorkDetailsGateway(manholeRehabilitationTDS);

                    switch (ddlFunction.SelectedValue)
                    {
                        case "Prep":
                            foreach (GridViewRow row in grdManholesRehabPrep.Rows)
                            {
                                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                DateTime? prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text);

                                if (selected)
                                {
                                    int assetId = Convert.ToInt32(grdManholesRehabPrep.DataKeys[row.RowIndex].Values["AssetID"].ToString());
                                    int workId = 0;

                                    workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Manhole Rehabilitation", companyId);

                                    manholeRehabilitationWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));

                                    if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0)
                                    {
                                        int? batchId = manholeRehabilitationWorkDetailsGateway.GetBatchID(workId);
                                        manholeRehabilitationWorkDetails.Update(workId, prepDate, manholeRehabilitationWorkDetailsGateway.GetSprayedDate(workId), batchId, manholeRehabilitationWorkDetailsGateway.GetDate(workId).Value, companyId);
                                    }
                                    else
                                    {
                                        manholeRehabilitationWorkDetails.Update(workId, prepDate, null, null, DateTime.Now, companyId);
                                    }

                                    manholeRehabilitationWorkDetails.Save2(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, true);
                                }
                            }
                            break;

                        case "Spray":
                            foreach (GridViewRow row in grdManholesRehabSpray.Rows)
                            {
                                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                DateTime? sprayDate = Convert.ToDateTime(((Label)row.FindControl("lblSprayDate")).Text);

                                if (selected)
                                {
                                    int assetId = Convert.ToInt32(grdManholesRehabSpray.DataKeys[row.RowIndex].Values["AssetID"].ToString());
                                    int workId = 0;

                                    workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Manhole Rehabilitation", companyId);

                                    manholeRehabilitationWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));

                                    if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0)
                                    {
                                        int? batchId = manholeRehabilitationWorkDetailsGateway.GetBatchID(workId);
                                        manholeRehabilitationWorkDetails.Update(workId, manholeRehabilitationWorkDetailsGateway.GetPreppedDate(workId), sprayDate, batchId, manholeRehabilitationWorkDetailsGateway.GetDate(workId).Value, companyId);
                                    }
                                    else
                                    {
                                        manholeRehabilitationWorkDetails.Update(workId, null, sprayDate, null, DateTime.Now, companyId);
                                    }

                                    manholeRehabilitationWorkDetails.Save2(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, true);
                                }
                            }
                            break;
                    }

                    DB.CommitTransaction();

                    // Store datasets
                    manholeRehabilitationTDS.AcceptChanges();
                }
                else
                {
                    if (ddlTypeOfWork.SelectedValue == "Full Length")
                    {
                        fullLengthLiningTDS = new FullLengthLiningTDS();
                        AssetSewerSectionGateway aass = new AssetSewerSectionGateway();
                        FullLengthLiningWorkDetails fullLengthLiningWorkDetails = new FullLengthLiningWorkDetails(fullLengthLiningTDS);
                        FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningTDS);

                        int assetId = 0;
                        int workId = 0;

                        // Get ids & location
                        int projectId = Int32.Parse(ddlProject.SelectedValue);
                        ProjectGateway projectGateway = new ProjectGateway();
                        projectGateway.LoadByProjectId(projectId);

                        Int64 countryId = projectGateway.GetCountryID(projectId);
                        Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId);
                        Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId);
                        Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId);

                        int companyId = Int32.Parse(hdfCompanyId.Value);

                        switch (ddlFunction.SelectedValue)
                        {
                            case "Install":
                                foreach (GridViewRow row in grdSectionsInstall.Rows)
                                {
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    DateTime? installDate = Convert.ToDateTime(((Label)row.FindControl("lblInstallDate")).Text);

                                    if (selected)
                                    {
                                        if (installDate != tkrdpDate_.SelectedDate.Value)
                                        {
                                            installDate = tkrdpDate_.SelectedDate.Value;
                                        }

                                        string sectionId = grdSectionsInstall.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                                        aass.LoadBySectionId(sectionId, companyId);
                                        assetId = aass.GetAssetID(sectionId);
                                        workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));
                                        fullLengthLiningWorkDetails.Update(workId, fullLengthLiningWorkDetailsGateway.GetP1Date(workId), fullLengthLiningWorkDetailsGateway.GetP1Completed(workId), installDate, fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId));
                                        fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false);
                                    }
                                }
                                break;

                            case "Prep & Measure":
                                foreach (GridViewRow row in grdSections.Rows)
                                {
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked;
                                    DateTime? prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text);

                                    if (selected)
                                    {
                                        if (completed)
                                        {
                                            if (prepDate != tkrdpDate_.SelectedDate.Value)
                                            {
                                                prepDate = tkrdpDate_.SelectedDate.Value;
                                            }
                                        }
                                        else
                                        {
                                            prepDate = null;
                                        }

                                        string sectionId = grdSections.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                                        aass.LoadBySectionId(sectionId, companyId);
                                        assetId = aass.GetAssetID(sectionId);
                                        workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));
                                        fullLengthLiningWorkDetails.Update(workId, prepDate, completed, fullLengthLiningWorkDetailsGateway.GetInstallDate(workId), fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId));
                                        fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false);
                                    }
                                }
                                break;

                            case "Reinstate & Post Video":
                                FullLengthLiningLateralDetails fullLengthLiningLateralDetails = new FullLengthLiningLateralDetails(fullLengthLiningTDS);
                                FullLengthLiningLateralDetailsGateway fullLengthLiningLateralDetailsGateway = new FullLengthLiningLateralDetailsGateway(fullLengthLiningTDS);

                                foreach (GridViewRow row in grdSectionsReinstatePostVideo.Rows)
                                {
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked;
                                    DateTime? postVideo = Convert.ToDateTime(((Label)row.FindControl("lblPostVideo")).Text);
                                    string sectionId = grdSectionsReinstatePostVideo.DataKeys[row.RowIndex].Values["SectionID"].ToString();

                                    aass.LoadBySectionId(sectionId, companyId);
                                    assetId = aass.GetAssetID(sectionId);
                                    workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                    if (selected)
                                    {
                                        if (completed)
                                        {
                                            if (postVideo != tkrdpDate_.SelectedDate.Value)
                                            {
                                                postVideo = tkrdpDate_.SelectedDate.Value;
                                            }
                                        }
                                        else
                                        {
                                            postVideo = null;
                                        }

                                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));
                                        fullLengthLiningWorkDetails.Update(workId, fullLengthLiningWorkDetailsGateway.GetP1Date(workId), fullLengthLiningWorkDetailsGateway.GetP1Completed(workId), fullLengthLiningWorkDetailsGateway.GetInstallDate(workId), postVideo);
                                        fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false);
                                    }
                                }

                                foreach (GridViewRow row in grdLaterals.Rows)
                                {
                                    string sectionId = grdLaterals.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                                    int assetIdLateral = Convert.ToInt32(((Label)row.FindControl("lblAssetIDLateral")).Text);
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    DateTime? opened = null; if (((CheckBox)row.FindControl("cbxOpened")).Checked) opened = tkrdpDate_.SelectedDate;
                                    DateTime? brushed = null; if (((CheckBox)row.FindControl("cbxBrushed")).Checked) brushed = tkrdpDate_.SelectedDate;

                                    if (selected)
                                    {
                                        aass.LoadBySectionId(sectionId, companyId);
                                        assetId = aass.GetAssetID(sectionId);
                                        workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                        fullLengthLiningLateralDetails.SaveFll(workId, assetIdLateral, companyId, opened, brushed);
                                    }
                                }
                                break;
                        }

                        DB.CommitTransaction();

                        // Store datasets
                        fullLengthLiningTDS.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }