public ActionResult CreateCtPn(Pn item, IEnumerable <Ctpn> lst) { try { SanPham sp; foreach (var x in lst) { // cap nhap so luong sp = SanPhamMager.GetSanPhamByID(x.MaSp); if (PhieuNhapMager.ktthamso(x.MaSp, x.SoLuong) == true) { sp.SoLuongTon = sp.SoLuongTon + x.SoLuong; SanPhamMager.uppdateSanPham(sp); x.MaPN = item.MaPN; x.TenSP = sp.TenSp; } else { return(PartialView("error")); //return Content("<script> alert(\"" + x.SanPham.TenSp + " da bi loi \")+ location.reload(); </script>"); } } CtPnMager.insertall(lst); return(RedirectToAction("Index")); } catch { return(View("error")); } }
public ActionResult Details(int?id) { List <Ctpn> lst = CtPnMager.GetItembyMapn(id); return(View(lst)); }