public ActionResult ThemPhieuChuyenKho(int pSanPhamId, int pSoLuongChuyen) { List <PhieuCK> lstPhieuCK = LayPhieu(); PhieuCK PCK = lstPhieuCK.Find(n => n.pSanPhamId == pSanPhamId); ViewBag.TongSoLuong = TongSoLuong(); if (PCK == null) { var check = db.SanPhams.SingleOrDefault(n => n.SanPhamId == pSanPhamId); if (check.SoLuong >= pSoLuongChuyen) { PCK = new PhieuCK(pSanPhamId, pSoLuongChuyen); lstPhieuCK.Add(PCK); string message = "Thêm Thành Công"; return(Json(new { Message = message, JsonRequestBehavior.AllowGet })); } else { string message = "Không Đủ Số Lượng"; return(Json(new { Message = message, JsonRequestBehavior.AllowGet })); } } else { string message = "ERROR"; return(Json(new { Message = message, JsonRequestBehavior.AllowGet })); } }
public ActionResult CapNhatPhieuCK(int pSanPhamId, FormCollection form) { List <PhieuCK> lstPhieuCK = LayPhieu(); PhieuCK PCK = lstPhieuCK.SingleOrDefault(n => n.pSanPhamId == pSanPhamId); if (PCK != null) { PCK.pSoLuongChuyen = int.Parse(form["SoLuongChuyen"].ToString()); } return(RedirectToAction("PhieuCK")); }
public ActionResult XoaPhieuCK(int pSanPhamId) { List <PhieuCK> lstPhieuCK = LayPhieu(); PhieuCK PCK = lstPhieuCK.SingleOrDefault(n => n.pSanPhamId == pSanPhamId); if (PCK != null) { lstPhieuCK.RemoveAll(n => n.pSanPhamId == pSanPhamId); return(RedirectToAction("PhieuCK")); } if (lstPhieuCK.Count == 0) { return(RedirectToAction("TrangChu", "Admin")); } return(RedirectToAction("PhieuCK")); }