public ActionResult sanphambanchay(int so, string ngaythang, int?page = 1) { int pnum = page ?? 1;//nếu ko có ??(null) thì mặc định là 1 caycanhModel db = new caycanhModel(); List <caycanh> ds = db.LaySPBanChay(so, ngaythang).ToList(); return(PartialView(ds.ToPagedList(pnum, 8))); }
public JsonResult DatHang(string tenkh, string email, string diachinhan, string sdtnhan, int trangthai) { //lay thong tin cac mat hang dat tu session Khachhang kh = new Khachhang(); kh.tenkh = tenkh; kh.email = email; kh.sdt = sdtnhan; kh.diachi = diachinhan; kh.email = email; kh.trangthai = trangthai; int thanhtien = 0; List <CTDHang> ds = new List <CTDHang>(); int total = 0; if (Session["GioHang"] == null) { Session["GioHang"] = new List <CTDHang>(); thanhtien = 0; } else { ds = Session["GioHang"] as List <CTDHang>; thanhtien = Convert.ToInt32(ds.Sum(s => s.DonGia * s.SoLuong)); } ds = Session["GioHang"] as List <CTDHang>; caycanhModel a = new caycanhModel(); List <caycanh> dsss = a.LaySPham(); foreach (CTDHang ct in ds) { foreach (caycanh sp in dsss) { if (sp.macaycanh == ct.MaSP) { a.SuaSLSP(ct.MaSP, ct.SoLuong); } } } checkoutBus mhb = new checkoutBus(); mhb.MuaHang(kh, thanhtien, ds, diachinhan, sdtnhan, trangthai); Session["GioHang"] = null; return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }