public ActionResult NhapHang(string mankh, string uudai, string masp, int soluong, int dongia) { int tongtien = soluong * dongia; DonDatHang sp = new DonDatHang(); //sp.MaPhieuNhap = mapn; sp.MaKH = mankh; sp.UuDai = uudai; sp.ThanhTien = tongtien; List <ChiTietDonDatHang> lct = new List <ChiTietDonDatHang>(); ChiTietDonDatHang pn = new ChiTietDonDatHang(); pn.MaSP = masp; pn.SoLuong = soluong; pn.DonGia = dongia; var ds = ssp.LaySanPham(masp); pn.TenSP = ds.TenSP; lct.Add(pn); QuanLyDonHangBus mhb = new QuanLyDonHangBus(); mhb.DatHangDon(sp, lct); return(Json(new { success = true, ms = "thanh cong" }, JsonRequestBehavior.AllowGet)); }
public ActionResult ThanhToan(string email, string hoten, string sodienthoai, string diachi) { KhachHang kh = new KhachHang(); kh.Email = email; kh.TenKH = hoten; kh.SoDienThoai = sodienthoai; kh.DiaChiGiaoHang = diachi; int thanhtien = 0; List <ChiTietDonDatHang> dsl = new List <ChiTietDonDatHang>(); List <itemGioHang> ds = new List <itemGioHang>(); if (Session["GioHang"] == null) { Session["GioHang"] = new List <itemGioHang>(); //thanhtien = 0; } else { ds = Session["GioHang"] as List <itemGioHang>; for (int i = 0; i < ds.Count(); i++) { ChiTietDonDatHang cthd = new ChiTietDonDatHang(); cthd.MaSP = ds.ElementAtOrDefault(i).MaSP; cthd.TenSP = ds.ElementAtOrDefault(i).TenSP; cthd.SoLuong = ds.ElementAtOrDefault(i).SoLuong; cthd.DonGia = ds.ElementAtOrDefault(i).DonGia; dsl.Add(cthd); thanhtien += Convert.ToInt32(dsl.Sum(s => s.DonGia * s.SoLuong)); } } QuanLyDonHangBus mhb = new QuanLyDonHangBus(); //mhb.MuaHang(kh, thanhtien, dsl); mhb.DatHang(kh, thanhtien, dsl); ds.Clear(); return(RedirectToAction("Index", "Home")); }