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
                tbxGeneralProposedLiningDate.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId).HasValue)
                {
                    DateTime proposedLiningDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId);
                    tbxGeneralProposedLiningDate.Text = proposedLiningDate.Month.ToString() + "/" + proposedLiningDate.Day.ToString() + "/" + proposedLiningDate.Year.ToString();
                }

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

                tbxGeneralP1Date.Text = "";
                tbxPrepDataP1Date.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetP1Date(workId).HasValue)
                {
                    DateTime p1Date = (DateTime)fullLengthLiningWorkDetailsGateway.GetP1Date(workId);
                    tbxGeneralP1Date.Text = p1Date.Month.ToString() + "/" + p1Date.Day.ToString() + "/" + p1Date.Year.ToString();
                    tbxPrepDataP1Date.Text = p1Date.Month.ToString() + "/" + p1Date.Day.ToString() + "/" + p1Date.Year.ToString();
                }

                tbxGeneralM1Date.Text = "";
                tbxM1DataM1Date.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetM1Date(workId).HasValue)
                {
                    DateTime m1Date = (DateTime)fullLengthLiningWorkDetailsGateway.GetM1Date(workId);
                    tbxGeneralM1Date.Text = m1Date.Month.ToString() + "/" + m1Date.Day.ToString() + "/" + m1Date.Year.ToString();
                    tbxM1DataM1Date.Text = m1Date.Month.ToString() + "/" + m1Date.Day.ToString() + "/" + m1Date.Year.ToString();
                }

                tbxGeneralM2Date.Text = "";
                tbxM2DataM2Date.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetM2Date(workId).HasValue)
                {
                    DateTime m2Date = (DateTime)fullLengthLiningWorkDetailsGateway.GetM2Date(workId);
                    tbxGeneralM2Date.Text = m2Date.Month.ToString() + "/" + m2Date.Day.ToString() + "/" + m2Date.Year.ToString();
                    tbxM2DataM2Date.Text = m2Date.Month.ToString() + "/" + m2Date.Day.ToString() + "/" + m2Date.Year.ToString();
                }

                tbxGeneralInstallDate.Text = "";
                tbxInstallDataInstallDate.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetInstallDate(workId).HasValue)
                {
                    DateTime installDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetInstallDate(workId);
                    tbxGeneralInstallDate.Text = installDate.Month.ToString() + "/" + installDate.Day.ToString() + "/" + installDate.Year.ToString();
                    tbxInstallDataInstallDate.Text = installDate.Month.ToString() + "/" + installDate.Day.ToString() + "/" + installDate.Year.ToString();
                }

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

                // ... for RA data
                tbxGeneralPreFlushDate.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId).HasValue)
                {
                    DateTime preFlushDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId);
                    tbxGeneralPreFlushDate.Text = preFlushDate.Month.ToString() + "/" + preFlushDate.Day.ToString() + "/" + preFlushDate.Year.ToString();
                }

                tbxGeneralPreVideoDate.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId).HasValue)
                {
                    DateTime preVideoDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId);
                    tbxGeneralPreVideoDate.Text = preVideoDate.Month.ToString() + "/" + preVideoDate.Day.ToString() + "/" + preVideoDate.Year.ToString();
                }

                // 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)
                {
                    DateTime prePrepDataRoboticPrepCompletedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId);
                    tbxPrepDataRoboticPrepCompletedDate.Text = prePrepDataRoboticPrepCompletedDate.Month.ToString() + "/" + prePrepDataRoboticPrepCompletedDate.Day.ToString() + "/" + prePrepDataRoboticPrepCompletedDate.Year.ToString();
                }
                ckbxPrepDataP1Completed.Checked = fullLengthLiningWorkDetailsGateway.GetP1Completed(workId);

                // For FullLengthLiningM1 data
                // ... for material
                tbxM1DataMaterial.Text = fullLengthLiningWorkDetailsGateway.GetMaterial(workId);

                // ... form m1 data
                tbxM1DataMeasurementsTakenBy.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId);
                tbxM1DataTrafficControl.Text = fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId);
                tbxM1DataSiteDetails.Text = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId);
                tbxM1DataAccessType.Text = fullLengthLiningWorkDetailsGateway.GetAccessType(workId);
                ckbxM1DataPipeSizeChange.Checked = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workId);
                ckbxM1DataStandardBypass.Checked = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workId);
                tbxM1DataStandardBypassComments.Text = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId);
                tbxM1DataTrafficControlDetails.Text = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId);
                tbxM1DataMeasurementType.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId);
                tbxM1DataMeasuredFromMH.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                hdfMeasuredFrom.Value = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                tbxM1DataVideoDoneFromMH.Text = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
                tbxM1DataToMH.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);
                tbxM2DataHydroWireWitin10FtOfInversionMh.Text = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workId);
                tbxM2DataDistanceToInversionMH.Text = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workId);
                tbxM2DataSurfaceGrade.Text = 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 (Validator.IsValidDouble(tbxConfirmedSize.Text))
                {
                    confirmedSize = double.Parse(tbxConfirmedSize.Text);
                }
                else
                {
                    if (!confirmedSizeDistance.ToStringInEng1().Contains("'"))
                    {
                        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
                    tbxWetOutDataLinerTube.Text = fullLengthLiningWorkDetailsGateway.GetLinerTube(workId);
                    if (tbxWetOutDataLinerTube.Text != "")
                    {
                        ckbxWetOutDataIncludeWetOutInformation.Checked = true;
                    }
                    else
                    {
                        ckbxWetOutDataIncludeWetOutInformation.Checked = false;
                    }

                    int resinId = fullLengthLiningWorkDetailsGateway.GetResinId(workId);
                    WorkFullLengthLiningResinsGateway workFullLengthLiningResinsGateway = new WorkFullLengthLiningResinsGateway();
                    workFullLengthLiningResinsGateway.LoadByResinId(resinId, companyId);
                    string resin = workFullLengthLiningResinsGateway.GetResinMake(resinId) + " " + workFullLengthLiningResinsGateway.GetResinType(resinId) + " " + workFullLengthLiningResinsGateway.GetResinNumber(resinId);
                    tbxWetOutDataResins.Text = resin;

                    tbxWetOutDataExcessResin.Text = fullLengthLiningWorkDetailsGateway.GetExcessResin(workId).ToString();
                    tbxWetOutDataPoundsDrums.Text = 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();

                    int employeeId = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId);
                    EmployeeGateway employeeGateway = new EmployeeGateway();
                    employeeGateway.LoadByEmployeeId(employeeId);
                    tbxWetOutDataMadeBy.Text = employeeGateway.GetLastName(employeeId) + " " + employeeGateway.GetFirstName(employeeId);
                    hdfRunDetails.Value = fullLengthLiningWorkDetailsGateway.GetRunDetails(workId);
                    tbxWetOutDataRunDetails2.Text = fullLengthLiningWorkDetailsGateway.GetRunDetails2(workId);
                    DateTime wetOutDataWetOutDate = fullLengthLiningWorkDetailsGateway.GetWetOutDate(workId);
                    tbxWetOutDataWetOutDate.Text = wetOutDataWetOutDate.Month.ToString() + "/" + wetOutDataWetOutDate.Day.ToString() + "/" + wetOutDataWetOutDate.Year.ToString();

                    DateTime? wetOutDataInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);
                    if (fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId).HasValue)
                    {
                        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);

                    tbxWetOutDataInversionType.Text = 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);
                    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 " + tbxWetOutDataTubeThickness.Text + " 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";
                }

                // ... 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 = "For:" + fullLengthLiningWorkDetailsGateway.GetLinerTube(workId);

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

                    tbxInversionDataMadeBy.Text = tbxWetOutDataMadeBy.Text;

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

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

                    tbxInversionDataPipeType.Text = fullLengthLiningWorkDetailsGateway.GetPipeType(workId);
                    if (tbxInversionDataPipeType.Text != "")
                    {
                        ckbxInversionDataIncludeInversionInformation.Checked = true;
                    }
                    else
                    {
                        ckbxInversionDataIncludeInversionInformation.Checked = false;
                    }

                    tbxInversionDataPipeCondition.Text = fullLengthLiningWorkDetailsGateway.GetPipeCondition(workId);
                    tbxInversionDataGroundMoisture.Text = 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);

                    FlInversionFieldCureRecord FlInversionFieldCureRecordForSummary = new FlInversionFieldCureRecord();
                    FlInversionFieldCureRecordForSummary.Load(workId, companyId);
                    if (FlInversionFieldCureRecordForSummary.Table.Rows.Count > 0)
                    {
                        lblInversionDataFieldCureRecordSummary.Text = FlInversionFieldCureRecordForSummary.GetSummary();
                    }

                    // ... ... 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";
                }

                // 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");
            }
        }
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP2 - SUMMARY
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP2 - SUMMARY - METHODS
        //
        private void StepSummaryIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Summary";

            // Initialize summary
            FlInversionFieldCureRecord flInversionFieldCureRecordForSummary = new FlInversionFieldCureRecord(flInversionFieldCureRecordTDS);
            tbxSummary.Text = flInversionFieldCureRecordForSummary.GetSummary();
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_EDIT"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["asset_id"] == null) || ((string)Request.QueryString["active_tab"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in fl_summary.aspx");
                }

                // Tag Page
                TagPage();

                Session.Remove("flAddLateralsNewDummy");
                Session.Remove("wetOutCatalystsDetailsDummy");

                // If comming from
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                int assetId = Int32.Parse(hdfAssetId.Value.Trim());
                string workType = hdfWorkType.Value;
                int workId = Int32.Parse(hdfWorkId.Value);

                // ... fl_navigator2.aspx
                if (Request.QueryString["source_page"] == "fl_navigator2.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    // Set initial tab
                    if ((string)Session["dialogOpenedFll"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        fullLengthLiningTDS = new FullLengthLiningTDS();

                        FullLengthLiningSectionDetails fullLengthLiningSectionDetails = new FullLengthLiningSectionDetails(fullLengthLiningTDS);
                        fullLengthLiningSectionDetails.LoadByWorkId(workId, companyId);

                        FullLengthLiningWorkDetails fullLengthLiningWorkDetails = new FullLengthLiningWorkDetails(fullLengthLiningTDS);
                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);

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

                        FullLengthLiningWetOutCatalystsDetails fullLengthLiningWetOutCatalystsDetails = new FullLengthLiningWetOutCatalystsDetails(fullLengthLiningTDS);
                        fullLengthLiningWetOutCatalystsDetails.LoadAll(workId, companyId);
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabFll"];

                        // Restore datasets
                        fullLengthLiningTDS = (FullLengthLiningTDS)Session["fullLengthLiningTDS"];
                    }

                    tcFlDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);

                    // Store dataset
                    Session["fullLengthLiningTDS"] = fullLengthLiningTDS;
                }

                // ... fl_delete.aspx or fl_edit.aspx
                if ((Request.QueryString["source_page"] == "fl_delete.aspx") || (Request.QueryString["source_page"] == "fl_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    fullLengthLiningTDS = (FullLengthLiningTDS)Session["fullLengthLiningTDS"];

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedFll"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabFll"];
                    }

                    tcFlDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);
                }

                // Prepare initial data
                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());

                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ") > Selected Section";

                // ... for wet out section list
                AssetSewerSectionList assetSewerSectionList = new AssetSewerSectionList();
                assetSewerSectionList.LoadAndAddItem(Int32.Parse(hdfCurrentProjectId.Value), hdfWorkType.Value, "-1", "(All)", Int32.Parse(hdfCompanyId.Value));
                cbxlWetOutDataSectionId.DataSource = assetSewerSectionList.Table;
                cbxlWetOutDataSectionId.DataValueField = "SectionID";
                cbxlWetOutDataSectionId.DataTextField = "FlowOrderID";
                cbxlWetOutDataSectionId.DataBind();

                cbxlInversionDataSectionId.DataSource = assetSewerSectionList.Table;
                cbxlInversionDataSectionId.DataValueField = "SectionID";
                cbxlInversionDataSectionId.DataTextField = "FlowOrderID";
                cbxlInversionDataSectionId.DataBind();

                // ... Data for current full length lining work
                LoadFullLengthLiningData(currentProjectId, assetId, companyId);

                // Databind
                Page.DataBind();

                // Especial load for Run details
                string runDetails = hdfRunDetails.Value;
                WorkFullLengthLiningWetOutGateway workFullLengthLiningWetOutGateway = new WorkFullLengthLiningWetOutGateway();
                workFullLengthLiningWetOutGateway.LoadByWorkId(workId, companyId);

                // ... Verify if work has cipp information to load run details
                if (workFullLengthLiningWetOutGateway.Table.Rows.Count > 0)
                {
                    string[] runDetailsList = runDetails.Split('>');
                    for (int i = 0; i < runDetailsList.Length; i++)
                    {
                        cbxlWetOutDataSectionId.Items.FindByValue(runDetailsList[i]).Selected = true;
                        cbxlInversionDataSectionId.Items.FindByValue(runDetailsList[i]).Selected = true;
                    }
                }
                else
                {
                    if (cbxlWetOutDataSectionId.Items.Count > 1)
                    {
                        cbxlWetOutDataSectionId.Items.FindByValue(hdfSectionId.Value).Selected = true;
                    }
                }
            }
            else
            {
                // Restore datasets
                fullLengthLiningTDS = (FullLengthLiningTDS)Session["fullLengthLiningTDS"];

                // Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcFlDetails.ActiveTabIndex = activeTab;

                // Load summary for inversionfield cure record
                int companyId =Int32.Parse(hdfCompanyId.Value);
                int workId = Int32.Parse(hdfWorkId.Value);

                FlInversionFieldCureRecord FlInversionFieldCureRecordForSummary = new FlInversionFieldCureRecord();
                FlInversionFieldCureRecordForSummary.Load(workId, companyId);
                if (FlInversionFieldCureRecordForSummary.Table.Rows.Count > 0)
                {
                    lblInversionDataFieldCureRecordSummary.Text = FlInversionFieldCureRecordForSummary.GetSummary();
                }

            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // STEP1 - BEGIN - METHODS
        //
        private void StepBeginIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Please provide field cure record information.";

            // Load
            int workId = Int32.Parse(hdfWorkId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);
            FlInversionFieldCureRecord model = new FlInversionFieldCureRecord(flInversionFieldCureRecordTDS);
            model.LoadAll(workId, companyId);

            // Store tables
            Session["flInversionFieldCureRecord"] = flInversionFieldCureRecordTDS.InversionFieldCureRecord;
            Session["flInversionFieldCureRecordTDS"] = flInversionFieldCureRecordTDS;
        }
        private void Save()
        {
            // save to database
            DB.Open();
            DB.BeginTransaction();
            try
            {
                string runDetails = hdfRunDetails.Value;
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int projectId = Int32.Parse(hdfProjectId.Value);
                FlInversionFieldCureRecord model = new FlInversionFieldCureRecord(flInversionFieldCureRecordTDS);
                model.Save(companyId, runDetails, projectId);

                DB.CommitTransaction();
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
        private void GrdFieldCureRecordAdd()
        {
            if (ValidateFieldCureRecordFooter())
            {
                Page.Validate("dataFooter");
                if (Page.IsValid)
                {
                    string readingTimeText = "";
                    string readingHoursFooter = ((DropDownList)grdFieldCureRecord.FooterRow.FindControl("ddlReadingTimeHourFooter")).SelectedValue.Trim();
                    string readingMinutesFooter = ((DropDownList)grdFieldCureRecord.FooterRow.FindControl("ddlReadingTimeMinuteFooter")).SelectedValue.Trim();

                    if ((readingHoursFooter != "") && (readingMinutesFooter != ""))
                    {
                        readingTimeText = readingHoursFooter + ":" + readingMinutesFooter;
                    }
                    DateTime readingTime = DateTime.Parse(readingTimeText);

                    decimal? headFt = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxHeadFtFooter")).Text.Trim() != "")
                    {
                        if (Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxHeadFtFooter")).Text.Trim()))
                        {
                            headFt = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxHeadFtFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? boilerInF = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxBoilerInFFooter")).Text.Trim() != "")
                    {
                        if (Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxBoilerInFFooter")).Text.Trim()))
                        {
                            boilerInF = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxBoilerInFFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? boilerOutF = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxBoilerOutFFooter")).Text.Trim() != "")
                    {
                        if (Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxBoilerOutFFooter")).Text.Trim()))
                        {
                            boilerOutF = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxBoilerOutFFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? pumpFlow = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxPumpFlowFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxPumpFlowFooter")).Text.Trim())))
                        {
                            pumpFlow = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxPumpFlowFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? pumpPsi = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxPumpPsiFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxPumpPsiFooter")).Text.Trim())))
                        {
                            pumpPsi = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxPumpPsiFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh1Top = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH1TopFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH1TopFooter")).Text.Trim())))
                        {
                            mh1Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH1TopFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh1Bot = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH1BotFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH1BotFooter")).Text.Trim())))
                        {
                            mh1Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH1BotFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh2Top = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH2TopFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH2TopFooter")).Text.Trim())))
                        {
                            mh2Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH2TopFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh2Bot = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH2BotFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH2BotFooter")).Text.Trim())))
                        {
                            mh2Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH2BotFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh3Top = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH3TopFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH3TopFooter")).Text.Trim())))
                        {
                            mh3Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH3TopFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh3Bot = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH3BotFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH3BotFooter")).Text.Trim())))
                        {
                            mh3Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH3BotFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh4Top = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH4TopFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH4TopFooter")).Text.Trim())))
                        {
                            mh4Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH4TopFooter")).Text.Trim()), 2);
                        }
                    }

                    decimal? mh4Bot = null;
                    if (((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH4BotFooter")).Text.Trim() != "")
                    {
                        if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH4BotFooter")).Text.Trim())))
                        {
                            mh4Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxMH4BotFooter")).Text.Trim()), 2);
                        }
                    }

                    string comments = ((TextBox)grdFieldCureRecord.FooterRow.FindControl("tbxCommentsFooter")).Text.Trim();

                    int workId = Int32.Parse(hdfWorkId.Value);
                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    bool inDatabase = false;
                    bool deleted = false;

                    FlInversionFieldCureRecord model = new FlInversionFieldCureRecord(flInversionFieldCureRecordTDS);
                    model.Insert(workId, readingTime, headFt, boilerInF, boilerOutF, pumpFlow, pumpPsi, mh1Top, mh1Bot, mh2Top, mh2Bot, mh3Top, mh3Bot, mh4Top, mh4Bot, comments, deleted, companyId, inDatabase);

                    Session.Remove("flInversionFieldCureRecordDummy");
                    Session["flInversionFieldCureRecordTDS"] = flInversionFieldCureRecordTDS;
                    Session["flInversionFieldCureRecord"] = flInversionFieldCureRecordTDS.InversionFieldCureRecord;

                    grdFieldCureRecord.DataBind();
                    grdFieldCureRecord.PageIndex = grdFieldCureRecord.PageCount - 1;
                }
            }
        }
        protected void grdFieldCureRecord_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("dataEdit");
            if (Page.IsValid)
            {
                int workId = Int32.Parse(hdfWorkId.Value);
                int refId = (int)e.Keys["RefID"];
                int companyId = Int32.Parse(hdfCompanyId.Value);

                string readingTimeText = "";
                string readingHoursEdit = ((DropDownList)grdFieldCureRecord.Rows[e.RowIndex].Cells[2].FindControl("ddlReadingTimeHourEdit")).SelectedValue.Trim();
                string readingMinutesEdit = ((DropDownList)grdFieldCureRecord.Rows[e.RowIndex].Cells[2].FindControl("ddlReadingTimeMinuteEdit")).SelectedValue.Trim();

                if ((readingHoursEdit != "") && (readingMinutesEdit != ""))
                {
                    readingTimeText = readingHoursEdit + ":" + readingMinutesEdit;
                }
                DateTime readingTime = DateTime.Parse(readingTimeText);

                decimal? headFt = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[3].FindControl("tbxHeadFtEdit")).Text.Trim() != "")
                {
                    if (Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[3].FindControl("tbxHeadFtEdit")).Text.Trim()))
                    {
                        headFt = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[3].FindControl("tbxHeadFtEdit")).Text.Trim()), 2);
                    }
                }

                decimal? boilerInF = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[4].FindControl("tbxBoilerInFEdit")).Text.Trim() != "")
                {
                    if (Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[4].FindControl("tbxBoilerInFEdit")).Text.Trim()))
                    {
                        boilerInF = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[4].FindControl("tbxBoilerInFEdit")).Text.Trim()), 2);
                    }
                }

                decimal? boilerOutF = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[5].FindControl("tbxBoilerOutFEdit")).Text.Trim() != "")
                {
                    if (Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[5].FindControl("tbxBoilerOutFEdit")).Text.Trim()))
                    {
                        boilerOutF = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[5].FindControl("tbxBoilerOutFEdit")).Text.Trim()), 2);
                    }
                }

                decimal? pumpFlow = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[6].FindControl("tbxPumpFlowEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[6].FindControl("tbxPumpFlowEdit")).Text.Trim())))
                    {
                        pumpFlow = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[6].FindControl("tbxPumpFlowEdit")).Text.Trim()), 2);
                    }
                }

               decimal? pumpPsi = null;
               if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[7].FindControl("tbxPumpPsiEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[7].FindControl("tbxPumpPsiEdit")).Text.Trim())))
                    {
                        pumpPsi = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[7].FindControl("tbxPumpPsiEdit")).Text.Trim()), 2);
                    }
                }

               decimal? mh1Top = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[8].FindControl("tbxMH1TopEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[8].FindControl("tbxMH1TopEdit")).Text.Trim())))
                    {
                        mh1Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[8].FindControl("tbxMH1TopEdit")).Text.Trim()), 2);
                    }
                }

                decimal? mh1Bot = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[9].FindControl("tbxMH1BotEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[9].FindControl("tbxMH1BotEdit")).Text.Trim())))
                    {
                        mh1Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[9].FindControl("tbxMH1BotEdit")).Text.Trim()), 2);
                    }
                }

                decimal? mh2Top = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[10].FindControl("tbxMH2TopEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[10].FindControl("tbxMH2TopEdit")).Text.Trim())))
                    {
                        mh2Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[10].FindControl("tbxMH2TopEdit")).Text.Trim()), 2);
                    }
                }

                decimal? mh2Bot = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[11].FindControl("tbxMH2BotEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[11].FindControl("tbxMH2BotEdit")).Text.Trim())))
                    {
                        mh2Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[11].FindControl("tbxMH2BotEdit")).Text.Trim()), 2);
                    }
                }

                decimal? mh3Top = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[12].FindControl("tbxMH3TopEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[12].FindControl("tbxMH3TopEdit")).Text.Trim())))
                    {
                        mh3Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[12].FindControl("tbxMH3TopEdit")).Text.Trim()), 2);
                    }
                }

                decimal? mh3Bot = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[13].FindControl("tbxMH3BotEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[13].FindControl("tbxMH3BotEdit")).Text.Trim())))
                    {
                        mh3Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[13].FindControl("tbxMH3BotEdit")).Text.Trim()), 2);
                    }
                }

                decimal? mh4Top = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[14].FindControl("tbxMH4TopEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[14].FindControl("tbxMH4TopEdit")).Text.Trim())))
                    {
                        mh4Top = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[14].FindControl("tbxMH4TopEdit")).Text.Trim()), 2);
                    }
                }

                decimal? mh4Bot = null;
                if (((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[15].FindControl("tbxMH4BotEdit")).Text.Trim() != "")
                {
                    if ((Validator.IsValidDecimal(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[15].FindControl("tbxMH4BotEdit")).Text.Trim())))
                    {
                        mh4Bot = decimal.Round(decimal.Parse(((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[15].FindControl("tbxMH4BotEdit")).Text.Trim()), 2);
                    }
                }

                string comments = ((TextBox)grdFieldCureRecord.Rows[e.RowIndex].Cells[16].FindControl("tbxCommentsEdit")).Text.Trim();

                FlInversionFieldCureRecord model = new FlInversionFieldCureRecord(flInversionFieldCureRecordTDS);
                model.Update(workId, refId, readingTime, headFt, boilerInF, boilerOutF, pumpFlow, pumpPsi, mh1Top, mh1Bot, mh2Top, mh2Bot, mh3Top, mh3Bot, mh4Top, mh4Bot,comments);

                // Store dataset
                Session["flInversionFieldCureRecordTDS"] = flInversionFieldCureRecordTDS;
                Session["flatSectionJlCommentDetails"] = flInversionFieldCureRecordTDS.InversionFieldCureRecord;
            }
            else
            {
                e.Cancel = true;
            }
        }
        protected void grdFieldCureRecord_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // FieldCureRecord Gridview, if the gridview is edition mode
            if (grdFieldCureRecord.EditIndex >= 0)
            {
                grdFieldCureRecord.UpdateRow(grdFieldCureRecord.EditIndex, true);
            }

            //Delete field cure record
            int workId = Int32.Parse(hdfWorkId.Value);
            int refId = (int)e.Keys["RefID"];
            int companyId = Int32.Parse(hdfCompanyId.Value);

            // Delete field cure record
            FlInversionFieldCureRecord model = new FlInversionFieldCureRecord(flInversionFieldCureRecordTDS);
            model.Delete(workId, refId, companyId);

            // Store dataset
            Session["flInversionFieldCureRecordTDS"] = flInversionFieldCureRecordTDS;

            grdFieldCureRecord.DataBind();
        }