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

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

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

                Distance d;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                flM1LateralReportGateway.LoadByAssetId(row.AssetID, row.COMPANY_ID);
                flM1LateralReport.UpdateForReport(row.FlowOrderID, unitType);
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // 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);
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="flowOrderId">flowOrderId</param>
        /// <param name="unitType">unitType</param>
        public void UpdateForReport(string flowOrderId, string unitType)
        {
            foreach (FlM1ReportTDS.M1_LATERALRow row in (FlM1ReportTDS.M1_LATERALDataTable)Table)
            {
                Distance d;

                if (!row.IsVideoDistanceNull())
                {
                    if (Distance.IsValidDistance(row.VideoDistance))
                    {
                        d = new Distance(row.VideoDistance);

                        try
                        {
                            row.VideoDistanceDouble = d.ToDoubleInEng3();
                        }
                        catch
                        {
                            row.VideoDistanceDouble = Convert.ToDouble(row.VideoDistance);
                        }
                    }
                }

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

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

                    if (!row.IsDistanceFromDSMHNull())
                    {
                        d = new Distance(row.DistanceFromDSMH);
                        row.DistanceFromDSMH = d.ToStringInMet2();
                    }

                    if (!row.IsVideoDistanceNull())
                    {
                        d = new Distance(row.VideoDistance);
                        row.VideoDistance = d.ToStringInMet2();
                    }

                    if (!row.IsDistanceToCentreNull())
                    {
                        d = new Distance(row.DistanceToCentre);
                        row.DistanceToCentre = d.ToStringInMet2();
                    }

                    if (!row.IsReverseSetupNull())
                    {
                        d = new Distance(row.ReverseSetup);
                        row.ReverseSetup = d.ToStringInMet2();
                    }

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

                if (unitType == "Imperial")
                {
                    if (!row.IsDistanceFromUSMHNull())
                    {
                        d = new Distance(row.DistanceFromUSMH);
                        row.DistanceFromUSMH = d.ToStringInEng1();
                    }

                    if (!row.IsDistanceFromDSMHNull())
                    {
                        d = new Distance(row.DistanceFromDSMH);
                        row.DistanceFromDSMH = d.ToStringInEng1();
                    }

                    if (!row.IsVideoDistanceNull())
                    {
                        d = new Distance(row.VideoDistance);
                        row.VideoDistance = d.ToStringInEng1();
                    }

                    if (!row.IsDistanceToCentreNull())
                    {
                        d = new Distance(row.DistanceToCentre);
                        row.DistanceToCentre = d.ToStringInEng1();
                    }

                    if (!row.IsReverseSetupNull())
                    {
                        d = new Distance(row.ReverseSetup);
                        row.ReverseSetup = d.ToStringInEng1();
                    }

                    if (!row.IsSize_Null())
                    {
                        try
                        {
                            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;
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }

                // Update flow order
                if (row.FlowOrderIDLateralID == "")
                {
                    row.FlowOrderIDLateralID = flowOrderId + "-FL-" + row.LateralID;
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        public void UpdateForReport(string unitType)
        {
            // Load comments
            foreach (FlM1ReportTDS.M2_SECTIONRow row in (FlM1ReportTDS.M2_SECTIONDataTable)Table)
            {
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(row.WorkID, row.COMPANY_ID);

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

                Distance d;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                //    if (!row.IsVideoLengthNull())
                //    {
                //        d = new Distance(row.VideoLength);
                //        row.VideoLength = d.ToStringInEng1();
                //    }
                //}
            //}
        }
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// 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 METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        private void UpdateForReport()
        {
            foreach (FlToBeMeasuredReportTDS.ToBeMeasuredRow row in (FlToBeMeasuredReportTDS.ToBeMeasuredDataTable)Table)
            {
                if (!row.IsCommentsNull())
                {
                    row.Comments = row.Comments.Replace("<br>", "\n");
                }

                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;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// UpdateFieldsForSections
        /// </summary>
        private void UpdateFieldsForSections(int projectId)
        {
            foreach (FullLengthLiningTDS.LateralDetailsRow row in (FullLengthLiningTDS.LateralDetailsDataTable)Table)
            {
                if (!row.IsSize_Null())
                {
                    try
                    {
                        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
                                    {
                                        if (Validator.IsValidInt32(row.Size_))
                                        {
                                            row.Size_ = row.Size_ + "\"";
                                        }
                                    }
                                    break;
                                case 4:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                // ... If lateral is not used in junction lining
                WorkGateway workGateway = new WorkGateway();
                if (!workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(row.Lateral, projectId, "Junction Lining Lateral", row.COMPANY_ID))
                {
                    row.InJl = false;
                    row.InJlDatabase = false;
                }
                else
                {
                    row.InJl = true;
                    row.InJlDatabase = true;
                }
            }
        }
        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>
        /// UpdateFieldsForSections
        /// </summary>
        private void UpdateFieldsForSections()
        {
            foreach (FlNavigatorTDS.FlNavigatorRow row in (FlNavigatorTDS.FlNavigatorDataTable)Table)
            {
                if (!row.IsSize_Null())
                {
                    try
                    {
                        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;
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                row.RoboticPrepRequired = false;
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateFieldsForSections
        /// </summary>
        private void UpdateFieldsForSections()
        {
            foreach (FlOverviewReportTDS.OverviewReportRow row in (FlOverviewReportTDS.OverviewReportDataTable)Table)
            {
                if (!row.IsSizeNull())
                {
                    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;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// UpdateFieldsForSections
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="companyId">companyId</param>
        private void UpdateFieldsForSections(int projectId, int companyId)
        {
            foreach (FlatSectionJlTDS.FlatSectionJlRow row in (FlatSectionJlTDS.FlatSectionJlDataTable)Table)
            {
                int jlWorkId = row.WorkID;

                // ... Get raWorkId
                int raWorkId = 0;
                WorkGateway raWorkGateway = new WorkGateway();
                raWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Rehab Assessment", companyId);
                if (raWorkGateway.Table.Rows.Count > 0)
                {
                    raWorkId = raWorkGateway.GetWorkId(row.Section_, "Rehab Assessment", projectId);
                }

                // ... Get flWorkId
                int flWorkId = 0;
                WorkGateway flWorkGateway = new WorkGateway();
                flWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Full Length Lining", companyId);
                if (flWorkGateway.Table.Rows.Count > 0)
                {
                    flWorkId = flWorkGateway.GetWorkId(row.Section_, "Full Length Lining", projectId);
                }

                // ... Load All Comments
                FlatSectionJLAllComments flatSectionJLAllComments = new FlatSectionJLAllComments();
                flatSectionJLAllComments.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId);

                row.Comments = flatSectionJLAllComments.GetJLOrFLOrRAComments(companyId, flatSectionJLAllComments.Table.Rows.Count, "\n");

                // Add M1 comments
                WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway();
                workFullLengthLiningM1LateralGateway.LoadByWorkIdLateral(flWorkId, row.AssetID, companyId);
                if (workFullLengthLiningM1LateralGateway.Table.Rows.Count > 0)
                {
                    string m1LateralComments = workFullLengthLiningM1LateralGateway.GetComments(flWorkId, row.AssetID);
                    if (m1LateralComments != "")
                    {
                        row.Comments = row.Comments + "\n\nType: M1 Lateral Comments\nComment: " + m1LateralComments ;
                    }
                }

                WorkFullLengthLiningM1Gateway workFullLengthLiningM1Gateway = new WorkFullLengthLiningM1Gateway();
                workFullLengthLiningM1Gateway.LoadByWorkId(flWorkId, companyId);
                if (workFullLengthLiningM1Gateway.Table.Rows.Count > 0)
                {
                    string trafficControlDetails = workFullLengthLiningM1Gateway.GetTrafficControlDetails(flWorkId);
                    if (trafficControlDetails != "")
                    {
                        row.Comments = row.Comments + "\n\nType: Traffic Control Details\nComment: " + trafficControlDetails;
                    }

                    string standardByPassComments = workFullLengthLiningM1Gateway.GetStandardBypassComments(flWorkId);
                    if (standardByPassComments != "")
                    {
                        row.Comments = row.Comments + "\n\nType: Standard Bypass Comments\nComment: " + standardByPassComments ;
                    }

                    string measurementFromMH = "USMH"; if (workFullLengthLiningM1Gateway.GetMeasurementFromMh(flWorkId) != "") measurementFromMH = workFullLengthLiningM1Gateway.GetMeasurementFromMh(flWorkId);

                    if (measurementFromMH == "DSMH")
                    {
                        string auxDistanceFromUSMH = row.DistanceFromUSMH;
                        row.DistanceFromUSMH = row.DistanceFromDSMH;
                        row.DistanceFromDSMH = auxDistanceFromUSMH;
                    }
                }

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

                // Update History
                FlatSectionJLAllHistory flatSectionJLAllHistory = new FlatSectionJLAllHistory();
                flatSectionJLAllHistory.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId);

                row.History = flatSectionJLAllHistory.GetJLOrFLOrRAHistory(companyId, flatSectionJLAllHistory.Table.Rows.Count, "\n");

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

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

                // Update MainSize
                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
                    {
                    }
                }
            }
        }
        /// <summary>
        /// UpdateForReport
        /// </summary>        
        /// <param name="companyId">companyId</param>
        public void UpdateForReport(int companyId)
        {
            foreach (JlLiningPlanTDS.JlLiningPlanJlinerRow row in (JlLiningPlanTDS.JlLiningPlanJlinerDataTable)Table)
            {
                // Update comments
                int jlWorkId = row.SectionWorkID;
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(jlWorkId, companyId);
                int assetId = workGateway.GetAssetId(jlWorkId);
                int projectId = workGateway.GetProjectId(jlWorkId);

                // ... Get raWorkId
                int raWorkId = 0;
                WorkGateway raWorkGateway = new WorkGateway();
                raWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Rehab Assessment", companyId);
                if (raWorkGateway.Table.Rows.Count > 0)
                {
                    raWorkId = raWorkGateway.GetWorkId(row.Section_, "Rehab Assessment", projectId);
                }

                // ... Get raWorkId
                int flWorkId = 0;
                WorkGateway flWorkGateway = new WorkGateway();
                flWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Full Length Lining", companyId);
                if (flWorkGateway.Table.Rows.Count > 0)
                {
                    flWorkId = flWorkGateway.GetWorkId(row.Section_, "Full Length Lining", projectId);
                }

                // ... Load All Comments
                FlatSectionJLAllComments flatSectionJLAllComments = new FlatSectionJLAllComments();
                flatSectionJLAllComments.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId);

                row.Comments = flatSectionJLAllComments.GetJLOrFLOrRAComments(companyId, flatSectionJLAllComments.Table.Rows.Count, "\n");

                // Add M1 comments
                WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway();
                workFullLengthLiningM1LateralGateway.LoadByWorkIdLateral(flWorkId, row.AssetID, companyId);
                if (workFullLengthLiningM1LateralGateway.Table.Rows.Count > 0)
                {
                    string m1LateralComment = workFullLengthLiningM1LateralGateway.GetComments(flWorkId, row.AssetID);
                    if (m1LateralComment != "")
                    {
                        row.Comments = row.Comments + "\n\nType: M1 Lateral Comments\nComment: " + m1LateralComment;
                    }
                }

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

                // Round PullInDistance
                if (Validator.IsValidDecimal(row.PullInDistance))
                {
                    row.PullInDistance = decimal.Round(decimal.Parse(row.PullInDistance), 1).ToString();
                }
                else
                {
                    row.PullInDistance = "0";
                }

                // Update Main size
                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.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;
                        }
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="flowOrderId">flowOrderId</param>
        /// <param name="unitType">unitType</param>
        /// <param name="measurementFromMH">measurementFromMH</param>
        public void UpdateForReport(string flowOrderId, string unitType, string measurementFromMH)
        {
            foreach (FlReinstateReportTDS.ReinstateLateralRow row in (FlReinstateReportTDS.ReinstateLateralDataTable)Table)
            {
                if (!row.IsCommentsNull())
                {
                    row.Comments = row.Comments.Replace("<br>", "\n");
                }

                Distance d;

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

                    if (!row.IsDistanceFromUSMHNull())
                    {
                        d = new Distance(row.DistanceFromUSMH);
                        row.DistanceFromUSMH = d.ToStringInMet1();
                    }

                    if (!row.IsDistanceFromDSMHNull())
                    {
                        d = new Distance(row.DistanceFromDSMH);
                        row.DistanceFromDSMH = 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.IsDistanceFromUSMHNull())
                    {
                        d = new Distance(row.DistanceFromUSMH);
                        row.DistanceFromUSMH = d.ToStringInEng2();
                    }

                    if (!row.IsDistanceFromDSMHNull())
                    {
                        d = new Distance(row.DistanceFromDSMH);
                        row.DistanceFromDSMH = d.ToStringInEng2();
                    }
                }

                // Update flow order
                if (row.FlowOrderIDLateralID == "")
                {
                    row.FlowOrderIDLateralID = flowOrderId + "-FL-" + row.LateralID;
                }

                // Update Reverse Clock Position
                TimeSpan timeToSubstract = TimeSpan.Parse("12:00");
                string clock = ""; if (!row.IsClockPositionNull()) clock = row.ClockPosition;

                if (clock != "")
                {
                    if (clock != "12" && clock != "12:00" && clock != "6" && clock != "6:00" && clock != "06:00")
                    {
                        try
                        {
                            DateTime time = DateTime.Parse(clock);
                            row.ReverseClockPosition = timeToSubstract.Subtract(new TimeSpan(time.Hour, time.Minute, 0)).ToString().Remove(5);
                        }
                        catch
                        {
                            if (Tools.Validator.IsValidInt32(clock))
                            {
                                int hour = int.Parse(clock);
                                row.ReverseClockPosition = timeToSubstract.Subtract(new TimeSpan(hour, 0, 0)).ToString().Remove(5);
                            }
                            else
                            {
                                row.ReverseClockPosition = clock;
                            }
                        }
                    }
                    else
                    {
                        if (clock == "12:00" || clock == "06:00" || clock == "6:00")
                        {
                            if (clock == "6:00")
                            {
                                row.ReverseClockPosition = "06:00";
                            }
                            else
                            {
                                row.ReverseClockPosition = clock;
                            }
                        }
                        else
                        {
                            try
                            {
                                row.ReverseClockPosition = DateTime.Parse(clock).ToString().Remove(5);
                            }
                            catch
                            {
                                if (Tools.Validator.IsValidInt32(clock))
                                {
                                    int hour = int.Parse(clock);
                                    row.ReverseClockPosition = new TimeSpan(hour, 0, 0).ToString().Remove(5);
                                }
                                else
                                {
                                    row.ReverseClockPosition = clock;
                                }
                            }
                        }
                    }
                }

                if (measurementFromMH == "DSMH")
                {
                    string auxDistanceFromUSMH = row.DistanceFromUSMH;
                    row.DistanceFromUSMH = row.DistanceFromDSMH;
                    row.DistanceFromDSMH = auxDistanceFromUSMH;
                }
            }
        }
 protected string GetDistance(object distance)
 {
     if (distance != DBNull.Value)
     {
         Distance distanceInch = new Distance(distance.ToString());
         return distanceInch.ToStringInEng1();
     }
     else
     {
         return "";
     }
 }
        // ////////////////////////////////////////////////////////////////////////
        // 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();
                    }
                }
            }
        }
        protected void btnWetOutCalculateOnClick(object sender, EventArgs e)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            double pi = double.Parse(Decimal.Round(decimal.Parse(Math.PI.ToString()),4).ToString());
            double breakSize = 10; // in
            double factor1 = 0.99;
            double factor2 = 0.01;

            // ...Section values
            // ... ... 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);
            }

            // ... For Calculations
            // ... ... Validate setup data
            if ((ddlWetOutDataLinerTube.SelectedValue != "") && (ddlWetOutDataResins.SelectedValue != "-1") && (tbxWetOutDataExcessResin.Text != "") && (ddlWetOutDataPoundsDrums.SelectedValue != "(Select)") && (tbxWetOutDataDrumDiameter.Text != "") && (tbxWetOutDataHoistMaximumHeight.Text != "") && (tbxWetOutDataHoistMinimumHeight.Text != "") && (tbxWetOutDataDownDropTubeLength.Text != "") && (tbxWetOutDataPumpHeightAboveGround.Text != "") && (tbxWetOutDataTubeResinToFeltFactor.Text != ""))
            {
                // ... ... validate wet out data
                if ((ddlThickness.SelectedValue != "") && (tbxWetOutDataPlusExtra.Text != "") && (tbxWetOutDataForTurnOffset.Text != "") && (tbxWetOutDataExtraResinForMix.Text != "") && (ddlWetOutDataInversionType.SelectedValue != "(Select)") && (tbxWetOutDataDepthOfInversionMH.Text != "") && (tbxWetOutDataTubeForColumn.Text != "") && (tbxWetOutDataTubeForStartDry.Text != "") && (tbxWetOutDataRollerGap.Text != ""))
                {
                    // Lenght to line of all sections (sume of lenght of asset table)
                    string newRunDetails = "";
                    foreach (ListItem lst in cbxlSectionId.Items)
                    {
                        if (lst.Selected)
                        {
                            newRunDetails = newRunDetails + lst.Value + ">";
                        }
                    }
                    newRunDetails = newRunDetails.Substring(0, newRunDetails.Length - 1);
                    string[] runDetailsList = newRunDetails.Split('>');

                    double lengthToLine = 0d;
                    for (int i = 0; i < runDetailsList.Length; i++)
                    {
                        AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                        string sectionId = runDetailsList[i].ToString();
                        if (sectionId != "-1")
                        {
                            assetSewerSectionGateway.LoadBySectionId(sectionId, companyId);
                            int assetId = assetSewerSectionGateway.GetAssetID(sectionId);

                            Distance lengthDistance = new Distance(assetSewerSectionGateway.GetLength(assetId));
                            lengthToLine = lengthToLine + lengthDistance.ToDoubleInEng3();
                        }
                    }
                    tbxWetOutDataLengthToLine.Text = decimal.Round(decimal.Parse(lengthToLine.ToString()), 1).ToString();
                    tbxInversionDataRunLength.Text = decimal.Round(decimal.Parse(lengthToLine.ToString()), 1).ToString();

                    // ... Inversion run details
                    for (int i = 0; i < runDetailsList.Length; i++)
                    {
                        cbxlInversionDataSectionId.Items.FindByValue(runDetailsList[i]).Selected = true;
                    }

                    // .. Resin Information
                    int resinId = Int32.Parse(ddlWetOutDataResins.SelectedValue);
                    WorkFullLengthLiningResinsGateway workFullLengthLiningResinsGateway = new WorkFullLengthLiningResinsGateway();
                    workFullLengthLiningResinsGateway.LoadByResinId(resinId, companyId);

                    string resinMake = workFullLengthLiningResinsGateway.GetResinMake(resinId);
                    string resinType = workFullLengthLiningResinsGateway.GetResinType(resinId);
                    string resinNumber = workFullLengthLiningResinsGateway.GetResinNumber(resinId);
                    double lbUsg = double.Parse(workFullLengthLiningResinsGateway.GetLbUsg(resinId).ToString());
                    int lbDrums = Int32.Parse(workFullLengthLiningResinsGateway.GetLbDrums(resinId).ToString());
                    double activeResin = double.Parse(workFullLengthLiningResinsGateway.GetActiveResin(resinId).ToString());
                    string applyCatalystTo = workFullLengthLiningResinsGateway.GetApplyCatalystTo(resinId);
                    double filter = double.Parse(workFullLengthLiningResinsGateway.GetFilter(resinId).ToString());

                    // ... Calculations
                    // ... ... LengthtToWetOut
                    Double plusExtra = double.Parse(tbxWetOutDataPlusExtra.Text);
                    Double forTurnOffset = double.Parse(tbxWetOutDataForTurnOffset.Text);

                    Double lengthtToWetOut = lengthToLine + plusExtra + forTurnOffset;
                    tbxWetOutDataLengthtToWetOut.Text = decimal.Round(decimal.Parse(lengthtToWetOut.ToString()), 1).ToString();
                    tbxInversionDataWetOutLenght.Text = decimal.Round(decimal.Parse(lengthtToWetOut.ToString()), 1).ToString();

                    // ... ... Resin label
                    lblWetOutDataResinGray.Text = "RESIN: " + resinMake + resinType + resinNumber + ", " + lbUsg + "lbs/usg, " + activeResin.ToString() + " % Active Resin ";

                    // ... ... Lb drum label
                    lblWetOutDataLbDrumsGrey.Text = "For " + lbDrums.ToString() + " lb drums";

                    // ... ... Drum contains label
                    // ... ... Drum Fill Height Information
                    double usgDrum = lbDrums / lbUsg;
                    double lbsPerUsg = lbUsg;
                    double lbsPerDrum = lbDrums;
                    double usgalsPerDrum = lbsPerDrum / lbsPerUsg;
                    double drumInsideDiameter = Double.Parse(tbxWetOutDataDrumDiameter.Text);
                    double drumInsideDiameterPow = Math.Pow(drumInsideDiameter, 2);
                    double usgalsPerDrumInch = (1 * (pi * drumInsideDiameterPow) / 4) * 0.004329;
                    double lbsPerDrumInch = usgalsPerDrumInch * lbsPerUsg;
                    double drumFillHeightShouldBeApprox = lbsPerDrum / lbsPerDrumInch;

                    if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                    {
                        lblWetOutDataDrumContainsGray.Text = "Drum contains: " + lbDrums.ToString() + "lbs / " + Decimal.Round(decimal.Parse(usgDrum.ToString()), 1).ToString() + "usg.  Full drum level: Approx " + Decimal.Round(Decimal.Parse(drumFillHeightShouldBeApprox.ToString()), 1).ToString() + "ins.";
                    }
                    else
                    {
                        lblWetOutDataDrumContainsGray.Text = "-";
                    }

                    // ... ... Liner Tube
                    string linerTube = ddlWetOutDataLinerTube.SelectedValue;
                    double tubeThickness = Double.Parse(ddlThickness.SelectedValue);
                    lblWetOutDataLinerTubeGray.Text = "LINER TUBE: " + linerTube.ToString() + ", Inversion. Tube Size: " + confirmedSize.ToString() + " ins x " + tubeThickness.ToString() + " mm.";
                    tbxInversionDataLinerSize.Text = confirmedSize + " ins x " + tubeThickness + " mm";
                    lblInversionDataSubtitle.Text = ddlWetOutDataLinerTube.SelectedValue;

                    double maxCold = -1;
                    double maxColdExact = -1;
                    double maxColdRounded = -1;

                    double maxHot = -1;
                    double maxHotExact = -1;
                    double maxHotRounded = -1;

                    double idealHead = -1;
                    double idealHeadExact = -1;
                    double idealHeadRounded = -1;

                    switch (linerTube)
                    {
                        case "Applied Felts":
                            double sizeAppliedFelts = confirmedSize * 25.4;

                            // ...  ... For max cold
                            maxColdExact = (tubeThickness / sizeAppliedFelts) * 308 * 3.2808;
                            maxColdRounded = Double.Parse(Decimal.Round(Decimal.Parse(maxColdExact.ToString()), 1).ToString());
                            maxCold = maxColdRounded;

                            // ... ... For max hot
                            maxHotExact = (tubeThickness / sizeAppliedFelts) * 269 * 3.2808;
                            maxHotRounded = Double.Parse(Decimal.Round(Decimal.Parse(maxHotExact.ToString()), 1).ToString());
                            maxHot = maxHotRounded;

                            // ... ... For Idead head
                            double sizeToUseAppliedFelts = 0d;
                            if (confirmedSize > breakSize)
                            {
                                sizeToUseAppliedFelts = sizeAppliedFelts;
                            }
                            else
                            {
                                sizeToUseAppliedFelts = sizeAppliedFelts - 25;
                            }
                            idealHeadExact = (tubeThickness / sizeToUseAppliedFelts) * 201 * 3.2808;
                            idealHeadRounded = Double.Parse(Decimal.Round(Decimal.Parse(idealHeadExact.ToString()), 1).ToString());
                            idealHead = idealHeadRounded;
                            break;

                        case "Novapipe":
                            // ...  ... For max cold
                            maxColdExact = (39 * tubeThickness) / confirmedSize;
                            maxColdRounded = double.Parse(Decimal.Round(Decimal.Parse(maxColdExact.ToString()), 1).ToString());
                            maxCold = maxColdRounded;

                            // ... ... For max hot
                            maxHotExact = (33.1 * tubeThickness) / confirmedSize;
                            maxHotRounded = Double.Parse(Decimal.Round(Decimal.Parse(maxHotExact.ToString()), 1).ToString());
                            maxHot = maxHotRounded;

                            // ... ... For Idead head
                            idealHeadExact = (25.76 * tubeThickness) / confirmedSize;
                            idealHeadRounded = Double.Parse(Decimal.Round(Decimal.Parse(idealHeadExact.ToString()), 1).ToString());
                            idealHead = idealHeadRounded;
                            break;

                        case "Liner Products":
                            // ...  ... For max cold
                            maxColdExact = (tubeThickness / confirmedSize) * 34.057;
                            maxColdRounded = double.Parse(Decimal.Round(Decimal.Parse(maxColdExact.ToString()), 1).ToString());
                            maxCold = maxColdRounded;

                            // ... ... For max hot
                            maxHotExact = (tubeThickness / confirmedSize) * 28.381;
                            maxHotRounded = Double.Parse(Decimal.Round(Decimal.Parse(maxHotExact.ToString()), 1).ToString());
                            maxHot = maxHotRounded;

                            // ... ... For Idead head
                            idealHeadExact = (tubeThickness / confirmedSize) * 20.888;
                            idealHeadRounded = Double.Parse(Decimal.Round(Decimal.Parse(idealHeadExact.ToString()), 1).ToString());
                            idealHead = idealHeadRounded;
                            break;

                        case "Generic":
                            double sizeGeneric = confirmedSize * 25.4;

                            // ...  ... For max cold
                            maxColdExact = (tubeThickness / sizeGeneric) * 308 * 3.2808;
                            maxColdRounded = Double.Parse(Decimal.Round(Decimal.Parse(maxColdExact.ToString()), 1).ToString());
                            maxCold = maxColdRounded;

                            // ... ... For max hot
                            maxHotExact = (tubeThickness / sizeGeneric) * 269 * 3.2808;
                            maxHotRounded = Double.Parse(Decimal.Round(Decimal.Parse(maxHotExact.ToString()), 1).ToString());
                            maxHot = maxHotRounded;

                            // ... ... For Idead head
                            double sizeToUseGeneric = 0d;

                            if (confirmedSize > breakSize)
                            {
                                sizeToUseGeneric = sizeGeneric;
                            }
                            else
                            {
                                sizeToUseGeneric = sizeGeneric - 25;
                            }
                            idealHeadExact = (tubeThickness / sizeToUseGeneric) * 201 * 3.2808;
                            idealHeadRounded = Double.Parse(Decimal.Round(Decimal.Parse(idealHeadExact.ToString()), 1).ToString());
                            idealHead = idealHeadRounded;
                            break;

                        case "Tube 5 No Data":
                            // ...  ... For max cold
                            maxCold = -1;

                            // ... ... For max hot
                            maxHot = -1;

                            // ... ... For Idead head
                            idealHead = -1;
                            break;

                        case "Tube 6 No Data":
                            // ...  ... For max cold
                            maxCold = -1;

                            // ... ... For max hot
                            maxHot = -1;

                            // ... ... For Idead head
                            idealHead = -1;
                            break;
                    }

                    // ... ... .... Tube Max Cold Head, Tube Max Cold head PSI
                    if (maxCold != -1)
                    {
                        tbxWetOutDataTubeMaxColdHead.Text = maxCold.ToString();
                        double maxColdPsi = 0.434 * maxCold;
                        tbxWetOutDataTubeMaxColdHeadPSI.Text = decimal.Round(decimal.Parse(maxColdPsi.ToString()), 1).ToString();
                    }
                    else
                    {
                        tbxWetOutDataTubeMaxColdHead.Text = "NA";
                        tbxWetOutDataTubeMaxColdHeadPSI.Text = "NA";
                    }

                    // ... ... .... Tube Max Hot Head, Tube Max Hot Head PSI
                    if (maxHot != -1)
                    {
                        tbxWetOutDataTubeMaxHotHead.Text = maxHot.ToString();
                        double maxHotPsi = 0.434 * maxHot;
                        tbxWetOutDataTubeMaxHotHeadPSI.Text = decimal.Round(decimal.Parse(maxHotPsi.ToString()), 1).ToString();
                    }
                    else
                    {
                        tbxWetOutDataTubeMaxHotHead.Text = "NA";
                        tbxWetOutDataTubeMaxHotHeadPSI.Text = "NA";
                    }

                    // ... ... .... Tube Ideal Head, Tube Ideal Head PSI
                    if (idealHead != -1)
                    {
                        tbxWetOutDataTubeIdealHead.Text = idealHead.ToString();
                        double idealHeadPsi = 0.434 * idealHead;
                        tbxWetOutDataTubeIdealHeadPSI.Text = Decimal.Round(Decimal.Parse(idealHeadPsi.ToString()), 1).ToString();
                    }
                    else
                    {
                        tbxWetOutDataTubeIdealHead.Text = "NA";
                        tbxWetOutDataTubeIdealHeadPSI.Text = "NA";
                    }

                    // ... ... Net Resins
                    // ... ... ... For net resin for tube lbs ft(lbs/ft)
                    double lbsFt = 0d;
                    double usgFt = 0d;
                    double excessResin = Double.Parse(tbxWetOutDataExcessResin.Text)/100;
                    double tubeResinToFeltFactor = Double.Parse(tbxWetOutDataTubeResinToFeltFactor.Text);

                    switch (linerTube)
                    {
                        case "Applied Felts":
                            // ... ... .... For lbsFt
                            double fromSetUp = tubeResinToFeltFactor / 100;
                            double t = tubeThickness / 25.4;
                            double id = confirmedSize - 2 * t;
                            double area = pi * (Math.Pow(confirmedSize, 2) - Math.Pow(id, 2)) / 4;
                            double v1 = 12 * area * 0.004329;
                            double v2 = v1 * fromSetUp;
                            double v3 = v2 * excessResin;
                            double v4 = v3 + v2;
                            lbsFt = v4 * lbUsg;

                            // ... ... .... For usgFt
                            usgFt = v4;
                            break;

                        case "Novapipe":
                            // ... ... .... For lbsFt
                            double fromSetUpNovapipe = tubeResinToFeltFactor / 100;
                            double tNovapipe = tubeThickness / 25.4;
                            double idNovapipe = confirmedSize - 2 * tNovapipe;
                            double areaNovapipe = pi * (Math.Pow(confirmedSize, 2) - Math.Pow(idNovapipe, 2)) / 4;
                            double v1Novapipe = 12 * areaNovapipe * 0.004329;
                            double v2Novapipe = v1Novapipe * fromSetUpNovapipe;
                            double v3Novapipe = v2Novapipe * excessResin;
                            double v4Novapipe = v3Novapipe + v2Novapipe;
                            lbsFt = v4Novapipe * lbUsg;

                            // ... ... .... For usgFt
                            usgFt = v4Novapipe;
                            break;

                        case "Liner Products":
                            // ... ... .... For lbsFt
                            double lbft3 = lbUsg / 0.1337;
                            double specificGravity = double.Parse(decimal.Round(decimal.Parse((lbft3 / 62.4).ToString()), 3).ToString());

                            double midCalc = 0d;
                            if (confirmedSize > 8)
                            {
                                midCalc = 261.5184;
                            }
                            else
                            {
                                midCalc = 217.932;
                            }

                            Decimal confirmedSizeDecimal = Decimal.Parse(confirmedSize.ToString());
                            Decimal firstDivision = confirmedSizeDecimal / 24;
                            Double firstDivisionDouble = Double.Parse(firstDivision.ToString());
                            double midCalc2 = RoundUp(firstDivisionDouble, 0);

                            Decimal secondDivision = confirmedSizeDecimal / 30;
                            double secondDivisionDouble = double.Parse(secondDivision.ToString());
                            double midCalc3 = RoundUp(secondDivisionDouble, 0);
                            double estimatedResinMultiplier = (((545.2 * (tubeThickness / 25.4) * ((((confirmedSize - 2 * (tubeThickness / 25.4)) * pi * 0.92) / pi) + (tubeThickness / 25.4)) + (midCalc * midCalc3 * ((tubeThickness - 3) / 25.4)) + (55.98 * midCalc2)) * specificGravity) / 453.59) * 0.92;

                            double excessResinAdded = excessResin * estimatedResinMultiplier;
                            lbsFt = excessResinAdded + estimatedResinMultiplier;

                            // ... ... .... For usgFt
                            double totalResin = excessResinAdded + estimatedResinMultiplier;
                            usgFt = totalResin / lbUsg;
                            break;

                        case "Generic":
                            // ... ... .... For lbsFt
                            double fromSetUpGeneric = tubeResinToFeltFactor / 100;
                            double tGeneric = tubeThickness / 25.4;
                            double idGeneric = confirmedSize - 2 * tGeneric;
                            double areaGeneric = pi * (Math.Pow(confirmedSize, 2) - Math.Pow(idGeneric, 2)) / 4;
                            double v1Generic = 12 * areaGeneric * 0.004329;
                            double v2Generic = v1Generic * fromSetUpGeneric;
                            double v3Generic = v2Generic * excessResin;
                            double v4Generic = v3Generic + v2Generic;
                            lbsFt = v4Generic * lbUsg;

                            // ... ... .... For usgFt
                            usgFt = v4Generic;
                            break;

                        case "Tube 5 No Data":
                            // ... ... .... For lbsFt
                            lbsFt = -1;

                            // ... ... .... For usgFt
                            usgFt = -1;
                            break;

                        case "Tube 6 No Data":
                            // ... ... .... For lbsFt
                            lbsFt = -1;

                            // ... ... .... For usgFt
                            usgFt = -1;
                            break;
                    }

                    double netResinForTubeLbsFt = Double.Parse(Decimal.Round(Decimal.Parse(lbsFt.ToString()), 2).ToString());
                    tbxWetOutDataNetResinForTubeLbsFt.Text = netResinForTubeLbsFt.ToString();

                    // ... ... ... For net resin for tube (lbs)
                    double netResinForTube = lengthtToWetOut * netResinForTubeLbsFt;
                    tbxWetOutDataNetResinForTube.Text = Decimal.Round(decimal.Parse(netResinForTube.ToString()), 0).ToString();

                    // ... ... ... For net resin for tube usg/ft (usg/ft)
                    double netResinForTubeUsgFt = Double.Parse(Decimal.Round(Decimal.Parse(usgFt.ToString()), 3).ToString());
                    tbxWetOutDataNetResinForTubeUsgFt.Text = netResinForTubeUsgFt.ToString();

                    // ... ... ... For net resin for tube (usgals)
                    double netResinForTubeUsgals = lengthtToWetOut * netResinForTubeUsgFt;
                    tbxWetOutDataNetResinForTubeUsgals.Text = Decimal.Round(decimal.Parse(netResinForTubeUsgals.ToString()), 1).ToString();

                    // ... ... ... For net resin for tube drums Ins
                    // ... ... ... .... Drum Fill Height Information
                    double exactDrumsRequired = netResinForTube / lbDrums;
                    double rounddownToWholeDrums = RoundDown(exactDrumsRequired, 0);
                    double remainingPartDrum = exactDrumsRequired - rounddownToWholeDrums;
                    double fillHeight = drumFillHeightShouldBeApprox;
                    double remainingPartDrumInInches = fillHeight * remainingPartDrum;
                    double drumFillHeight = fillHeight;
                    double difference = drumFillHeight - remainingPartDrumInInches;

                    double drumsToUseInString = 0d;
                    if (remainingPartDrum > factor1)
                    {
                        drumsToUseInString = rounddownToWholeDrums + 1;
                    }
                    else
                    {
                        if (remainingPartDrum < factor2)
                        {
                            drumsToUseInString = rounddownToWholeDrums;
                        }
                        else
                        {
                            drumsToUseInString = rounddownToWholeDrums;
                        }
                    }

                    double inchesToUseInString = 0;
                    if (remainingPartDrum > factor1)
                    {
                        inchesToUseInString = 0;
                    }
                    else
                    {
                        if (remainingPartDrum < factor2)
                        {
                            inchesToUseInString = 0;
                        }
                        else
                        {
                            inchesToUseInString = remainingPartDrumInInches;
                        }
                    }

                    string stringForDrumInches = "= " + drumsToUseInString + " Drum + " + Decimal.Round(Decimal.Parse(inchesToUseInString.ToString()), 1).ToString() + " ins";
                    string stringForDrumsInches = "= " + drumsToUseInString + " Drums + " + Decimal.Round(Decimal.Parse(inchesToUseInString.ToString()), 1).ToString() + " ins";

                    string stringToCarry = "";
                    if (drumsToUseInString == 1)
                    {
                        stringToCarry = stringForDrumInches;
                    }
                    else
                    {
                        stringToCarry = stringForDrumsInches;
                    }
                    tbxWetOutDataNetResinForTubeDrumsIns.Text = stringToCarry.ToString();

                    // ... ... Newt resin label
                    lblWetOutDataNetResinGrey.Text = "Net resin is amount required in the tube after wet out complete and tube ready for installation. Includes excess at " + excessResin * 100 + "%";

                    // ... ... Extra lbs for Mix
                    double extraResinForMix = Double.Parse(tbxWetOutDataExtraResinForMix.Text);
                    double extraLbsForMix = netResinForTube * extraResinForMix/100;
                    tbxWetOutDataExtraLbsForMix.Text = Decimal.Round(decimal.Parse(extraLbsForMix.ToString()), 0).ToString();

                    // ... ... Total Mix Quantity
                    double totalMixQuantity = (1 + extraResinForMix / 100) * netResinForTube;
                    tbxWetOutDataTotalMixQuantity.Text = Decimal.Round(decimal.Parse(totalMixQuantity.ToString()), 0).ToString();

                    // .... ... Total Mix Quantity usgals
                    double totalMixQuantityUsgals = (1 + extraResinForMix / 100) * netResinForTubeUsgals;
                    tbxWetOutDataTotalMixQuantityUsgals.Text = Decimal.Round(decimal.Parse(totalMixQuantityUsgals.ToString()), 1).ToString(); ;

                    // ... ... Total Mix Quantity Drums Ins
                    if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                    {
                        tbxWetOutDataTotalMixQuantityDrumsIns.Text = stringToCarry;
                    }
                    else
                    {
                        tbxWetOutDataTotalMixQuantityDrumsIns.Text = "-";
                    }

                    // ... ... Catalyst label
                    string catalystLabel = "";

                    if (applyCatalystTo == "Active Resin")
                    {
                        double activeResinVal = totalMixQuantity * activeResin/100;
                        double activeResinInDrum = lbsPerDrum * activeResin/100;
                        if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                        {
                            catalystLabel = "Catalyst % applied to weight of Active Resin = " + decimal.Round(decimal.Parse(activeResinVal.ToString()), 0) + " lbs  (" + decimal.Round(decimal.Parse(activeResinInDrum.ToString()), 1).ToString() + " lbs per drum )";
                        }
                        else
                        {
                            catalystLabel = "Catalyst % applied to weight of Active Resin = " + decimal.Round(decimal.Parse(activeResinVal.ToString()), 0) + " lbs";
                        }
                    }
                    else
                    {
                        if (applyCatalystTo == "Active Resin & Filter")
                        {
                            if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                            {
                                catalystLabel = "Catalyst % applied to weight of Active Resin and Filler = " + decimal.Round(decimal.Parse(totalMixQuantity.ToString()), 0).ToString() + " lbs (" + decimal.Round(decimal.Parse(lbsPerDrum.ToString()), 1).ToString() + " lbs per drum )";
                            }
                            else
                            {
                                catalystLabel = "Catalyst % applied to weight of Active Resin and Filler = " + decimal.Round(decimal.Parse(totalMixQuantity.ToString()), 0).ToString() + " lbs";
                            }
                        }
                        else
                        {
                            catalystLabel = "ERROR IN RESIN LIST ENTRY(S). CATALYST QTYS ARE INCORRECT!";
                        }
                    }

                    lblWetOutDataCatalystGrey.Text = catalystLabel;

                    // ... ... Total Tube
                    double tubeForColumn = Double.Parse(tbxWetOutDataTubeForColumn.Text);
                    double tubeForStartDry = Double.Parse(tbxWetOutDataTubeForStartDry.Text);
                    double totalTube = tubeForColumn + tubeForStartDry + lengthtToWetOut; ;
                    tbxWetOutDataTotalTube.Text = Decimal.Round(decimal.Parse(totalTube.ToString()), 1).ToString();

                    // ... ... Drop Tube Connects
                    string inversionType = ddlWetOutDataInversionType.SelectedValue;
                    double depthOfInversionMH = Double.Parse(tbxWetOutDataDepthOfInversionMH.Text);

                    if (inversionType == "Bottom")
                    {
                        if (depthOfInversionMH == tubeForColumn)
                        {
                            tbxWetOutDataDropTubeConnects.Text = "At MH lid";
                        }
                        else
                        {
                            if (depthOfInversionMH > tubeForColumn)
                            {
                                tbxWetOutDataDropTubeConnects.Text = "Below MH lid";
                            }
                            else
                            {
                                tbxWetOutDataDropTubeConnects.Text = "Above MH lid";
                            }
                        }
                    }
                    else
                    {
                        tbxWetOutDataDropTubeConnects.Text = "-";
                    }

                    // ... ... Allows Head To
                    double allowsToHeadTo = 0d;
                    double downDropTubeLength = Double.Parse(tbxWetOutDataDownDropTubeLength.Text);
                    if (inversionType == "Top")
                    {
                        allowsToHeadTo = tubeForColumn;
                        tbxWetOutDataAllowsHeadTo.Text = allowsToHeadTo.ToString();
                    }
                    else
                    {
                        if (inversionType == "Bottom")
                        {
                            allowsToHeadTo = tubeForColumn + downDropTubeLength;
                            tbxWetOutDataAllowsHeadTo.Text = allowsToHeadTo.ToString();
                        }
                        else
                        {
                            tbxWetOutDataAllowsHeadTo.Text = "NA";
                        }
                    }

                    // ... ... Height Needed
                    double heightNeeded = 0;
                    if (tbxWetOutDataAllowsHeadTo.Text != "NA")
                    {
                        heightNeeded = allowsToHeadTo - depthOfInversionMH;
                        tbxWetOutDataHeightNeeded.Text = heightNeeded.ToString();
                    }

                    // ... ... Available
                    double hoistMinimumHeight = Double.Parse(tbxWetOutDataHoistMinimumHeight.Text);
                    double hoistMaximunHeight = Double.Parse(tbxWetOutDataHoistMaximumHeight.Text);
                    tbxWetOutDataAvailable.Text = hoistMinimumHeight.ToString() + " ft to " + hoistMaximunHeight.ToString() + " ft";

                    // ... ... Hoist Height?
                    if (heightNeeded > hoistMaximunHeight)
                    {
                        tbxWetOutDataHoistHeight.Text = "Too High";
                    }
                    else
                    {
                        if (heightNeeded < hoistMinimumHeight)
                        {
                            tbxWetOutDataHoistHeight.Text = "Too Low";
                        }
                        else
                        {
                            tbxWetOutDataHoistHeight.Text = "OK";
                        }
                    }

                    // ... ... Warning
                    if ((tbxWetOutDataHoistHeight.Text == "OK") || (tbxWetOutDataHoistHeight.Text == ""))
                    {
                        lblWetOutDataWarning.Visible = false;
                    }
                    else
                    {
                        lblWetOutDataWarning.Visible = true;
                    }

                    // ... ... graphic labels
                    lblWetOutDataDimensionLabel.Text = confirmedSize + " ins x " + tubeThickness + " 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";

                    // ... ... Inversion Liner Size
                    tbxInversionDataLinerSize.Text = confirmedSize + " ins x " + tubeThickness + " mm";

                    // ... ... Inversion Gray texts
                    lblInversionDataSubtitle.Text = "For: " + ddlWetOutDataLinerTube.SelectedValue;
                    lblInversionDataLinerInfoGrey.Text = linerTube + " tube with " + resinMake + " " + resinType + " " + resinNumber + " resin";
                    lblInversionDataHeadsGrey.Text = "Heads Ideal: " + tbxWetOutDataTubeIdealHead.Text + " ft (" + tbxWetOutDataTubeIdealHeadPSI.Text + ");  Max Hot: " + tbxWetOutDataTubeMaxHotHead.Text + " ft (" + tbxWetOutDataTubeMaxHotHeadPSI.Text + "psi);  Max Cold: " + tbxWetOutDataTubeMaxColdHead.Text + " ft (" + tbxWetOutDataTubeMaxColdHeadPSI.Text + ")";

                    // ... ... .... Validate data for calcs
                    if ((ddlInversionDataInversionPipeType.SelectedValue != "(Select)") && (ddlInversionDataPipeCondition.SelectedValue != "(Select)") && (ddlInversionDataGroundMoisture.SelectedValue != "(Select)") && (tbxInversionDataBoilerSize.Text != "") && (tbxInversionDataPumpsTotalCapacity.Text != "") && (tbxInversionDataLayflatSize.Text != "") && (tbxInversionDataLayflatQuantityTotal.Text != ""))
                    {
                        if ((tbxInversionDataWaterStartTempTs.Text != "") && (tbxInversionDataTempT1.Text != "") && (tbxInversionDataHoldAtT1For.Text != "") && (tbxInversionDataTempT2.Text != "") && (tbxInversionDataCookAtT2For.Text != "") && (tbxInversionDataCoolDownFor.Text != "") && (tbxInversionDataCoolToTemp.Text != "") && (tbxInversionDataDropInPipeRun.Text != ""))
                        {
                            // ... ... Inversion Pipe Slope Of
                            Decimal dropInPipeRun = Decimal.Parse(tbxInversionDataDropInPipeRun.Text);
                            Decimal pipeSlopeOf = Decimal.Round(dropInPipeRun, 1) / Decimal.Parse(lengthToLine.ToString())*100;
                            tbxInversionDataPipeSlopeOf.Text = Decimal.Round(decimal.Parse(pipeSlopeOf.ToString()), 2).ToString();

                            // ... ... Inversion 45F120F
                            double odsIns = confirmedSize;
                            double tIns = (tubeThickness / 25.4);
                            double inversionId = (odsIns - 2 * tIns);
                            lblInversionData45F120F.Text = tbxInversionDataWaterStartTempTs.Text + "°F-" + tbxInversionDataTempT1.Text + "°F (hr)";

                            // ... ... Inversion Hold
                            tbxInversionDataHold.Text = Decimal.Round(decimal.Parse(tbxInversionDataHoldAtT1For.Text), 1).ToString();

                            // ... ... Inversion 120F185F
                            lblInversionData120F185F.Text = tbxInversionDataTempT1.Text + "°F-" + tbxInversionDataTempT2.Text + "°F (hr)";
                            double pipeTypeFactor = 0d;
                            string pipeType = ddlInversionDataInversionPipeType.SelectedValue;
                            if (pipeType == "Clay") pipeTypeFactor = 0.90;
                            if (pipeType == "Concrete") pipeTypeFactor = 0.80;
                            if (pipeType == "Brick") pipeTypeFactor = 1.00;

                            double pipeConditionFactor = 0d;
                            string pipeCondition = ddlInversionDataPipeCondition.SelectedValue;
                            if (pipeCondition == "Good") pipeConditionFactor = 1.00;
                            if (pipeCondition == "Fair") pipeConditionFactor = 0.90;
                            if (pipeCondition == "Poor") pipeConditionFactor = 0.80;
                            if (pipeCondition == "Badly Broken") pipeConditionFactor = 0.60;

                            double groundMoistureFactor = 0d;
                            string groundMoisture = ddlInversionDataGroundMoisture.SelectedValue;
                            if (groundMoisture == "Dry") groundMoistureFactor = 1.00;
                            if (groundMoisture == "Typical") groundMoistureFactor = 0.80;
                            if (groundMoisture == "Wet") groundMoistureFactor = 0.60;

                            double boilerSize = double.Parse(tbxInversionDataBoilerSize.Text);
                            double matFactorF1 = pipeTypeFactor;
                            double conditionFactorF2 = pipeConditionFactor;
                            double groundMoistureFactorF3 = groundMoistureFactor;
                            double overallFactorF3 = matFactorF1 * conditionFactorF2 * groundMoistureFactorF3;
                            double ianCorrectionFactor = 0.85;
                            double tubeMaxColdHead = double.Parse(tbxWetOutDataTubeMaxColdHead.Text);
                            double totalTubee = tubeMaxColdHead + lengthToLine;
                            double idForLinerFt = inversionId / 12;
                            double particalCalc = Math.Pow(idForLinerFt, 2);
                            double areaFt2 = (pi * particalCalc) / 4;
                            double ft3PerFt = areaFt2 * 1;
                            double usgPerFt = 7.481 * ft3PerFt;
                            double totalUsg = totalTubee * usgPerFt;
                            double cubFt = totalUsg / 7.481;
                            double punds = cubFt * 62.4;
                            double temp1 = double.Parse(tbxInversionDataTempT1.Text);
                            double temp2 = double.Parse(tbxInversionDataTempT2.Text);
                            double ts = double.Parse(tbxInversionDataWaterStartTempTs.Text);
                            double t1t2Btus = ((temp2 - temp1) * punds);
                            double netBtu = (ianCorrectionFactor * overallFactorF3 * boilerSize);
                            double timeHrs = (t1t2Btus / netBtu);
                            tbxInversionData120F185F.Text = Decimal.Round(decimal.Parse(timeHrs.ToString()), 1).ToString();

                            double tsT1Btus = (temp1 - ts) * punds;
                            double timeHrs1 = tsT1Btus / netBtu;
                            tbxInversionData45F120F.Text = Decimal.Round(decimal.Parse(timeHrs1.ToString()), 1).ToString();

                            // ... ... Inversion Cook Time
                            tbxInversionDataCookTime.Text = Decimal.Round(decimal.Parse(tbxInversionDataCookAtT2For.Text), 1).ToString(); ;

                            // ... ... Inversion Cool Time
                            tbxInversionDataCoolTime.Text = Decimal.Round(decimal.Parse(tbxInversionDataCoolDownFor.Text), 1).ToString();

                            // ... ... Inversion Aprox Total
                            double f45f120 = timeHrs1;
                            double hold = Double.Parse(tbxInversionDataHold.Text);
                            double f120f185 = timeHrs;
                            double cookTime = Double.Parse(tbxInversionDataCookTime.Text);
                            double coolTime = Double.Parse(tbxInversionDataCoolTime.Text);
                            tbxInversionDataAproxTotal.Text = Decimal.Round(decimal.Parse((f45f120 + hold + f120f185 + cookTime + coolTime).ToString()), 1).ToString();

                            // ... ... Inversion pumping circulation subtitle
                            double pumpsTotalCapacity = double.Parse(tbxInversionDataPumpsTotalCapacity.Text);
                            lblInversionDataPumpingCirculationSubtitle.Text = "Pumping and Circulation Parameters at " + tbxInversionDataPumpsTotalCapacity.Text + "usgpm (= " + (pumpsTotalCapacity * 60).ToString() + " usgph)";

                            // ... ... Inversion water changes per hour
                            double totalLinerInWaterCol = totalUsg;
                            double pumpsTotalCapacity60 = pumpsTotalCapacity * 60;
                            double changesPerHour = pumpsTotalCapacity60 / totalLinerInWaterCol;
                            decimal waterChangesPerHour = Decimal.Round(decimal.Parse(changesPerHour.ToString()), 2);
                            tbxInversionDataWaterChangesPerHour.Text = Decimal.Round(decimal.Parse(waterChangesPerHour.ToString()), 2).ToString();

                            // ... ... Inversion return water velocity
                            double layFlatQuantity = double.Parse(tbxInversionDataLayflatQuantityTotal.Text);
                            double layFlatSize = double.Parse(tbxInversionDataLayflatSize.Text);
                            double middleCalcEach = Math.Pow(layFlatSize, 2);
                            double areaLayFlatft2Each = ((pi * (middleCalcEach)) / 4) / 144;
                            double areaLayflatft2 = areaLayFlatft2Each * layFlatQuantity;
                            double qInCfs = pumpsTotalCapacity / 448.8;
                            double netQAreaFt2 = areaFt2 - areaLayflatft2;
                            double returnFlowArea = netQAreaFt2;
                            double returnsWaterVelocity = qInCfs / returnFlowArea;
                            tbxInversionDataReturnWaterVelocity.Text = Decimal.Round(decimal.Parse(returnsWaterVelocity.ToString()), 2).ToString();

                            // ... ... Inversion layflat back pressure
                            double c = 130;
                            double dFt = layFlatSize / 12;
                            double flowPerLayFlat = pumpsTotalCapacity / layFlatQuantity;
                            double qCfm = flowPerLayFlat * 0.1336;
                            double qCfs = qCfm / 60;
                            double middleCalcAreaIns2 = Math.Pow(layFlatSize, 2);
                            double areaIns2 = (pi * middleCalcAreaIns2) / 4;
                            double areaft2 = areaIns2 / 144;
                            double vFtS = qCfs / areaft2;
                            double wetOutLenght = double.Parse(tbxInversionDataWetOutLenght.Text);
                            double totalLfLength = tubeMaxColdHead + wetOutLenght;
                            double hfFtL = (Math.Pow((1.816 / c), 1.852) * ((totalLfLength / (Math.Pow(dFt, 1.167))) * Math.Pow(vFtS, 1.852)));
                            double hfPsiL = hfFtL * 0.4335;
                            double layFlatBackPressure = hfPsiL;
                            tbxInversionDataLayflatBackPressure.Text = Decimal.Round(decimal.Parse(layFlatBackPressure.ToString()), 1).ToString();

                            // ... ... Inversion pump lift at ideal head
                            double pumpHeightAboveGround = double.Parse(tbxWetOutDataPumpHeightAboveGround.Text);
                            double pumpFromInvert = pumpHeightAboveGround + depthOfInversionMH;
                            double lift = pumpFromInvert - idealHead;
                            double pumpLiftAtIdealHead = lift;
                            tbxInversionDataPumpLiftAtIdealHead.Text = Decimal.Round(decimal.Parse(pumpLiftAtIdealHead.ToString()), 1).ToString();

                            // ... ... Inversion water to fil liner column
                            double waterToFillLinerColumn = totalUsg;
                            tbxInversionDataWaterToFillLinerColumn.Text = Decimal.Round(decimal.Parse(waterToFillLinerColumn.ToString()), 0).ToString();

                            // ... ... Inversion water per ft
                            double waterPerFt = usgPerFt;
                            tbxInversionDataWaterPerFit.Text = Decimal.Round(decimal.Parse(waterPerFt.ToString()), 2).ToString();

                            // ... ... 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" + tubeThickness.ToString() + " Liner";

                            lblInversionDataRunLengthLabel.Text = "Run Length: " + tbxInversionDataRunLength.Text + " ft; Fall: " + tbxInversionDataDropInPipeRun.Text + " ft";
                            lblInversionDataDepthOfInversionMHLabel.Text = "   " + tbxWetOutDataDepthOfInversionMH.Text + " ft";
                            lblInversionDataEndLabel.Text = "End";
                        }
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        private void UpdateForReport()
        {
            foreach (FlLiningCompletedReportTDS.LiningCompletedRow row in (FlLiningCompletedReportTDS.LiningCompletedDataTable)Table)
            {
                if (!row.IsLengthNull())
                {
                    Distance distance = new Distance(row.Length);
                    row.Length = distance.ToStringInEng3();
                }

                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;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// UpdateFieldsForSections
        /// </summary>
        private void UpdateFieldsForSections()
        {
            foreach (RehabAssessmentTDS.SectionDetailsRow row in (RehabAssessmentTDS.SectionDetailsDataTable)Table)
            {
                if (!row.IsSize_Null())
                {
                    try
                    {
                        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
                                    {
                                        if (Validator.IsValidInt32(row.Size_))
                                        {
                                            row.Size_ = row.Size_ + "\"";
                                        }
                                    }
                                    break;
                                case 4:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
        /// <summary>
        /// ProcessForReport
        /// </summary>
        /// <param name="jlLiningPlanTDS">TDS for process</param>
        public void ProcessForReport(JlLiningPlanTDS jlLiningPlanTDS)
        {
            JlLiningPlanJlinerGateway jlLiningPlanJlinerGateway = new JlLiningPlanJlinerGateway(Data);
            jlLiningPlanJlinerGateway.ClearBeforeFill = false;
            JlLiningPlanJliner jlLiningPlanJliner = new JlLiningPlanJliner(Data);

            foreach (JlLiningPlanTDS.JlLiningPlanRow jlLiningPlanRow in jlLiningPlanTDS.JlLiningPlan.Rows)
            {
                if (jlLiningPlanRow.Selected != "9")
                {
                    // Create row for report
                    JlLiningPlanTDS.JlLiningPlanRow newRow = ((JlLiningPlanTDS.JlLiningPlanDataTable)Table).NewJlLiningPlanRow();

                    newRow.AssetID = jlLiningPlanRow.AssetID;
                    newRow.COMPANY_ID = jlLiningPlanRow.COMPANY_ID;
                    newRow.SectionID = jlLiningPlanRow.SectionID;
                    if (!jlLiningPlanRow.IsStreetNull()) newRow.Street = jlLiningPlanRow.Street;
                    if (!jlLiningPlanRow.IsSize_Null())
                    {
                        if (Distance.IsValidDistance(jlLiningPlanRow.Size_))
                        {
                            Distance distance = new Distance(jlLiningPlanRow.Size_);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    jlLiningPlanRow.Size_ = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    if (Convert.ToDouble(jlLiningPlanRow.Size_) > 99)
                                    {
                                        double newSize_ = 0;
                                        newSize_ = Convert.ToDouble(jlLiningPlanRow.Size_) * 0.03937;
                                        jlLiningPlanRow.Size_ = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                    }
                                    else
                                    {
                                        jlLiningPlanRow.Size_ = jlLiningPlanRow.Size_ + "\"";
                                    }
                                    break;
                                case 4:
                                    jlLiningPlanRow.Size_ = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    jlLiningPlanRow.Size_ = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }
                    if (!jlLiningPlanRow.IsStandardBypassNull()) newRow.StandardBypass = jlLiningPlanRow.StandardBypass;
                    if (!jlLiningPlanRow.IsTrafficControlNull()) newRow.TrafficControl = jlLiningPlanRow.TrafficControl;
                    if (!jlLiningPlanRow.IsNumLatsNull()) newRow.NumLats = jlLiningPlanRow.NumLats;
                    if (!jlLiningPlanRow.IsNotLinedYetNull()) newRow.NotLinedYet = jlLiningPlanRow.NotLinedYet;
                    if (!jlLiningPlanRow.IsLengthNull()) newRow.Length = jlLiningPlanRow.Length;
                    if (!jlLiningPlanRow.IsUSMHNull()) newRow.USMH = jlLiningPlanRow.USMH;
                    if (!jlLiningPlanRow.IsDSMHNull()) newRow.DSMH = jlLiningPlanRow.DSMH;
                    if (!jlLiningPlanRow.IsAllMeasuredNull()) newRow.AllMeasured = jlLiningPlanRow.AllMeasured;
                    if (!jlLiningPlanRow.IsDate_Null()) newRow.Date_ = jlLiningPlanRow.Date_;
                    if (!jlLiningPlanRow.IsFlusherNull()) newRow.Flusher = jlLiningPlanRow.Flusher;
                    if (!jlLiningPlanRow.IsFlusherMNNull()) newRow.FlusherMN = jlLiningPlanRow.FlusherMN;
                    if (!jlLiningPlanRow.IsLinerNull()) newRow.Liner = jlLiningPlanRow.Liner;
                    if (!jlLiningPlanRow.IsLinerMNNull()) newRow.LinerMN = jlLiningPlanRow.LinerMN;
                    if (!jlLiningPlanRow.IsRotatorNull()) newRow.Rotator = jlLiningPlanRow.Rotator;
                    if (!jlLiningPlanRow.IsRotatorMNNull()) newRow.RotatorMN = jlLiningPlanRow.RotatorMN;
                    if (!jlLiningPlanRow.IsCompressorNull()) newRow.Compressor = jlLiningPlanRow.Compressor;
                    if (!jlLiningPlanRow.IsCompressorMNNull()) newRow.CompressorMN = jlLiningPlanRow.CompressorMN;
                    if (!jlLiningPlanRow.IsUSMHDescriptionNull()) newRow.USMHDescription = jlLiningPlanRow.USMHDescription; else newRow.SetUSMHDescriptionNull();
                    if (!jlLiningPlanRow.IsDSMHDescriptionNull()) newRow.DSMHDescription = jlLiningPlanRow.DSMHDescription; else newRow.SetDSMHDescriptionNull();
                    if (!jlLiningPlanRow.IsUSMHAddressNull()) newRow.USMHAddress = jlLiningPlanRow.USMHAddress; else newRow.SetUSMHAddressNull();
                    if (!jlLiningPlanRow.IsDSMHAddressNull()) newRow.DSMHAddress = jlLiningPlanRow.DSMHAddress; else newRow.SetDSMHAddressNull();
                    newRow.Selected = jlLiningPlanRow.Selected;
                    newRow.FlowOrderID = jlLiningPlanRow.FlowOrderID;
                    newRow.StandardBypassComments = jlLiningPlanRow.StandardBypassComments;
                    newRow.TrafficControlDetails = jlLiningPlanRow.TrafficControlDetails;

                    ((JlLiningPlanTDS.JlLiningPlanDataTable)Table).AddJlLiningPlanRow(newRow);

                    // Select jliners for report
                    foreach (JlLiningPlanTDS.JlLiningPlanJlinerRow jlLiningPlanJlinerRow in jlLiningPlanTDS.JlLiningPlanJliner.Rows)
                    {
                        if (jlLiningPlanJlinerRow.Selected != 30)
                        {
                            jlLiningPlanJlinerGateway.LoadBySection_AssetIdAndLateralOrder(jlLiningPlanRow.AssetID, jlLiningPlanRow.COMPANY_ID, newRow.LinerMN, jlLiningPlanJlinerRow.Selected, jlLiningPlanRow.Selected, jlLiningPlanJlinerRow.AssetID);
                        }
                    }

                    jlLiningPlanJliner.UpdateForReport(jlLiningPlanRow.COMPANY_ID);
                }
            }
        }