Example #1
0
        public override void DataBind()
        {
            if (_bound)
            {
                return;
            }
            _bound = true;

            object obj = DataBinder.Eval(this.NamingContainer, "DataItem.ItemId");

            if (obj != null)
            {
                int itemId = (int)obj;

                ChoicesMgr cMgr = new ChoicesMgr();

                Choices.ItemOptionsInventoryViewDataTable options = cMgr.GetItemOptionInventory(itemId);

                if (options.Count == 0)
                {
                    this.Visible = false;
                }

                this.Items.Add(new ListItem(HeaderText, ""));

                foreach (Choices.ItemOptionsInventoryViewRow row in options)
                {
                    Items.Add(new ListItem(row.OptionNames, row.Key));
                }
            }

            base.DataBind();
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            System.Web.HttpRequest  Request  = context.Request;
            System.Web.HttpResponse Response = context.Response;



            int itemId = -1, qty = 1;

            if (Request.Form["ItemId"] != null)
            {
                try
                {
                    itemId = Int32.Parse(Request.Form["ItemId"]);
                }
                catch
                {
                }
            }
            else
            {
                if (Request.QueryString["ItemId"] != null)
                {
                    try
                    {
                        itemId = Int32.Parse(Request.QueryString["ItemId"]);
                    }
                    catch
                    {
                    }
                }
            }
            if (Request.Form["QTY"] != null)
            {
                try
                {
                    qty = Int32.Parse(Request.Form["QTY"]);
                }
                catch
                {
                }
            }
            else
            {
                if (Request.QueryString["QTY"] != null)
                {
                    try
                    {
                        qty = Int32.Parse(Request.QueryString["QTY"]);
                    }
                    catch
                    {
                    }
                }
            }



            lw.ShoppingCart.ShoppingCart sCart = new lw.ShoppingCart.ShoppingCart();
            sCart.Empty();
            string optionsKey = Request["Options"];

            optionsKey = String.IsNullOrEmpty(optionsKey)? "": optionsKey;

            ChoicesMgr cMgr = new ChoicesMgr();

            if (optionsKey == "")
            {
                DataTable dt = cMgr.GetItemOptions(itemId);
                if (dt.Rows.Count > 0)
                {
                    Config   cfg  = new Config();
                    ItemsMgr iMgr = new ItemsMgr();
                    DataRow  item = iMgr.GetItem(itemId);
                    string   ProductDetailsFolder = cfg.GetKey("ProductDetailsFolder");
                    string   red = string.Format("{2}/{1}/{0}.aspx",
                                                 item["UniqueName"],
                                                 ProductDetailsFolder,
                                                 WebContext.Root
                                                 );
                    Response.Redirect(red + "?err=" + lw.CTE.Errors.SelectItemOptions);
                }
            }

            sCart.AddItem(itemId, qty, optionsKey, "", "");
            Response.Redirect(WebContext.Root + "/shopping-cart/");
        }
Example #3
0
        public void AddItem(int ItemId, decimal qty, string optionsKey, string priceOption, string category)
        {
            ItemsMgr itemsMgr = new ItemsMgr();


            DataRow item        = itemsMgr.GetItem(ItemId);
            string  description = "";

            if (!String.IsNullOrWhiteSpace(optionsKey))
            {
                ChoicesMgr cMgr    = new ChoicesMgr();
                DataTable  options = cMgr.GetItemOptionInventory(ItemId, optionsKey);
                if (options.Rows.Count > 0)
                {
                    description = options.Rows[0]["OptionNames"].ToString();
                }
            }

            UserStatus memberStatus = UserStatus.Enabled;

            //if (lw.Security.User.LoggedIn)
            //	memberStatus = lw.Members.MembersManager.GetUserStatus(lw.Security.User.LoggedInUser);


            decimal price = 0, salePrice = 0, resellerPrice = 0;

            if (lw.Products.Tools.CheckStatus(ItemStatus.ForSale, item))
            {
                if (String.IsNullOrWhiteSpace(priceOption))
                {
                    if (item["Price"] != System.DBNull.Value)
                    {
                        price = (decimal)item["Price"];
                    }

                    if (item["SalePrice"] != System.DBNull.Value)
                    {
                        salePrice = (decimal)item["SalePrice"];
                    }

                    if (item["ResellerPrice"] != System.DBNull.Value)
                    {
                        resellerPrice = (decimal)item["ResellerPrice"];
                    }
                }
                else
                {
                    ItemPricesAdp itemPricesAdp = new ItemPricesAdp();
                    DataRow       priceRow      = itemPricesAdp.GetItemPrice(ItemId, priceOption);

                    if (priceRow["Price"] != System.DBNull.Value)
                    {
                        price = (decimal)priceRow["Price"];
                    }

                    if (priceRow["SalePrice"] != System.DBNull.Value)
                    {
                        salePrice = (decimal)priceRow["SalePrice"];
                    }

                    if (priceRow["ResellerPrice"] != System.DBNull.Value)
                    {
                        resellerPrice = (decimal)priceRow["ResellerPrice"];
                    }
                }
                if (Tools.CheckStatus(ItemStatus.OnSale, item))
                {
                    price = salePrice > 0 ? salePrice : price;
                }
                else
                {
                    switch (memberStatus)
                    {
                    case UserStatus.Reseller:
                        price = resellerPrice > 0 ? resellerPrice : price;
                        break;

                    default:
                        break;
                    }
                }
            }

            DataRow[] rows = this.ShoppingItems.BasketItems.Select(string.Format("ItemId={0} and OptionsKey='{1}' and PriceFor='{2}'",
                                                                                 ItemId,
                                                                                 StringUtils.SQLEncode(optionsKey),
                                                                                 StringUtils.SQLEncode(priceOption)
                                                                                 ));
            if (rows.Length > 0)
            {
                rows[0]["Quantity"] = (decimal)rows[0]["Quantity"] + qty;
            }
            else
            {
                DataRow row = ShoppingItems.BasketItems.NewRow();

                decimal weight = 0;
                if (item["ShippingWeight"] != DBNull.Value)
                {
                    weight = decimal.Parse(item["ShippingWeight"].ToString());
                }

                if (item["ShippingVWeight"] != DBNull.Value)
                {
                    weight = Math.Max(weight, decimal.Parse(item["ShippingVWeight"].ToString()));
                }


                row["Weight"] = weight;

                row["ItemId"]      = ItemId;
                row["Title"]       = item["Title"].ToString();
                row["ItemNumber"]  = item["ProductNumber"].ToString();
                row["Quantity"]    = qty;
                row["UnitPrice"]   = price;
                row["Discount"]    = 0;
                row["UniqueName"]  = item["UniqueName"].ToString();
                row["OptionsKey"]  = optionsKey;
                row["Description"] = description;
                row["Tax"]         = 0;

                row["UniqueName"] = item["UniqueName"].ToString();
                row["PriceFor"]   = priceOption;
                row["Category"]   = category;

                this.ShoppingItems.BasketItems.Rows.Add(row);

                this.ShoppingItems.BasketItems.AcceptChanges();
            }
            this.AdjustTotals(true);
        }