Exemplo n.º 1
0
        private void HandleAddToCart()
        {
            // extract the input parameters from the form post
            AddToCartInfo formInput = AddToCartInfo.FromForm(ThisCustomer);

            if (formInput != AddToCartInfo.INVALID_FORM_COMPOSITION)
            {
                string returnUrl = SE.MakeObjectLink("Product", formInput.ProductId, String.Empty);

                if (!ThisCustomer.IsRegistered && AppLogic.AppConfigBool("DisallowAnonCustomerToCreateWishlist"))
                {
                    string ErrMsg = string.Empty;

                    ErrorMessage er;

                    if (formInput.CartType == CartTypeEnum.WishCart)
                    {
                        ErrMsg = AppLogic.GetString("signin.aspx.27", 1, ThisCustomer.LocaleSetting);
                        er     = new ErrorMessage(ErrMsg);
                        Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(returnUrl));
                    }

                    if (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                    {
                        ErrMsg = AppLogic.GetString("signin.aspx.28", 1, ThisCustomer.LocaleSetting);
                        er     = new ErrorMessage(ErrMsg);
                        Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(returnUrl));
                    }
                }


                bool success = ShoppingCart.AddToCart(ThisCustomer, formInput);
                AppLogic.eventHandler("AddToCart").CallEvent("&AddToCart=true&VariantID=" + formInput.VariantId.ToString() + "&ProductID=" + formInput.ProductId.ToString() + "&ChosenColor=" + formInput.ChosenColor.ToString() + "&ChosenSize=" + formInput.ChosenSize.ToString());
                if (success)
                {
                    bool stayOnThisPage = AppLogic.AppConfig("AddToCartAction").Equals("STAY", StringComparison.InvariantCultureIgnoreCase);
                    if (stayOnThisPage)
                    {
                        // some tokens like the shoppingcart qty may already be rendered
                        // we therefore need to re-display the page to display the correct qty
                        Response.Redirect(this.Request.Url.ToString());
                    }
                    else
                    {
                        if (formInput.CartType == CartTypeEnum.WishCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/wishlist.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        if (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/giftregistry.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        // default
                        Response.Redirect(ResolveClientUrl("~/ShoppingCart.aspx?add=true&ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    }
                }
            }

            return;
        }
Exemplo n.º 2
0
        private void HandleAddToCart()
        {
            if (String.IsNullOrEmpty(txtBluBuksUsed.Text) || String.IsNullOrWhiteSpace(txtBluBuksUsed.Text) || txtBluBuksUsed.Text == ".")
            {
                txtBluBuksUsed.Text = "0";
            }

            if (String.IsNullOrEmpty(txtproductcategoryfundusedforsalesrep.Text) || String.IsNullOrWhiteSpace(txtproductcategoryfundusedforsalesrep.Text) || (txtproductcategoryfundusedforsalesrep.Text == "."))
            {
                txtproductcategoryfundusedforsalesrep.Text = "0";
            }
            // extract the input parameters from the form post
            AddToCartInfo formInput = AddToCartInfo.FromForm(ThisCustomer);

            formInput.BluBucksUsed = Convert.ToDecimal(txtBluBuksUsed.Text);
            formInput.FundID       = Convert.ToInt32(hdnProductFundID.Text);
            //GLcode holds decision parameter value
            formInput.GLcode = SOFCodeChoice;
            if (ThisCustomer.CustomerLevelID == 3 || ThisCustomer.CustomerLevelID == 7)
            {
                if (Convert.ToInt16(formInput.GLcode) == (int)SOFUsedType.NF)
                {
                    formInput.CategoryFundUsed = Convert.ToDecimal("0.00");
                }
                else
                {
                    formInput.CategoryFundUsed = Convert.ToDecimal(txtproductcategoryfundusedforsalesrep.Text);
                }

                formInput.FundID = (int)FundType.SOFFunds;
            }
            else
            {
                formInput.CategoryFundUsed = Convert.ToDecimal(hdnProductFundAmountUsed.Text);
            }


            formInput.BluBucksPercentageUsed = Convert.ToDecimal(hdnBudgetPercentValue.Text);
            formInput.ProductCategoryID      = Convert.ToInt32(hdnProductCategoryID.Text);

            if (Convert.ToInt16(formInput.GLcode) == (int)SOFUsedType.SOFF)
            {
                formInput.SOFCode = txtSOFCode.Text;
            }
            else if (Convert.ToInt16(formInput.GLcode) == (int)SOFUsedType.CAPEX)
            {
                formInput.SOFCode = txtCAPEX.Text;
            }
            else
            {
                formInput.SOFCode = "0";
            }
            if (formInput != AddToCartInfo.INVALID_FORM_COMPOSITION)
            {
                string returnUrl = SE.MakeObjectLink("Product", formInput.ProductId, String.Empty);

                if (!ThisCustomer.IsRegistered && AppLogic.AppConfigBool("DisallowAnonCustomerToCreateWishlist"))
                {
                    string ErrMsg = string.Empty;

                    ErrorMessage er;

                    if (formInput.CartType == CartTypeEnum.WishCart)
                    {
                        ErrMsg = AppLogic.GetString("signin.aspx.27", 1, ThisCustomer.LocaleSetting);
                        er     = new ErrorMessage(ErrMsg);
                        Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(returnUrl));
                    }

                    if (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                    {
                        ErrMsg = AppLogic.GetString("signin.aspx.28", 1, ThisCustomer.LocaleSetting);
                        er     = new ErrorMessage(ErrMsg);
                        Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(returnUrl));
                    }
                }


                bool success = ShoppingCart.AddToCart(ThisCustomer, formInput);
                AppLogic.eventHandler("AddToCart").CallEvent("&AddToCart=true&VariantID=" + formInput.VariantId.ToString() + "&ProductID=" + formInput.ProductId.ToString() + "&ChosenColor=" + formInput.ChosenColor.ToString() + "&ChosenSize=" + formInput.ChosenSize.ToString());
                if (success)
                {
                    bool stayOnThisPage = AppLogic.AppConfig("AddToCartAction").Equals("STAY", StringComparison.InvariantCultureIgnoreCase);
                    if (stayOnThisPage)
                    {
                        // some tokens like the shoppingcart qty may already be rendered
                        // we therefore need to re-display the page to display the correct qty
                        Response.Redirect(this.Request.Url.ToString());
                    }
                    else
                    {
                        if (formInput.CartType == CartTypeEnum.WishCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/wishlist.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        if (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/giftregistry.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        // default
                        Response.Redirect(ResolveClientUrl("~/ShoppingCart.aspx?add=true&ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    }
                }
            }


            return;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the table order add to cart which was handled before by the tableorder_process.aspx .
        /// </summary>
        private void HandleTableOrderAddToCart()
        {
            CartTypeEnum CartType = CartTypeEnum.ShoppingCart;

            m_SkinBase.ThisCustomer.RequireCustomerRecord();
            int CustomerID = m_SkinBase.ThisCustomer.CustomerID;

            ShoppingCart cart = new ShoppingCart(1, m_SkinBase.ThisCustomer, CartType, 0, false);

            for (int i = 0; i < HttpContext.Current.Request.Form.Count; i++)
            {
                String FieldName = HttpContext.Current.Request.Form.Keys[i];
                String FieldVal  = HttpContext.Current.Request.Form[HttpContext.Current.Request.Form.Keys[i]];
                if (FieldName.ToUpperInvariant().IndexOf("_VLDT") == -1 && (FieldName.ToLowerInvariant().StartsWith("price_") || FieldName.ToLowerInvariant().StartsWith("qty_")) && FieldVal.Trim().Length != 0)
                {
                    try // ignore errors, just add what items we can:
                    {
                        decimal CustomerEnteredPrice = Decimal.Zero;
                        int     Qty = 0;
                        if (FieldName.ToLowerInvariant().StartsWith("price_"))
                        {
                            CustomerEnteredPrice = Currency.ConvertToBaseCurrency(Localization.ParseLocaleDecimal(FieldVal, m_SkinBase.ThisCustomer.LocaleSetting), m_SkinBase.ThisCustomer.CurrencySetting);
                        }
                        else
                        {
                            Qty = Localization.ParseNativeInt(FieldVal);
                        }
                        String[] flds      = FieldName.Split('_');
                        int      ProductID = Localization.ParseUSInt(flds[1]);
                        int      VariantID = Localization.ParseUSInt(flds[2]);
                        int      ColorIdx  = Localization.ParseUSInt(flds[3]);
                        int      SizeIdx   = Localization.ParseUSInt(flds[4]);
                        if (Qty == 0)
                        {
                            Qty = 1;
                        }

                        String ChosenColor            = String.Empty;
                        String ChosenSize             = String.Empty;
                        String ChosenColorSKUModifier = String.Empty;
                        String ChosenSizeSKUModifier  = String.Empty;

                        if (ColorIdx > -1 || SizeIdx > -1)
                        {
                            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                            {
                                dbconn.Open();
                                using (IDataReader rs = DB.GetRS("select * from productvariant where VariantID=" + VariantID.ToString(), dbconn))
                                {
                                    rs.Read();
                                    ChosenColor = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale()).Split(',')[ColorIdx].Trim();
                                    if (DB.RSField(rs, "ColorSKUModifiers").Length != 0)
                                    {
                                        ChosenColorSKUModifier = DB.RSField(rs, "ColorSKUModifiers").Split(',')[ColorIdx].Trim();
                                    }

                                    ChosenSize = DB.RSFieldByLocale(rs, "Sizes", Localization.GetDefaultLocale()).Split(',')[SizeIdx].Trim();
                                    if (DB.RSField(rs, "SizeSKUModifiers").Length != 0)
                                    {
                                        ChosenSizeSKUModifier = DB.RSField(rs, "SizeSKUModifiers").Split(',')[SizeIdx].Trim();
                                    }
                                }
                            }
                        }

                        String TextOption = String.Empty;
                        cart.AddItem(m_SkinBase.ThisCustomer, m_SkinBase.ThisCustomer.PrimaryShippingAddressID, ProductID, VariantID, Qty, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, TextOption, CartType, false, false, 0, CustomerEnteredPrice);
                    }
                    catch { }
                }
            }
            cart = null;


            String ReturnURL = m_SkinBase.Page.Request.Url.ToString();

            if (AppLogic.AppConfig("AddToCartAction").Equals("STAY", StringComparison.InvariantCultureIgnoreCase) && ReturnURL.Length != 0)
            {
                HttpContext.Current.Response.Redirect(ReturnURL);
            }
            else
            {
                String previousEntityPage = SE.MakeObjectLink("Category", m_EntityInstanceID, String.Empty);
                String url = CommonLogic.IIF(CartType.Equals(CartTypeEnum.WishCart), "wishlist.aspx", "ShoppingCart.aspx?add=true&returnurl=" + previousEntityPage);
                HttpContext.Current.Response.Redirect(url);
            }
        }