/// <summary>
 /// Gets the shipping options.
 /// </summary>
 /// <param name="order"></param>
 /// <returns></returns>
 public ShippingOptionCollection GetShippingOptions(Order order)
 {
     ShippingOptionCollection shippingOptionCollection = new ShippingOptionCollection();
       SimpleWeightShippingRateCollection simpleWeightShippingRateCollection = new SimpleWeightShippingRateController().FetchAll();
       ShippingOption shippingOption;
       foreach(SimpleWeightShippingRate simpleWeightShippingRate in simpleWeightShippingRateCollection) {
     shippingOption = new ShippingOption();
     shippingOption.Service = simpleWeightShippingRate.Service;
     shippingOption.Rate = simpleWeightShippingRate.AmountPerUnit * order.TotalWeight;
     shippingOptionCollection.Add(shippingOption);
       }
       return shippingOptionCollection;
 }
 /// <summary>
 /// Handles the Delete event of the dgSimpleWeight control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
 protected void dgSimpleWeight_Delete(object sender, CommandEventArgs e)
 {
     try {
         int shippingRateId = 0;
         int.TryParse(e.CommandArgument.ToString(), out shippingRateId);
         bool deleted = new SimpleWeightShippingRateController().Delete(shippingRateId);
         LoadSimpleShippingWeightRates();
         base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblServiceDeleted"));
     }
     catch (Exception ex) {
         Logger.Error(typeof(simpleweightconfiguration).Name + ".dgSimpleWeight_Delete", ex);
         base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the shipping options.
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public ShippingOptionCollection GetShippingOptions(Order order)
        {
            ShippingOptionCollection           shippingOptionCollection           = new ShippingOptionCollection();
            SimpleWeightShippingRateCollection simpleWeightShippingRateCollection = new SimpleWeightShippingRateController().FetchAll();
            ShippingOption shippingOption;

            foreach (SimpleWeightShippingRate simpleWeightShippingRate in simpleWeightShippingRateCollection)
            {
                shippingOption         = new ShippingOption();
                shippingOption.Service = simpleWeightShippingRate.Service;
                shippingOption.Rate    = simpleWeightShippingRate.AmountPerUnit * order.TotalWeight;
                shippingOptionCollection.Add(shippingOption);
            }
            return(shippingOptionCollection);
        }
        /// <summary>
        /// Loads the simple shipping weight rates.
        /// </summary>
        private void LoadSimpleShippingWeightRates()
        {
            SimpleWeightShippingRateCollection simpleWeightShippingRateCollection = new SimpleWeightShippingRateController().FetchAll();

            if (simpleWeightShippingRateCollection.Count > 0)
            {
                pnlAvailableServices.Visible         = true;
                dgSimpleWeight.DataSource            = simpleWeightShippingRateCollection;
                dgSimpleWeight.ItemDataBound        += new DataGridItemEventHandler(dgSimpleWeight_ItemDataBound);
                dgSimpleWeight.Columns[0].HeaderText = LocalizationUtility.GetText("hdrService");
                dgSimpleWeight.Columns[1].HeaderText = LocalizationUtility.GetText("hdrAmountPerUnit");
                dgSimpleWeight.Columns[2].HeaderText = LocalizationUtility.GetText("lblDelete");
                dgSimpleWeight.DataBind();
            }
            else
            {
                pnlAvailableServices.Visible = false;
            }
        }