public ActionResult Edit(Sach tt) { if (ModelState.IsValid) { var dao = new ProductDao(); var result = dao.Update(tt); if (result) { SetAlert("Cập nhật thông tin sản phẩm thành công", "success"); return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Cập nhật thông tin sản phẩm không thành công"); } } SetViewBag(); return(View("Index")); }
public ActionResult AddItem(long productID, int quantity) { var product = new ProductDao().Details(productID); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Product.ID == productID)) { foreach (var item in list) { if (item.Product.ID == productID) { item.Quantity += quantity; } } } else { //tao moi doi tuong cartItem var item = new CartItem(); item.Product = product; item.Quantity = quantity; list.Add(item); //gan vao session Session[CartSession] = list; } } else { //tao moi doi tuong cartItem var item = new CartItem(); item.Product = product; item.Quantity = quantity; var list = new List <CartItem>(); list.Add(item); //gan vao session Session[CartSession] = list; } return(RedirectToAction("Index")); }
public ActionResult Create(Sach tt) { if (ModelState.IsValid) { var dao = new ProductDao(); long id = dao.Insert(tt); if (id > 0) { SetAlert("Thêm sản phẩm thành công", "success"); return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Thêm sản phẩm không thành công"); } } SetViewBag(); return(View("Index")); }
public JsonResult LoadImages(long id) { var dao = new ProductDao(); var product = dao.ViewDetail(id); var images = product.MoreImages; if (images == null) { return(Json(new { status = true, lst = new { } }, JsonRequestBehavior.AllowGet)); } XElement xImages = XElement.Parse(images); List <string> lstImages = new List <string>(); foreach (var item in xImages.Elements()) { lstImages.Add(item.Value); } return(Json(new { status = true, lst = lstImages }, JsonRequestBehavior.AllowGet)); }
public IActionResult Category(long cateId, int page = 1, int pageSize = 5) { var category = new ProductCategoryDao().ViewDetail(cateId); ViewBag.Category = category; int ToTalRecord = 0; var model = new ProductDao().ListProductByCategoryId(cateId, ref ToTalRecord, page, pageSize); ViewBag.Total = ToTalRecord; ViewBag.Page = page; int maxPage = 5; int TotalPage = 0; TotalPage = (int)Math.Ceiling((double)(ToTalRecord / pageSize)); ViewBag.TotalPage = TotalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = TotalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); /*var category = new CategoryDao().ViewDetail(cateid); * ViewBag.Category = category; * int ToTalRecord = 0; * var model = new ProductDao().ListProductByCategoryId(cateid,ref ToTalRecord, page, pageSize); * ViewBag.Total = ToTalRecord; * ViewBag.Page = page; * * int maxPage = 5; * int TotalPage = 0; * * TotalPage = (int)Math.Ceiling((double)(ToTalRecord / pageSize)); * ViewBag.TotalPage = TotalPage; * ViewBag.MaxPage = maxPage; * ViewBag.First = 1; * ViewBag.Last = TotalPage; * ViewBag.Next = page + 1; * ViewBag.Previus = page - 1; * return View(model);*/ }
public void DisplayProducts() { ProductDao productDao = new ProductDao(); clPager.BindToControl = lstProductTopView; clPager.DataSource = productLogic.GetTopView12Product().DefaultView; lstProductTopView.DataSource = clPager.DataSourcePaged; lstProductTopView.DataBind(); //Hiển thị câu thông báo không có sản phẩm nào if (productLogic.GetTopView12Product().Rows.Count == 0) { lblNotFoundProduct.Visible = true; } else { lblNotFoundProduct.Visible = false; } }
public ActionResult Search(string keyword, int page = 1, int pageSize = 8) { int totalRecord = 0; var model = new ProductDao().Search(keyword, ref totalRecord, page, pageSize); ViewBag.Total = totalRecord; ViewBag.Keyword = keyword; ViewBag.Page = page; int maxpage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.Maxpage = maxpage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); }
public ActionResult Create(Product product) { if (ModelState.IsValid) { var dao = new ProductDao(); long id = dao.Insert(product); if (id > 0) { return(RedirectToAction("Index", "Products")); } else { ModelState.AddModelError("", "Thêm sản phẩm thành công"); } } return(RedirectToAction("Index", "Products")); }
public ActionResult Edit(Product product) { if (ModelState.IsValid) { var dao = new ProductDao(); var result = dao.Update(product); if (result) { ModelState.AddModelError("", "Cập nhật thành công"); return(RedirectToAction("Index", "Products")); } else { ModelState.AddModelError("", "Cập nhật không thành công"); } } return(RedirectToAction("Index", "Products")); }
public ActionResult Edit(int id) { var product = new ProductDao().ViewDetail(id); var productModel = new ProductModel() { ID = product.ID, Name = product.Name, Code = product.Code, Price = product.Price, Description = product.Description, CreatedDate = product.CreatedDate, CategoryID = product.CategoryID, Image = product.Image, MetaTitle = product.MetaTitle, Quantity = product.Quantity }; return(View(productModel)); }
public ActionResult Create(Product product) { if (ModelState.IsValid) { var dao = new ProductDao(); product.CreatedDate = DateTime.Now; long id = dao.Insert(product); if (id > 0) { return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Thêm danh mục không thành công"); } } SetViewBag(); return(View("Create")); }
public ActionResult AddItem(long productId, int quantity) { // lấy thông tin của một đối tượng product var product = new ProductDao().ViewDetail(productId); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Product.ID == productId)) { foreach (var item in list) { if (item.Product.ID == productId) { item.Quantity += quantity; } } } else { // tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; list.Add(item); } // Gán vào session Session[CartSession] = list; } else { // TH chưa có giỏ hàng: tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; var list = new List <CartItem>(); list.Add(item); // Gán vào session Session[CartSession] = list; } return(RedirectToAction("Index")); }
//thêm vào giỏ hàng public ActionResult AddItem(int maMonAn, int soluong) { var monan = new ProductDao().Detail(maMonAn); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.MonAn.MaMonAn == maMonAn)) { foreach (var item in list) { if (item.MonAn.MaMonAn == maMonAn) { item.SoLuong += soluong; } } } else { //tạo mới đối tượng card item var item = new CartItem(); item.MonAn = monan; item.SoLuong = soluong; list.Add(item); } //gán vào session Session[CartSession] = list; } else { //tạo mới đối tượng card item var item = new CartItem(); item.MonAn = monan; item.SoLuong = soluong; var list = new List <CartItem>(); list.Add(item); //gán vào session Session[CartSession] = list; } return(Redirect("/gio-hang")); }
public ActionResult FormDanhGiaMonAn(int maMonAn) { var session = (UserLogin)Session[CommonConstants.SESSION]; if (session == null) { return(Redirect("/dang-nhap")); } else { var dao = new ProductDao(); TempData["MaMonAn"] = dao.GetByMaMonAn(maMonAn).MaMonAn; TempData["ChuDe"] = dao.GetByMaMonAn(maMonAn).MaCD; TempData["TenMonAn"] = dao.GetByMaMonAn(maMonAn).TenMonAn; TempData["HinhMinhHoa"] = dao.GetByMaMonAn(maMonAn).HinhMinhHoa; TempData.Keep(); return(View("FormDanhGiaMonAn")); } }
public ActionResult AddItem(int IdSP, int SoLuong) { var product = new ProductDao().ViewDetail(IdSP); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.SanPham.ID == IdSP)) { foreach (var item in list) { if (item.SanPham.ID == IdSP) { item.SoLuong += SoLuong; } } } else { //tao moi doi tuong cart item var item = new CartItem(); item.SanPham = product; item.SoLuong = SoLuong; list.Add(item); } // gan vao session Session[CartSession] = list; } else { //tao moi doi tuong cart item var item = new CartItem(); item.SanPham = product; item.SoLuong = SoLuong; var list = new List <CartItem>(); list.Add(item); // gan vao session Session[CartSession] = list; } return(RedirectToAction("Index")); }
public ActionResult addItem(long productID, int quantity) { var product = new ProductDao().ViewDetail(productID); var cart = Session[CommonConstants.CART_SEDSSION]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Product.MaSP == productID)) { foreach (var item in list) { if (item.Product.MaSP == productID) { item.Quantity += quantity; } } } else { // Tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; list.Add(item); } // Gán vào session Session[CommonConstants.CART_SEDSSION] = list; } else { // Tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; var list = new List <CartItem>(); list.Add(item); // Gán vào session Session[CommonConstants.CART_SEDSSION] = list; } return(RedirectToAction("index")); }
// GET: Admin/Product public ActionResult Index(string name, string state = "0", string categoryID = "0", string brandID = "0", int page = 1, int pageSize = 8) { int totalRecord = 0; var productDao = new ProductDao(); var model = productDao.ListAll(name, int.Parse(state), long.Parse(categoryID), long.Parse(brandID), ref totalRecord, page, pageSize); ViewBag.TotalRecord = totalRecord; ViewBag.CurrentPage = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord * 1.0 / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.FirstPage = 1; ViewBag.LastPage = totalPage; ViewBag.NextPage = page + 1; ViewBag.PreviousPage = page - 1; if (Int32.Parse(state) == 0) { ViewBag.AllState = "selected"; } else if (Int32.Parse(state) == -1) { ViewBag.LockState = "selected"; } else if (Int32.Parse(state) == 1) { ViewBag.OpenState = "selected"; } ViewBag.State = state; ViewBag.Name = name; ViewBag.CategoryID = long.Parse(categoryID); ViewBag.BrandID = long.Parse(brandID); SetViewBagCategory(long.Parse(categoryID), true); SetViewBagBrand(long.Parse(brandID), true); return(View(model)); }
public ActionResult AddItem(string tensp, string mota, DateTime handaugia, int giadukien, int danhmuc, string hinhanh) { if (ModelState.IsValid) { var dao = new ProductDao(); var res = dao.AddItem(tensp, mota, handaugia, giadukien, danhmuc, hinhanh); if (res > 0) { return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Thêm thành công"); } } return(View("Index")); }
// GET: Home public ActionResult Index() { CategoryDao categoryDao = new CategoryDao(); IList <Category> categories = categoryDao.GetAll(); ViewBag.Categories = categories; if (TempData["foundProducts"] != null) { IList <Product> incomingProducts = TempData["foundProducts"] as List <Product>; return(View(incomingProducts)); } ProductDao productDao = new ProductDao(); IList <Product> products = productDao.GetAll(); return(View(products)); }
public ActionResult AddItem(long productId, int quantity) { var product = new ProductDao().ViewDetail(productId); var cart = Session[OnlineShop.Common.CommonConstants.CartSession]; List <CartItem> list = new List <CartItem>(); if (cart != null) { list = (List <CartItem>)cart; if (list.Exists(x => x.Product.ID == productId)) { foreach (var item in list) { if (item.Product.ID == productId) { item.Quantity += quantity; } } } else { //tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; list.Add(item); } //Gán vào session Session[OnlineShop.Common.CommonConstants.CartSession] = list; } else { //tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; list = new List <CartItem>(); list.Add(item); //Gán vào session Session[OnlineShop.Common.CommonConstants.CartSession] = list; } return(RedirectToAction("Index")); }
public JsonResult Update(long id) { var product = new ProductDao().ViewDetail(id); var cart = Session[Common.CommonConstants.CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Product.ID == id)) { foreach (var item in list) { if (item.Product.ID == id) { item.Quantity += 1; } } } else { var item = new CartItem(); item.Product = product; item.Quantity = 1; list.Add(item); } } else { var item = new CartItem(); item.Product = product; item.Quantity = 1; var list = new List <CartItem>(); list.Add(item); Session[Common.CommonConstants.CartSession] = list; } return(Json(new { status = true })); }
public ActionResult create(Product model) { if (ModelState.IsValid) { var dao = new ProductDao(); long id = dao.Insert(model); if (id > 0) { return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Them product thanh cong"); } } SetViewbag(); return(View()); }
public ActionResult Edit(Product Product) { if (ModelState.IsValid) { var dao = new ProductDao(); var result = dao.Update(Product); if (result) { return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Cập nhật user không thành công"); } } SetViewBag(Product.CategoryID); return(View(Product.CategoryID)); }
public ActionResult Edit(m_product acc) { if (ModelState.IsValid) { var dao = new ProductDao(); var result = dao.update(acc); if (result) { setAleart("Sửa sản phẩm thành công !", "Success"); return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Cập nhập không thành công"); } } SetViewBag_Supplier(); return(View()); }
public ActionResult Create(m_product user) { if (ModelState.IsValid) { var dao = new ProductDao(); long id = dao.Insert(user); if (id > 0) { setAleart("Thêm sản phẩm thành công !", "Success"); return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Thêm sản phẩm khong thành công"); } } SetViewBag_Supplier(); return(View()); }
public JsonResult Search(string text, int?page) { ProductDao productDao = new ProductDao(); List <Models.EF.sanpham> list = productDao.Search(text); if (page < 1) { page = 1; } int start = (int)(page - 1) * 6; ViewBag.pageCurrent = page; int totalPage = list.Count; float totalNumsize = (totalPage / (float)6); int numSize = (int)Math.Ceiling(totalNumsize); ViewBag.numSize = numSize; return(Json(new { data = list.OrderByDescending(x => x.TENSP).Skip(start).Take(6), pageCurrent = page, numSize = numSize }, JsonRequestBehavior.AllowGet)); }
//thêm item vào giỏ hàng và trả về trang loại hiện tại public ActionResult AddItem_Catagory(long productId, int quantity, int page) { var product = new ProductDao().ViewDetail(productId); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Product.ID == productId)) { foreach (var item in list) { if (item.Product.ID == productId) { item.Quantity += quantity; } } } else { //tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; list.Add(item); } //Gán vào session Session[CartSession] = list; } else { //tạo mới đối tượng cart item var item = new CartItem(); item.Product = product; item.Quantity = quantity; var list = new List <CartItem>(); list.Add(item); //Gán vào session Session[CartSession] = list; } return(RedirectToAction("Category", "Product", new { cateID = product.CategoryID, page = page })); }
// them vao gio hang public ActionResult AddItem(long productId, int quantity) { var product = new ProductDao().ViewDetail(productId); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Sach.MaSach == productId)) { foreach (var item in list) { if (item.Sach.MaSach == productId) { item.SoLuong += quantity; } } } else { //tạo mới đối tượng cart item var item = new CartItem(); item.Sach = product; item.SoLuong = quantity; list.Add(item); } //Gán vào session Session[CartSession] = list; } else { //tạo mới đối tượng cart item var item = new CartItem(); item.Sach = product; item.SoLuong = quantity; var list = new List <CartItem>(); list.Add(item); //Gán vào session Session[CartSession] = list; } return(RedirectToAction("Index")); }
public ActionResult AddItem(long id, int quantity = 1) { var product = new ProductDao().GetDetail(id); var cart = (List <CartItem>)Session[Constants.CART_SESSION]; if (cart == null) { CartItem item = new CartItem(); item.Product = product; item.Quantity = quantity; List <CartItem> listcart = new List <CartItem>(); listcart.Add(item); Session[Constants.CART_SESSION] = listcart; } else { if (cart.Exists(x => x.Product.ID == id)) { for (int i = 0; i < cart.Count; i++) { if (cart[i].Product.ID == id) { cart[i].Quantity += quantity; } } Session[Constants.CART_SESSION] = cart; } else { CartItem item = new CartItem(); item.Product = product; item.Quantity = quantity; cart.Add(item); Session[Constants.CART_SESSION] = cart; } } if (Session[Constants.USER_INFO] != null) { new LogDao().SetLog("Add Item Cart", null, ((User)Session[Constants.USER_INFO]).ID); } return(Redirect((string)Session[Constants.CURRENT_URL])); }
public ActionResult AddItem(long productId, int quantity) { var product = new ProductDao().ViewDetail(productId); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.Product.id == productId)) { foreach (var item in list) { if (item.Product.id == productId) { item.Quantity += quantity; } } } else { //Tao ra Cart Item var item = new CartItem(); item.Product = product; item.Quantity = quantity; list.Add(item); } //Gan vao Session Session[CartSession] = list; } else { //Tao ra doi tuong moi trong Cart Item var item = new CartItem(); item.Product = product; item.Quantity = quantity; var list = new List <CartItem>(); list.Add(item); //Gan vao Session Session[CartSession] = list; } return(RedirectToAction("Index")); }
public ProductService() { ProductDao = new ProductDao<ProductInfo>(); UnitDao = new DictionaryDao<Unit>(); SpecificationDao = new SpecificationDao<Specification>(); }
public WarehouseService() { ProductDao = new ProductDao<ProductInfo>(); }