// ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        private void UpdateForReport()
        {
            double total = 0.0F;
            double totalConfirmed = 0;
            Distance d;

            foreach (FLWorkAheadReportTDS.WorkAheadRow rowTemp in (FLWorkAheadReportTDS.WorkAheadDataTable)Table)
            {
                if (!rowTemp.IsMapLengthNull())
                {
                    if (Distance.IsValidDistance(rowTemp.MapLength))
                    {
                        d = new Distance(rowTemp.MapLength);
                        total = total + d.ToDoubleInEng3();
                    }
                }

                if (!rowTemp.IsSize_Null())
                {
                    if (Distance.IsValidDistance(rowTemp.Size_))
                    {
                        d = new Distance(rowTemp.Size_);
                        totalConfirmed = totalConfirmed + d.ToDoubleInEng3();
                    }
                }
            }

            foreach (FLWorkAheadReportTDS.WorkAheadRow row in (FLWorkAheadReportTDS.WorkAheadDataTable)Table)
            {
                if (!row.IsMapLengthNull())
                {
                    if (Distance.IsValidDistance(row.MapLength))
                    {
                        d = new Distance(row.MapLength);
                        row.SumScaled = Math.Round(d.ToDoubleInEng3(), 2);
                    }
                }

                if (!row.IsSize_Null())
                {
                    if (Distance.IsValidDistance(row.Size_))
                    {
                        try
                        {
                            d = new Distance(row.Size_);
                            row.SumConfirmed = Convert.ToInt32(d.ToStringInEng3());
                        }
                        catch
                        {
                            row.SumConfirmed = 0;
                        }
                    }
                }

                row.TotalAhead = Math.Round(total, 2);
                row.TotalAhead2 = totalConfirmed;
            }
        }
 // ////////////////////////////////////////////////////////////////////////
 // PRIVATE METHODS
 //
 /// <summary>
 /// UpdateFieldsForSections
 /// </summary>
 private void UpdateFieldsForSections()
 {
     foreach (GerencialDailyProductionReportTDS.DailyProductionReportRow row in (GerencialDailyProductionReportTDS.DailyProductionReportDataTable)Table)
     {
         // ... modify for length
         if (row.IsLengthNull())
         {
             row.TotalFtInstalled = 0;
         }
         else
         {
             Distance distance = new Distance(row.Length);
             row.TotalFtInstalled = distance.ToDoubleInEng3();
         }
     }
 }
        public override void Validate()
        {
            // Validate page
            base.Validate();

            if (Page.IsValid)
            {
                // Update flatSectionJlineTDS
                foreach (GridViewRow row in grdvJliner.Rows)
                {
                    // ... Get standard fields
                    Guid id = new Guid(((HiddenField)row.FindControl("hdfId")).Value);
                    int companyId = int.Parse(((HiddenField)row.FindControl("hdfCompanyId")).Value);
                    double? distanceFromUSMH = null; if (((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim() != "") distanceFromUSMH = double.Parse(((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim());

                    // ... Calculate fields
                    double? distanceFromDSMH = null;
                    if (distanceFromUSMH.HasValue)
                    {
                        SectionGateway sectionGateway = new SectionGateway();
                        sectionGateway.LoadById(id, companyId);

                        Distance length = new Distance(sectionGateway.GetActualLength(id)) - new Distance(((double)distanceFromUSMH).ToString());
                        distanceFromDSMH = length.ToDoubleInEng3();
                    }

                    // ... Check validation fields
                    if (distanceFromDSMH.HasValue)
                    {
                        if ((double)distanceFromDSMH < 0)
                        {
                            CompareValidator cvDistanceFromDSMH = ((CompareValidator)row.FindControl("cvDistanceFromDSMH"));
                            cvDistanceFromDSMH.IsValid = false;
                        }
                    }
                }
            }
        }
예제 #4
0
        private void LoadWorkData(int workId, int assetId)
        {
            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningTDS);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    tbxInversionDataNotesAndInstallationResults.Text = fullLengthLiningWorkDetailsGateway.GetInstallationResults(workId);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                // ... ... Show comments
                tbxCommentsDataComments.Text = fullLengthLiningAllComments.GetFLOrRAComments(companyId, fullLengthLiningAllComments.Table.Rows.Count, "\n");
            }
        }
예제 #5
0
        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";
                        }
                    }
                }
            }
        }
예제 #6
0
        protected void cvVideoDistance_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value.Trim() != "")
            {
                // Initialize
                CustomValidator cvDistanceFromUsmh = (CustomValidator)source;
                args.IsValid = true;

                // Control of format
                if (!Distance.IsValidDistance(args.Value))
                {
                    cvDistanceFromUsmh.Text = "Invalid format. (please use X'Y\", or Xft Yin, or X.Y, or X.Ym, or X.Ymm)";
                    args.IsValid = false;
                    hdfErrorFieldList.Value = hdfErrorFieldList.Value + ", Video Length";
                }

                // Control of distance > 0
                if (args.IsValid)
                {
                    Distance distance = new Distance(args.Value);
                    if (distance.ToDoubleInEng3() < 0)
                    {
                        cvDistanceFromUsmh.Text = "Invalid distance. (must be equal or greater than 0)";
                        args.IsValid = false;
                        hdfErrorFieldList.Value = hdfErrorFieldList.Value + ",Video Length";
                    }
                }
            }
        }
예제 #7
0
        protected void cvRehabilitationDataChimneyDiameter_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value.Trim() != "")
            {
                // Initialize
                CustomValidator cvRehabilitationDataChimneyDiameter = (CustomValidator)source;
                string shape = ddlShape.SelectedValue;
                args.IsValid = true;

                // Control of format
                if ((!Distance.IsValidDistance(args.Value)) && (shape == "Round"))
                {
                    cvRehabilitationDataChimneyDiameter.Text = "Invalid format. (please use X'Y\", or X\", or Xft Yin, or X.Y, or X.Ym, or X.Ymm)";
                    args.IsValid = false;
                    hdfErrorFieldList.Value = hdfErrorFieldList.Value + ", Chimney Diameter";
                }

                // Control of distance > 0
                if ((args.IsValid) && (shape == "Round"))
                {
                    Distance distance = new Distance(args.Value);
                    if (distance.ToDoubleInEng3() < 0)
                    {
                        cvRehabilitationDataChimneyDiameter.Text = "Invalid measurement. (must be equal or greater than 0)";
                        args.IsValid = false;
                        hdfErrorFieldList.Value = hdfErrorFieldList.Value + ", Chimney Diameter";
                    }
                }
            }
        }
