Exemple #1
0
        public ActionResult Edit(int masanpham)
        {
            ViewBag.danhmucsanpham = dmDao.li();
            ViewBag.loaisanpham    = loaiSPDao.dsLoaiSP();
            SanPhamDao spDao = new SanPhamDao();

            return(View(spDao.searchProduct(masanpham)));
        }
        public ActionResult Update(int masanpham, int soluong)
        {
            SanPhamDao  spDao = new SanPhamDao();
            SanPham     sp    = spDao.searchProduct(masanpham);
            ShopingCart cart  = (ShopingCart)Session[shop];

            cart.UpdateAmount(sp, soluong);
            Session[shop] = cart;
            return(Redirect(Request.UrlReferrer.ToString()));
        }
        public ActionResult Delete(int id)
        {
            SanPhamDao  spDAo = new SanPhamDao();
            SanPham     sp    = spDAo.searchProduct(id);
            ShopingCart cart  = (ShopingCart)Session[shop];

            cart.ReMove(sp);
            Session[shop] = cart;
            return(Redirect(Request.UrlReferrer.ToString()));
        }
Exemple #4
0
        public ActionResult DanhGiaSp(PhanHoi ph, int masanpham)
        {
            SanPhamDao   spDao = new SanPhamDao();
            DanhGiaSpDao dgDao = new DanhGiaSpDao();

            if (ModelState.IsValid)
            {
                dgDao.DanhGiaSp(ph);
            }
            return(View("ChiTietSp", spDao.searchProduct(masanpham)));
        }
        public ActionResult AddItem(int id, int soluong = 1)
        {
            SanPhamDao  spDao = new SanPhamDao();
            SanPham     sp    = spDao.searchProduct(id);
            ShopingCart cart  = (ShopingCart)Session[shop];

            if (cart == null)
            {
                cart = new ShopingCart();
            }
            cart.AddItem(sp, soluong);
            Session[shop] = cart;
            return(Redirect(Request.UrlReferrer.ToString()));
        }
Exemple #6
0
 public ActionResult EditProduct(SanPham sp, HttpPostedFileBase linkanh)
 {
     ViewBag.danhmucsanpham = dmDao.li();
     ViewBag.loaisanpham    = loaiSPDao.dsLoaiSP();
     try
     {
         // lấy tên của hình ảnh
         var tenfile = Path.GetFileName(linkanh.FileName);
         // tạo đường dẫn
         var duongdan = Path.Combine(Server.MapPath("/Photo"), tenfile);
         if (System.IO.File.Exists(duongdan))
         {
             sp.linkanh  = linkanh.FileName;
             ViewBag.loi = "Hình ảnh đã tồn tại";
         }
         else
         {
             linkanh.SaveAs(duongdan);
             sp.linkanh = linkanh.FileName;
         }
     }
     catch (Exception)
     {
         SanPhamDao spDao = new SanPhamDao();
         sp.linkanh = spDao.searchProduct(sp.masanpham).linkanh;
     }
     if (ModelState.IsValid)
     {
         SanPhamDao spDao = new SanPhamDao();
         spDao.Edit(sp);
         return(Redirect("Index"));
     }
     else
     {
         return(View("Edit", sp));
     }
 }
Exemple #7
0
        public ActionResult ChiTietSp(int masanpham)
        {
            SanPhamDao spDao = new SanPhamDao();

            return(View(spDao.searchProduct(masanpham)));
        }