コード例 #1
0
        /// <summary>
        /// Updating the delivered orders
        /// </summary>

        protected void confirmbtn_Click(object sender, EventArgs e)
        {
            PizzaDbEntities db   = new PizzaDbEntities();
            var             name = Session["name"].ToString();
            Cart_Table      c    = new Cart_Table();
            var             ob1  = (from a in db.Cart_Table where a.State == 1 && a.Username == name select a);

            foreach (var item in ob1)
            {
                item.State = 0;
            }

            db.SaveChanges();
            Response.Redirect("Final.aspx");
        }
コード例 #2
0
        /// <summary>
        /// Adding the datas to the cart_table
        /// </summary>


        protected void addtochatrbtn_Click(object sender, EventArgs e)
        {
            var name = Session["name"].ToString();

            int id;


            int.TryParse(DropDownList1.SelectedValue, out id);//To know the id of selected pizza
            if (id == 0)
            {
                alertlbl.Text = "please select pizza name!!!";
            }
            else
            {
                var        pname = Session["pizzaname"].ToString();
                Cart_Table ob    = new Cart_Table();
                //Getting the details of the pizza
                Pizza_Table ob2 = (from y in db.Pizza_Table where y.PizzaName == pname select y).FirstOrDefault();
                //Getting the details if the pizza was earlier selected
                Cart_Table ob3 = (from z in db.Cart_Table where z.Pizza_Table.PizzaName == pname && z.Username == name && z.State == 1 select z).FirstOrDefault();

                //If pizza name already present
                if (ob3 != null)
                {
                    ob3.Quantity = Convert.ToInt32(quantitytxt.Text) + ob3.Quantity;
                    ob3.Amount   = ob3.Quantity * ob2.PizzaPrice;
                }
                //If same pizza does not exist
                else
                {
                    ob.Username = Session["name"].ToString();
                    ob.PizzaId  = ob2.PizzaId;
                    ob.Quantity = Convert.ToInt32(quantitytxt.Text);
                    ob.Amount   = ob.Quantity * ob2.PizzaPrice;
                    ob.State    = 1;
                    db.Cart_Table.Add(ob);
                }

                // adding the details to the cart

                db.SaveChanges();
                Response.Redirect("Confirm.aspx");
            }
        }