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;
                    if (giohang.Tinhtongtiensanpham() > 500000)
                    {
                        dhkh.PhiVanChuyen = 0;
                    }
                    else
                    {
                        dhkh.PhiVanChuyen = 30000;
                    }
                    dhkh.Tongtien = giohang.Tinhtongtiensanpham() + (double)dhkh.PhiVanChuyen;

                    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"];

            cookie.Expires = DateTime.Now.AddHours(10);
            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)
 {
 }