Exemplo n.º 1
0
        // if the basket grid view row is not selected, it will cause an error
        protected void deleteBasket_Click(object sender, EventArgs e)
        {
            if (BasketGridView.Rows.Count == 0)
            {
                // when basket is completly deleted, the order is set as not purchased
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "UPDATE Basket SET Purchased = '" + NoPurchase.SelectedItem.ToString() + "' WHERE BasketId = '" + basketID.Text + "'";
                cmd.ExecuteNonQuery();

                con.Close();

                Response.Redirect("ViewBasket.aspx");
                emptyConfirm.Visible = true;
            }
            else

            {
                SuperDBEntities db         = new SuperDBEntities();
                var             itemBasket = db.ItemBaskets.Find(BasketGridView.SelectedValue);
                db.Entry(itemBasket).State = System.Data.Entity.EntityState.Deleted;

                db.SaveChanges();

                Response.Redirect("ViewBasket.aspx");
                //var basket = db.Baskets.Find(basketID.Text);
                //basket.Purchased = NoPurchase.SelectedItem.ToString();

                //db.SaveChanges();
                //Response.Redirect("ViewBasket.aspx");
                //itemDeletion.Visible = true;
            }
        }
Exemplo n.º 2
0
        protected void addItem_Click(object sender, EventArgs e) // add items to basket
        {
            SuperDBEntities db = new SuperDBEntities();


            var itemBasket = new ItemBasket();
            var bask       = new Basket();
            var customer   = new Customer();

            // //what items the customer is going to add to thier basket of items
            itemBasket.ItemId   = Convert.ToInt32(ItemIDText.Text);
            itemBasket.BasketId = bask.BasketId;
            itemBasket.Quantity = Convert.ToInt32(ItemQuantity.SelectedValue);

            // adds to Basket

            bask.BasketId    = bask.BasketId;
            bask.CustomerId  = customer.CustomerId;
            bask.DateOrdered = Convert.ToDateTime(dateText.Text);


            // customer information
            customer.CustomerName = customerName.Text;

            db.ItemBaskets.Add(itemBasket);
            db.Baskets.Add(bask);
            db.Customers.Add(customer);



            db.SaveChanges();
            addItemConfirm.Visible = true;
        }
Exemplo n.º 3
0
        // adds item to item table
        protected void AddItem_Click(object sender, EventArgs e)
        {
            SuperDBEntities db   = new SuperDBEntities();
            var             item = new Item();

            item.ItemName = FoodItemText.Text;
            item.FoodDept = DeptText.Text;
            db.Items.Add(item);
            db.SaveChanges();
            addConfirm.Visible = true;
        }
Exemplo n.º 4
0
        protected void regUser_Click(object sender, EventArgs e)
        {
            SuperDBEntities db   = new SuperDBEntities();
            var             user = new User();

            user.Username = uname1.Text;
            user.Password = password1.Text;
            user.Usertype = ddlUserType.Text;
            db.Users.Add(user);
            db.SaveChanges();
            regConfirm.Visible = true;
        }