// GET: ADMIN/SanPham/Create public ActionResult Create() { var dao = new DanhMucFunction().DANHMUCs.Where(p => p.Tendanhmuc != null); ViewBag.DanhmucID = new SelectList(dao, "DanhmucID", "Tendanhmuc", null); return(View()); }
// POST: ADMIN/DanhMuc/Delete/5 public RedirectToRouteResult XoaDM(int id, DanhMuc model) { model.DanhmucID = id; var result = new DanhMucFunction().Delete(model); return(RedirectToAction("Index")); }
// 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 Create(DanhMuc model) { try { // TODO: Add insert logic here var result = new DanhMucFunction().Insert(model); if (result == 0) { return(View()); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, DanhMuc model) { try { // TODO: Add update logic here model.DanhmucID = id; var result = new DanhMucFunction().Update(model); //if (result == null) //{ // return View(); //} 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 DownloadExcel() { var collection = new DanhMucFunction().GetDanhMucs(); ExcelPackage Ep = new ExcelPackage(); ExcelWorksheet Sheet = Ep.Workbook.Worksheets.Add("Report"); Sheet.Cells["A1"].Value = "Mã danh mục"; Sheet.Cells["B1"].Value = "Tên danh mục"; int row = 2; foreach (var item in collection) { Sheet.Cells[string.Format("A{0}", row)].Value = item.DanhmucID; Sheet.Cells[string.Format("B{0}", row)].Value = item.Tendanhmuc; 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("Index")); }
public ActionResult Footer() { var dm = new DanhMucFunction().GetDanhMucs(); return(PartialView(dm)); }
// GET: ADMIN/DanhMuc/Edit/5 public ActionResult Edit(int id) { var model = new DanhMucFunction().FindEntity(id); return(View(model)); }
// GET: ADMIN/DanhMuc public ActionResult Index() { var dm = new DanhMucFunction().GetDanhMucs(); return(View(dm)); }