예제 #8
0
        private void GrdJLinerAdd()
        {
            Page.Validate("dataFooter");
            if (Page.IsValid)
            {
                if (ValidateJlinerFooter())
                {
                    Guid id = new Guid(hdfSelectedId.Value);
                    int companyId = Convert.ToInt32(Session["companyID"]);
                    string detailId = ""; if (((TextBox)grdJliner2.FooterRow.FindControl("tbxDetailIdFooter")).Text.Trim() != "") detailId = ((TextBox)grdJliner2.FooterRow.FindControl("tbxDetailIdFooter")).Text.Trim();
                    string address = ""; if (((TextBox)grdJliner2.FooterRow.FindControl("tbxAddressFooter")).Text.Trim() != "") address = ((TextBox)grdJliner2.FooterRow.FindControl("tbxAddressFooter")).Text.Trim();
                    double? distanceFromUSMH = null; if (((TextBox)grdJliner2.FooterRow.FindControl("tbxDistanceFromUSMHFooter")).Text.Trim() != "") distanceFromUSMH = double.Parse(((TextBox)grdJliner2.FooterRow.FindControl("tbxDistanceFromUSMHFooter")).Text.Trim());
                    int buildRebuild = 0;
                    bool inDatabase = false;
                    string issue = "No";

                    // Calculate fields
                    double? distanceFromDSMH = null;
                    if (distanceFromUSMH.HasValue)
                    {
                        Distance length = new Distance(tbxActualLength.Text.Trim()) - new Distance(distanceFromUSMH.ToString());
                        distanceFromDSMH = length.ToDoubleInEng3();
                    }

                    JlinerAddJunctionLiner2 model = new JlinerAddJunctionLiner2(jlinerAddTDS);
                    model.Insert(id, companyId, detailId, address, null, null, null, null, null, null, null, null, null, "", null, null, null, buildRebuild, null, null, null, distanceFromUSMH, distanceFromDSMH, "", issue, null, false, null, false, false, "", false, "", "", null, null, "", "", false, "", null, inDatabase);

                    Session.Remove("jliner2Dummy");
                    Session["jlinerAddTDS"] = jlinerAddTDS;
                    jliner2 = jlinerAddTDS.JunctionLiner2;
                    masterArea = jlinerAddTDS.MasterArea;
                    Session["masterArea"] = masterArea;

                    grdJliner2.DataBind();
                    grdJliner2.PageIndex = grdJliner2.PageCount - 1;
                }
            }
        }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <param name="companyId">companyId</param>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        private void ProcessDataForProject(int companyId)
        {
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;
            int numPeriods = 0;

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRARow rowOriginal in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRADataTable)Table)
            {
                if (!rowOriginal.IsTotalFtNull())
                {
                    Distance distOriginal = new Distance(rowOriginal.TotalFt);
                    rowOriginal.TotalFtDouble = distOriginal.ToDoubleInEng3();
                    rowOriginal.RealFt = distOriginal.ToDoubleInEng3();
                }
                else
                {
                    rowOriginal.TotalFtDouble = 0;
                    rowOriginal.RealFt = 0;
                }

                rateAcum = rateAcum + rowOriginal.RealFt / rowOriginal.Hrs;

                // For get number of periods
                if (!alDays.Contains(rowOriginal.Date))
                {
                    alDays.Add(rowOriginal.Date);
                    numPeriods = numPeriods + 1;
                }
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRARow row3 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRADataTable)Table)
            {
                row3.AverageRate = rateAcum / numPeriods;
                row3.NumPeriods = numPeriods;
            }
        }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        public void ProcessDataForProject(int companyId)
        {
            ArrayList al = new ArrayList();
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;
            int lateralsAcum = 0;
            double totalHrsAcum = 0;

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLReinstatePostVideoRow row1 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLReinstatePostVideoDataTable)Table)
            {
                if (row1.Phase.Contains("Prep") || row1.Phase.Contains("Reinstate"))
                {
                    if (!row1.Completed)
                    {
                        if (!al.Contains(row1.SectionID))
                        {
                            al.Add(row1.SectionID);
                        }
                    }
                }

                if (!row1.IsTotalFtNull())
                {
                    Distance distOriginal = new Distance(row1.TotalFt);
                    row1.TotalFtDouble = distOriginal.ToDoubleInEng3();
                }
                else
                {
                    row1.TotalFtDouble = 0;
                }

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

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLReinstatePostVideoRow row2 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLReinstatePostVideoDataTable)Table)
            {
                if (row2.Phase.Contains("Prep"))
                {
                    if (!row2.IsTotalFtNull())
                    {
                        Distance dist = new Distance(row2.TotalFt);
                        double distD = dist.ToDoubleInEng3();

                        if (!row2.Completed)
                        {
                            row2.RealFt = distD / 2;
                        }
                        else
                        {
                            if (al.Contains(row2.SectionID))
                            {
                                row2.RealFt = distD / 2;
                            }
                            else
                            {
                                row2.RealFt = dist.ToDoubleInEng3();
                            }
                        }
                    }
                    else
                    {
                        row2.RealFt = 0;
                    }

                    rateAcum = rateAcum + row2.RealFt / row2.Hrs;
                }

                if (row2.Phase.Contains("Reinstate"))
                {
                    if (!row2.IsLiveLateralsNull())
                    {
                        if (!row2.Completed)
                        {
                            row2.RealLiveLaterals = row2.LiveLaterals / 2;
                        }
                        else
                        {
                            if (al.Contains(row2.SectionID))
                            {
                                row2.RealLiveLaterals = row2.LiveLaterals / 2;
                            }
                            else
                            {
                                row2.RealLiveLaterals = row2.LiveLaterals;
                            }
                        }
                    }
                    else
                    {
                        row2.RealLiveLaterals = 0;
                    }

                    lateralsAcum = lateralsAcum + row2.RealLiveLaterals;
                    rateAcum = rateAcum + (row2.Hrs / row2.RealLiveLaterals);
                    row2.TotalHrs = totalHrsAcum;
                }

                if (row2.Phase.Contains("Install"))
                {
                    if (!row2.IsTotalFtNull())
                    {
                        Distance dist = new Distance(row2.TotalFt);
                        row2.RealFt = dist.ToDoubleInEng3();
                    }
                    else
                    {
                        row2.RealFt = 0;
                    }

                    rateAcum = rateAcum + row2.RealFt / row2.Hrs;
                }

                row2.NumPeriods = alDays.Count;
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLReinstatePostVideoRow row3 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLReinstatePostVideoDataTable)Table)
            {
                if (row3.Phase.Contains("Reinstate"))
                {
                    row3.AverageRate = totalHrsAcum / lateralsAcum;
                }
                else
                {
                    row3.AverageRate = rateAcum / alDays.Count;
                }
            }
        }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        private void ProcessDataForProject(int currentProjectId, string currentPhase, int companyId)
        {
            ArrayList al = new ArrayList();
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;
            int lateralsAcum = 0;
            double totalHrsAcum = 0;

            string projectName = "";
            ProjectGateway projectGateway = new ProjectGateway();
            projectGateway.LoadByProjectId(currentProjectId);
            projectName = projectGateway.GetName(currentProjectId);

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLRow row1 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLDataTable)Table)
            {
                if (row1.ProjectName.Contains(projectName) && row1.Phase.Contains(currentPhase))
                {
                    if (row1.Phase.Contains("Prep") || row1.Phase.Contains("Reinstate"))
                    {
                        if (!row1.Completed)
                        {
                            if (!al.Contains(row1.SectionID))
                            {
                                al.Add(row1.SectionID);
                            }
                        }
                    }

                    if (!row1.IsTotalFtNull())
                    {
                        Distance distOriginal = new Distance(row1.TotalFt);
                        row1.TotalFtDouble = distOriginal.ToDoubleInEng3();
                    }
                    else
                    {
                        row1.TotalFtDouble = 0;
                    }

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

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLRow row2 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLDataTable)Table)
            {
                if (row2.ProjectName.Contains(projectName) && row2.Phase.Contains(currentPhase))
                {
                    if (row2.Phase.Contains("Prep"))
                    {
                        if (!row2.IsTotalFtNull())
                        {
                            Distance dist = new Distance(row2.TotalFt);
                            double distD = dist.ToDoubleInEng3();

                            if (!row2.Completed)
                            {
                                row2.RealFt = distD / 2;
                            }
                            else
                            {
                                if (al.Contains(row2.SectionID))
                                {
                                    row2.RealFt = distD / 2;
                                }
                                else
                                {
                                    row2.RealFt = dist.ToDoubleInEng3();
                                }
                            }
                        }
                        else
                        {
                            row2.RealFt = 0;
                        }

                        rateAcum = rateAcum + row2.RealFt / row2.Hrs;
                    }

                    if (row2.Phase.Contains("Reinstate"))
                    {
                        if (!row2.IsLiveLateralsNull())
                        {
                            if (!row2.Completed)
                            {
                                row2.RealLiveLaterals = row2.LiveLaterals / 2;
                            }
                            else
                            {
                                if (al.Contains(row2.SectionID))
                                {
                                    row2.RealLiveLaterals = row2.LiveLaterals / 2;
                                }
                                else
                                {
                                    row2.RealLiveLaterals = row2.LiveLaterals;
                                }
                            }
                        }
                        else
                        {
                            row2.RealLiveLaterals = 0;
                        }

                        lateralsAcum = lateralsAcum + row2.RealLiveLaterals;
                        rateAcum = rateAcum + (row2.Hrs / row2.RealLiveLaterals);
                        row2.TotalHrs = totalHrsAcum;
                    }

                    if (row2.Phase.Contains("Install"))
                    {
                        if (!row2.IsTotalFtNull())
                        {
                            Distance dist = new Distance(row2.TotalFt);
                            row2.RealFt = dist.ToDoubleInEng3();
                        }
                        else
                        {
                            row2.RealFt = 0;
                        }

                        rateAcum = rateAcum + row2.RealFt / row2.Hrs;
                    }

                    row2.NumPeriods = alDays.Count;
                }
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLRow row3 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseFLLDataTable)Table)
            {
                if (row3.ProjectName.Contains(projectName) && row3.Phase.Contains(currentPhase))
                {
                    if (row3.Phase.Contains("Reinstate"))
                    {
                        row3.AverageRate = totalHrsAcum / lateralsAcum;
                    }
                    else
                    {
                        row3.AverageRate = rateAcum / alDays.Count;
                    }
                }
            }
        }
