public ActionResult Create(SanPham sp)
 {
     try
     {
         // TODO: Add insert logic here
         SanPhamBus.Them(sp);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
예제 #2
0
 public ActionResult Create(sanpham sp)
 {
     //try
     //{
     // TODO: Add insert logic here
     SanPhamBus.Them(sp);
     return(RedirectToAction("Index"));
     //}
     //catch
     //{
     //    return View();
     //}
 }
예제 #3
0
 public ActionResult Create(SanPham sp)
 {
     if (HttpContext.Request.Files.Count > 0)
     {
         var hpf = HttpContext.Request.Files[0];
         if (hpf.ContentLength > 0)
         {
             string fileName             = Guid.NewGuid().ToString();
             string fullPathWithFileName = "/ShopOnline/img/" + fileName + ".jpg";
             hpf.SaveAs(Server.MapPath(fullPathWithFileName));
             sp.HinhAnh = fileName + ".jpg";
         }
     }
     SanPhamBus.Them(sp);
     return(RedirectToAction("Index"));
 }