예제 #1
0
        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) { }
        }
예제 #2
0
        public void LoadCartfromCookie(HttpRequestBase request)
        {
            HttpCookie cookie = request.Cookies["Cart"];

            if (cookie == null)
            {
                giohang = new Giohang();
                return;
            }
        }
예제 #3
0
 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();
 }
예제 #4
0
 public void saveCarttoCookie(HttpResponseBase reponse, Giohang gh)
 {
 }