예제 #12
0
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="flowOrderId">flowOrderId</param>
        /// <param name="unitType">unitType</param>
        public void UpdateForReport(string flowOrderId, string unitType)
        {
            foreach (FlM1ReportTDS.M1_LATERALRow row in (FlM1ReportTDS.M1_LATERALDataTable)Table)
            {
                Distance d;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if (!row.IsSize_Null())
                    {
                        try
                        {
                            if (Distance.IsValidDistance(row.Size_))                            {

                                Distance distance = new Distance(row.Size_);

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

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

            if (Page.IsValid)
            {
                FlatSectionJliner flatSectionJliner = new FlatSectionJliner(flatSectionJlinerTDS);

                // Update flatSectionJlinerTDS
                foreach (GridViewRow row in grdvJliner.Rows)
                {
                    // ... Get standard fields
                    Guid id = new Guid(((HiddenField)row.FindControl("hdfId")).Value);
                    int companyId = int.Parse(((HiddenField)row.FindControl("hdfCompanyId")).Value);
                    int refId = int.Parse(((HiddenField)row.FindControl("hdfRefId")).Value);
                    string recordId = ((HiddenField)row.FindControl("hdfRecordId")).Value;
                    string detailId = ((HiddenField)row.FindControl("hdfDetailId")).Value;
                    string id_ = ((TextBox)row.FindControl("tbxId_")).Text.Trim();
                    string address = ((TextBox)row.FindControl("tbxAddress")).Text.Trim();
                    DateTime? pipeLocated = null; if (((TextBox)row.FindControl("tbxPipeLocated")).Text.Trim() != "") pipeLocated = DateTime.Parse(((TextBox)row.FindControl("tbxPipeLocated")).Text.Trim());
                    DateTime? servicesLocated = null; if (((TextBox)row.FindControl("tbxServicesLocated")).Text.Trim() != "") servicesLocated = DateTime.Parse(((TextBox)row.FindControl("tbxServicesLocated")).Text.Trim());
                    DateTime? coInstalled = null; if (((TextBox)row.FindControl("tbxCoInstalled")).Text.Trim() != "") coInstalled = DateTime.Parse(((TextBox)row.FindControl("tbxCoInstalled")).Text.Trim());
                    DateTime? backfilledConcrete = null; if (((TextBox)row.FindControl("tbxBackfilledConcrete")).Text.Trim() != "") backfilledConcrete = DateTime.Parse(((TextBox)row.FindControl("tbxBackfilledConcrete")).Text.Trim());
                    DateTime? backfilledSoil = null; if (((TextBox)row.FindControl("tbxBackfilledSoil")).Text.Trim() != "") backfilledSoil = DateTime.Parse(((TextBox)row.FindControl("tbxBackfilledSoil")).Text.Trim());
                    DateTime? grouted = null; if (((TextBox)row.FindControl("tbxGrouted")).Text.Trim() != "") grouted = DateTime.Parse(((TextBox)row.FindControl("tbxGrouted")).Text.Trim());
                    DateTime? cored = null; if (((TextBox)row.FindControl("tbxCored")).Text.Trim() != "") cored = DateTime.Parse(((TextBox)row.FindControl("tbxCored")).Text.Trim());
                    DateTime? prepped = null; if (((TextBox)row.FindControl("tbxPrepped")).Text.Trim() != "") prepped = DateTime.Parse(((TextBox)row.FindControl("tbxPrepped")).Text.Trim());
                    DateTime? measured = null; if (((TextBox)row.FindControl("tbxMeasured")).Text.Trim() != "") measured = DateTime.Parse(((TextBox)row.FindControl("tbxMeasured")).Text.Trim());
                    string linerSize = ""; if (((TextBox)row.FindControl("tbxLinerSize")).Text.Trim() != "") linerSize = ((TextBox)row.FindControl("tbxLinerSize")).Text.Trim();
                    bool liningThruCo = ((CheckBox)row.FindControl("cbxLiningThruCo")).Checked;
                    DateTime? inProcess = null; if (((TextBox)row.FindControl("tbxInProcess")).Text.Trim() != "") inProcess = DateTime.Parse(((TextBox)row.FindControl("tbxInProcess")).Text.Trim());
                    DateTime? inStock = null; if (((TextBox)row.FindControl("tbxInStock")).Text.Trim() != "") inStock = DateTime.Parse(((TextBox)row.FindControl("tbxInStock")).Text.Trim());
                    DateTime? delivered = null; if (((TextBox)row.FindControl("tbxDelivered")).Text.Trim() != "") delivered = DateTime.Parse(((TextBox)row.FindControl("tbxDelivered")).Text.Trim());
                    DateTime? preVideo = null; if (((TextBox)row.FindControl("tbxPreVideo")).Text.Trim() != "") preVideo = DateTime.Parse(((TextBox)row.FindControl("tbxPreVideo")).Text.Trim());
                    DateTime? linerInstalled = null; if (((TextBox)row.FindControl("tbxLinerInstalled")).Text.Trim() != "") linerInstalled = DateTime.Parse(((TextBox)row.FindControl("tbxLinerInstalled")).Text.Trim());
                    DateTime? finalVideo = null; if (((TextBox)row.FindControl("tbxFinalVideo")).Text.Trim() != "") finalVideo = DateTime.Parse(((TextBox)row.FindControl("tbxFinalVideo")).Text.Trim());
                    double? distanceFromUSMH = null; if (((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim() != "") distanceFromUSMH = double.Parse(((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim());
                    string comments = ""; if (((TextBox)row.FindControl("tbxComments")).Text.Trim() != "") comments = ((TextBox)row.FindControl("tbxComments")).Text.Trim();
                    string history = ""; if (((TextBox)row.FindControl("tbxHistory")).Text.Trim() != "") history = ((TextBox)row.FindControl("tbxHistory")).Text.Trim();
                    string issue = ((DropDownList)row.FindControl("ddlIssue")).SelectedValue.Trim();
                    decimal? cost = null; if (((TextBox)row.FindControl("tbxCost")).Text.Trim() != "") cost = decimal.Parse(((TextBox)row.FindControl("tbxCost")).Text.Trim());
                    bool deleted = false;
                    bool selected = true;
                    DateTime? videoInspection = null; if (((TextBox)row.FindControl("tbxVideoInspection")).Text.Trim() != "") videoInspection = DateTime.Parse(((TextBox)row.FindControl("tbxVideoInspection")).Text.Trim());
                    string videoLengthToPropertyLine = ""; if (((TextBox)row.FindControl("tbxVideoLengthToPropertyLine")).Text.Trim() != "") videoLengthToPropertyLine = ((TextBox)row.FindControl("tbxVideoLengthToPropertyLine")).Text.Trim();
                    bool coRequired = ((CheckBox)row.FindControl("cbxCoReq")).Checked;
                    bool pitRequired = ((CheckBox)row.FindControl("cbxPitReq")).Checked;
                    string coPitLocation = ""; coPitLocation = ((DropDownList)row.FindControl("ddlCoPitLocation")).SelectedValue;
                    bool postContractDigRequired = ((CheckBox)row.FindControl("cbxPostContractDigRequired")).Checked;
                    DateTime? coCutDown = null; if (((TextBox)row.FindControl("tbxCoCutDown")).Text.Trim() != "") coCutDown = DateTime.Parse(((TextBox)row.FindControl("tbxCoCutDown")).Text.Trim());
                    DateTime? finalRestoration = null; if (((TextBox)row.FindControl("tbxFinalRestoration")).Text.Trim() != "") finalRestoration = DateTime.Parse(((TextBox)row.FindControl("tbxFinalRestoration")).Text.Trim());
                    string clientLateralId = ""; if (((TextBox)row.FindControl("tbxClientLateralId")).Text.Trim() != "") clientLateralId = ((TextBox)row.FindControl("tbxClientLateralId")).Text.Trim();
                    string hamiltonInspectionNumber = ""; if (((TextBox)row.FindControl("tbxHamiltonInspectionNumber")).Text.Trim() != "") hamiltonInspectionNumber = ((TextBox)row.FindControl("tbxHamiltonInspectionNumber")).Text.Trim();
                    DateTime? noticeDelivered = null; if (((TextBox)row.FindControl("tbxNoticeDelivered")).Text.Trim() != "") noticeDelivered = DateTime.Parse(((TextBox)row.FindControl("tbxNoticeDelivered")).Text.Trim());

                    // ... Calculate fields
                    double? distanceFromDSMH = null;
                    if (distanceFromUSMH.HasValue)
                    {
                        SectionGateway sectionGateway = new SectionGateway();
                        sectionGateway.LoadById(id, companyId);

                        Distance length = new Distance(sectionGateway.GetActualLength(id)) - new Distance(((double)distanceFromUSMH).ToString());
                        distanceFromDSMH = length.ToDoubleInEng3();
                    }

                    // ... Update row
                    flatSectionJliner.Update(id_, id, refId, companyId, recordId, detailId, address, pipeLocated, servicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, preVideo, linerInstalled, finalVideo, distanceFromUSMH, distanceFromDSMH, comments, history, issue, cost, deleted, selected, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, coCutDown, finalRestoration, clientLateralId, videoLengthToPropertyLine, liningThruCo, hamiltonInspectionNumber, noticeDelivered);
                }

                // Store datasets
                Session["flatSectionJlinerTDS"] = flatSectionJlinerTDS;

                // Update section and jliners
                sectionTDS = new SectionTDS();
                flatSectionJliner.Save(sectionTDS);
            }
        }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        private void ProcessDataForProject(int currentProjectId, string currentPhase, int companyId)
        {
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;

            string projectName = "";
            ProjectGateway projectGateway = new ProjectGateway();
            projectGateway.LoadByProjectId(currentProjectId);
            projectName = projectGateway.GetName(currentProjectId);

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHRow row in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHDataTable)Table)
            {
                if (row.ProjectName.Contains(projectName) && row.Phase.Contains(currentPhase))
                {
                    if (!row.IsTotalFtNull())
                    {
                        Distance dist = new Distance(row.TotalFt);
                        row.RealFt = dist.ToDoubleInEng3();
                        row.TotalFtDouble = dist.ToDoubleInEng3();
                    }
                    else
                    {
                        row.RealFt = 0;
                        row.TotalFtDouble = 0;
                    }

                    if (!alDays.Contains(row.Date))
                    {
                        alDays.Add(row.Date);
                    }

                    rateAcum = rateAcum + row.RealFt / row.Hrs;
                }
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHRow row2 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHDataTable)Table)
            {
                if (row2.ProjectName.Contains(projectName) && row2.Phase.Contains(currentPhase))
                {
                    row2.NumPeriods = alDays.Count;
                    row2.AverageRate = rateAcum / alDays.Count;
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="works">works</param>
        /// <param name="projectId">projectId</param>
        /// <param name="startDate">startDate</param>
        /// <param name="endDate">endDate</param>
        /// <param name="companyId">companyId</param>
        public void Load(ArrayList works, int projectId, DateTime startDate, DateTime endDate, int companyId)
        {
            // Foreach of Works (FLL, JL, PR, MH Rehab)
            foreach (string work_ in works)
            {
                ProjectCostingSheetAddMaterialListGateway projectCostingSheetAddMaterialListGateway = new ProjectCostingSheetAddMaterialListGateway(Data);
                projectCostingSheetAddMaterialListGateway.LoadByWork_(work_);

                foreach (ProjectCostingSheetAddTDS.MaterialListRow materialListRow in (ProjectCostingSheetAddTDS.MaterialListDataTable)projectCostingSheetAddMaterialListGateway.Table)
                {
                    string thickness1 = ""; if (!materialListRow.IsThicknessNull()) thickness1 = materialListRow.Thickness;
                    string size1 = ""; if (!materialListRow.IsSizeNull()) size1 = materialListRow.Size;
                    string length1 = ""; if (!materialListRow.IsLengthNull()) length1 = materialListRow.Length;
                    int refId = 0;
                    DateTime newStartDate = new DateTime();
                    newStartDate = startDate;
                    DateTime newEndDate = new DateTime();
                    newEndDate = endDate;
                    string function_ = "";

                    ProjectCostingSheetAddMaterialPayPeriodGateway projectCostingSheetAddMaterialPayPeriodGateway = new ProjectCostingSheetAddMaterialPayPeriodGateway(Data);
                    projectCostingSheetAddMaterialPayPeriodGateway.LoadByStartDateEndDateMaterialId(startDate, endDate, materialListRow.MaterialID);

                    if (projectCostingSheetAddMaterialPayPeriodGateway.Table.Rows.Count > 0)
                    {
                        foreach (ProjectCostingSheetAddTDS.MaterialPayPeriodRow materialPayPeriodRow in (ProjectCostingSheetAddTDS.MaterialPayPeriodDataTable)projectCostingSheetAddMaterialPayPeriodGateway.Table)
                        {
                            newEndDate = materialPayPeriodRow.Date_.AddDays(-1);

                            ProjectCostingSheetAddOriginalMaterialGateway projectCostingSheetAddOriginalMaterialGateway = new ProjectCostingSheetAddOriginalMaterialGateway(Data);

                            switch (materialListRow.Description)
                            {
                                case "Lateral / Misc Supplies":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Misc Supplies", size1, thickness1, length1, newStartDate, newEndDate);
                                    function_ = "Install";
                                    break;

                                case "Lateral / Cleanout Material":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Cleanout Material", size1, thickness1, length1, newStartDate, newEndDate);
                                    function_ = "Other";
                                    break;

                                case "Lateral / Backfill - Cleanout":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Backfill Cleanut", size1, thickness1, length1, newStartDate, newEndDate);
                                    function_ = "Other";
                                    break;

                                case "Lateral / Restoration & Crowle Cap":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Restoration Crowle", size1, thickness1, length1, newStartDate, newEndDate);
                                    function_ = "Restoration";
                                    break;

                                default:
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, work_, size1, thickness1, length1, newStartDate, newEndDate);
                                    function_ = "Install";
                                    break;
                            }

                            if (projectCostingSheetAddOriginalMaterialGateway.Table.Rows.Count > 0)
                            {
                                double quantity = 0;
                                decimal costCad = 0;
                                decimal costUsd = 0;
                                refId++;

                                ProjectCostingSheetAddTDS.MaterialsInformationRow newRow = ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).NewMaterialsInformationRow();
                                GetMaterialData(newStartDate, newEndDate, materialListRow.MaterialID, work_, newRow);

                                if (work_ == "Full Length Lining")
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        double steelTapeLengt = 0;

                                        if (!originalRow.IsSteelTapeLengthNull())
                                        {
                                            Distance d2 = new Distance(originalRow.SteelTapeLength);
                                            steelTapeLengt = d2.ToDoubleInEng3();
                                        }

                                        quantity = quantity + steelTapeLengt;
                                    }
                                }

                                if (work_ == "Point Repairs")
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        quantity = quantity + 1;
                                    }
                                }

                                if (work_ == "Manhole Rehab")
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        double totalSurfaceArea = 0;

                                        if (!originalRow.IsSizeNull())
                                        {
                                            Distance d2 = new Distance(originalRow.Size);
                                            totalSurfaceArea = d2.ToDoubleInEng3();
                                        }

                                        quantity = quantity + totalSurfaceArea;
                                    }
                                }

                                if (work_ == "Junction Lining")
                                {
                                    if (materialListRow.Description == "Lateral / Misc Supplies" || materialListRow.Description == "Lateral / Cleanout Material" || materialListRow.Description == "Lateral / Backfill - Cleanout" || materialListRow.Description == "Lateral / Restoration & Crowle Cap")
                                    {
                                        foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                        {
                                            quantity = quantity + 1;
                                        }
                                    }
                                    else
                                    {
                                        foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                        {
                                            if (!originalRow.IsLinerSizeNull())
                                            {
                                                // Ex: M1 Size = 6", Liner Size = 30' or 29'6"
                                                if (!originalRow.LinerSize.ToLower().Contains("x"))
                                                {
                                                    // 6"
                                                    string m1Size = "Junction Liner / Lateral " + originalRow.Size;
                                                    decimal m1SizeCostCad = GetCostCad(newStartDate, newEndDate, m1Size, work_, companyId);
                                                    decimal m1SizeCostUsd = GetCostUsd(newStartDate, newEndDate, m1Size, work_, companyId);

                                                    // 30'
                                                    if (originalRow.LinerSize[originalRow.LinerSize.Length - 1] == '\'')
                                                    {
                                                        string linerSize = originalRow.LinerSize.Substring(0, originalRow.LinerSize.Length - 1);
                                                        decimal dmLinerSize = decimal.Parse(linerSize);

                                                        //newRow.CostCad = Cost (Main Size)
                                                        costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                        costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                    }
                                                    else
                                                    {
                                                        // or 29'6"
                                                        string linerSize = originalRow.LinerSize.Substring(0, originalRow.LinerSize.Length);
                                                        Distance dLinerSize = new Distance(linerSize);
                                                        double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                        decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                        dmLinerSize = Math.Ceiling(dmLinerSize);

                                                        //newRow.CostCad = Cost (Main Size)
                                                        costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                        costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                    }
                                                }
                                                else
                                                {
                                                    int numX = originalRow.LinerSize.ToLower().Split('x').Length - 1;

                                                    // Ex: Liner Size = 4" x 10' or 4" x 9'6" or (4" x 10') or (4" x 9'6") ==> M1 Size = 4"
                                                    if (numX == 1)
                                                    {
                                                        //4"
                                                        string m1Size = "";
                                                        int endIndexM1Size = originalRow.LinerSize.IndexOf('"');

                                                        //(....)
                                                        if (originalRow.LinerSize[0] == '(')
                                                        {
                                                            m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Substring(1, endIndexM1Size);
                                                            decimal m1SizeCostCad = GetCostCad(newStartDate, newEndDate, m1Size, work_, companyId);
                                                            decimal m1SizeCostUsd = GetCostUsd(newStartDate, newEndDate, m1Size, work_, companyId);

                                                            //9'6")
                                                            if (originalRow.LinerSize[originalRow.LinerSize.Length - 2] == '"')
                                                            {
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, (endIndexLinerSize + 1) - startIndexLinerSize);
                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                                dmLinerSize = Math.Ceiling(dmLinerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                            else
                                                            {
                                                                //10')
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, endIndexLinerSize - startIndexLinerSize);
                                                                decimal dmLinerSize = decimal.Parse(linerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            //.....
                                                            m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Substring(0, endIndexM1Size);
                                                            decimal m1SizeCostCad = GetCostCad(newStartDate, newEndDate, m1Size, work_, companyId);
                                                            decimal m1SizeCostUsd = GetCostUsd(newStartDate, newEndDate, m1Size, work_, companyId);

                                                            //9'6"
                                                            if (originalRow.LinerSize[originalRow.LinerSize.Length - 1] == '"')
                                                            {
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, (endIndexLinerSize + 1) - startIndexLinerSize);
                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                                dmLinerSize = Math.Ceiling(dmLinerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                            else
                                                            {
                                                                //10'
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, endIndexLinerSize - startIndexLinerSize);
                                                                decimal dmLinerSize = decimal.Parse(linerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        // Ex: M1 Size = 6", Liner Size = 20' x (4" x 10') or 19'6" x (4" x 9'3") ==> M1 Size 2 = 4"
                                                        if (numX == 2)
                                                        {
                                                            if (originalRow.LinerSize[0] == '(')
                                                            {
                                                                // Ex: M1 Size = 6", Liner Size = (6"x20')(4"x10') or (6"x19'6")(4"x10') or (6"x20')(4"x19'6"') or (6"x19'6")(4"x19'6"')
                                                                //6"
                                                                string m1Size = "";
                                                                int endIndexM1Size = originalRow.LinerSize.Trim().IndexOf('"');
                                                                m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(1, endIndexM1Size);

                                                                decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                                decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                                decimal dmLinerSize = 0;

                                                                //19'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.Trim().IndexOf(')', endIndexM1Size) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //20'
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, endIndexLinerSize - firtsXIndex);
                                                                    dmLinerSize = decimal.Parse(linerSize);
                                                                }

                                                                //4"
                                                                int startIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('(', 1) + 1;
                                                                int endIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('"', startIndexM1Size2);
                                                                string m1Size2 = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(startIndexM1Size2, (endIndexM1Size2 + 1) - startIndexM1Size2);

                                                                decimal m1Size2CostCad = GetCostCad(startDate, endDate, m1Size2, work_, companyId);
                                                                decimal m1Size2CostUsd = GetCostUsd(startDate, endDate, m1Size2, work_, companyId);

                                                                decimal dmLinerSize2 = 0;

                                                                //9'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf(')', endIndexM1Size2) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize2 = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //10'
                                                                    int startIndexLinerSize2 = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize2 = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize2);
                                                                    string linerSize2 = originalRow.LinerSize.Trim().Substring(startIndexLinerSize2, endIndexLinerSize2 - startIndexLinerSize2);
                                                                    dmLinerSize2 = decimal.Parse(linerSize2);
                                                                }

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + transitionBuildCostCad + (m1SizeCostCad * dmLinerSize) + (m1Size2CostCad * dmLinerSize2);
                                                                costUsd = newRow.CostUsd + transitionBuildCostUsd + (m1SizeCostUsd * dmLinerSize) + (m1Size2CostUsd * dmLinerSize2);
                                                            }
                                                            else
                                                            {
                                                                //Ex: M1 Size = 6", Liner Size = 20' x (4" x 10') or 19'6" x (4" x 9'3") ==> M1 Size 2 = 4"
                                                                //6"
                                                                string m1Size = "Junction Liner / Lateral " + originalRow.Size;

                                                                decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                                decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                                decimal dmLinerSize = 0;

                                                                //19'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf('x', 0) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = 0;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //20'
                                                                    int firtsXIndex = 0;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, endIndexLinerSize - firtsXIndex);
                                                                    dmLinerSize = decimal.Parse(linerSize);
                                                                }

                                                                //4"
                                                                int startIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('(') + 1;
                                                                int endIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('"', startIndexM1Size2);
                                                                string m1Size2 = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(startIndexM1Size2, (endIndexM1Size2 + 1) - startIndexM1Size2);

                                                                decimal m1Size2CostCad = GetCostCad(startDate, endDate, m1Size2, work_, companyId);
                                                                decimal m1Size2CostUsd = GetCostUsd(startDate, endDate, m1Size2, work_, companyId);

                                                                decimal dmLinerSize2 = 0;

                                                                //9'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf(')', endIndexM1Size2) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize2 = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //10'
                                                                    int startIndexLinerSize2 = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize2 = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize2);
                                                                    string linerSize2 = originalRow.LinerSize.Trim().Substring(startIndexLinerSize2, endIndexLinerSize2 - startIndexLinerSize2);
                                                                    dmLinerSize2 = decimal.Parse(linerSize2);
                                                                }

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + transitionBuildCostCad + (m1SizeCostCad * dmLinerSize) + (m1Size2CostCad * dmLinerSize2);
                                                                costUsd = newRow.CostUsd + transitionBuildCostUsd + (m1SizeCostUsd * dmLinerSize) + (m1Size2CostUsd * dmLinerSize2);
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                            ////
                                            if (materialListRow.Description != "Lateral / Misc Supplies" && materialListRow.Description != "Lateral / Cleanout Material" && materialListRow.Description != "Lateral / Backfill - Cleanout" && materialListRow.Description != "Lateral / Restoration & Crowle Cap")
                                            {
                                                ProjectCostingSheetAddTDS.MaterialsInformationRow newRow2 = ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).NewMaterialsInformationRow();
                                                GetMaterialData(startDate, endDate, materialListRow.MaterialID, work_, newRow2);

                                                newRow2.CostingSheetID = 0;
                                                newRow2.RefID = refId;
                                                newRow2.Quantity = 1;
                                                newRow2.CostCad = costCad;
                                                newRow2.CostUsd = costUsd;
                                                newRow2.TotalCostCad = newRow2.CostCad;
                                                newRow2.TotalCostUsd = newRow2.CostUsd;
                                                newRow2.Deleted = false;
                                                newRow2.COMPANY_ID = companyId;
                                                newRow2.InDatabase = false;
                                                newRow2.Process = work_;
                                                newRow2.Description = materialListRow.Description;
                                                newRow2.UnitOfMeasurement = "Each";
                                                newRow2.StartDate = newStartDate;
                                                newRow2.EndDate = newEndDate;
                                                newRow2.FromDatabase = true;
                                                newRow2.MaterialID = materialListRow.MaterialID;
                                                refId++;
                                                newRow2.Function_ = function_;
                                                newRow2.WorkFunction = work_ + " . " + function_;
                                                ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).AddMaterialsInformationRow(newRow2);
                                            }
                                            ////
                                        }
                                    }
                                }//JL

                                if (work_ != "Junction Lining" || materialListRow.Description == "Lateral / Misc Supplies" || materialListRow.Description == "Lateral / Cleanout Material" || materialListRow.Description == "Lateral / Backfill - Cleanout" || materialListRow.Description == "Lateral / Restoration & Crowle Cap")
                                {
                                    newRow.CostingSheetID = 0;
                                    newRow.RefID = refId;
                                    newRow.Quantity = quantity;
                                    newRow.TotalCostCad = (Convert.ToDecimal(quantity) * newRow.CostCad);
                                    newRow.TotalCostUsd = (Convert.ToDecimal(quantity) * newRow.CostUsd);
                                    newRow.Deleted = false;
                                    newRow.COMPANY_ID = companyId;
                                    newRow.InDatabase = false;
                                    newRow.Process = work_;
                                    newRow.Description = materialListRow.Description;
                                    if (work_ == "Point Repairs" || work_ == "Junction Lining")
                                    {
                                        newRow.UnitOfMeasurement = "Each";
                                    }
                                    else
                                    {
                                        if (work_ == "Manhole Rehab")
                                        {
                                            newRow.UnitOfMeasurement = "Square Foot";
                                        }
                                        {
                                            newRow.UnitOfMeasurement = materialListRow.UnitOfMeasurement;
                                        }
                                    }
                                    newRow.StartDate = newStartDate;
                                    newRow.EndDate = newEndDate;
                                    newRow.FromDatabase = true;
                                    newRow.MaterialID = materialListRow.MaterialID;
                                    newRow.Function_ = function_;
                                    newRow.WorkFunction = work_ + " . " + function_;
                                    ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).AddMaterialsInformationRow(newRow);
                                }
                            }

                            newStartDate = newEndDate.AddDays(1);
                        }

                        if (newEndDate <= endDate)
                        {
                            ProjectCostingSheetAddOriginalMaterialGateway projectCostingSheetAddOriginalMaterialGateway = new ProjectCostingSheetAddOriginalMaterialGateway(Data);

                            switch (materialListRow.Description)
                            {
                                case "Lateral / Misc Supplies":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Misc Supplies", size1, thickness1, length1, newStartDate, endDate);
                                    function_ = "Install";
                                    break;

                                case "Lateral / Cleanout Material":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Cleanout Material", size1, thickness1, length1, newStartDate, endDate);
                                    function_ = "Other";
                                    break;

                                case "Lateral / Backfill - Cleanout":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Backfill Cleanut", size1, thickness1, length1, newStartDate, endDate);
                                    function_ = "Other";
                                    break;

                                case "Lateral / Restoration & Crowle Cap":
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Restoration Crowle", size1, thickness1, length1, newStartDate, endDate);
                                    function_ = "Restoration";
                                    break;

                                default:
                                    projectCostingSheetAddOriginalMaterialGateway.Load(projectId, work_, size1, thickness1, length1, newStartDate, endDate);
                                    function_ = "Install";
                                    break;
                            }

                            if (projectCostingSheetAddOriginalMaterialGateway.Table.Rows.Count > 0)
                            {
                                double quantity = 0;
                                decimal costCad = 0;
                                decimal costUsd = 0;
                                refId++;

                                ProjectCostingSheetAddTDS.MaterialsInformationRow newRow = ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).NewMaterialsInformationRow();
                                GetMaterialData(newStartDate, endDate, materialListRow.MaterialID, work_, newRow);

                                if (work_ == "Full Length Lining")
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        double steelTapeLengt = 0;

                                        if (!originalRow.IsSteelTapeLengthNull())
                                        {
                                            Distance d2 = new Distance(originalRow.SteelTapeLength);
                                            steelTapeLengt = d2.ToDoubleInEng3();
                                        }

                                        quantity = quantity + steelTapeLengt;
                                    }
                                }

                                if (work_ == "Point Repairs")
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        quantity = quantity + 1;
                                    }
                                }

                                if (work_ == "Manhole Rehab")
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        double totalSurfaceArea = 0;

                                        if (!originalRow.IsSizeNull())
                                        {
                                            Distance d2 = new Distance(originalRow.Size);
                                            totalSurfaceArea = d2.ToDoubleInEng3();
                                        }

                                        quantity = quantity + totalSurfaceArea;
                                    }
                                }

                                if (work_ == "Junction Lining")
                                {
                                    if (materialListRow.Description == "Lateral / Misc Supplies" || materialListRow.Description == "Lateral / Cleanout Material" || materialListRow.Description == "Lateral / Backfill - Cleanout" || materialListRow.Description == "Lateral / Restoration & Crowle Cap")
                                    {
                                        foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                        {
                                            quantity = quantity + 1;
                                        }
                                    }
                                    else
                                    {
                                        foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                        {
                                            if (!originalRow.IsLinerSizeNull())
                                            {
                                                // Ex: M1 Size = 6", Liner Size = 30' or 29'6"
                                                if (!originalRow.LinerSize.ToLower().Contains("x"))
                                                {
                                                    // 6"
                                                    string m1Size = "Junction Liner / Lateral " + originalRow.Size;
                                                    decimal m1SizeCostCad = GetCostCad(newStartDate, endDate, m1Size, work_, companyId);
                                                    decimal m1SizeCostUsd = GetCostUsd(newStartDate, endDate, m1Size, work_, companyId);

                                                    // 30'
                                                    if (originalRow.LinerSize[originalRow.LinerSize.Length - 1] == '\'')
                                                    {
                                                        string linerSize = originalRow.LinerSize.Substring(0, originalRow.LinerSize.Length - 1);
                                                        decimal dmLinerSize = decimal.Parse(linerSize);

                                                        //newRow.CostCad = Cost (Main Size)
                                                        costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                        costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                    }
                                                    else
                                                    {
                                                        // or 29'6"
                                                        string linerSize = originalRow.LinerSize.Substring(0, originalRow.LinerSize.Length);
                                                        Distance dLinerSize = new Distance(linerSize);
                                                        double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                        decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                        dmLinerSize = Math.Ceiling(dmLinerSize);

                                                        //newRow.CostCad = Cost (Main Size)
                                                        costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                        costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                    }
                                                }
                                                else
                                                {
                                                    int numX = originalRow.LinerSize.ToLower().Split('x').Length - 1;

                                                    // Ex: Liner Size = 4" x 10' or 4" x 9'6" or (4" x 10') or (4" x 9'6") ==> M1 Size = 4"
                                                    if (numX == 1)
                                                    {
                                                        //4"
                                                        string m1Size = "";
                                                        int endIndexM1Size = originalRow.LinerSize.IndexOf('"');

                                                        //(....)
                                                        if (originalRow.LinerSize[0] == '(')
                                                        {
                                                            m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Substring(1, endIndexM1Size);
                                                            decimal m1SizeCostCad = GetCostCad(newStartDate, endDate, m1Size, work_, companyId);
                                                            decimal m1SizeCostUsd = GetCostUsd(newStartDate, endDate, m1Size, work_, companyId);

                                                            //9'6")
                                                            if (originalRow.LinerSize[originalRow.LinerSize.Length - 2] == '"')
                                                            {
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, (endIndexLinerSize + 1) - startIndexLinerSize);
                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                                dmLinerSize = Math.Ceiling(dmLinerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                            else
                                                            {
                                                                //10')
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, endIndexLinerSize - startIndexLinerSize);
                                                                decimal dmLinerSize = decimal.Parse(linerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            //.....
                                                            m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Substring(0, endIndexM1Size);
                                                            decimal m1SizeCostCad = GetCostCad(newStartDate, endDate, m1Size, work_, companyId);
                                                            decimal m1SizeCostUsd = GetCostUsd(newStartDate, endDate, m1Size, work_, companyId);

                                                            //9'6"
                                                            if (originalRow.LinerSize[originalRow.LinerSize.Length - 1] == '"')
                                                            {
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, (endIndexLinerSize + 1) - startIndexLinerSize);
                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                                dmLinerSize = Math.Ceiling(dmLinerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                            else
                                                            {
                                                                //10'
                                                                int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, endIndexLinerSize - startIndexLinerSize);
                                                                decimal dmLinerSize = decimal.Parse(linerSize);

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                                costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        // Ex: M1 Size = 6", Liner Size = 20' x (4" x 10') or 19'6" x (4" x 9'3") ==> M1 Size 2 = 4"
                                                        if (numX == 2)
                                                        {
                                                            if (originalRow.LinerSize[0] == '(')
                                                            {
                                                                // Ex: M1 Size = 6", Liner Size = (6"x20')(4"x10') or (6"x19'6")(4"x10') or (6"x20')(4"x19'6"') or (6"x19'6")(4"x19'6"')
                                                                //6"
                                                                string m1Size = "";
                                                                int endIndexM1Size = originalRow.LinerSize.Trim().IndexOf('"');
                                                                m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(1, endIndexM1Size);

                                                                decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                                decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                                decimal dmLinerSize = 0;

                                                                //19'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.Trim().IndexOf(')', endIndexM1Size) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //20'
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, endIndexLinerSize - firtsXIndex);
                                                                    dmLinerSize = decimal.Parse(linerSize);
                                                                }

                                                                //4"
                                                                int startIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('(', 1) + 1;
                                                                int endIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('"', startIndexM1Size2);
                                                                string m1Size2 = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(startIndexM1Size2, (endIndexM1Size2 + 1) - startIndexM1Size2);

                                                                decimal m1Size2CostCad = GetCostCad(startDate, endDate, m1Size2, work_, companyId);
                                                                decimal m1Size2CostUsd = GetCostUsd(startDate, endDate, m1Size2, work_, companyId);

                                                                decimal dmLinerSize2 = 0;

                                                                //9'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf(')', endIndexM1Size2) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize2 = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //10'
                                                                    int startIndexLinerSize2 = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize2 = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize2);
                                                                    string linerSize2 = originalRow.LinerSize.Trim().Substring(startIndexLinerSize2, endIndexLinerSize2 - startIndexLinerSize2);
                                                                    dmLinerSize2 = decimal.Parse(linerSize2);
                                                                }

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + transitionBuildCostCad + (m1SizeCostCad * dmLinerSize) + (m1Size2CostCad * dmLinerSize2);
                                                                costUsd = newRow.CostUsd + transitionBuildCostUsd + (m1SizeCostUsd * dmLinerSize) + (m1Size2CostUsd * dmLinerSize2);
                                                            }
                                                            else
                                                            {
                                                                //Ex: M1 Size = 6", Liner Size = 20' x (4" x 10') or 19'6" x (4" x 9'3") ==> M1 Size 2 = 4"
                                                                //6"
                                                                string m1Size = "Junction Liner / Lateral " + originalRow.Size;

                                                                decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                                decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                                decimal dmLinerSize = 0;

                                                                //19'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf('x', 0) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = 0;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //20'
                                                                    int firtsXIndex = 0;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, endIndexLinerSize - firtsXIndex);
                                                                    dmLinerSize = decimal.Parse(linerSize);
                                                                }

                                                                //4"
                                                                int startIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('(') + 1;
                                                                int endIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('"', startIndexM1Size2);
                                                                string m1Size2 = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(startIndexM1Size2, (endIndexM1Size2 + 1) - startIndexM1Size2);

                                                                decimal m1Size2CostCad = GetCostCad(startDate, endDate, m1Size2, work_, companyId);
                                                                decimal m1Size2CostUsd = GetCostUsd(startDate, endDate, m1Size2, work_, companyId);

                                                                decimal dmLinerSize2 = 0;

                                                                //9'6"
                                                                if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf(')', endIndexM1Size2) - 1] == '"')
                                                                {
                                                                    int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                    string linerSize = originalRow.LinerSize.Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                    Distance dLinerSize = new Distance(linerSize);
                                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                    dmLinerSize2 = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                                }
                                                                else
                                                                {
                                                                    //10'
                                                                    int startIndexLinerSize2 = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                    int endIndexLinerSize2 = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize2);
                                                                    string linerSize2 = originalRow.LinerSize.Trim().Substring(startIndexLinerSize2, endIndexLinerSize2 - startIndexLinerSize2);
                                                                    dmLinerSize2 = decimal.Parse(linerSize2);
                                                                }

                                                                //newRow.CostCad = Cost (Main Size)
                                                                costCad = newRow.CostCad + transitionBuildCostCad + (m1SizeCostCad * dmLinerSize) + (m1Size2CostCad * dmLinerSize2);
                                                                costUsd = newRow.CostUsd + transitionBuildCostUsd + (m1SizeCostUsd * dmLinerSize) + (m1Size2CostUsd * dmLinerSize2);
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                            ////
                                            if (materialListRow.Description != "Lateral / Misc Supplies" && materialListRow.Description != "Lateral / Cleanout Material" && materialListRow.Description != "Lateral / Backfill - Cleanout" && materialListRow.Description != "Lateral / Restoration & Crowle Cap")
                                            {
                                                ProjectCostingSheetAddTDS.MaterialsInformationRow newRow2 = ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).NewMaterialsInformationRow();
                                                GetMaterialData(startDate, endDate, materialListRow.MaterialID, work_, newRow2);

                                                newRow2.CostingSheetID = 0;
                                                newRow2.RefID = refId;
                                                newRow2.Quantity = 1;
                                                newRow2.CostCad = costCad;
                                                newRow2.CostUsd = costUsd;
                                                newRow2.TotalCostCad = newRow2.CostCad;
                                                newRow2.TotalCostUsd = newRow2.CostUsd;
                                                newRow2.Deleted = false;
                                                newRow2.COMPANY_ID = companyId;
                                                newRow2.InDatabase = false;
                                                newRow2.Process = work_;
                                                newRow2.Description = materialListRow.Description;
                                                newRow2.UnitOfMeasurement = "Each";
                                                newRow2.StartDate = newStartDate;
                                                newRow2.EndDate = endDate;
                                                newRow2.FromDatabase = true;
                                                newRow2.MaterialID = materialListRow.MaterialID;
                                                refId++;
                                                newRow2.Function_ = function_;
                                                newRow2.WorkFunction = work_ + " . " + function_;
                                                ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).AddMaterialsInformationRow(newRow2);
                                            }
                                            ////
                                        }
                                    }
                                }

                                if (work_ != "Junction Lining" || materialListRow.Description == "Lateral / Misc Supplies" || materialListRow.Description == "Lateral / Cleanout Material" || materialListRow.Description == "Lateral / Backfill - Cleanout" || materialListRow.Description == "Lateral / Restoration & Crowle Cap")
                                {
                                    newRow.CostingSheetID = 0;
                                    newRow.RefID = refId;
                                    newRow.Quantity = quantity;
                                    newRow.TotalCostCad = (Convert.ToDecimal(quantity) * newRow.CostCad);
                                    newRow.TotalCostUsd = (Convert.ToDecimal(quantity) * newRow.CostUsd);
                                    newRow.Deleted = false;
                                    newRow.COMPANY_ID = companyId;
                                    newRow.InDatabase = false;
                                    newRow.Process = work_;
                                    newRow.Description = materialListRow.Description;
                                    if (work_ == "Point Repairs" || work_ == "Junction Lining")
                                    {
                                        newRow.UnitOfMeasurement = "Each";
                                    }
                                    else
                                    {
                                        if (work_ == "Manhole Rehab")
                                        {
                                            newRow.UnitOfMeasurement = "Square Foot";
                                        }
                                        {
                                            newRow.UnitOfMeasurement = materialListRow.UnitOfMeasurement;
                                        }
                                    }
                                    newRow.StartDate = newStartDate;
                                    newRow.EndDate = endDate;
                                    newRow.FromDatabase = true;
                                    newRow.MaterialID = materialListRow.MaterialID;
                                    newRow.Function_ = function_;
                                    newRow.WorkFunction = work_ + " . " + function_;
                                    ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).AddMaterialsInformationRow(newRow);
                                }
                            }
                        }
                    }
                    else
                    {
                        ProjectCostingSheetAddOriginalMaterialGateway projectCostingSheetAddOriginalMaterialGateway = new ProjectCostingSheetAddOriginalMaterialGateway(Data);

                        switch (materialListRow.Description)
                        {
                            case "Lateral / Misc Supplies":
                                projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Misc Supplies", size1, thickness1, length1, startDate, endDate);
                                function_ = "Install";
                                break;

                            case "Lateral / Cleanout Material":
                                projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Cleanout Material", size1, thickness1, length1, startDate, endDate);
                                function_ = "Other";
                                break;

                            case "Lateral / Backfill - Cleanout":
                                projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Backfill Cleanut", size1, thickness1, length1, startDate, endDate);
                                function_ = "Other";
                                break;

                            case "Lateral / Restoration & Crowle Cap":
                                projectCostingSheetAddOriginalMaterialGateway.Load(projectId, "Junction Lining Restoration Crowle", size1, thickness1, length1, startDate, endDate);
                                function_ = "Restoration";
                                break;

                            default:
                                projectCostingSheetAddOriginalMaterialGateway.Load(projectId, work_, size1, thickness1, length1, startDate, endDate);
                                function_ = "Install";
                                break;
                        }

                        if (projectCostingSheetAddOriginalMaterialGateway.Table.Rows.Count > 0)
                        {
                            double quantity = 0;
                            decimal costCad = 0;
                            decimal costUsd = 0;
                            refId++;

                            ProjectCostingSheetAddTDS.MaterialsInformationRow newRow = ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).NewMaterialsInformationRow();
                            GetMaterialData(startDate, endDate, materialListRow.MaterialID, work_, newRow);

                            if (work_ == "Full Length Lining")
                            {
                                foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                {
                                    double steelTapeLengt = 0;

                                    if (!originalRow.IsSteelTapeLengthNull())
                                    {
                                        Distance d2 = new Distance(originalRow.SteelTapeLength);
                                        steelTapeLengt = d2.ToDoubleInEng3();
                                    }

                                    quantity = quantity + steelTapeLengt;
                                }
                            }

                            if (work_ == "Point Repairs")
                            {
                                foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                {
                                    quantity = quantity + 1;
                                }
                            }

                            if (work_ == "Manhole Rehab")
                            {
                                foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                {
                                    double totalSurfaceArea = 0;

                                    if (!originalRow.IsSizeNull())
                                    {
                                        Distance d2 = new Distance(originalRow.Size);
                                        totalSurfaceArea = d2.ToDoubleInEng3();
                                    }

                                    quantity = quantity + totalSurfaceArea;
                                }
                            }

                            if (work_ == "Junction Lining")
                            {
                                if (materialListRow.Description == "Lateral / Misc Supplies" || materialListRow.Description == "Lateral / Cleanout Material" || materialListRow.Description == "Lateral / Backfill - Cleanout" || materialListRow.Description == "Lateral / Restoration & Crowle Cap")
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        quantity = quantity + 1;
                                    }
                                }
                                else
                                {
                                    foreach (ProjectCostingSheetAddTDS.OriginalMaterialRow originalRow in (ProjectCostingSheetAddTDS.OriginalMaterialDataTable)projectCostingSheetAddOriginalMaterialGateway.Table)
                                    {
                                        if (!originalRow.IsLinerSizeNull())
                                        {
                                            // Ex: M1 Size = 6", Liner Size = 30' or 29'6"
                                            if (!originalRow.LinerSize.ToLower().Contains("x"))
                                            {
                                                // 6"
                                                string m1Size = "Junction Liner / Lateral " + originalRow.Size;
                                                decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                // 30'
                                                if (originalRow.LinerSize[originalRow.LinerSize.Length - 1] == '\'')
                                                {
                                                    string linerSize = originalRow.LinerSize.Substring(0, originalRow.LinerSize.Length - 1);
                                                    decimal dmLinerSize = decimal.Parse(linerSize);

                                                    //newRow.CostCad = Cost (Main Size)
                                                    costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                    costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                }
                                                else
                                                {
                                                    // or 29'6"
                                                    string linerSize = originalRow.LinerSize.Substring(0, originalRow.LinerSize.Length);
                                                    Distance dLinerSize = new Distance(linerSize);
                                                    double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                    decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                    dmLinerSize = Math.Ceiling(dmLinerSize);

                                                    //newRow.CostCad = Cost (Main Size)
                                                    costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                    costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                }
                                            }
                                            else
                                            {
                                                int numX = originalRow.LinerSize.ToLower().Split('x').Length - 1;

                                                // Ex: Liner Size = 4" x 10' or 4" x 9'6" or (4" x 10') or (4" x 9'6") ==> M1 Size = 4"
                                                if (numX == 1)
                                                {
                                                    //4"
                                                    string m1Size = "";
                                                    int endIndexM1Size = originalRow.LinerSize.Trim().IndexOf('"');

                                                    //(....)
                                                    if (originalRow.LinerSize[0] == '(')
                                                    {
                                                        m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(1, endIndexM1Size);
                                                        decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                        decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                        //9'6")
                                                        if (originalRow.LinerSize[originalRow.LinerSize.Length - 2] == '"')
                                                        {
                                                            int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                            int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', startIndexLinerSize);
                                                            string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, (endIndexLinerSize + 1) - startIndexLinerSize);
                                                            Distance dLinerSize = new Distance(linerSize);
                                                            double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                            decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                            dmLinerSize = Math.Ceiling(dmLinerSize);

                                                            //newRow.CostCad = Cost (Main Size)
                                                            costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                            costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                        }
                                                        else
                                                        {
                                                            //10')
                                                            int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                            int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize);
                                                            string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, endIndexLinerSize - startIndexLinerSize);
                                                            decimal dmLinerSize = decimal.Parse(linerSize);

                                                            //newRow.CostCad = Cost (Main Size)
                                                            costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                            costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        //.....
                                                        m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(0, endIndexM1Size+1);
                                                        decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                        decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                        //9'6"
                                                        if (originalRow.LinerSize[originalRow.LinerSize.Length - 1] == '"')
                                                        {
                                                            int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                            int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', startIndexLinerSize);
                                                            string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, (endIndexLinerSize + 1) - startIndexLinerSize);
                                                            Distance dLinerSize = new Distance(linerSize);
                                                            double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                            decimal dmLinerSize = decimal.Parse(doubleLinerSize.ToString());
                                                            dmLinerSize = Math.Ceiling(dmLinerSize);

                                                            //newRow.CostCad = Cost (Main Size)
                                                            costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                            costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                        }
                                                        else
                                                        {
                                                            //10'
                                                            int startIndexLinerSize = originalRow.LinerSize.ToLower().Trim().IndexOf('x') + 1;
                                                            int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize);
                                                            string linerSize = originalRow.LinerSize.Trim().Substring(startIndexLinerSize, endIndexLinerSize - startIndexLinerSize);
                                                            decimal dmLinerSize = decimal.Parse(linerSize);

                                                            //newRow.CostCad = Cost (Main Size)
                                                            costCad = newRow.CostCad + (m1SizeCostCad * dmLinerSize);
                                                            costUsd = newRow.CostUsd + (m1SizeCostUsd * dmLinerSize);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    // Ex: M1 Size = 6", Liner Size = 20' x (4" x 10') or 19'6" x (4" x 9'3") ==> M1 Size 2 = 4" or  M1 Size = 6", Liner Size = (6"x20')(4"x10') or (6"x19'6")(4"x10') or (6"x20')(4"x19'6"') or (6"x19'6")(4"x19'6"')
                                                    if (numX == 2)
                                                    {
                                                        if (originalRow.LinerSize[0] == '(')
                                                        {
                                                            // Ex: M1 Size = 6", Liner Size = (6"x20')(4"x10') or (6"x19'6")(4"x10') or (6"x20')(4"x19'6"') or (6"x19'6")(4"x19'6"')
                                                            //6"
                                                            string m1Size = "";
                                                            int endIndexM1Size = originalRow.LinerSize.Trim().IndexOf('"');
                                                            m1Size = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(1, endIndexM1Size);

                                                            decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                            decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                            decimal dmLinerSize = 0;

                                                            //19'6"
                                                            if (originalRow.LinerSize[originalRow.LinerSize.Trim().IndexOf(')', endIndexM1Size)-1] == '"')
                                                            {
                                                                int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size) + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                dmLinerSize = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                            }
                                                            else
                                                            {
                                                                //20'
                                                                int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size) + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', firtsXIndex);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, endIndexLinerSize - firtsXIndex);
                                                                dmLinerSize = decimal.Parse(linerSize);
                                                            }

                                                            //4"
                                                            int startIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('(', 1) + 1;
                                                            int endIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('"', startIndexM1Size2);
                                                            string m1Size2 = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(startIndexM1Size2, (endIndexM1Size2 + 1) - startIndexM1Size2);

                                                            decimal m1Size2CostCad = GetCostCad(startDate, endDate, m1Size2, work_, companyId);
                                                            decimal m1Size2CostUsd = GetCostUsd(startDate, endDate, m1Size2, work_, companyId);

                                                            decimal dmLinerSize2 = 0;

                                                            //9'6"
                                                            if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf(')', endIndexM1Size2) - 1] == '"')
                                                            {
                                                                int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                dmLinerSize2 = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                            }
                                                            else
                                                            {
                                                                //10'
                                                                int startIndexLinerSize2 = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                int endIndexLinerSize2 = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize2);
                                                                string linerSize2 = originalRow.LinerSize.Trim().Substring(startIndexLinerSize2, endIndexLinerSize2 - startIndexLinerSize2);
                                                                dmLinerSize2 = decimal.Parse(linerSize2);
                                                            }

                                                            //newRow.CostCad = Cost (Main Size)
                                                            costCad = newRow.CostCad + transitionBuildCostCad + (m1SizeCostCad * dmLinerSize) + (m1Size2CostCad * dmLinerSize2);
                                                            costUsd = newRow.CostUsd + transitionBuildCostUsd + (m1SizeCostUsd * dmLinerSize) + (m1Size2CostUsd * dmLinerSize2);
                                                        }
                                                        else
                                                        {
                                                            //Ex: M1 Size = 6", Liner Size = 20' x (4" x 10') or 19'6" x (4" x 9'3") ==> M1 Size 2 = 4"
                                                            //6"
                                                            string m1Size = "Junction Liner / Lateral " + originalRow.Size;

                                                            decimal m1SizeCostCad = GetCostCad(startDate, endDate, m1Size, work_, companyId);
                                                            decimal m1SizeCostUsd = GetCostUsd(startDate, endDate, m1Size, work_, companyId);

                                                            decimal dmLinerSize = 0;

                                                            //19'6"
                                                            if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf('x', 0) - 1] == '"')
                                                            {
                                                                int firtsXIndex = 0;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                string linerSize = originalRow.LinerSize.Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                dmLinerSize = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                            }
                                                            else
                                                            {
                                                                //20'
                                                                int firtsXIndex = 0;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('\'', firtsXIndex);
                                                                string linerSize = originalRow.LinerSize.Trim().Substring(firtsXIndex, endIndexLinerSize - firtsXIndex);
                                                                dmLinerSize = decimal.Parse(linerSize);
                                                            }

                                                            //4"
                                                            int startIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('(')+1;
                                                            int endIndexM1Size2 = originalRow.LinerSize.Trim().IndexOf('"', startIndexM1Size2);
                                                            string m1Size2 = "Junction Liner / Lateral " + originalRow.LinerSize.Trim().Substring(startIndexM1Size2, (endIndexM1Size2 + 1) - startIndexM1Size2);

                                                            decimal m1Size2CostCad = GetCostCad(startDate, endDate, m1Size2, work_, companyId);
                                                            decimal m1Size2CostUsd = GetCostUsd(startDate, endDate, m1Size2, work_, companyId);

                                                            decimal dmLinerSize2 = 0;

                                                            //9'6"
                                                            if (originalRow.LinerSize[originalRow.LinerSize.ToLower().Trim().IndexOf(')', endIndexM1Size2) - 1] == '"')
                                                            {
                                                                int firtsXIndex = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                int endIndexLinerSize = originalRow.LinerSize.Trim().IndexOf('"', firtsXIndex);
                                                                string linerSize = originalRow.LinerSize.Substring(firtsXIndex, (endIndexLinerSize + 1) - firtsXIndex);

                                                                Distance dLinerSize = new Distance(linerSize);
                                                                double doubleLinerSize = dLinerSize.ToDoubleInEng3();
                                                                dmLinerSize2 = Math.Ceiling(decimal.Parse(doubleLinerSize.ToString()));
                                                            }
                                                            else
                                                            {
                                                                //10'
                                                                int startIndexLinerSize2 = originalRow.LinerSize.ToLower().Trim().IndexOf('x', endIndexM1Size2) + 1;
                                                                int endIndexLinerSize2 = originalRow.LinerSize.Trim().IndexOf('\'', startIndexLinerSize2);
                                                                string linerSize2 = originalRow.LinerSize.Trim().Substring(startIndexLinerSize2, endIndexLinerSize2 - startIndexLinerSize2);
                                                                dmLinerSize2 = decimal.Parse(linerSize2);
                                                            }

                                                            //newRow.CostCad = Cost (Main Size)
                                                            costCad = newRow.CostCad + transitionBuildCostCad + (m1SizeCostCad * dmLinerSize) + (m1Size2CostCad * dmLinerSize2);
                                                            costUsd = newRow.CostUsd + transitionBuildCostUsd + (m1SizeCostUsd * dmLinerSize) + (m1Size2CostUsd * dmLinerSize2);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        ////
                                        if (materialListRow.Description != "Lateral / Misc Supplies" && materialListRow.Description != "Lateral / Cleanout Material" && materialListRow.Description != "Lateral / Backfill - Cleanout" && materialListRow.Description != "Lateral / Restoration & Crowle Cap")
                                        {
                                            ProjectCostingSheetAddTDS.MaterialsInformationRow newRow2 = ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).NewMaterialsInformationRow();
                                            GetMaterialData(startDate, endDate, materialListRow.MaterialID, work_, newRow2);

                                            newRow2.CostingSheetID = 0;
                                            newRow2.RefID = refId;
                                            newRow2.Quantity = 1;
                                            newRow2.CostCad = costCad;
                                            newRow2.CostUsd = costUsd;
                                            newRow2.TotalCostCad = newRow2.CostCad;
                                            newRow2.TotalCostUsd = newRow2.CostUsd;
                                            newRow2.Deleted = false;
                                            newRow2.COMPANY_ID = companyId;
                                            newRow2.InDatabase = false;
                                            newRow2.Process = work_;
                                            newRow2.Description = materialListRow.Description;
                                            newRow2.UnitOfMeasurement = "Each";
                                            newRow2.StartDate = startDate;
                                            newRow2.EndDate = endDate;
                                            newRow2.FromDatabase = true;
                                            newRow2.MaterialID = materialListRow.MaterialID;
                                            refId++;
                                            newRow2.Function_ = function_;
                                            newRow2.WorkFunction = work_ + " . " + function_;
                                            ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).AddMaterialsInformationRow(newRow2);
                                        }
                                        ////
                                    }
                                }
                            }

                            if (work_ != "Junction Lining" || materialListRow.Description == "Lateral / Misc Supplies" || materialListRow.Description == "Lateral / Cleanout Material" || materialListRow.Description == "Lateral / Backfill - Cleanout" || materialListRow.Description == "Lateral / Restoration & Crowle Cap")
                            {
                                newRow.CostingSheetID = 0;
                                newRow.RefID = refId;
                                newRow.Quantity = quantity;
                                newRow.TotalCostCad = (Convert.ToDecimal(quantity) * newRow.CostCad);
                                newRow.TotalCostUsd = (Convert.ToDecimal(quantity) * newRow.CostUsd);
                                newRow.Deleted = false;
                                newRow.COMPANY_ID = companyId;
                                newRow.InDatabase = false;
                                newRow.Process = work_;
                                newRow.Description = materialListRow.Description;
                                if (work_ == "Point Repairs" || work_ == "Junction Lining")
                                {
                                    newRow.UnitOfMeasurement = "Each";
                                }
                                else
                                {
                                    if (work_ == "Manhole Rehab")
                                    {
                                        newRow.UnitOfMeasurement = "Square Foot";
                                    }
                                    {
                                        newRow.UnitOfMeasurement = materialListRow.UnitOfMeasurement;
                                    }
                                }
                                newRow.StartDate = startDate;
                                newRow.EndDate = endDate;
                                newRow.FromDatabase = true;
                                newRow.MaterialID = materialListRow.MaterialID;
                                newRow.Function_ = function_;
                                newRow.WorkFunction = work_ + " . " + function_;
                                ((ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Table).AddMaterialsInformationRow(newRow);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        public void ProcessDataForProject(int companyId)
        {
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHPrepRow row in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHPrepDataTable)Table)
            {
                if (!row.IsTotalFtNull())
                {
                    Distance dist = new Distance(row.TotalFt);
                    row.RealFt = dist.ToDoubleInEng3();
                    row.TotalFtDouble = dist.ToDoubleInEng3();
                }
                else
                {
                    row.RealFt = 0;
                    row.TotalFtDouble = 0;
                }

                if (!alDays.Contains(row.Date))
                {
                    alDays.Add(row.Date);
                }

                rateAcum = rateAcum + row.RealFt / row.Hrs;
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHPrepRow row2 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseMHPrepDataTable)Table)
            {
                row2.NumPeriods = alDays.Count;
                row2.AverageRate = rateAcum / alDays.Count;
            }
        }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <param name="companyId">companyId</param>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        private void ProcessDataForProject(int companyId)
        {
            ArrayList al = new ArrayList();
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;
            int linersAcum = 0;
            double totalHrsAcum = 0;

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

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

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

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

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

                row2.NumPeriods = alDays.Count;
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepRow row3 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhasePLPrepDataTable)Table)
            {
                if (row3.Phase.Contains("Prep"))
                {
                    row3.AverageRate = rateAcum / alDays.Count;
                }
                else
                {
                    row3.AverageRate = totalHrsAcum / linersAcum;
                }
            }
        }
