protected void RptCartItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        var drv = (System.Data.DataRowView)e.Item.DataItem;

        if (drv != null)
        {
            int currentSKUID = ValidationHelper.GetInteger(drv["SKUID"], 0);
            if (currentSKUID > 0)
            {
                SKUInfo sku = SKUInfoProvider.GetSKUInfo(currentSKUID);
                if (sku != null)
                {
                    int    subTotal = 0;
                    double remise   = 0;
                    //Display product image
                    var ltlProductImage = e.Item.FindControl("ltlProductImage") as Literal;
                    if (ltlProductImage != null)
                    {
                        //<%--# EcommerceFunctions.GetProductImage(Eval("SKUImagePath"), Eval("SKUName"))--%>
                        ltlProductImage.Text = EcommerceFunctions.GetProductImage(sku.SKUImagePath, sku.SKUName);
                    }

                    var ltlProductName = e.Item.FindControl("ltlProductName") as Literal;
                    if (ltlProductName != null)
                    {
                        ltlProductName.Text = sku.SKUName;
                    }

                    var txtProductCount = e.Item.FindControl("txtProductCount") as TextBox;
                    if (txtProductCount != null)
                    {
                        foreach (ShoppingCartItemInfo shoppingCartItem in ShoppingCart.CartItems)
                        {
                            if (shoppingCartItem.SKUID == sku.SKUID)
                            {
                                remise = shoppingCartItem.UnitTotalDiscount;
                                txtProductCount.Text = shoppingCartItem.CartItemUnits.ToString();
                                subTotal             = shoppingCartItem.CartItemUnits;
                                break;
                            }
                        }
                    }

                    var ltlProductPrice = e.Item.FindControl("ltlProductPrice") as Literal;
                    if (ltlProductPrice != null)
                    {
                        //ltlProductPrice.Text = (sku.SKUPrice * subTotal).ToString();
                        ltlProductPrice.Text = EcommerceFunctions.GetFormatedPrice((sku.SKUPrice - remise) * subTotal, sku.SKUDepartmentID, sku.SKUID);

                        //ltlProductPrice.Text = string.Format("{0} <em>�</em>", CurrencyInfoProvider.GetFormattedValue(sku.SKUPrice * subTotal, ShoppingCart.Currency).ToString());
                        ltlProductPrice.Text = string.Format("{0}<em>{1}</em>", ltlProductPrice.Text.Substring(0, ltlProductPrice.Text.Length - 1).Trim(), ltlProductPrice.Text.Substring(ltlProductPrice.Text.Length - 1, 1).Trim());
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    protected double GetFormatedPrice(object skuid, object price)
    {
        SKUInfo sku    = SKUInfoProvider.GetSKUInfo((int)skuid);
        string  res    = string.Empty;
        double  result = 0;

        if (sku != null)
        {
            res    = EcommerceFunctions.GetFormatedPrice(GetPriceWithDiscount(skuid, price), sku.SKUDepartmentID, sku.SKUID);
            res    = res.Substring(0, res.Length - 1);
            result = double.Parse(res);
        }
        return(System.Math.Round(result, 2));
    }