Ejemplo n.º 1
0
 /// <summary>
 /// Gets the shipping rates.
 /// </summary>
 private void GetShippingRates()
 {
     if (!ThisPage.SiteSettings.DisplayShippingOnCart || this.Order.ShippingAmount > 0 || Request.Url.AbsolutePath.Contains("checkout.aspx"))
     {
         lblShippingAmount.Text = StoreUtility.GetFormattedAmount(this.Order.ShippingAmount, true);
         lblTotalAmount.Text    = StoreUtility.GetFormattedAmount(this.Order.Total, true);
     }
     else
     {
         // Get Shipping Options
         ShippingOptionCollection shippingOptionCollection = OrderController.FetchShippingOptions(this.Order);
         if (shippingOptionCollection.Count > 0)
         {
             if (shippingOptionCollection.Count > 1)
             {
                 ddlShipping.Visible = true;
                 foreach (ShippingOption shippingOption in shippingOptionCollection)
                 {
                     ddlShipping.Items.Add(new ListItem(shippingOption.Service, shippingOption.Rate.ToString()));
                 }
             }
             lblShippingAmount.Text = StoreUtility.GetFormattedAmount(shippingOptionCollection[0].Rate.ToString(), true);
             lblTotalAmount.Text    = StoreUtility.GetFormattedAmount(this.Order.Total + shippingOptionCollection[0].Rate, true);
         }
         else
         {
             lblShippingAmount.Text = StoreUtility.GetFormattedAmount(this.Order.ShippingAmount, true);
             lblTotalAmount.Text    = StoreUtility.GetFormattedAmount(this.Order.Total, true);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the page title.
        /// </summary>
        private void LoadPageTitle()
        {
            string pageTitle = string.Empty;

            foreach (DataRow dr in breadCrumbs.Tables[0].Rows)
            {
                if (string.IsNullOrEmpty(pageTitle.Trim()))
                {
                    pageTitle = dr["Name"].ToString();
                }
                else
                {
                    pageTitle += string.Format(" :: {0}", dr["Name"]);
                }
            }
            if (manufacturerId > 0)
            {
                Manufacturer manufacturer = new Manufacturer(manufacturerId);
                pageTitle += string.Format(" :: {0}", manufacturer.Name);
            }
            if (priceStart >= 0 && priceEnd > 0)
            {
                pageTitle += string.Format(" :: {0} - {1}", StoreUtility.GetFormattedAmount(priceStart, true), StoreUtility.GetFormattedAmount(priceEnd, true));
            }
            Page.Title = string.Format(WebUtility.MainTitleTemplate, Master.SiteSettings.SiteName, pageTitle);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Handles the Click event of the btnCoupon control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnCoupon_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtCouponCode.Text))
     {
         CouponService couponService = new CouponService();
         couponService.ApplyCoupon(txtCouponCode.Text, order);
         lblCouponInformationDisplay.Text = StoreUtility.GetFormattedAmount(order.DiscountAmount, true);
         ReloadOrder();
     }
     else
     {
         foreach (OrderItem orderItem in order.OrderItemCollection)
         {
             orderItem.DiscountAmount = 0.00M;
             orderItem.Save("CouponService");
         }
         lblCouponInformationDisplay.Text = StoreUtility.GetFormattedAmount(0.00M, true);
     }
     //re-calculate the tax
     OrderController.CalculateTax(WebUtility.GetUserName());
     //reload the order
     orderSummary.Order = new OrderController().FetchOrder(WebUtility.GetUserName());
     orderSummary.LoadOrder();
     acCheckout.SelectedIndex = acCheckout.SelectedIndex + 1;
     SetProcessOrderEnablement();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the coupon display.
 /// </summary>
 private void SetCouponDisplay()
 {
     if (order.DiscountAmount > 0)
     {
         lblCouponInformationDisplay.Text      = StoreUtility.GetFormattedAmount(order.DiscountAmount, true);
         cpeCouponInformationDisplay.Collapsed = false;
         //acCheckout.SelectedIndex = acCheckout.SelectedIndex + 1; //Dont advance this because they may have adjusted the cart.
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles the ItemDataBound event of the dlCatalog control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataListItemEventArgs"/> instance containing the event data.</param>
        void dlCatalog_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Product product = e.Item.DataItem as Product;
                if (product == null)
                {
                    return;
                }
                HyperLink imageLink  = e.Item.FindControl("hlImageLink") as HyperLink;
                site      masterPage = this.Page.Master as site;
                if (imageLink != null && !string.IsNullOrEmpty(product.DefaultImagePath))
                {
                    imageLink.ImageUrl = ImageProcess.GetProductThumbnailUrl(product.DefaultImagePath);
                }

                Label retailPrice = e.Item.FindControl("lblRetailPrice") as Label;
                if (masterPage != null)
                {
                    if (masterPage.SiteSettings.DisplayRetailPrice && product.RetailPrice != 0)
                    {
                        if (retailPrice != null)
                        {
                            retailPrice.Text = StoreUtility.GetFormattedAmount(product.RetailPrice, true);
                        }
                    }
                    else
                    {
                        retailPrice.Visible = false;
                    }
                }
                Label ourPrice = e.Item.FindControl("lblOurPrice") as Label;
                if (ourPrice != null)
                {
                    ourPrice.Text = StoreUtility.GetFormattedAmount(product.DisplayPrice, true);
                }
                if (masterPage.SiteSettings.AddTaxToPrice && TaxService.GetDefaultTaxProvider().IsProductLevelTaxProvider)
                {
                    Label taxApplied = e.Item.FindControl("lblTaxApplied") as Label;
                    if (taxApplied != null)
                    {
                        taxApplied.Visible = true;
                    }
                }
                AjaxControlToolkit.Rating ajaxRating = e.Item.FindControl("ajaxRating") as AjaxControlToolkit.Rating;
                if (ajaxRating != null && masterPage.SiteSettings.DisplayRatings)
                {
                    ajaxRating.GroupingText  = LocalizationUtility.GetText("lblAverageRating");
                    ajaxRating.CurrentRating = product.Rating;
                }
                else
                {
                    ajaxRating.Visible = false;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                Page.Title = string.Format(WebUtility.MainTitleTemplate, Master.SiteSettings.SiteName, LocalizationUtility.GetText("titleCart"));
                order      = new OrderController().FetchOrder(WebUtility.GetUserName());
                PaymentServiceSettings providers = PaymentService.FetchConfiguredPaymentProviders();
                if (providers != null)
                {
                    if (providers.DefaultProvider == "PayPalProPaymentProvider" && !(string.IsNullOrEmpty(providers.ProviderSettingsCollection["PayPalProPaymentProvider"].Parameters[PayPalProPaymentProvider.BUSINESS_EMAIL])))
                    {
                        pnlExpressCheckout.Visible = true;
                    }
                }
                if (!Page.IsPostBack)
                {
                    bool changesMade = OrderController.NormalizeCartQuantities(order);
                    if (changesMade)
                    {
                        messageCenter.Visible = true;
                        messageCenter.DisplayInformationMessage(LocalizationUtility.GetText("lblCartChanged"));
                    }
                    if (order.OrderId > 0 && order.OrderItemCollection.Count > 0)
                    {
                        pnlNoCart.Visible  = false;
                        orderSummary.Order = order;

                        lblSubTotalAmountTop.Text = StoreUtility.GetFormattedAmount(order.SubTotal, true);
                        lbUpdate.Text             = LocalizationUtility.GetText("lblUpdate");
                    }
                    else
                    {
                        pnlCart.Visible = false;

                        ProductCollection productCollection;
                        if (this.Master.SiteSettings.CollectBrowsingProduct)
                        {
                            productCollection = Store.Caching.ProductCache.GetMostPopularProducts();
                        }
                        else
                        {
                            productCollection = new ProductController().FetchRandomProducts();//Should we cache this?
                        }
                        catalogList.ProductCollection = productCollection;
                    }
                }
            }
            catch (Exception ex) {
                Logger.Error(typeof(cart).Name + ".Page_Load", ex);
                throw;
            }
        }
Ejemplo n.º 7
0
        protected void ddlShipping_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblShippingAmount.Text = StoreUtility.GetFormattedAmount(decimal.Parse(ddlShipping.SelectedValue), true);

            string subTotal = lblSubTotalAmount.Text.Replace(',', '.');

            subTotal = Regex.Replace(subTotal, @"[^\d\.]", "");

            string shipping = lblShippingAmount.Text.Replace(',', '.');

            shipping = Regex.Replace(shipping, @"[^\d\.]", "");

            lblTotalAmount.Text = StoreUtility.GetFormattedAmount(decimal.Parse(subTotal) + decimal.Parse(shipping), true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                productId = Utility.GetIntParameter("productId");
                view      = Utility.GetParameter("view");
                if (view == "g")
                {
                    SetGeneralProperties();
                    SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();
                    if (productId > 0)
                    {
                        product = new Product(productId);
                    }
                    else
                    {
                        product = new Product();
                    }

                    if (!Page.IsPostBack)
                    {
                        LoadManufacturer();
                        LoadProductStatus();
                        LoadProductType();
                        LoadShippingEstimate();
                        LoadTaxRates();
                        txtBaseSku.Text                   = product.BaseSku;
                        txtName.Text                      = product.Name;
                        txtShortDescription.Value         = HttpUtility.HtmlDecode(product.ShortDescription);
                        txtOurPrice.Text                  = StoreUtility.GetFormattedAmount(product.OurPrice, false);
                        txtRetailPrice.Text               = StoreUtility.GetFormattedAmount(product.RetailPrice, false);
                        ddlManufacturer.SelectedValue     = product.ManufacturerId.ToString();
                        ddlStatus.SelectedValue           = product.ProductStatusDescriptorId.ToString();
                        ddlTaxRate.SelectedValue          = product.TaxRateId.ToString();
                        ddlProductType.SelectedValue      = product.ProductTypeId.ToString();
                        ddlShippingEstimate.SelectedValue = product.ShippingEstimateId.ToString();
                        txtWeight.Text                    = product.Weight.ToString();
                        txtLength.Text                    = product.Length.ToString();
                        txtHeight.Text                    = product.Height.ToString();
                        txtWidth.Text                     = product.Width.ToString();
                    }
                    lblOurPriceCurrencySymbol.Text    = siteSettings.CurrencySymbol;
                    lblRetailPriceCurrencySymbol.Text = siteSettings.CurrencySymbol;
                }
            }
            catch (Exception ex) {
                Logger.Error(typeof(general).Name + ".Page_Load", ex);
                base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Loads the product.
 /// </summary>
 private void LoadProduct()
 {
     _product = Store.Caching.ProductCache.GetProductByProductID(productId);
     productAttributes.Product = _product;
     lblProductName.Text       = _product.Name;
     lblOurPriceAmount.Text    = StoreUtility.GetFormattedAmount(_product.DisplayPrice, true);
     if (Master.SiteSettings.AddTaxToPrice && TaxService.GetDefaultTaxProvider().IsProductLevelTaxProvider)
     {
         lblTaxApplied.Visible = true;
     }
     ajaxRating.CurrentRating = _product.Rating;
     ajaxRating.Visible       = SiteSettings.DisplayRatings;
     lblShortDescription.Text = HttpUtility.HtmlDecode(_product.ShortDescription);
     if (_product.RetailPrice != 0 && Master.SiteSettings.DisplayRetailPrice)
     {
         lblRetailPriceAmount.Text = StoreUtility.GetFormattedAmount(_product.RetailPrice, true);
         pnlRetailPrice.Visible    = true;
         pnlYouSave.Visible        = true;
         lblYouSaveAmount.Text     = string.Format("{0}&nbsp;({1})", StoreUtility.GetFormattedAmount(_product.YouSaveAmount, true), _product.YouSavePercentage.ToString("p"));
     }
     if (!IsPostBack)
     {
         SkuCollection productSkus = _product.SkuRecords(); //TODO: Cache this?
         if (productSkus.Count > 0)
         {
             if (productSkus.Count == 1)//there is only 1 Sku, so load the inventory
             {
                 productAttributes.GetInventory(productSkus[0].SkuX);
             }
             else
             {
                 ddlQuantity.Enabled  = false;
                 btnAddToCart.Enabled = false;
             }
         }
     }
     if (_product.AllowNegativeInventories)
     {
         ddlQuantity.Visible = false;
         txtQuantity.Visible = true;
         rfvQuantity.Visible = true;
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Handles the ItemDataBound event of the dgAttributeItems control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataGridItemEventArgs"/> instance containing the event data.</param>
        void dgAttributeItems_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                e.Item.Cells[3].Text = StoreUtility.GetFormattedAmount(DataBinder.Eval(e.Item.DataItem, "Adjustment").ToString(), true);

                LinkButton editButton = e.Item.Cells[0].FindControl("lbAttrbuteItemEdit") as LinkButton;
                if (editButton != null)
                {
                    editButton.Text = LocalizationUtility.GetText("lblEdit");
                }
                LinkButton deleteButton = e.Item.Cells[5].FindControl("lbAttrbuteItemDelete") as LinkButton;
                if (deleteButton != null)
                {
                    deleteButton.Text = LocalizationUtility.GetText("lblDelete");
                    deleteButton.Attributes.Add("onclick", "return confirm(\"" + LocalizationUtility.GetText("lblConfirmDelete") + "\");return false;");
                }
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Handles the AttributeItem Edit.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
 protected void lbAttributeItemEdit(object sender, CommandEventArgs e)
 {
     try {
         int attributeItemId = 0;
         int.TryParse(e.CommandArgument.ToString(), out attributeItemId);
         if (attributeItemId > 0)
         {
             AttributeItem attributeItem = new AttributeItem(attributeItemId);
             lblAttributeItemId.Text   = attributeItem.AttributeItemId.ToString();
             txtAttributeItemName.Text = attributeItem.Name;
             txtAdjustment.Text        = StoreUtility.GetFormattedAmount(attributeItem.Adjustment, false);
             txtSkuSuffix.Text         = attributeItem.SkuSuffix;
             btnAdd.Text = LocalizationUtility.GetText("lblEdit");
         }
     }
     catch (Exception ex) {
         Logger.Error(typeof(attributeedit).Name + ".lbAttributeItemEdit", ex);
         Master.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         SetShippingGeneralSettingsProperties();
         shippingServiceSettings = ShippingService.FetchConfiguredShippingProviders();
         if (shippingServiceSettings == null)
         {
             shippingServiceSettings = new ShippingServiceSettings();
         }
         if (!Page.IsPostBack)
         {
             LoadCountries();
             chkUseShipping.Checked           = shippingServiceSettings.UseShipping;
             txtShipFromZip.Text              = shippingServiceSettings.ShipFromZip;
             ddlShipFromCountry.SelectedValue = shippingServiceSettings.ShipFromCountryCode;
             txtShippingBuffer.Text           = StoreUtility.GetFormattedAmount(shippingServiceSettings.ShippingBuffer, false);
         }
     }
     catch (Exception ex) {
         Logger.Error(typeof(shippinggeneralsettings).Name + ".Page_Load", ex);
         base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Loads the order.
        /// </summary>
        public void LoadOrder()
        {
            rptrCart.DataSource     = this.Order.OrderItemCollection;
            rptrCart.ItemDataBound += new RepeaterItemEventHandler(rptrCart_ItemDataBound);
            rptrCart.DataBind();

            lblSubTotalAmount.Text = StoreUtility.GetFormattedAmount(this.Order.SubTotal, true);

            if (this.Order.DiscountAmount > 0)
            {
                lblCouponAmount.Text = "-" + StoreUtility.GetFormattedAmount(this.Order.DiscountAmount, true);
            }
            else
            {
                lblCouponAmount.Text = StoreUtility.GetFormattedAmount(this.Order.DiscountAmount, true);
            }

            lblTaxAmount.Text = StoreUtility.GetFormattedAmount(this.Order.TaxTotal, true);

            lblShippingAmount.Text = StoreUtility.GetFormattedAmount(this.Order.ShippingAmount, true);

            lblTotalAmount.Text = StoreUtility.GetFormattedAmount(this.Order.Total, true);
        }
Ejemplo n.º 14
0
 protected string GetFormattedAmount(string amount)
 {
     return(StoreUtility.GetFormattedAmount(amount, true));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Loads the item.
        /// </summary>
        void LoadItem()
        {
            if (CurrentProduct == null)
            {
                return;
            }
            HyperLink imageLink = hlImageLink;
            dashCommerceMasterPage masterPage = DashCommerceMasterPage;

            if (imageLink != null)
            {
                if (!string.IsNullOrEmpty(CurrentProduct.DefaultImagePath))
                {
                    bool defaultImageExists = File.Exists(Server.MapPath(CurrentProduct.DefaultImagePath));
                    if (masterPage.SiteSettings.GenerateThumbs)
                    {
                        string thumbnail = CurrentProduct.DefaultImagePath.Replace("product/", string.Format("product/thumbs/{0}x{1}_", masterPage.SiteSettings.ThumbSmallWidth, masterPage.SiteSettings.ThumbSmallHeight));
                        if (!File.Exists(Server.MapPath(thumbnail)))
                        {
                            if (defaultImageExists)
                            {
                                //Thumbnails don't exist so lets generate them...
                                string fileName = CurrentProduct.DefaultImagePath.Substring(CurrentProduct.DefaultImagePath.LastIndexOf("/") + 1);
                                using (FileStream fs = File.Open(Server.MapPath(CurrentProduct.DefaultImagePath), FileMode.Open, FileAccess.Read, FileShare.None)) {
                                    ImageProcess.ResizeAndSave(fs, fileName, Server.MapPath(@"~/repository/product/thumbs/"), masterPage.SiteSettings.ThumbSmallWidth, masterPage.SiteSettings.ThumbSmallHeight);
                                }
                            }
                        }
                        imageLink.ImageUrl = thumbnail;
                    }
                    else if (defaultImageExists)
                    {
                        imageLink.ImageUrl = CurrentProduct.DefaultImagePath;
                    }
                }
            }

            if (masterPage != null)
            {
                if (masterPage.SiteSettings.DisplayRetailPrice)
                {
                    if (lblRetailPrice != null)
                    {
                        lblRetailPrice.Text = StoreUtility.GetFormattedAmount(CurrentProduct.RetailPrice, true);
                    }
                }
                else
                {
                    lblRetailPrice.Visible = false;
                }
            }
            if (lblOurPrice != null)
            {
                lblOurPrice.Text = StoreUtility.GetFormattedAmount(CurrentProduct.OurPrice, true);
            }
            if (ajaxRating != null && masterPage.SiteSettings.DisplayRatings)
            {
                ajaxRating.GroupingText  = LocalizationUtility.GetText("lblAverageRating");
                ajaxRating.CurrentRating = CurrentProduct.Rating;
            }
            else
            {
                ajaxRating.Visible = false;
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Gets the formatted price range.
 /// </summary>
 /// <param name="lowRange">The low range.</param>
 /// <param name="hiRange">The hi range.</param>
 protected string GetFormattedPriceRange(string lowRange, string hiRange)
 {
     return(string.Format("{0} - {1}", StoreUtility.GetFormattedAmount(lowRange, true), StoreUtility.GetFormattedAmount(hiRange, true)));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Gets the formatted amount.
 /// </summary>
 /// <param name="total">The total.</param>
 /// <returns></returns>
 protected string GetFormattedAmount(string total)
 {
     return(StoreUtility.GetFormattedAmount(total, true));
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Gets the shipping rates.
        /// </summary>
        private void GetShippingRates()
        {
            ShippingOptionCollection shippingOptionCollection = OrderController.FetchShippingOptions(WebUtility.GetUserName());

            rblShippingOptions.Items.Clear();
            ListItem listItem;

            foreach (ShippingOption shippingOption in shippingOptionCollection)
            {
                listItem = new ListItem(string.Format("{0}: {1}", shippingOption.Service, StoreUtility.GetFormattedAmount(shippingOption.Rate, true)), shippingOption.Rate.ToString());
                rblShippingOptions.Items.Add(listItem);
            }
            if (rblShippingOptions.Items.Count > 0)
            {
                rblShippingOptions.SelectedIndex = 0;
            }
            if (order.ShippingAmount > 0)
            {
                ListItem selectedItem = rblShippingOptions.Items.FindByValue(order.ShippingAmount.ToString());
                if (selectedItem != null)
                {
                    selectedItem.Selected = true;
                }
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Gets the formatted amount.
 /// </summary>
 /// <param name="pricePaid">The price paid.</param>
 /// <returns></returns>
 protected string GetFormattedAmount(string pricePaid)
 {
     return(StoreUtility.GetFormattedAmount(pricePaid, true));
 }