Пример #1
0
        public void Luudonhang(DonHangTongQuan a, long maKH, GioHang giohang)
        {
            try
            {
                using (Shopbanhang db = new Shopbanhang())
                {
                    DONHANG dhkh = new DONHANG();
                    dhkh.MADONHANG = 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.Tinhtongtiensanpham();
                    dhkh.PHIVANCHUYEN = 0;

                    dhkh = db.DONHANGs.Add(dhkh);
                    db.SaveChanges();
                    Luuchitietdonhang(giohang, db, dhkh.MADONHANG);
                }
            }
            catch (Exception) { }
        }
Пример #2
0
 public void Luuchitietdonhang(GioHang giohang, Shopbanhang db, string madh)
 {
     foreach (var item in giohang.getGiohang())
     {
         CTDONHANG ctdh = new CTDONHANG();
         ctdh.MADONHANG = madh;
         ctdh.MASP      = item.sanpham.MASP;
         ctdh.SOLUONG   = item.soluong;
         ctdh.THANHTIEN = item.Thanhtien;
         db.CTDONHANGs.Add(ctdh);
         db.SaveChanges();
     }
 }