public ActionResult DeleteConfirmed(int id) { phieuthanhtoan phieuthanhtoan = db.phieuthanhtoans.Find(id); db.phieuthanhtoans.Remove(phieuthanhtoan); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,tenphieu,idloaiphieu,iddoandulich,ngaytao")] phieuthanhtoan phieuthanhtoan) { if (ModelState.IsValid) { p.sua(phieuthanhtoan); return(RedirectToAction("Index")); } ViewBag.iddoandulich = new SelectList(db.doanduliches, "id", "tendoan", phieuthanhtoan.iddoandulich); ViewBag.idloaiphieu = new SelectList(db.loaiphieux, "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu); return(View(phieuthanhtoan)); }
public bool add(phieuthanhtoan ptt) { int i = 1; foreach (chitietthanhtoan ct in ptt.chitietthanhtoan) { ct.idchitiet = i; i++; } return(db.Add(ptt)); }
// GET: phieuthanhtoans/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } phieuthanhtoan phieuthanhtoan = pttbus.db.First(c => c.id == id); if (phieuthanhtoan == null) { return(HttpNotFound()); } return(View(phieuthanhtoan)); }
// GET: phieuthanhtoans/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } phieuthanhtoan phieuthanhtoan = db.phieuthanhtoans.Find(id); if (phieuthanhtoan == null) { return(HttpNotFound()); } return(View(phieuthanhtoan)); }
public ActionResult Edit([Bind(Include = "id,tenphieu,idloaiphieu,iddoandulich,ngaytao")] phieuthanhtoan phieuthanhtoan, [Bind(Prefix = "ct")] chitietthanhtoan[] chitietthanhtoan) { if (ModelState.IsValid) { pttbus.update(phieuthanhtoan, chitietthanhtoan); return(RedirectToAction("Index")); } ViewBag.iddoandulich = new SelectList(pttbus.db1.GetAll(), "id", "tendoan", phieuthanhtoan.iddoandulich); ViewBag.idloaiphieu = new SelectList(pttbus.db2.GetAll(), "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu); phieuthanhtoanviewmodel pttvm = new phieuthanhtoanviewmodel(); pttvm.phieuthanhtoan = phieuthanhtoan; return(View(pttvm)); }
// GET: phieuthanhtoans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } phieuthanhtoan phieuthanhtoan = db.phieuthanhtoans.Find(id); if (phieuthanhtoan == null) { return(HttpNotFound()); } ViewBag.iddoandulich = new SelectList(db.doanduliches, "id", "tendoan", phieuthanhtoan.iddoandulich); ViewBag.idloaiphieu = new SelectList(db.loaiphieux, "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu); return(View(phieuthanhtoan)); }
// GET: phieuthanhtoans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } phieuthanhtoan phieuthanhtoan = pttbus.db.First(c => c.id == id); if (phieuthanhtoan == null) { return(HttpNotFound()); } ViewBag.iddoandulich = new SelectList(pttbus.db1.GetAll(), "id", "tendoan", phieuthanhtoan.iddoandulich); ViewBag.idloaiphieu = new SelectList(pttbus.db2.GetAll(), "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu); phieuthanhtoanviewmodel pttvm = new phieuthanhtoanviewmodel(); pttvm.phieuthanhtoan = phieuthanhtoan; return(View(pttvm)); }
public bool update(phieuthanhtoan ptt, chitietthanhtoan[] cttt) { List <chitietthanhtoan> ctttcu = db3.Find(c => c.idphieuthanhtoan == ptt.id).ToList(); foreach (chitietthanhtoan ct in ctttcu) { db3.Delete(ct); } int i = 1; foreach (chitietthanhtoan ct in cttt) { ct.idphieuthanhtoan = ptt.id; ct.idchitiet = i; i++; db3.Add(ct); } return(db.Update(ptt)); }
public bool sua(phieuthanhtoan p) { db.Entry(p).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool them(phieuthanhtoan p) { db.phieuthanhtoans.Add(p); db.SaveChanges(); return(true); }