Ejemplo n.º 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            List <CartItem> cartItems = (List <CartItem>)Session["items"];

            drinks = ProductsDA.GetAllDrinks();
            double pricemultiplier = 1;
            string size            = null;

            if (rdoSmall.Checked)
            {
                size = "small";
            }
            else if (rdoMedium.Checked)
            {
                pricemultiplier = MEDIUM_PRICE_MULTIPLIER;
                size            = "medium";
            }
            else if (rdoLarge.Checked)
            {
                pricemultiplier = LARGE_PRICE_MULTIPLIER;
                size            = "large";
            }
            else
            {
                Response.Redirect("Drinks.aspx");
            }

            foreach (Control rdoDrink in pnlDrink.Controls)
            {
                if ((rdoDrink.GetType().Name == "RadioButton") && (((CheckBox)rdoDrink).Checked))
                {
                    foreach (Products product in drinks)
                    {
                        if (product.ProductDetail == (((RadioButton)rdoDrink).Text))
                        {
                            int productID = ProductsDA.GetLatestProductID() + 2000;

                            drink = new Drink(size, product.ProductDetail, Math.Round(product.ProductPrice * pricemultiplier, 2), productID, Math.Round(product.ProductPrice * pricemultiplier, 2), product.ProductType, 1, product.ProductDetail);

                            cartItems = Cart.AddItemToCart(drink, cartItems);


                            Session["items"] = cartItems;

                            Response.Redirect("CartView.aspx");
                        }
                    }
                }
            }
            Response.Redirect("Drinks.aspx");
        }
Ejemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            double sideTotal     = 0;
            string selectedSides = "";

            Side            newSide   = null;
            List <CartItem> cartItems = (List <CartItem>)Session["items"];

            foreach (Control sides in pnlSides.Controls)
            {
                if (sides.GetType().Name == "RadioButton")
                {
                    if (((CheckBox)sides).Checked)
                    {
                        string currentSide = ((CheckBox)sides).Text;
                        selectedSides += currentSide + " ";
                        foreach (Products s in allSides)
                        {
                            if (s.ProductDetail == currentSide)
                            {
                                sideTotal += s.ProductPrice;
                            }
                        }
                    }
                }
            }

            int productID = ProductsDA.GetLatestProductID();

            newSide = new Side(selectedSides, sideTotal, productID, sideTotal, "Side Item", 1, selectedSides);

            cartItems = Cart.AddItemToCart(newSide, cartItems);


            Session["items"] = cartItems;

            Response.Redirect("CartView.aspx");



            //newSide.SideType = selectedSides;
            //newSide.SidePrice = sideTotal;
        }
Ejemplo n.º 3
0
        //protected void rdoFamPk_CheckedChanged(object sender, EventArgs e)
        //{
        //    //specials.ProductPrice = 19.99;
        //    //specials.ProductType = "Special";
        //    //specials.ProductDetail = "Family Pack";
        //}

        //protected void rdoIndivPk_CheckedChanged(object sender, EventArgs e)
        //{
        //    ////specials.ProductPrice = 9.99;
        //    //specials.ProductType = "Special";
        //    //specials.ProductDetail = "Individual Pack";
        //}

        //protected void rdoLGFamPk_CheckedChanged(object sender, EventArgs e)
        //{
        //    //specials.ProductPrice = 29.99;
        //    //specials.ProductType = "Special";
        //    //specials.ProductDetail = "Large Family Pack";

        //}

        protected void btnSpecOrder_Click(object sender, EventArgs e)
        {
            specials  = new Products();
            cartItems = (List <CartItem>)Session["items"];

            int productID = ProductsDA.GetLatestProductID();

            if (rdoFamPk.Checked == true)
            {
                specials.ProductID     = productID;
                specials.ProductPrice  = 19.99;
                specials.ProductQty    = 1;
                specials.ProductType   = "Special";
                specials.ProductDetail = "Family Pack";
            }
            else if (rdoIndivPk.Checked == true)
            {
                specials.ProductID     = productID;
                specials.ProductPrice  = 9.99;
                specials.ProductQty    = 1;
                specials.ProductType   = "Special";
                specials.ProductDetail = "Individual Pack";
            }
            else if (rdoLGFamPk.Checked == true)
            {
                specials.ProductID     = productID;
                specials.ProductPrice  = 29.99;
                specials.ProductQty    = 1;
                specials.ProductType   = "Special";
                specials.ProductDetail = "Large Family Pack";
            }

            cartItems = Cart.AddItemToCart(specials, cartItems);

            Session["items"] = cartItems;

            Response.Redirect("CartView.aspx");
        }
