示例#1
0
        protected void Btncart_Click(object sender, EventArgs e)
        {
            string veg_Selected_list = Convert.ToString(List_veg.SelectedItem);
            int    quantity          = Convert.ToInt32(txt_V_quantity.Text);
            int?   price             = 0;


            sb09DBcontext          db  = new sb09DBcontext();
            List <FoodDetails_veg> veg = db.FoodDetails_veg.ToList();

            foreach (FoodDetails_veg item in veg)
            {
                if (veg_Selected_list == item.Food_name)
                {
                    price = item.Price * quantity;
                }
            }

            cart carts_veg = new cart()
            {
                foodname = veg_Selected_list, price = price, quantity = quantity
            };

            db.carts.Add(carts_veg);
            db.SaveChanges();
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Lbl_wc_txt.Text = "Welcome," + Session["username"].ToString();

            if (!IsPostBack)
            {
                sb09DBcontext db    = new sb09DBcontext();
                List <cart>   carts = db.carts.ToList();

                foreach (var item in carts)
                {
                    db.carts.Remove(item);
                }
                db.SaveChanges();
            }
        }