Пример #1
0
 public ActionResult cartt(int id)
 {
     using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
     {
         var x = dbb.billinfoes.ToList().Where(s => s.idfood == id).FirstOrDefault();
         if (x == null)
         {
             billinfo y = new billinfo();
             y.idbill = 1;
             y.idfood = id;
             y.count  = 1;
             dbb.billinfoes.Add(y);
             dbb.SaveChanges();
         }
         else
         {
             x.count++;
             dbb.SaveChanges();
         }
     }
     using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
     {
         listfood.allbillinfos = dbb.billinfoes.ToList();
         listfood.allfoods     = new List <food>();
         foreach (billinfo item in listfood.allbillinfos)
         {
             var x = dbb.foods.ToList().Where(s => s.id == item.idfood).FirstOrDefault();
             listfood.allfoods.Add(x);
         }
     }
     //return PartialView("/views/shares/_cartproduct.cshtml", listfood);
     return(RedirectToAction("Index", "order", new { id = Session["id"] }));
 }
Пример #2
0
        public List <billinfo> getlistbillinfo(int id)
        {
            List <billinfo> listbillinfo = new List <billinfo>();
            DataTable       data         = DataProvider.Instance.ExecuteQuery(" SELECT * FROM dbo.BillInfo WHERE idBill = '" + id + "'");

            foreach (DataRow item in data.Rows)
            {
                billinfo info = new billinfo(item);
                listbillinfo.Add(info);
            }
            return(listbillinfo);
        }
Пример #3
0
        public ActionResult delproduct(int id)
        {
            using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
            {
                billinfo x = new billinfo();
                x = dbb.billinfoes.ToList().Find(s => s.idfood == id);
                dbb.billinfoes.Remove(x);
                dbb.SaveChanges();
            }

            using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
            {
                listfood.allbillinfos = dbb.billinfoes.ToList();
                listfood.allfoods     = new List <food>();
                foreach (billinfo item in listfood.allbillinfos)
                {
                    var x = dbb.foods.ToList().Where(s => s.id == item.idfood).FirstOrDefault();
                    listfood.allfoods.Add(x);
                }
            }

            return(PartialView("/views/shares/_cartproduct.cshtml", listfood));
        }