/// <summary> /// DeleteDirect /// </summary> /// <param name="assetId">assetId</param> /// <param name="companyId">companyId</param> public bool DeleteDirect(int assetId, int companyId) { // Get initial data AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadByAssetId(assetId, companyId); int section_ = assetSewerLateralGateway.GetSection(assetId); string state = assetSewerLateralGateway.GetState(assetId); // Delete lateral assetSewerLateralGateway.Delete(assetId, companyId); AssetSewer assetSewer = new AssetSewer(null); assetSewer.DeleteDirect(assetId, companyId); Asset asset = new Asset(null); asset.DeleteDirect(assetId, companyId); // Update Section // ... Load section AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); assetSewerSectionGateway.LoadByAssetId(section_, companyId); // ... Get old values of section string sectionIdS = assetSewerSectionGateway.GetSectionId(section_); string streetS = assetSewerSectionGateway.GetStreet(section_); int? usmhIdS = assetSewerSectionGateway.GetUSMH(section_); int? dsmhIdS = assetSewerSectionGateway.GetDSMH(section_); string mapSizeS = assetSewerSectionGateway.GetMapSize(section_); string size_S = assetSewerSectionGateway.GetSize_(section_); string mapLengthS = assetSewerSectionGateway.GetMapSize(section_); string lengthS = assetSewerSectionGateway.GetLength(section_); int? lateralsS = assetSewerSectionGateway.GetLaterals(section_); int? liveLateralsS = assetSewerSectionGateway.GetLiveLaterals(section_); string flowDirectionS = assetSewerSectionGateway.GetFlowDirection(section_); string usmhDepthS = assetSewerSectionGateway.GetUSMHDepth(section_); string dsmhDepthS = assetSewerSectionGateway.GetDSMHDepth(section_); bool deletedS = assetSewerSectionGateway.GetDeleted(section_); string flowOrderIdS = assetSewerSectionGateway.GetFlowOrderID(section_); // ... Calculate new values of section int? newLaterals = lateralsS - 1; int? newLiveLaterals = liveLateralsS; if ((newLiveLaterals.HasValue) && (state == "Live")) { newLiveLaterals = newLiveLaterals - 1; } // ... Update section AssetSewerSection assetSewerSection = new AssetSewerSection(assetSewerSectionGateway.Data); assetSewerSection.UpdateDirect(section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, liveLateralsS, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, companyId, flowOrderIdS, section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, newLaterals, newLiveLaterals, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, companyId, flowOrderIdS); return true; }
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"; } } } } }
/// <summary> /// UpdateDirect /// </summary> /// <param name="originalAssetId">originalAssetId</param> /// <param name="originalSection_">originalSection_</param> /// <param name="originalAddress">originalAddress</param> /// <param name="originalLateralId">originalLateralId</param> /// <param name="originalLatitudeAtSection">originalLatitudeAtSection</param> /// <param name="originalLongitudeAtSection">originalLongitudeAtSection</param> /// <param name="originalLatitudeAtPropertyLine">originalLatitudeAtPropertyLine</param> /// <param name="originalLongitudeAtPropertyLine">originalLongitudeAtPropertyLine</param> /// <param name="originalState">originalState</param> /// <param name="orignalSize">orignalSize</param> /// <param name="originalDistanceFromUsmh">originalDistanceFromUsmh</param> /// <param name="originalDistanceFromDsmh">originalDistanceFromDsmh</param> /// <param name="originalMapSize">originalMapSize</param> /// <param name="originalDeleted">originalDeleted</param> /// <param name="originalCompanyId">originalCompanyId</param> /// <param name="originalConnectionType">originalConnectionType</param> /// /// <param name="newAssetId">newAssetId</param> /// <param name="newSection_">newSection_</param> /// <param name="newAddress">newAddress</param> /// <param name="newLateralId">newLateralId</param> /// <param name="newLatitudeAtSection">newLatitudeAtSection</param> /// <param name="newLongitudeAtSection">newLongitudeAtSection</param> /// <param name="newLatitudeAtPropertyLine">newLatitudeAtPropertyLine</param> /// <param name="newLongitudeAtPropertyLine">newLongitudeAtPropertyLine</param> /// <param name="newState">newState</param> /// <param name="newSize">newSize</param> /// <param name="newDistanceFromUsmh">newDistanceFromUsmh</param> /// <param name="newDistanceFromDsmh">newDistanceFromDsmh</param> /// <param name="newMapSize">newMapSize</param> /// <param name="newDeleted">newDeleted</param> /// <param name="newCompanyId">newCompanyId</param> /// <param name="newConnectionType">newConnectionType</param> public void UpdateDirect(int originalAssetId, int originalSection_, string originalAddress, string originalLateralId, string originalLatitudeAtSection, string originalLongitudeAtSection, string originalLatitudeAtPropertyLine, string originalLongitudeAtPropertyLine, string originalState, string orignalSize, string originalDistanceFromUsmh, string originalDistanceFromDsmh, string originalMapSize, bool originalDeleted, int originalCompanyId, string originalConnectionType, int newAssetId, int newSection_, string newAddress, string newLateralId, string newLatitudeAtSection, string newLongitudeAtSection, string newLatitudeAtPropertyLine, string newLongitudeAtPropertyLine, string newState, string newSize, string newDistanceFromUsmh, string newDistanceFromDsmh, string newMapSize, bool newDeleted, int newCompanyId, string newConnectionType) { AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.Update(originalAssetId, originalSection_, originalAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, orignalSize, originalDistanceFromUsmh, originalDistanceFromDsmh, originalMapSize, originalDeleted, originalCompanyId, originalConnectionType, newAssetId, newSection_, newAddress, newLateralId, newLatitudeAtSection, newLongitudeAtSection, newLatitudeAtPropertyLine, newLongitudeAtPropertyLine, newState, newSize, newDistanceFromUsmh, newDistanceFromDsmh, newMapSize, newDeleted, newCompanyId, newConnectionType); // Update section if ((originalState != newState) && ((newState == "Live") || (originalState == "Live"))) { // ... Load section AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); assetSewerSectionGateway.LoadByAssetId(originalSection_, originalCompanyId); // ... Get old values of section string sectionIdS = assetSewerSectionGateway.GetSectionId(originalSection_); string streetS = assetSewerSectionGateway.GetStreet(originalSection_); int? usmhIdS = assetSewerSectionGateway.GetUSMH(originalSection_); int? dsmhIdS = assetSewerSectionGateway.GetDSMH(originalSection_); string mapSizeS = assetSewerSectionGateway.GetMapSize(originalSection_); string size_S = assetSewerSectionGateway.GetSize_(originalSection_); string mapLengthS = assetSewerSectionGateway.GetMapSize(originalSection_); string lengthS = assetSewerSectionGateway.GetLength(originalSection_); int? lateralsS = assetSewerSectionGateway.GetLaterals(originalSection_); int? liveLateralsS = assetSewerSectionGateway.GetLiveLaterals(originalSection_); string flowDirectionS = assetSewerSectionGateway.GetFlowDirection(originalSection_); string usmhDepthS = assetSewerSectionGateway.GetUSMHDepth(originalSection_); string dsmhDepthS = assetSewerSectionGateway.GetDSMHDepth(originalSection_); bool deletedS = assetSewerSectionGateway.GetDeleted(originalSection_); string flowOrderIdS = assetSewerSectionGateway.GetFlowOrderID(originalSection_); // ... Calculate new values of section int? newLiveLaterals = liveLateralsS; if (originalState == "Live") { newLiveLaterals = newLiveLaterals - 1; } if (newState == "Live") { newLiveLaterals = newLiveLaterals + 1; } // ... Update section AssetSewerSection assetSewerSection = new AssetSewerSection(assetSewerSectionGateway.Data); assetSewerSection.UpdateDirect(originalSection_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, liveLateralsS, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, originalCompanyId, flowOrderIdS, originalSection_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, newLiveLaterals, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, originalCompanyId, flowOrderIdS); } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// InsertDirect /// </summary> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="section_">section_</param> /// <param name="address">address</param> /// <param name="lateralID">lateralID</param> /// <param name="latitudeAtSection">latitudeAtSection</param> /// <param name="longitudeAtSection">longitudeAtSection</param> /// <param name="latitudeAtPropertyLine">latitudeAtPropertyLine</param> /// <param name="longitudeAtPropertyLine">longitudeAtPropertyLine</param> /// <param name="state">state</param> /// <param name="size_">size_</param> /// <param name="distanceFromUSMH">distanceFromUSMH</param> /// <param name="distanceFromDSMH">distanceFromDSMH</param> /// <param name="mapSize">mapSize</param> /// <param name="deleted">deleted</param> /// <param name="companyId">companyId</param> /// <param name="connectionType">connectionType</param> /// <returns></returns> public int InsertDirect(Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int section_, string address, string lateralID, string latitudeAtSection, string longitudeAtSection, string latitudeAtPropertyLine, string longitudeAtPropertyLine, string state, string size_, string distanceFromUSMH, string distanceFromDSMH, string mapSize, bool deleted, int companyId, string connectionType) { AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadBySectionLateralId(section_, lateralID, companyId); int lateral_assetId = 0; if (assetSewerLateralGateway.Table.Rows.Count == 0) { // Insert Asset lateral_assetId = new Asset(new DataSet()).InsertDirect("Sewer", countryId, provinceId, countyId, cityId, deleted, companyId); new AssetSewer(new DataSet()).InsertDirect(lateral_assetId, "Lateral", deleted, companyId); assetSewerLateralGateway.Insert(lateral_assetId, section_, address, lateralID, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, state, size_, distanceFromUSMH, distanceFromDSMH, mapSize, deleted, companyId, connectionType); // Update Section // ... load section AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); assetSewerSectionGateway.LoadByAssetId(section_, companyId); // ... get old values of section string sectionIdS = assetSewerSectionGateway.GetSectionId(section_); string streetS = assetSewerSectionGateway.GetStreet(section_); int? usmhIdS = assetSewerSectionGateway.GetUSMH(section_); int? dsmhIdS = assetSewerSectionGateway.GetDSMH(section_); string mapSizeS = assetSewerSectionGateway.GetMapSize(section_); string size_S = assetSewerSectionGateway.GetSize_(section_); string mapLengthS = assetSewerSectionGateway.GetMapSize(section_); string lengthS = assetSewerSectionGateway.GetLength(section_); int? lateralsS = assetSewerSectionGateway.GetLaterals(section_); int? liveLateralsS = assetSewerSectionGateway.GetLiveLaterals(section_); string flowDirectionS = assetSewerSectionGateway.GetFlowDirection(section_); string usmhDepthS = assetSewerSectionGateway.GetUSMHDepth(section_); string dsmhDepthS = assetSewerSectionGateway.GetDSMHDepth(section_); string flowOrderIdS = assetSewerSectionGateway.GetFlowOrderID(section_); // ... calculate new values of section int? newLaterals = lateralsS; if (newLaterals.HasValue) { newLaterals = newLaterals + 1; } else { newLaterals = 1; } int? newLiveLaterals = liveLateralsS; if (state == "Live") { if (newLiveLaterals.HasValue) { newLiveLaterals = newLiveLaterals + 1; } else { newLiveLaterals = 1; } } else { newLiveLaterals = 0; } // ... update section AssetSewerSection assetSewerSection = new AssetSewerSection(assetSewerSectionGateway.Data); assetSewerSection.UpdateDirect(section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, liveLateralsS, flowDirectionS, usmhDepthS, dsmhDepthS, deleted, companyId, flowOrderIdS, section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, newLaterals, newLiveLaterals, flowDirectionS, usmhDepthS, dsmhDepthS, deleted, companyId, flowOrderIdS); } else { lateral_assetId = assetSewerLateralGateway.GetAssetID(section_, lateralID); } return lateral_assetId; }