public ActionResult Create(PhieuTiepNhan_Xe phieuTiepNhan_Xe) { if (ModelState.IsValid) { Xe xe = new Xe(); PhieuTiepNhan phieuTiepNhan = new PhieuTiepNhan(); //Add 1 xe xe.IDBienSo = phieuTiepNhan_Xe.IDBienSo; xe.TenChuXe = phieuTiepNhan_Xe.TenChuXe; xe.IDHieuXe = phieuTiepNhan_Xe.IDHieuXe; xe.DiaChi = phieuTiepNhan_Xe.DiaChi; xe.DienThoai = phieuTiepNhan_Xe.DienThoai; db.Xes.Add(xe); db.SaveChanges(); //Add 1 Phieu tiep nhan int latestIDXe = xe.IDBienSo; phieuTiepNhan.IDBienSo = latestIDXe; phieuTiepNhan.NgayTiepNhan = phieuTiepNhan_Xe.NgayTiepNhan; db.PhieuTiepNhans.Add(phieuTiepNhan); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDHieuXe = new SelectList(db.HieuXes, "IDHieuXe", "TenHieuXe", db.HieuXes.First().TenHieuXe); return(View(phieuTiepNhan_Xe)); }
public ActionResult Create(PhieuTiepNhan phieu) { List <SelectListItem> Gender = new List <SelectListItem>() { new SelectListItem { Value = "true", Text = "Nam" }, new SelectListItem { Value = "false", Text = "Nữ" } }; int soLuongPhieu = Convert.ToInt32(db.ThamSoes.First().GiaTri); if (db.PhieuTiepNhans.Where(x => x.NgayTiepNhan == phieu.NgayTiepNhan).Count() >= soLuongPhieu) { ViewBag.Error = "Đã đủ số lượng tiếp nhận trong ngày!"; ViewBag.ID_BenhNhan = new SelectList(db.HoSoBenhNhans.Where(x => x.Deleted == false), "ID_BenhNhan", "HoTen", phieu.ID_BenhNhan); ViewBag.Gender = new SelectList(Gender, "Value", "Text"); return(View(phieu)); } if (ModelState.IsValid) { db.PhieuTiepNhans.Add(phieu); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Gender = new SelectList(Gender, "Value", "Text"); ViewBag.ID_BenhNhan = new SelectList(db.HoSoBenhNhans.Where(x => x.Deleted == false), "ID_BenhNhan", "HoTen", phieu.ID_BenhNhan); return(View(phieu)); }
public ActionResult DeleteConfirmed(int id) { PhieuTiepNhan phieuTiepNhan = db.PhieuTiepNhans.Find(id); db.PhieuTiepNhans.Remove(phieuTiepNhan); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "IDPhieuTN,IDBienSo,NgayTiepNhan")] PhieuTiepNhan phieuTiepNhan) { if (ModelState.IsValid) { db.Entry(phieuTiepNhan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDBienSo = new SelectList(db.Xes, "IDBienSo", "TenChuXe", phieuTiepNhan.IDBienSo); return(View(phieuTiepNhan)); }
public ActionResult Edit([Bind(Include = "IDPhieuTN,ID_BenhNhan,NgayTiepNhan,Deleted")] PhieuTiepNhan phieuTiepNhan) { if (ModelState.IsValid) { db.Entry(phieuTiepNhan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_BenhNhan = new SelectList(db.HoSoBenhNhans.Where(x => x.Deleted == false), "ID_BenhNhan", "HoTen", phieuTiepNhan.ID_BenhNhan); return(View(phieuTiepNhan)); }
// GET: PhieuTiepNhans/Delete/5 public JsonResult DeleteConfirmation(int IDPhieu) { bool result = false; PhieuTiepNhan phieuTiep = db.PhieuTiepNhans.Find(IDPhieu); if (phieuTiep != null) { db.PhieuTiepNhans.Remove(phieuTiep); db.SaveChanges(); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
//public ActionResult Index(string searchString, int? page) //{ // var phieuTiepNhans = db.PhieuTiepNhans.Include(p => p.Xe).OrderBy(p => p.Xe.TenChuXe).ToPagedList(page ?? 1, 10); // if (!String.IsNullOrEmpty(searchString)) // { // phieuTiepNhans = phieuTiepNhans.Where(s => s.Xe.TenChuXe.Contains(searchString)).OrderBy(p => p.Xe.TenChuXe).ToPagedList(page ?? 1, 10); // } // return View(phieuTiepNhans); //} // GET: PhieuTiepNhans/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuTiepNhan phieuTiepNhan = db.PhieuTiepNhans.Find(id); if (phieuTiepNhan == null) { return(HttpNotFound()); } return(View(phieuTiepNhan)); }
// GET: PhieuTiepNhans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuTiepNhan phieuTiepNhan = db.PhieuTiepNhans.Find(id); if (phieuTiepNhan == null) { return(HttpNotFound()); } ViewBag.IDBienSo = new SelectList(db.Xes, "IDBienSo", "TenChuXe", phieuTiepNhan.IDBienSo); return(View(phieuTiepNhan)); }
// GET: PhieuTiepNhans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuTiepNhan phieuTiepNhan = db.PhieuTiepNhans.Find(id); if (phieuTiepNhan == null) { return(HttpNotFound()); } ViewBag.ID_BenhNhan = new SelectList(db.HoSoBenhNhans.Where(x => x.Deleted == false), "ID_BenhNhan", "HoTen", phieuTiepNhan.ID_BenhNhan); return(View(phieuTiepNhan)); }
// GET: PhieuTiepNhans/Create public ActionResult Create() { PhieuTiepNhan phieu = new PhieuTiepNhan(); ViewBag.ID_BenhNhan = new SelectList(db.HoSoBenhNhans.Where(x => x.Deleted == false), "ID_BenhNhan", "HoTen"); List <SelectListItem> Gender = new List <SelectListItem>() { new SelectListItem { Value = "true", Text = "Nam" }, new SelectListItem { Value = "false", Text = "Nữ" } }; ViewBag.Gender = new SelectList(Gender, "Value", "Text"); return(View(phieu)); }