public ActionResult Themsanpham() { LoaisanphamDao loaisanphamDao = new LoaisanphamDao(); ViewData["danhsachloaisanpham"] = loaisanphamDao.getLoaisanpham(); SelectList listoption = new SelectList(loaisanphamDao.getLoaisanpham().ToList(), "maloaisp", "tenloaisp"); ViewBag.option = listoption; return(View()); }
public ActionResult Suasanpham(sanpham sanpham) { SanphamDao sanphamDao = new SanphamDao(); if (sanpham.hinhanh == "") { sanpham.hinhanh = Request["hinhanhcu"].ToString(); } int ketqua = sanphamDao.postSuasanpham(sanpham); if (ketqua > 0) { ViewData["thongbao"] = "ok"; LoaisanphamDao loaisanphamDao = new LoaisanphamDao(); ViewData["danhsachsanpham"] = sanphamDao.getSanpham((int)sanpham.masp); SelectList list = new SelectList(loaisanphamDao.getLoaisanpham().ToList(), "maloaisp", "tenloaisp"); list.Where(x => x.Text == sanphamDao.getSanpham((int)sanpham.masp).tenloaisp).First().Selected = true; ViewBag.optionslp = list; return(View()); } else { ViewData["thongbao"] = "error"; LoaisanphamDao loaisanphamDao = new LoaisanphamDao(); ViewData["danhsachsanpham"] = sanphamDao.getSanpham((int)sanpham.masp); SelectList list = new SelectList(loaisanphamDao.getLoaisanpham().ToList(), "maloaisp", "tenloaisp"); list.Where(x => x.Text == sanphamDao.getSanpham((int)sanpham.masp).tenloaisp).First().Selected = true; ViewBag.optionslp = list; return(View()); } }
// GET: Loaisanpham public ActionResult Danhsachloaisanpham() { LoaisanphamDao loaisanphamDao = new LoaisanphamDao(); ViewData["loaisp"] = loaisanphamDao.getLoaisanpham(); return(View()); }
public ActionResult Suasanpham(int masp) { LoaisanphamDao loaisanphamDao = new LoaisanphamDao(); SanphamDao sanphamDao = new SanphamDao(); ViewData["danhsachsanpham"] = sanphamDao.getSanpham(masp); SelectList list = new SelectList(loaisanphamDao.getLoaisanpham().ToList(), "maloaisp", "tenloaisp"); list.Where(x => x.Text == sanphamDao.getSanpham(masp).tenloaisp).First().Selected = true; ViewBag.optionslp = list; return(View()); }
public ActionResult Themsanpham(sanpham sanpham) { SanphamDao sanphamDao = new SanphamDao(); int ketqua = sanphamDao.postSanpham(sanpham); LoaisanphamDao loaisanphamDao = new LoaisanphamDao(); ViewData["danhsachloaisanpham"] = loaisanphamDao.getLoaisanpham(); SelectList listoption = new SelectList(loaisanphamDao.getLoaisanpham().ToList(), "maloaisp", "tenloaisp"); ViewBag.option = listoption; if (ketqua != 0) { ViewData["thongbao"] = "ok"; return(View()); } else { ViewData["thongbao"] = "error"; return(View()); } }