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 Delete(int id) { if (Ktdangnhap() == true) { return(View(PhieuNhapMager.GetItemById(id))); } else { return(RedirectToAction("Index")); } }
[HttpPost] // xoa san pham , luu tt nhan vien xoa public ActionResult Delete(int id, FormCollection f) { try { PhieuNhapMager.delete(id); return(RedirectToAction("Index")); } catch { return(RedirectToAction("Delete", id)); } }
public ActionResult Create(Pn item) { PhieuNhapMager.insert(item); return(RedirectToAction("CreateCtPn", item)); }
// GET: NhapHang public ActionResult Index() { List <Pn> lst = PhieuNhapMager.getAll(); return(View(lst)); }