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";
                        }
                    }
                }
            }
        }
        protected void tbxPercentageByWeightEdit_TextChanged(object sender, EventArgs e)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int catalystId = Int32.Parse(((Label)grdCatalysts.Rows[grdCatalysts.EditIndex].Cells[2].FindControl("lblCatalystIdEdit")).Text);
            double percentageByWeight = Double.Parse(((TextBox)grdCatalysts.Rows[grdCatalysts.EditIndex].Cells[3].FindControl("tbxPercentageByWeightEdit")).Text);

            if (catalystId != -1)
            {
                // .. Resin Information
                if ((ddlWetOutDataResins.SelectedValue != "-1") && (ddlWetOutDataPoundsDrums.SelectedValue != "(Select)"))
                {
                    int resinId = Int32.Parse(ddlWetOutDataResins.SelectedValue);
                    WorkFullLengthLiningResinsGateway workFullLengthLiningResinsGateway = new WorkFullLengthLiningResinsGateway();
                    workFullLengthLiningResinsGateway.LoadByResinId(resinId, companyId);

                    int lbDrums = Int32.Parse(workFullLengthLiningResinsGateway.GetLbDrums(resinId).ToString());
                    double activeResin = double.Parse(workFullLengthLiningResinsGateway.GetActiveResin(resinId).ToString()) / 100;
                    string applyCatalystTo = workFullLengthLiningResinsGateway.GetApplyCatalystTo(resinId);

                    // Calc  the other columms
                    // ... ... For Mix Quantity
                    string forMixQuantity = "";
                    if (percentageByWeight.ToString() == "-1")
                    {
                        forMixQuantity = "-";
                    }
                    else
                    {
                        double totalMixQuantity = double.Parse(tbxWetOutDataTotalMixQuantity.Text);
                        double catalyse = 0d;
                        if (applyCatalystTo == "(Select)")
                        {
                            catalyse = -1;
                        }
                        else
                        {
                            if (applyCatalystTo == "Active Resin & Filter")
                            {
                                catalyse = 1;
                            }
                            else
                            {
                                catalyse = activeResin;
                            }
                        }

                        if (catalyse != -1)
                        {
                            double pureResin = totalMixQuantity * catalyse;
                            forMixQuantity = (pureResin * totalMixQuantity / 100).ToString();
                            ((Label)grdCatalysts.Rows[grdCatalysts.EditIndex].Cells[4].FindControl("lblLbsForMixQuantityEdit")).Text = forMixQuantity; ;
                        }
                        else
                        {
                            ((Label)grdCatalysts.Rows[grdCatalysts.EditIndex].Cells[4].FindControl("lblLbsForMixQuantityEdit")).Text = "ERROR";
                        }
                    }

                    // ... ... For Lbs For Drums
                    string firstPart = "";
                    double percentageToCatalyse = -1;
                    if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                    {
                        if (percentageByWeight == -1)
                        {
                            firstPart = "-";
                        }
                        else
                        {
                            if (applyCatalystTo == "(Select)")
                            {
                                percentageToCatalyse = -1;
                            }
                            else
                            {
                                if (applyCatalystTo == "Active Resin & Filter")
                                {
                                    percentageToCatalyse = 1;
                                }
                                else
                                {
                                    percentageToCatalyse = activeResin;
                                }
                            }

                            if (percentageToCatalyse != -1)
                            {
                                double drumRes = lbDrums * percentageToCatalyse;
                                double catalystPerDrum = drumRes * percentageByWeight / 100;
                                firstPart = catalystPerDrum.ToString();
                            }
                            else
                            {
                                firstPart = "ERROR";
                            }

                        }
                    }
                    else
                    {
                        firstPart = "-";
                    }

                    string secondPart = "";
                    if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                    {
                        if (percentageByWeight == -1)
                        {
                            secondPart = "-";
                        }
                        else
                        {
                            double drumRes = lbDrums * percentageToCatalyse;
                            double catalystPerDrum = drumRes * percentageByWeight / 100;
                            double roundUp = RoundUp(catalystPerDrum, 0);
                            string upDown = "";
                            if ((roundUp - catalystPerDrum) > 0.05)
                            {
                                upDown = "Down";
                            }
                            else
                            {
                                upDown = "Up";
                            }

                            double fulllbs = 0d;
                            if (upDown == "Up")
                            {
                                fulllbs = roundUp;
                            }
                            else
                            {
                                double roundDown = RoundDown(catalystPerDrum, 0);
                                fulllbs = roundDown;
                            }

                            double partLbs = 0d;
                            if (upDown == "Up")
                            {
                                partLbs = 0;
                            }
                            else
                            {
                                partLbs = catalystPerDrum - fulllbs;
                            }
                            double ozes = double.Parse(decimal.Round(decimal.Parse(partLbs.ToString()) * 16, 0).ToString());
                            string lbOzes = " = (" + fulllbs.ToString() + " lbs + " + ozes.ToString() + " oz) per drum";
                            secondPart = lbOzes;
                        }
                    }
                    else
                    {
                        secondPart = "-";
                    }

                    ((Label)grdCatalysts.Rows[grdCatalysts.EditIndex].Cells[4].FindControl("lblLbsForDrumEdit")).Text = firstPart + "lb/Drum " + secondPart;
                }
            }
        }
        protected void ddlNameFooter_SelectedIndexChanged(object sender, EventArgs e)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int catalystId = Int32.Parse(((DropDownList)grdCatalysts.FooterRow.FindControl("ddlNameFooter")).SelectedValue);

            if (catalystId != -1)
            {
                // Load catalyst data
                WorkFullLengthLiningCatalystsGateway workFullLengthLiningCatalystsGateway = new WorkFullLengthLiningCatalystsGateway();
                workFullLengthLiningCatalystsGateway.LoadByCatalystId(catalystId, companyId);

                double defaultPercentageByWeight = double.Parse(decimal.Round(decimal.Parse(workFullLengthLiningCatalystsGateway.GetDefaultPercentageByWeight(catalystId).ToString()), 2).ToString());

                // .. Resin Information
                if ((ddlWetOutDataResins.SelectedValue != "-1") && (ddlWetOutDataPoundsDrums.SelectedValue != "(Select)") && (tbxWetOutDataTotalMixQuantity.Text != ""))
                {
                    int resinId = Int32.Parse(ddlWetOutDataResins.SelectedValue);
                    WorkFullLengthLiningResinsGateway workFullLengthLiningResinsGateway = new WorkFullLengthLiningResinsGateway();
                    workFullLengthLiningResinsGateway.LoadByResinId(resinId, companyId);

                    int lbDrums = Int32.Parse(workFullLengthLiningResinsGateway.GetLbDrums(resinId).ToString());
                    double activeResin = double.Parse(workFullLengthLiningResinsGateway.GetActiveResin(resinId).ToString()) / 100;
                    string applyCatalystTo = workFullLengthLiningResinsGateway.GetApplyCatalystTo(resinId);

                    // Set data to grid
                    ((TextBox)grdCatalysts.FooterRow.FindControl("tbxPercentageByWeightFooter")).Text = defaultPercentageByWeight.ToString();

                    // Calc  the other columms
                    // ... ... For Mix Quantity
                    string forMixQuantity = "";
                    if (defaultPercentageByWeight.ToString() == "-1")
                    {
                        forMixQuantity = "-";
                    }
                    else
                    {
                        double totalMixQuantity = double.Parse(tbxWetOutDataTotalMixQuantity.Text);
                        double catalyse = 0d;
                        if (applyCatalystTo == "(Select)")
                        {
                            catalyse = -1;
                        }
                        else
                        {
                            if (applyCatalystTo == "Active Resin & Filter")
                            {
                                catalyse = 1;
                            }
                            else
                            {
                                catalyse = activeResin;
                            }
                        }

                        if (catalyse != -1)
                        {
                            double pureResin = totalMixQuantity * catalyse;
                            decimal forMixQuantityDecimal = decimal.Parse((pureResin * (defaultPercentageByWeight) / 100).ToString());
                            forMixQuantity = decimal.Round(forMixQuantityDecimal,2).ToString();
                            ((Label)grdCatalysts.FooterRow.FindControl("lblLbsForMixQuantityFooter")).Text = forMixQuantity;
                        }
                        else
                        {
                            ((Label)grdCatalysts.FooterRow.FindControl("lblLbsForMixQuantityFooter")).Text = "ERROR";
                        }
                    }

                    // ... ... For Lbs For Drums
                    string firstPart = "";
                    double percentageToCatalyse = -1;
                    if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                    {
                        if (defaultPercentageByWeight == -1)
                        {
                            firstPart = "-";
                        }
                        else
                        {
                            if (applyCatalystTo == "(Select)")
                            {
                                percentageToCatalyse = -1;
                            }
                            else
                            {
                                if (applyCatalystTo == "Active Resin & Filter")
                                {
                                    percentageToCatalyse = 1;
                                }
                                else
                                {
                                    percentageToCatalyse = activeResin;
                                }
                            }

                            if (percentageToCatalyse != -1)
                            {
                                double drumRes = lbDrums * percentageToCatalyse;
                                double catalystPerDrum = drumRes * defaultPercentageByWeight / 100;
                                decimal catalystPerDrumDecimal = Decimal.Parse(catalystPerDrum.ToString());

                                catalystPerDrumDecimal = decimal.Round(catalystPerDrumDecimal,2);
                                firstPart = catalystPerDrumDecimal.ToString();
                            }
                            else
                            {
                                firstPart = "ERROR";
                            }
                        }
                    }
                    else
                    {
                        firstPart = "-";
                    }

                    string secondPart = "";
                    if (ddlWetOutDataPoundsDrums.SelectedValue == "Pounds & Drums")  // OP 1
                    {
                        if (defaultPercentageByWeight == -1)
                        {
                            secondPart = "-";
                        }
                        else
                        {
                            double drumRes = lbDrums * percentageToCatalyse;
                            double catalystPerDrum = drumRes * defaultPercentageByWeight / 100;
                            double roundUp = RoundUp(catalystPerDrum, 0);
                            string upDown = "";
                            if ((roundUp - catalystPerDrum) > 0.05)
                            {
                                upDown = "Down";
                            }
                            else
                            {
                                upDown = "Up";
                            }

                            double fulllbs = 0d;
                            if (upDown == "Up")
                            {
                                fulllbs = roundUp;
                            }
                            else
                            {
                                double roundDown = RoundDown(catalystPerDrum, 0);
                                fulllbs = roundDown;
                            }

                            double partLbs = 0d;
                            if (upDown == "Up")
                            {
                                partLbs = 0;
                            }
                            else
                            {
                                partLbs = catalystPerDrum - fulllbs;
                            }
                            double ozes = double.Parse(decimal.Round(decimal.Parse(partLbs.ToString()) * 16, 0).ToString());
                            string lbOzes = " = (" + fulllbs.ToString() + " lbs + " + ozes.ToString() + " oz) per drum";
                            secondPart = lbOzes;
                        }
                    }
                    else
                    {
                        secondPart = "-";
                    }

                    ((Label)grdCatalysts.FooterRow.FindControl("lblLbsForDrumFooter")).Text = firstPart + "lb/Drum " + secondPart;

                    // Addition is available
                    ((ImageButton)grdCatalysts.FooterRow.FindControl("ibtnAdd")).Visible = true;
                }
                else
                {
                    // Addition is not available
                    ((ImageButton)grdCatalysts.FooterRow.FindControl("ibtnAdd")).Visible = false;
                }
            }
        }
        private void LoadWorkData(int workId, int assetId)
        {
            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningTDS);
            if (fullLengthLiningWorkDetailsGateway.Table.Rows.Count > 0)
            {
                // For Header
                tbxVideoLength.Text = fullLengthLiningWorkDetailsGateway.GetVideoLength(workId);

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

                // ... Load Dates
                tbxGeneralProposedLiningDate.Text = "";
                if (fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId).HasValue)
                {
                    DateTime proposedLiningDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId);
                    tbxGeneralProposedLiningDate.Text = proposedLiningDate.Month.ToString() + "/" + proposedLiningDate.Day.ToString() + "/" + proposedLiningDate.Year.ToString();
                }

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

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

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

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

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

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

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

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

                // For FullLengthLiningP1 data
                tbxPrepDataCXIsRemoved.Text = ""; if (fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).HasValue) tbxPrepDataCXIsRemoved.Text = fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).ToString();
                ckbxPrepDataRoboticPrepCompleted.Checked = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workId);
                if (fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId).HasValue)
                {
                    DateTime prePrepDataRoboticPrepCompletedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId);
                    tbxPrepDataRoboticPrepCompletedDate.Text = prePrepDataRoboticPrepCompletedDate.Month.ToString() + "/" + prePrepDataRoboticPrepCompletedDate.Day.ToString() + "/" + prePrepDataRoboticPrepCompletedDate.Year.ToString();
                }
                ckbxPrepDataP1Completed.Checked = fullLengthLiningWorkDetailsGateway.GetP1Completed(workId);

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

                // ... form m1 data
                tbxM1DataMeasurementsTakenBy.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId);
                tbxM1DataTrafficControl.Text = fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId);
                tbxM1DataSiteDetails.Text = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId);
                tbxM1DataAccessType.Text = fullLengthLiningWorkDetailsGateway.GetAccessType(workId);
                ckbxM1DataPipeSizeChange.Checked = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workId);
                ckbxM1DataStandardBypass.Checked = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workId);
                tbxM1DataStandardBypassComments.Text = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId);
                tbxM1DataTrafficControlDetails.Text = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId);
                tbxM1DataMeasurementType.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId);
                tbxM1DataMeasuredFromMH.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                hdfMeasuredFrom.Value = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                tbxM1DataVideoDoneFromMH.Text = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
                tbxM1DataToMH.Text = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);

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

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

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

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

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

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

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

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

                    // ... wet out sheet
                    DateTime wetOutDataDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheet(workId);
                    tbxWetOutDataDateOfSheet.Text = wetOutDataDateOfSheet.Month.ToString() + "/" + wetOutDataDateOfSheet.Day.ToString() + "/" + wetOutDataDateOfSheet.Year.ToString();

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

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

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

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

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

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

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

                    tbxWetOutDataHeightNeeded.Text = fullLengthLiningWorkDetailsGateway.GetHeightNeeded(workId).ToString();
                    tbxWetOutDataAvailable.Text = fullLengthLiningWorkDetailsGateway.GetAvailable(workId);
                    tbxWetOutDataHoistHeight.Text = fullLengthLiningWorkDetailsGateway.GetHoistHeight(workId);
                    tbxWetOutDataNotes.Text = fullLengthLiningWorkDetailsGateway.GetCommentsCipp(workId);

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

                    // ... ... graphic labels
                    lblWetOutDataDimensionLabel.Text = confirmedSize + " ins x " + tbxWetOutDataTubeThickness.Text + " mm Tube";
                    lblWetOutDataTotalTubeLengthlabel.Text = "Total Tube Length " + tbxWetOutDataTotalTube.Text + " ft";
                    lblWetOutDataForColumnLabel.Text = tbxWetOutDataTubeForColumn.Text + " ft  for Column";
                    lblWetOutDataDryFtLabel.Text = "Dry " + tbxWetOutDataTubeForStartDry.Text + " ft";
                    lblWetOutDataWetOutLengthlabel.Text = "Wet-Out Length " + tbxWetOutDataLengthtToWetOut.Text + " ft";
                    lblWetOutDataDryFtEndLabel.Text = "Dry " + tbxWetOutDataTubeForColumn.Text + " ft";
                    lblWetOutDataTailEndlabel.Text = "Tail End";
                    lblWetOutDataColumnEndlabel.Text = "Column End";
                    lblWetOutDataRollerGapLabel.Text = "Roller Gap " + tbxWetOutDataRollerGap.Text + " mm";
                }

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

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

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

                    tbxInversionDataMadeBy.Text = tbxWetOutDataMadeBy.Text;

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

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

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

                    tbxInversionDataPipeCondition.Text = fullLengthLiningWorkDetailsGateway.GetPipeCondition(workId);
                    tbxInversionDataGroundMoisture.Text = fullLengthLiningWorkDetailsGateway.GetGroundMoisture(workId);
                    tbxInversionDataBoilerSize.Text = fullLengthLiningWorkDetailsGateway.GetBoilerSize(workId).ToString();
                    tbxInversionDataPumpsTotalCapacity.Text = fullLengthLiningWorkDetailsGateway.GetPumpTotalCapacity(workId).ToString();
                    tbxInversionDataLayflatSize.Text = fullLengthLiningWorkDetailsGateway.GetLayFlatSize(workId).ToString();
                    tbxInversionDataLayflatQuantityTotal.Text = fullLengthLiningWorkDetailsGateway.GetLayFlatQuantityTotal(workId).ToString();

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

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

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

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

                    tbxInversionDataNotesAndInstallationResults.Text = fullLengthLiningWorkDetailsGateway.GetInstallationResults(workId);

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

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

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

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

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

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

                    lblInversionDataRunLengthLabel.Text = "Run Length: " + tbxInversionDataRunLength.Text + " ft; Fall: " + tbxInversionDataDropInPipeRun.Text + " ft";
                    lblInversionDataDepthOfInversionMHLabel.Text = "   " + tbxWetOutDataDepthOfInversionMH.Text + " ft";
                    lblInversionDataEndLabel.Text = "End";
                }

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

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

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

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

                // ... ... Show comments
                tbxCommentsDataComments.Text = fullLengthLiningAllComments.GetFLOrRAComments(companyId, fullLengthLiningAllComments.Table.Rows.Count, "\n");
            }
        }
 /// <summary>
 /// UpdateDirect a resin
 /// </summary>
 /// <param name="originalResinId">originalResinId</param>
 /// <param name="originalResinMake">originalResinMake</param>
 /// <param name="originalResinType">originalResinType</param>
 /// <param name="originalResinNumber">originalResinNumber</param>
 /// <param name="originalLbUsg">originalLbUsg</param>
 /// <param name="originalLbDrums">originalLbDrums</param>
 /// <param name="originalActiveResin">originalActiveResin</param>
 /// <param name="originalApplyCatalystTo">originalApplyCatalystTo</param>
 /// <param name="originalFilter">originalFilter</param>
 /// <param name="originalDeleted">originalDeleted</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// 
 /// <param name="newResinId">newResinId</param>
 /// <param name="newResinMake">newResinMake</param>
 /// <param name="newResinType">newResinType</param>
 /// <param name="newResinNumber">newResinNumber</param>
 /// <param name="newLbUsg">newLbUsg</param>
 /// <param name="newLbDrums">newLbDrums</param>
 /// <param name="newActiveResin">newActiveResin</param>
 /// <param name="newApplyCatalystTo">newApplyCatalystTo</param>
 /// <param name="newFilter">newFilter</param>
 /// <param name="newDeleted">newDeleted</param>
 /// <param name="newCompanyId">newCompanyId</param>
 public void UpdateDirect(int originalResinId, string originalResinMake, string originalResinType, string originalResinNumber, decimal originalLbUsg, int originalLbDrums, decimal originalActiveResin, string originalApplyCatalystTo, decimal originalFilter, bool originalDeleted, int originalCompanyId, int newResinId, string newResinMake, string newResinType, string newResinNumber, decimal newLbUsg, int newLbDrums, decimal newActiveResin, string newApplyCatalystTo, decimal newFilter, bool newDeleted, int newCompanyId)
 {
     WorkFullLengthLiningResinsGateway workFullLengthLiningResinsGateway = new WorkFullLengthLiningResinsGateway(null);
     workFullLengthLiningResinsGateway.Update(originalResinId, originalResinMake, originalResinType, originalResinNumber, originalLbUsg, originalLbDrums, originalActiveResin, originalApplyCatalystTo, originalFilter, originalDeleted, originalCompanyId, newResinId, newResinMake, newResinType, newResinNumber, newLbUsg, newLbDrums, newActiveResin, newApplyCatalystTo, newFilter, newDeleted, newCompanyId);
 }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// InsertDirect a resin
 /// </summary>
 /// <param name="resinId">resinId</param>
 /// <param name="resinMake">resinMake</param>
 /// <param name="resinType">resinType</param>
 /// <param name="resinNumber">resinNumber</param>
 /// <param name="lbUsg">lbUsg</param>
 /// <param name="lbDrums">lbDrums</param>
 /// <param name="activeResin">activeResin</param>
 /// <param name="applyCatalystTo">applyCatalystTo</param>
 /// <param name="filter">filter</param>
 /// <param name="deleted">deleted</param>       
 /// <param name="companyId">companyId</param>        
 public void InsertDirect(int resinId, string resinMake, string resinType, string resinNumber, decimal lbUsg, int lbDrums, decimal activeResin, string applyCatalystTo, decimal filter, bool deleted, int companyId)
 {
     WorkFullLengthLiningResinsGateway workFullLengthLiningResinsGateway = new WorkFullLengthLiningResinsGateway(null);
     workFullLengthLiningResinsGateway.Insert(resinId, resinMake, resinType, resinNumber, lbUsg, lbDrums, activeResin, applyCatalystTo, filter, deleted, companyId);
 }
 /// <summary>
 /// DeleteDirect a resin
 /// </summary>
 /// <param name="resinId">resinId</param>
 /// <param name="companyId">companyId</param>
 public void DeleteDirect(int resinId, int companyId)
 {
     WorkFullLengthLiningResinsGateway workFullLengthLiningResinsGateway = new WorkFullLengthLiningResinsGateway(null);
     workFullLengthLiningResinsGateway.Delete(resinId, companyId);
 }