private void show_estimate(string invoiceNo) { txtBox_estimate_AP.Text = "Invalid"; txtBox_estimate_AP_factor = 0.0; txtBox_estimate_AP_nonfactor = 0.0; txtBox_estimate_HE.Text = "Invalid"; txtBox_estimate_HE_factor = 0.0; txtBox_estimate_HE_nonfactor = 0.0; txtBox_estimate_EP.Text = "Invalid"; txtBox_estimate_EP_factor = 0.0; txtBox_estimate_EP_nonfactor = 0.0; txtBox_estimate_EP_weightfactor = 0.0; txtBox_estimate_TL.Text = "Invalid"; txtBox_estimate_TL_factor = 0.0; txtBox_estimate_TL_nonfactor = 0.0; txtBox_estimate_TL_weightfactor = 0.0; double AP_total = 0.0; double EP_total = 0.0; double HE_total = 0.0; double TL_total = 0.0; double EP_size_total = 0.0; double TL_size_total = 0.0; cost_estimates = new ArrayList(6) { "","","","","",""}; string new_temp_city = temp_invoice.InvoiceCustomer.City; int num_parcels = int.Parse(txtBox_input_parcelnum.Text); int parcel_number = 1; //int numSizeWeights = txtBox_input_dimensions.Text == "" ? 0 : txtBox_input_dimensions.Text.Split('/').Length; // Split the weights and do separate checks for each foreach (string str_weight in txtBox_input_weight.Text.Split('/')) { float weight = float.Parse(str_weight); if (weight > 25.0) { MessageBox.Show("Parcel weight is larger than 25KGs!"); return; } Parcel p = new Parcel(weight, parcel_number, 0.0d, num_parcels); temp_invoice.addParcel(p); //if (numSizeWeights > 0 && parcel_number <= numSizeWeights) { Dimensions d = new Dimensions(); //string vals = txtBox_input_dimensions.Text.Split('/')[parcel_number - 1]; //string[] items = vals.Split('-'); txtBox_input_L.Text = string.IsNullOrEmpty(txtBox_input_L.Text) ? "0" : txtBox_input_L.Text; txtBox_input_W.Text = string.IsNullOrEmpty(txtBox_input_W.Text) ? "0" : txtBox_input_W.Text; txtBox_input_H.Text = string.IsNullOrEmpty(txtBox_input_H.Text) ? "0" : txtBox_input_H.Text; //if (items.Length == 3) { d.Length = float.Parse(txtBox_input_L.Text); d.Width = float.Parse(txtBox_input_W.Text); d.Height = float.Parse(txtBox_input_H.Text); p.Size = d; //} //} // Get Australia post estimate //PricingMatrix matrix = GetMatrix(AP); float rate = BusinessLayer.PricingAPI.GetCostEstimate(AustraliaPost, p, temp_invoice); //float rate = matrix.getCostEstimate(p, temp_invoice); AP_total += rate; if (parcel_number == 1) cost_estimates[0] = (rate.ToString()); else cost_estimates[0] += "|" + (rate.ToString()); // Get Hunter Express estimate //matrix = GetMatrix(HE); rate = BusinessLayer.PricingAPI.GetCostEstimate(HunterExpress, p, temp_invoice); HE_total += rate; if (parcel_number == 1) cost_estimates[1] = (rate.ToString()); else cost_estimates[1] += "|" + (rate.ToString()); // Get E-post estimate // matrix = GetMatrix(EP); rate = BusinessLayer.PricingAPI.GetCostEstimate(EPost, p, temp_invoice); EP_total += rate; if (parcel_number == 1) { cost_estimates[2] = (rate.ToString()); } else { cost_estimates[2] += "|" + (rate.ToString()); } // Get E-post size estimate float sizeWeight = p.getSizeWeight() * EPost.DimensionWeightRate; rate = BusinessLayer.PricingAPI.GetCostEstimateByWeight(sizeWeight, EPost, p, temp_invoice); //rate = matrix.getEstimateByWeight(sizeWeight, temp_invoice.InvoiceCustomer.Postcode, p.ParcelNumber); EP_size_total += rate; if (parcel_number == 1) { cost_estimates[3] = (rate.ToString()); txtBox_sizeweight_EP.Text = sizeWeight.ToString("N2") + "kg"; } else { cost_estimates[3] += "|" + (rate.ToString()); txtBox_sizeweight_EP.Text += "|" + sizeWeight.ToString("N2") + "kg"; } // Get TOLL estimate //matrix = GetMatrix(TL); rate = BusinessLayer.PricingAPI.GetCostEstimate(Toll, p, temp_invoice); //rate = matrix.getCostEstimate(p, temp_invoice); TL_total += rate; if (parcel_number == 1) cost_estimates[4] = (rate.ToString()); else cost_estimates[4] += "|" + (rate.ToString()); // Get TOLL size estimate sizeWeight = p.getSizeWeight() * Toll.DimensionWeightRate; rate = BusinessLayer.PricingAPI.GetCostEstimateByWeight(sizeWeight, Toll, p, temp_invoice); //rate = matrix.getEstimateByWeight(sizeWeight, temp_invoice.InvoiceCustomer.Postcode, p.ParcelNumber); TL_size_total += rate; if (parcel_number == 1) { cost_estimates[5] = (rate.ToString()); txtBox_sizeweight_TL.Text = sizeWeight.ToString("N2") + "kg"; } else { cost_estimates[5] += "|" + (rate.ToString()); txtBox_sizeweight_TL.Text += "|" + sizeWeight.ToString("N2") + "kg"; } parcel_number++; } txtBox_estimate_AP_factor = AP_total; txtBox_estimate_HE_factor = HE_total; txtBox_estimate_EP_factor = EP_total; txtBox_estimate_EP_weightfactor = EP_size_total; txtBox_estimate_TL_factor = TL_total; txtBox_estimate_TL_weightfactor = TL_size_total; txtBox_estimate_AP.Text = AP_total.ToString("c2"); txtBox_estimate_EP.Text = EP_total.ToString("c2"); txtBox_estimate_HE.Text = HE_total.ToString("c2"); if (temp_invoice.InvoiceCustomer.HasEmailOrMobile()) { txtBox_estimate_TL.Text = TL_total == PricingMatrix.MAX_VAL ? "N/A" : TL_total.ToString("c2"); } else { txtBox_estimate_TL.Text = "N/A"; } txtBox_sizeweight_AP.Text = "N/A"; txtBox_sizeweight_HE.Text = "N/A"; txtBox_size_estimate_EP.Text = EP_size_total.ToString("c2"); txtBox_size_estimate_AP.Text = "N/A"; txtBox_size_estimate_HE.Text = "N/A"; txtBox_size_estimate_TL.Text = TL_size_total.ToString("c2"); //update_all(); txtTitle_estimate.Show(); table_estimate.Show(); }