download Product.ascx.cs
Language: C#
LOC: 92
Project Info
commercefinity - An open source eCommerce ...odule(commercefinity)
Server: Google
Type: svn
...runk\Commerce\PageControls\
   AddItemResult.ascx
   AddItemResult.ascx.cs
   Catalog.ascx
   Catalog.ascx.cs
   Checkout.ascx
   Checkout.ascx.cs
   MyOrders.ascx
   MyOrders.ascx.cs
   PPCheckout.ascx
   PPCheckout.ascx.cs
   Product.ascx
   Product.ascx.cs
   Receipt.ascx
   Receipt.ascx.cs
   ShoppingBasket.ascx
   ShoppingBasket.ascx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Commerce.Common;
using Commerce.Promotions;
using Telerik.WebControls;

public partial class Commerce_PageControls_Product : System.Web.UI.UserControl
{
    protected PageView Page1;

    protected int productID;
    protected string productSku;
    protected Guid productGUID;

    private Commerce.Common.Product product = null;
    protected ProductDiscount discount;

    protected void Page_Load(object sender, EventArgs e)
    {
        //###############################################################################
		//  Page Validators - these must be implemented or they will be redirected
		//###############################################################################

       

            try
            {
                string sProductGUID = Utility.GetParameter("guid");
                productID = Utility.GetIntParameter("id");
                productSku = Utility.GetParameter("n");

                if (sProductGUID != string.Empty)
                {
                    productGUID = new Guid(sProductGUID);
                    product = ProductController.GetProductDeepByGUID(productGUID);
                    LoadData();
                }
                else if (productID != 0)
                {
                    product = ProductController.GetProductDeep(productID);
                    LoadData();
                }
                else if (productSku != string.Empty)
                {
                    product = ProductController.GetProductDeep(productSku);
                    LoadData();
                }
                else
                {
                   return;
                }

            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, "Application Exception");
                Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
                
            }

	}

    void LoadData()
    {
        //set the page variables
        productID = product.ProductID;
        productSku = product.Sku;

        //load the product ratings        
        
        BindProductInfo();
        TickStats();
    }

	void BindProductInfo() {
		ProductTopDisplay1.product = product;

		//set the ratings
		//this was passed in 

		BundleDisplay1.product = product;
		ReviewDisplay1.product = product;
        ProductGallery1.product = product;
		FeedBackDisplay1.ProductID = product.ProductID;
        FeedBackDisplay1.ProductName = product.ProductName;
		FeedBackDisplay1.InitialRating = Convert.ToDouble(product.Rating);
		ProductDescriptorDisplay1.DescriptorList = product.Descriptors;
		Page.Title = product.ProductName;
        lblCrumb.Text = product.ProductName;
	}

	void TickStats() {
		//track this
		Commerce.Stats.Tracker.Add(Commerce.Stats.BehaviorType.BrowsingProduct, product.Sku);
	}

	protected decimal ParseAdjustedPrice(string selection) {
		decimal dOut = 0;
		string sOut = "";

		//This will be redone  for 2.0 Release. It's Kantona's fault.

		if(selection.IndexOf("(add") > 0 || selection.IndexOf("(subtract") > 0) {
			sOut = selection.Substring(selection.IndexOf("("), selection.IndexOf(")") - selection.IndexOf("("));
			sOut = sOut.Replace("(", "").Replace(")", "").Trim().Replace("add", "").Replace("subtract", "");

			//strip the currency symbol
			sOut = sOut.Replace(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol, "");

			//thanks to Jon_ProLogic for this :)
			decimal.TryParse(sOut, out dOut);
			if(selection.IndexOf("subtract") > 0)
				dOut = 0 - dOut;
		}
		return dOut;
	}
	
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us