예제 #18
0
        protected void cvDistanceDsmhFooter_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;
            double? distanceFromUsmhFooter = null;
            double? distanceFromDSMH = null;

            // Calculate distance form dsmh
            if (((TextBox)grdJliner2.FooterRow.FindControl("tbxDistanceFromUSMHFooter")).Text.Trim() != "")
            {
                distanceFromUsmhFooter = double.Parse(((TextBox)grdJliner2.FooterRow.FindControl("tbxDistanceFromUSMHFooter")).Text.Trim());
                Distance length = new Distance(tbxActualLength.Text.Trim()) - new Distance(distanceFromUsmhFooter.ToString());
                distanceFromDSMH = length.ToDoubleInEng3();

                if (distanceFromDSMH < 0)
                {
                    args.IsValid = false;
                }
            }
        }
        /// <summary>
        /// ProcessDataForProject
        /// </summary>
        /// <param name="companyId">companyId</param>
        /// <para>Process de data from the original table for the Project Costing report </para>  
        private void ProcessDataForProject(int currentProjectId, string currentPhase, int companyId)
        {
            ArrayList alDays = new ArrayList();
            double rateAcum = 0;
            int numPeriods = 0;

            string projectName = "";
            ProjectGateway projectGateway = new ProjectGateway();
            projectGateway.LoadByProjectId(currentProjectId);
            projectName = projectGateway.GetName(currentProjectId);

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRARow rowOriginal in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRADataTable)Table)
            {
                if (rowOriginal.ProjectName.Contains(projectName) && rowOriginal.Phase.Contains(currentPhase))
                {
                    if (!rowOriginal.IsTotalFtNull())
                    {
                        Distance distOriginal = new Distance(rowOriginal.TotalFt);
                        rowOriginal.TotalFtDouble = distOriginal.ToDoubleInEng3();
                        rowOriginal.RealFt = distOriginal.ToDoubleInEng3();
                    }
                    else
                    {
                        rowOriginal.TotalFtDouble = 0;
                        rowOriginal.RealFt = 0;
                    }

                    rateAcum = rateAcum + rowOriginal.RealFt / rowOriginal.Hrs;

                    // For get number of periods
                    if (!alDays.Contains(rowOriginal.Date))
                    {
                        alDays.Add(rowOriginal.Date);
                        numPeriods = numPeriods + 1;
                    }
                }
            }

            foreach (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRARow row2 in (PrintManhoursPerPhaseTDS.PrintManHoursPerPhaseRADataTable)Table)
            {
                if (row2.ProjectName.Contains(projectName) && row2.Phase.Contains(currentPhase))
                {
                    row2.AverageRate = rateAcum / numPeriods;
                    row2.NumPeriods = numPeriods;
                }
            }
        }
