Exemplo n.º 1
0
 //thêm món ăn vào hóa đơn
 public ActionResult formThemMonAnVaoBan(int id)
 {
     //banan_current_id = id;
     ViewBag.BaID = id;
     Models.BanAn ba = dc.BanAns.Find(id);
     ViewBag.BaTen = ba.banan_ten;
     return(View(dc.MonAns.ToList()));
 }
Exemplo n.º 2
0
        //action thêm món ăn vào bàn
        public ActionResult actThemMonAnVaoBan(int id, int idBan)
        {
            var thongbao = "";

            //var idBan = banan_current_id;
            //int idBanAn = Int32.Parse(idBan.ToString());
            Models.BanAn ba         = dc.BanAns.Find(idBan);
            Models.MonAn ma         = dc.MonAns.Find(id);
            string       session_id = "hoadon" + idBan;

            Models.HoaDon        hd   = Session[session_id] as Models.HoaDon;
            Models.ChiTietHoaDon cthd = null;
            foreach (var a in hd.ChiTietHoaDons.Where(x => x.monan_id == id))
            {
                cthd = a; break;
            }
            if (cthd == null)
            {
                cthd           = new Models.ChiTietHoaDon();
                cthd.monan_id  = ma.monan_id;
                cthd.dongia    = ma.monan_gia;
                cthd.soluong   = 1;
                cthd.hoadon_id = hd.hoadon_id;
                cthd.MonAn     = ma;

                hd.ChiTietHoaDons.Add(cthd);
                //thongbao = "<script language='javascript' type='text/javascript'>alert('Thành công!');</script>";
                //ViewBag.thongbao = thongbao;
                Session["Thongbao_Noidung"] = "Thành công!";
                Session["Thongbao_Kieu"]    = "alert-success";
                return(RedirectToAction("formThemMonAnVaoBan/" + idBan));
            }
            else
            {
                cthd.soluong += 1; //int.Parse(Request["soluong"].ToString());
                //thongbao = "<script language='javascript' type='text/javascript'>alert('Thành công!');</script>";
                //return Content(thongbao);
            }
            return(RedirectToAction("formThemMonAnVaoBan/" + idBan));
        }