void cboExtraType_SelectedIndexChanged(object sender, EventArgs e) { eExtraType extraType = (eExtraType)Enum.Parse(typeof(eExtraType), cboExtraType.SelectedValue.Replace(" ", "")); if (this.OrderID > 0) { Facade.IOrder facOrder = new Facade.Order(); Entities.Order order = facOrder.GetForOrderID(this.OrderID); IEnumerable <Repositories.DTOs.RateSurcharge> surcharges = null; try { Repositories.DTOs.RateInformation rateInfo = facOrder.GetRate(order, true, out surcharges); } catch (ApplicationException) { // Swallow application exceptions as get rate can fall over if a rate cannot be // found for a given postcode. If this happens then we don't really care. } if (surcharges != null) { var rs = (from s in surcharges where s.ExtraTypeID == (int)extraType select s).FirstOrDefault(); if (rs != null) { rntAmount.Value = (double?)rs.ForeignRate; } } } }
void rntAmount_PreRender(object sender, EventArgs e) { if (!IsUpdate && this.OrderID > 0) { eExtraType extraType = (eExtraType)Enum.Parse(typeof(eExtraType), cboExtraType.SelectedValue.Replace(" ", "")); // If the order has a tariff rate id, then see if this extra type has a specific amount configured. Facade.IOrder facOrder = new Facade.Order(); Entities.Order order = facOrder.GetForOrderID(this.OrderID); if (order.IsAutorated) { IEnumerable <Repositories.DTOs.RateSurcharge> surcharges = null; try { Repositories.DTOs.RateInformation rateInfo = facOrder.GetRate(order, true, out surcharges, false); } catch (ApplicationException) { // Swallow application exceptions as get rate can fall over if a rate cannot be // found for a given postcode. If this happens then we don't really care. } if (surcharges != null) { var rs = (from s in surcharges where s.ExtraTypeID == (int)extraType select s).FirstOrDefault(); if (rs != null) { rntAmount.Value = (double?)rs.ForeignRate; } } } } }