예제 #20
0
        protected void grdJliner2_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("dataEdit");
            if (Page.IsValid)
            {
                Guid id = new Guid(((Label)grdJliner2.Rows[e.RowIndex].Cells[0].FindControl("lblIDEdit")).Text);
                int refId = Int32.Parse(((Label)grdJliner2.Rows[e.RowIndex].Cells[1].FindControl("lblRefIDEdit")).Text);
                int companyId = Int32.Parse(((Label)grdJliner2.Rows[e.RowIndex].Cells[2].FindControl("lblCOMPANY_IDEdit")).Text);
                string detailId = ((TextBox)grdJliner2.Rows[e.RowIndex].Cells[4].FindControl("tbxDetailIdEdit")).Text.Trim();
                string address = ""; if (((TextBox)grdJliner2.Rows[e.RowIndex].Cells[5].FindControl("tbxAddressEdit")).Text.Trim() != "") address = ((TextBox)grdJliner2.Rows[e.RowIndex].Cells[5].FindControl("tbxAddressEdit")).Text.Trim();
                double? distanceFromUSMH = null; if (((TextBox)grdJliner2.Rows[e.RowIndex].Cells[6].FindControl("tbxDistanceFromUSMHEdit")).Text.Trim() != "") distanceFromUSMH = double.Parse(((TextBox)grdJliner2.Rows[e.RowIndex].Cells[6].FindControl("tbxDistanceFromUSMHEdit")).Text.Trim());

                // Calculate fields
                double? distanceFromDSMH = null;
                if (distanceFromUSMH.HasValue)
                {
                    Distance length = new Distance(tbxActualLength.Text.Trim()) - new Distance(distanceFromUSMH.ToString());
                    distanceFromDSMH = length.ToDoubleInEng3();
                }

                JlinerAddJunctionLiner2 model = new JlinerAddJunctionLiner2(jlinerAddTDS);
                model.Update(id, refId, companyId, detailId, address, distanceFromUSMH, distanceFromDSMH );

                Session["jlinerAddTDS"] = jlinerAddTDS;
            }
            else
            {
                e.Cancel = true;
            }
        }