public RedirectToRouteResult XoaSP(int id, SanPham model) { model.SanphamID = id; var result = new SanPhamFunction().Delete(model); return(RedirectToAction("Index")); }
public ActionResult Edit(int id, SanPham model, HttpPostedFileBase file) { try { // TODO: Add update logic here if (file == null) { ModelState.AddModelError("File", "Please Upload Your file"); } else if (file.ContentLength > 0) { //TO:DO var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/images/laptop"), fileName); file.SaveAs(path); // ModelState.Clear(); // TODO: Add insert logic here model.Imagelink = fileName; SanPhamFunction _sanphamF = new SanPhamFunction(); _sanphamF.Update(model); // Upload File đẩy về Server } return(RedirectToAction("Index")); } catch { return(View()); } }
public RedirectToRouteResult XoaKhoiGio(int sanphamID) { var product = new SanPhamFunction().FindEntity(sanphamID);; var cart = (Cart)Session[CartSession]; if (cart != null) { cart.RemoveLine(product); //Gán vào session Session[CartSession] = cart; } //var cart =(Cart)Session[CartSession]; //if (cart != null) //{ // var list = cart.Lines.ToList(); // CartItem itemXoa = list.FirstOrDefault(m => m.sanpham.SanphamID == sanphamID); // if (itemXoa != null) // { // list.Remove(itemXoa); // } // Session[CartSession] = list; //} // List<CartItemModel> giohang = Session["CartSession"] as List<CartItemModel>; return(RedirectToAction("Index", "Cart")); }
// GET: ADMIN/ThongKeSPTheoTG public ActionResult Index(int i) { var model = new SanPhamFunction().GetSPTK(0, 2020); if (i == 1) { model.AddRange(new SanPhamFunction().GetSPTK(1, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(2, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(3, 2020)); } if (i == 2) { model.AddRange(new SanPhamFunction().GetSPTK(5, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(6, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(4, 2020)); } if (i == 3) { model.AddRange(new SanPhamFunction().GetSPTK(7, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(8, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(9, 2020)); } if (i == 4) { model.AddRange(new SanPhamFunction().GetSPTK(12, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(10, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(11, 2020)); } return(View(model)); }
// GET: ADMIN/SanPham/Edit/5 public ActionResult Edit(int id) { var model = new SanPhamFunction().FindEntity(id); var dao = new DanhMucFunction().DANHMUCs; ViewBag.DanhmucID = new SelectList(dao, "DanhmucID", "Tendanhmuc", model.DanhmucID); ViewBag.Tendanhmuc = model.DanhMuc.Tendanhmuc; var test = new SelectList(dao, "DanhmucID", "Tendanhmuc", model.DanhmucID); return(View(model)); }
public ActionResult Delete(int id, SanPham model) { try { // TODO: Add delete logic here model.SanphamID = id; var result = new SanPhamFunction().Delete(model); return(RedirectToAction("Index")); } catch { return(View()); } }
//đưa ra điện thoại theo mục public ActionResult sanphamtheomuc(string id_theloai) { //lay ra the loai co theloai_id la id_theloai theloaisp theloai = new DanhMucFunction().FindEntity(id_theloai); //dua ra list san pham co theloai la id_theloai var model = new SanPhamFunction().sanphams.Where(n => n.theloai_id == id_theloai).ToList(); if (model == null) { ViewBag.danhmuc = "Đang cập nhật"; return(null); } else { ViewBag.danhmuc = theloai.theloai_name; return(View(model)); } }
public ActionResult SPViewKG(string keyword, int?page, int?cantren, int?canduoi) { int pageNumber = (page ?? 1); int itemsPerPage = 12; int?ct = cantren; int?cd = canduoi; var db = new SanPhamFunction(); var products = db.Sanphams.ToList(); var pageSize = products.Count / itemsPerPage; var sp = products .Where(p => p.Giabandau > cd & p.Giabandau <= ct) .OrderBy(p => p.Tensanpham) .ToList(); if (!string.IsNullOrEmpty(keyword) && !string.IsNullOrWhiteSpace(keyword)) { sp = sp.Where(p => !string.IsNullOrEmpty(p.Tensanpham) && p.Tensanpham.ToLower().Contains(keyword.ToLower())) .ToList(); } return(View("SPViewKG", sp.OrderBy(n => n.SanphamID).ToPagedList(pageNumber, itemsPerPage))); }
public PartialViewResult SPOfNew() { var sp = new SanPhamFunction().SPOfNew(); return(PartialView("SPOfNew", sp)); }
// GET: ADMIN/SanPham public ActionResult Index() { var sp = new SanPhamFunction().GetSanPhams(); return(View(sp)); }
public ActionResult DownloadExcel(int i) { var model = new SanPhamFunction().GetSPTK(0, 2020); if (i == 1) { model.AddRange(new SanPhamFunction().GetSPTK(1, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(2, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(3, 2020)); } if (i == 2) { model.AddRange(new SanPhamFunction().GetSPTK(5, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(6, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(4, 2020)); } if (i == 3) { model.AddRange(new SanPhamFunction().GetSPTK(7, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(8, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(9, 2020)); } if (i == 4) { model.AddRange(new SanPhamFunction().GetSPTK(12, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(10, 2020)); model.AddRange(new SanPhamFunction().GetSPTK(11, 2020)); } ExcelPackage.LicenseContext = LicenseContext.NonCommercial; ExcelPackage Ep = new ExcelPackage(); ExcelWorksheet Sheet = Ep.Workbook.Worksheets.Add("Report"); Sheet.Cells["A1"].Value = "Mã sản phẩm"; Sheet.Cells["B1"].Value = "Tên danh mục"; Sheet.Cells["C1"].Value = "Tên sản phẩm"; Sheet.Cells["D1"].Value = "Giá sản phẩm"; Sheet.Cells["E1"].Value = "Họ tên khách hàng"; Sheet.Cells["F1"].Value = "Địa chỉ giao hàng"; Sheet.Cells["G1"].Value = "Số lượng đã bán"; int row = 2; foreach (var item in model) { Sheet.Cells[string.Format("A{0}", row)].Value = item.SanphamID; Sheet.Cells[string.Format("B{0}", row)].Value = item.Tendanhmuc; Sheet.Cells[string.Format("C{0}", row)].Value = item.Tensanpham; Sheet.Cells[string.Format("D{0}", row)].Value = item.Giabandau; Sheet.Cells[string.Format("E{0}", row)].Value = item.Hotenkhachhang; Sheet.Cells[string.Format("F{0}", row)].Value = item.Diachigiaohang; Sheet.Cells[string.Format("G{0}", row)].Value = item.Soluong; row++; } Sheet.Cells["A:AZ"].AutoFitColumns(); Response.Clear(); Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment: filename=" + "Report.xlsx"); Response.BinaryWrite(Ep.GetAsByteArray()); Response.End(); return(RedirectToAction("/")); }
//đưa ra điện thoại liên quan public PartialViewResult dienthoailienquan(string theloai_id) { var model = new SanPhamFunction().sanphams.Where(n => n.theloai_id == theloai_id).ToList(); return(PartialView(model)); }
//xem chi tiết sản phẩm public ActionResult xemchitiet(int masp) { sanpham sp = new SanPhamFunction().FindEntity(masp); return(View(sp)); }
//đưa ra sản phẩm moi public PartialViewResult dienthoaimoi() { var model = new SanPhamFunction().sanphams.Where(n => n.moi == 1 && n.style == 0).ToList(); return(PartialView(model)); }