protected void Page_Load(object sender, EventArgs e)
        {
            int count = 0;

            cartItems = new List <CartItem>();
            drinks    = ProductsDA.GetAllDrinks();
            double basePrice = drinks.First().ProductPrice;

            rdoSmall.Text  = rdoSmall.Text + " (" + Math.Round(basePrice, 2).ToString("C") + ")";
            rdoMedium.Text = rdoMedium.Text + " (" + Math.Round(basePrice * MEDIUM_PRICE_MULTIPLIER, 2).ToString("C") + ")";
            rdoLarge.Text  = rdoLarge.Text + " (" + Math.Round(basePrice * LARGE_PRICE_MULTIPLIER, 2).ToString("C") + ")";
            foreach (Products drink in drinks)
            {
                RadioButton newDrink = new RadioButton();
                newDrink.Text      = drink.ProductDetail;
                newDrink.GroupName = "grpDrinks";
                if (count < 1)
                {
                    newDrink.Checked = true;
                }
                pnlDrink.Controls.Add(newDrink);
                pnlDrink.Controls.Add(new LiteralControl("<br />"));
                count++;
            }
        }
        public HttpResponseMessage Delete(int id)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;

            ProductsDA.DeleteProduct(id, p.Claims);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Exemple #3
0
 protected void UpdatePrice_Click(object sender, EventArgs e)
 {
     try
     {
         double price = Convert.ToDouble(Price.Text);
         if (price < 0)
         {
             InvalidSelectionError();
         }
         else
         {
             Products product = ProductsDA.GetProductByID(Convert.ToInt32(MenuItemID.Text));
             product.ProductPrice = price;
             ProductsDA.UpdateProduct(product);
             Price.Text         = "";
             MenuItemID.Text    = "";
             MenuItemName.Text  = "";
             PriceTable.Visible = false;
             ItemTable.Visible  = false;
         }
     }
     catch (Exception ex)
     {
         InvalidSelectionError();
     }
 }
        public HttpResponseMessage Put(Product c)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;

            ProductsDA.UpdateProduct(c, p.Claims);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Exemple #5
0
        protected void EditItem_Click(object sender, EventArgs e)
        {
            Products product = ProductsDA.GetProductByID(Convert.ToInt32(dropdownItems.SelectedValue));

            MenuItemName.Text  = product.ProductDetail;
            MenuItemID.Text    = dropdownItems.SelectedValue;
            Price.Text         = product.ProductPrice.ToString();
            PriceTable.Visible = true;
        }
        public HttpResponseMessage Post(Product c)
        {
            ClaimsPrincipal p  = RequestContext.Principal as ClaimsPrincipal;
            int             id = ProductsDA.InsertProduct(c, p.Claims);

            HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);

            message.Content = new StringContent(id.ToString());
            return(message);
        }
Exemple #7
0
        public HttpResponseMessage Put(Product c)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;
            int             i = ProductsDA.NotActiveToActive(c, p.Claims);

            if (i == 0)
            {
                return(new HttpResponseMessage(HttpStatusCode.NoContent));
            }
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Exemple #8
0
        //add all the product corresponding to the customer aircraft loaded int he invoice and load the invoiceid, customer id and aircraft id from that same invoice
        private void Sub_Create_Sub_Load(object sender, EventArgs e)
        {
            MySqlConnection connection = new MySqlConnection(connec);

            connection.Open();
            string       query_1 = @"Select * 
                                FROM sales_orders AS s1
                                JOIN invoices as i1
                                ON i1.Invoice_ID = s1.invoices_Invoice_ID
                                 JOIN subscriptions AS s2
                                ON s2.Subscription_ID = s1.Subscription_ID
                                JOIN products as p1
                                ON s1.products_Product_ID = p1.Product_ID
                                 WHERE invoice_completed_1y_2n = 1
                                        AND invoices_Invoice_ID = " + invid + "";
            MySqlCommand comm    = connection.CreateCommand();

            comm.CommandText = query_1;
            DataTable        table = new DataTable();
            MySqlDataAdapter adapt = new MySqlDataAdapter(query_1, connection);

            adapt.Fill(table);
            while (row < table.Rows.Count)

            {
                SubscriptionsDA sub = new SubscriptionsDA();
                txtInvID.Text     = table.Rows[row]["invoices_Invoice_ID"].ToString();
                custIdTxt.Text    = table.Rows[row]["Customer_ID"].ToString();
                aircraft_lbl.Text = table.Rows[row]["Aircraft_ID"].ToString();


                string       query_2 = @"Select * 
                                FROM  products as p1
                                 WHERE Aircraft_ID = " + table.Rows[row]["Aircraft_ID"] + "";
                MySqlCommand comm2   = connection.CreateCommand();
                comm2.CommandText = query_2;
                MySqlDataAdapter adapt2 = new MySqlDataAdapter(query_2, connection);
                adapt2.Fill(table2);
                while (row < table2.Rows.Count)

                {
                    ProductsDA pro = new ProductsDA();
                    pro.Product_id   = Convert.ToInt32(table2.Rows[row]["Product_ID"]);
                    pro.Product_name = table2.Rows[row]["Product_Name"].ToString();
                    pro.Product_type = table2.Rows[row]["Product_Type"].ToString();
                    product_list.Items.Add(pro.Show_product());
                    row += 1;
                }

                row += 1;
            }
            row = 0;
            connection.Close();
        }
        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");
        }
Exemple #10
0
        protected void UpdateCategory_Click(object sender, EventArgs e)
        {
            dropdownItems.Items.Clear();
            string category = dropdownCategory.SelectedValue;

            products = ProductsDA.GetAllProducts();
            foreach (Products product in products)
            {
                if (product.ProductType == category)
                {
                    ListItem productItem = new ListItem();
                    productItem.Text  = product.ProductDetail;
                    productItem.Value = product.ProductID.ToString();
                    dropdownItems.Items.Add(productItem);
                    ItemTable.Visible  = true;
                    PriceTable.Visible = false;
                }
            }
        }
Exemple #11
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;
        }
Exemple #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (((Employee)Session["employee"] == null) || (((Employee)Session["employee"]).EmployeeRole != "store manager"))
     {
         Response.Redirect("AdminLogin.aspx");
     }
     products   = ProductsDA.GetAllProducts();
     categories = new List <string>();
     foreach (Products product in products)
     {
         if (!categories.Contains(product.ProductType))
         {
             categories.Add(product.ProductType);
             ListItem categoryItem = new ListItem();
             categoryItem.Text  = product.ProductType;
             categoryItem.Value = product.ProductType;
             dropdownCategory.Items.Add(categoryItem);
         }
     }
 }
        //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");
        }
Exemple #14
0
 public HttpResponseMessage Put(Products p)
 {
     ProductsDA.EditProduct(p);
     return(new HttpResponseMessage(HttpStatusCode.OK));
 }
        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");
        }
        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;
            //}
        }
Exemple #17
0
 // GET: Products
 public List <Products> Get()
 {
     return(ProductsDA.GetProducts());
 }
        public List <Product> Get()
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;

            return(ProductsDA.GetProducts(p.Claims));
        }
        public Product Get(int id)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;

            return(ProductsDA.GetProduct(id, p.Claims));
        }
Exemple #20
0
 public HttpResponseMessage Delete(int id)
 {
     ProductsDA.Remove(id);
     return(new HttpResponseMessage(HttpStatusCode.OK));
 }