public void Luudonhang(Donhangtongquan a, string maKH, Giohang giohang) { try { using (Entities db = new Entities()) { DonHangKH dhkh = new DonHangKH(); dhkh.MaDH = RandomMa(); dhkh.MaKH = maKH; dhkh.Diachi = a.address; dhkh.Dienthoai = a.phoneNumber; dhkh.Ghichu = a.Note; dhkh.NgayDatMua = DateTime.Now; dhkh.TinhTrangDH = 1; dhkh.Tongtien = giohang.TinhtongtienCart(); dhkh.PhiVanChuyen = 0; dhkh = db.DonHangKHs.Add(dhkh); db.SaveChanges(); Luuchitietdonhang(giohang, db, dhkh.MaDH); } } catch (Exception e) { } }
public void LoadCartfromCookie(HttpRequestBase request) { HttpCookie cookie = request.Cookies["Cart"]; if (cookie == null) { giohang = new Giohang(); return; } }
private void Luuchitietdonhang(Giohang giohang, Entities db, string maDH) { foreach (var temp in giohang.getGiohang()) { ChiTietDonHang chiTiet = new ChiTietDonHang() { MaDH = maDH, MaSP = temp.sanPham.MaSP, SoLuong = temp.Soluong, ThanhTien = (decimal)temp.Thanhtien }; db.ChiTietDonHangs.Add(chiTiet); } db.SaveChanges(); }
public void saveCarttoCookie(HttpResponseBase reponse, Giohang gh) { }