Ejemplo n.º 4
0
        protected void btnOrder_Click(object sender, EventArgs e)
        {
            cartItems    = (List <CartItem>)Session["items"];
            currentPromo = new Promotional();

            Promotional shirt1 = new Promotional();
            Promotional shirt2 = new Promotional();
            Promotional shirt3 = new Promotional();
            Promotional shirt4 = new Promotional();

            int productID = ProductsDA.GetLatestProductID();

            if (ddlQtyShirt1.SelectedValue != "0" && ddlSizeShirt1.SelectedValue != " ")
            {
                shirt1.ProductID       = productID;
                shirt1.ProductQty      = Convert.ToInt32(ddlQtyShirt1.SelectedValue);
                shirt1.ProductPrice    = 15.99 * shirt1.ProductQty;
                shirt1.PromotionalSize = ddlSizeShirt1.SelectedValue;
                shirt1.ProductType     = "Promotional";
                shirt1.ProductDetail   = "Let the Shenanigans begin female shirt";

                currentPromo = shirt1;
            }
            else
            {
                shirt1 = null;
            }
            if (ddlQtyShirt2.SelectedValue != "0" && ddlSizeShirt2.SelectedValue != " ")
            {
                shirt2.ProductID       = productID;
                shirt2.ProductQty      = Convert.ToInt32(ddlQtyShirt2.SelectedValue);
                shirt2.ProductPrice    = 15.99 * shirt2.ProductQty;
                shirt2.PromotionalSize = ddlSizeShirt2.SelectedValue;
                shirt2.ProductType     = "Promotional";
                shirt2.ProductDetail   = "Kiss me I'm a piza baker shirt";
                currentPromo           = shirt2;
            }
            else
            {
                shirt2 = null;
            }
            if (ddlQtyShirt3.SelectedValue != "0" && ddlSizeShirt3.SelectedValue != " ")
            {
                shirt3.ProductID       = productID;
                shirt3.ProductQty      = Convert.ToInt32(ddlQtyShirt3.SelectedValue);
                shirt3.ProductPrice    = 15.99 * shirt3.ProductQty;
                shirt3.PromotionalSize = ddlSizeShirt3.SelectedValue;
                shirt3.ProductType     = "Promotional";
                shirt3.ProductDetail   = "I shamrock Shenanigans shirt";
                currentPromo           = shirt3;
            }
            else
            {
                shirt3 = null;
            }
            if (ddlQtyShirt4.SelectedValue != "0" && ddlSizeShirt4.SelectedValue != " ")
            {
                shirt4.ProductID       = productID;
                shirt4.ProductQty      = Convert.ToInt32(ddlQtyShirt4.SelectedValue);
                shirt4.ProductPrice    = 15.99 * shirt4.ProductQty;
                shirt4.PromotionalSize = ddlSizeShirt4.SelectedValue;
                shirt4.ProductType     = "Promotional";
                shirt4.ProductDetail   = "I shamrock Shenanigans shirt";
                currentPromo           = shirt4;
            }
            else
            {
                shirt4 = null;
            }

            cartItems = Cart.AddItemToCart(currentPromo, cartItems);

            Session["items"] = cartItems;

            Response.Redirect("CartView.aspx");



            //double orderTotal = 0;

            //if(shirt1 != null)
            //{
            //    shirt1.ProductPrice += orderTotal;
            //}
            //if (shirt2 != null)
            //{
            //    shirt2.ProductPrice += orderTotal;
            //}
            //if (shirt3 != null)
            //{
            //    shirt3.ProductPrice += orderTotal;
            //}
            //if (shirt4 != null)
            //{
            //    shirt4.ProductPrice += orderTotal;
            //}
        }
