public ActionResult DeleteConfirmed(int id) { Phieu_Xuat_Kho_Chua phieu_Xuat_Kho_Chua = db.Phieu_Xuat_Kho_Chua.Find(id); db.Phieu_Xuat_Kho_Chua.Remove(phieu_Xuat_Kho_Chua); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Hang_Hoa_Id,Phieu_Xuat_Id,Don_Gia,So_Luong")] Phieu_Xuat_Kho_Chua phieu_Xuat_Kho_Chua) { if (ModelState.IsValid) { db.Entry(phieu_Xuat_Kho_Chua).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Hang_Hoa_Id = new SelectList(db.Kho_Chua, "Hang_Hoa_Id", "Hang_Hoa_Id", phieu_Xuat_Kho_Chua.Hang_Hoa_Id); ViewBag.Phieu_Xuat_Id = new SelectList(db.Phieu_Xuat, "Phieu_Xuat_Id", "Phieu_Xuat_Id", phieu_Xuat_Kho_Chua.Phieu_Xuat_Id); return(View(phieu_Xuat_Kho_Chua)); }
// GET: Phieu_Xuat_Kho_Chua/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Phieu_Xuat_Kho_Chua phieu_Xuat_Kho_Chua = db.Phieu_Xuat_Kho_Chua.Find(id); if (phieu_Xuat_Kho_Chua == null) { return(HttpNotFound()); } return(View(phieu_Xuat_Kho_Chua)); }
// GET: Phieu_Xuat_Kho_Chua/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Phieu_Xuat_Kho_Chua phieu_Xuat_Kho_Chua = db.Phieu_Xuat_Kho_Chua.Find(id); if (phieu_Xuat_Kho_Chua == null) { return(HttpNotFound()); } ViewBag.Hang_Hoa_Id = new SelectList(db.Kho_Chua, "Hang_Hoa_Id", "Hang_Hoa_Id", phieu_Xuat_Kho_Chua.Hang_Hoa_Id); ViewBag.Phieu_Xuat_Id = new SelectList(db.Phieu_Xuat, "Phieu_Xuat_Id", "Phieu_Xuat_Id", phieu_Xuat_Kho_Chua.Phieu_Xuat_Id); return(View(phieu_Xuat_Kho_Chua)); }
public bool ThemPhieuXuatHH(int ma_phieu, Phieu_Nhap_Json pn) { using (QuanLyKhoEntities db = new QuanLyKhoEntities()) { using (var tran = db.Database.BeginTransaction()) { try { var pxhh = new Phieu_Xuat_Kho_Chua(); pxhh.Phieu_Xuat_Id = ma_phieu; pxhh.Don_Gia = pn.Don_gia; pxhh.So_Luong = pn.So_Luong; pxhh.Hang_Hoa_Id = pn.Hang_Hoa_id; db.Phieu_Xuat_Kho_Chua.Add(pxhh); var kho = db.Kho_Chua.Find(pxhh.Hang_Hoa_Id); if (kho.So_Luong >= pxhh.So_Luong) { kho.So_Luong -= pxhh.So_Luong; db.Entry(kho).State = System.Data.Entity.EntityState.Modified; } else { throw new Exception(); } db.SaveChanges(); tran.Commit(); return(true); } catch (Exception) { tran.Rollback(); return(false); } } } }