// GET: CTHDs public ActionResult Index(string mahd) { using (qlbanhangEntities db = new qlbanhangEntities()) { List <KhachHang> khachhang = db.KhachHangs.ToList(); List <HoaDon> hoadon = db.HoaDons.ToList(); List <CTHD> cthd = db.CTHDs.ToList(); List <SanPham> sanpham = db.SanPhams.ToList(); var main = from h in hoadon join k in khachhang on h.MaKH equals k.MaKH where (h.MaHD == mahd) select new ViewModel { hoadon = h, khachhang = k }; var sub = from c in cthd join s in sanpham on c.MaSP equals s.MaSP where (c.MaHD == mahd) select new ViewModel { cthd = c, sanpham = s, Thanhtien = Convert.ToDouble(c.DongiaBan * c.Soluong) }; ViewBag.Main = main; ViewBag.Sub = sub; return(View()); } }
// GET: Menu public ActionResult Index() { using (qlbanhangEntities db = new qlbanhangEntities()) { var loaisp = db.LoaiSPs.ToList(); Hashtable tenloaisp = new Hashtable(); foreach (var item in loaisp) { tenloaisp.Add(item.MaLoaiSP, item.TenLoaiSP); } ViewBag.TenLoaiSP = tenloaisp; return(PartialView("Index")); } }