Beispiel #1
0
 public int TaoCTHD(int idHD)
 {
     try
     {
         var db   = new TraSuaDbContext();
         var cart = Session["CartItem"] as List <CartModel>;
         foreach (var item in cart)
         {
             var cthd = new CTHoaDon
             {
                 MaHD    = idHD,
                 MaSP    = item.SP.MaSP,
                 SoLuong = item.Quantity,
                 MaSize  = item.size.MaSize
             };
             db.CTHoaDons.Add(cthd);
             db.SaveChanges();
         }
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Beispiel #2
0
        public JsonResult DangKy(KhachHang model)
        {
            if (ModelState.IsValid)
            {
                model.MatKhau = MD5Hash(model.MatKhau);
                model.NgayTao = DateTime.Now;

                var db = new TraSuaDbContext();
                db.KhachHangs.Add(model);
                db.SaveChanges();

                return(Json(new { Success = 1 }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { Success = 0 }, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
 public int TaoHD(HoaDon model, int userid)
 {
     try
     {
         var hd = new HoaDon
         {
             NgayTao  = DateTime.Now,
             MaKH     = userid,
             SDT      = model.SDT,
             TenKH    = model.TenKH,
             DiaChi   = model.DiaChi,
             MaTT     = 1,
             TongTien = GetTotal()
         };
         var db = new TraSuaDbContext();
         db.HoaDons.Add(hd);
         db.SaveChanges();
         return(hd.MaHD);
     }
     catch
     {
         return(0);
     }
 }