Beispiel #1
0
        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());
            }
        }
Beispiel #2
0
        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());
        }