Ejemplo n.º 5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            List <CartItem> cartItems = (List <CartItem>)Session["items"];

            string pizzaSize     = "";
            string pizzaCheese   = "";
            string pizzaSauce    = "";
            string pizzaCrust    = "";
            string pizzaToppings = "";
            string pizzaExtras   = "";
            double pizzaCost     = 0;

            //check for pizza size
            if (rdoSmall.Checked)
            {
                pizzaSize = "Small";
                pizzaCost = 8.99;
            }
            else if (rdoMedium.Checked)
            {
                pizzaSize = "Medium";
                pizzaCost = 11.99;
            }
            else if (rdoLarge.Checked)
            {
                pizzaSize = "Large";
                pizzaCost = 14.99;
            }

            //check for crust type

            //found logic on stack overflow checks or Controls within the Panel
            foreach (Control crustType in pnlCrusts.Controls)
            {
                //Searches for the type of the control, checks for RadioButton
                if (crustType.GetType().Name == "RadioButton")
                {
                    //casts the crust type control to radio button, checks if it's selected
                    if (((RadioButton)crustType).Checked)
                    {
                        //sets the pizza crust type
                        pizzaCrust = ((RadioButton)crustType).Text;
                    }
                }
            }

            //String currentCrust = newPizza.PizzaCrust;

            foreach (Products crust in allCrusts)
            {
                String crustSelection = crust.ProductDetail;
                if (pizzaCrust == crustSelection)
                {
                    pizzaCost += Convert.ToDouble(crust.ProductPrice);
                }
            }

            //check for selection in rdoSauceList
            foreach (Control sauceType in pnlSauce.Controls)
            {
                if (sauceType.GetType().Name == "RadioButton")
                {
                    if (((RadioButton)sauceType).Checked)
                    {
                        pizzaSauce = ((RadioButton)sauceType).Text;
                    }
                }
            }

            foreach (Products sauce in allSauces)
            {
                if (pizzaSauce == sauce.ProductDetail)
                {
                    pizzaCost += sauce.ProductPrice;
                }
            }


            //check for cheese type
            if (rdoNone.Checked)
            {
                pizzaCheese = rdoNone.Text;
            }
            else if (rdoRegular.Checked)
            {
                pizzaCheese = rdoRegular.Text;
            }

            //check for toppings
            foreach (Control topping in pnlToppings.Controls)
            {
                if (topping.GetType().Name == "CheckBox")
                {
                    if (((CheckBox)topping).Checked)
                    {
                        string currentTopping = ((CheckBox)topping).Text;
                        pizzaToppings += currentTopping + " ";
                        foreach (Products top in allToppings)
                        {
                            if (top.ProductDetail == currentTopping)
                            {
                                pizzaCost += top.ProductPrice;
                            }
                        }
                    }
                }
            }

            //check for extras
            if (chkExtraCheese.Checked)
            {
                pizzaExtras = chkExtraCheese.Text + " ";
                pizzaCost  += 1.50;
            }

            if (chkExtraSauce.Checked)
            {
                pizzaExtras += chkExtraSauce.Text;
                pizzaCost   += 1.50;
            }

            //newPizza.PizzaExtras = pizzaExtras;
            //newPizza.PizzaPrice = Math.Round(pizzaCost, 2);
            //newPizza.ProductPrice = Math.Round(pizzaCost, 2);
            //newPizza.ProductType = "Pizza";
            //newPizza.ProductDetail = "New Pizza object";



            //string pizza = newPizza.PizzaToppings;
            int productID = ProductsDA.GetLatestProductID();

            //if(rdolarge)

            newPizza = new Pizza(productID, pizzaCost, "Pizza", 1, pizzaCost, pizzaSize + " " + pizzaCrust + " Pizza: " + pizzaToppings, pizzaToppings, pizzaCheese, pizzaSauce, pizzaCrust, pizzaExtras, pizzaSize, pizzaCost);


            cartItems = Cart.AddItemToCart(newPizza, cartItems);


            Session["items"] = cartItems;

            Response.Redirect("CartView.aspx");
        }