public ActionResult Create([Bind(Include = "MaCTBH,SerialNumber,MaNV,MaBH,TrangThai,NgayBH,GhiChuBH,NgayTra")] ChiTietBH chiTietBH) { var count = from sl in db.ChiTietBH select sl; int a = KTTonTai(count.Count()); if (ModelState.IsValid) { if (Common.MaNV != "") { } else { Common.Alert = "Đăng nhập trước khi chỉnh sữa !"; return(RedirectToAction("Index", "Logins")); } chiTietBH.MaCTBH = a; db.ChiTietBH.Add(chiTietBH); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaBH = new SelectList(db.BaoHanh, "MaBH", "HinhThucBH", chiTietBH.MaBH); ViewBag.MaNV = new SelectList(db.NhanVien, "MaNV", "TenNV"); ViewBag.SerialNumber = new SelectList(db.SanPham, "SerialNumber", "SerialNumber", chiTietBH.SerialNumber); return(View(chiTietBH)); }
public ActionResult DeleteConfirmed(int id) { ChiTietBH chiTietBH = db.ChiTietBH.Find(id); db.ChiTietBH.Remove(chiTietBH); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: ChiTietBHs/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChiTietBH chiTietBH = db.ChiTietBH.Find(id); if (chiTietBH == null) { return(HttpNotFound()); } return(View(chiTietBH)); }
// GET: ChiTietBHs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChiTietBH chiTietBH = db.ChiTietBH.Find(id); if (chiTietBH == null) { return(HttpNotFound()); } ViewBag.MaBH = new SelectList(db.BaoHanh, "MaBH", "HinhThucBH", chiTietBH.MaBH); ViewBag.MaNV = new SelectList(db.NhanVien, "MaNV", "TenNV"); ViewBag.SerialNumber = new SelectList(db.SanPham, "SerialNumber", "SerialNumber", chiTietBH.SerialNumber); return(View(chiTietBH)); }
public ActionResult Edit([Bind(Include = "MaCTBH,SerialNumber,MaNV,MaBH,TrangThai,NgayBH,GhiChuBH,NgayTra")] ChiTietBH chiTietBH) { if (ModelState.IsValid) { if (Common.MaNV != "") { } else { Common.Alert = "Đăng nhập trước khi chỉnh sữa !"; return(RedirectToAction("Index", "Logins")); } db.Entry(chiTietBH).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaBH = new SelectList(db.BaoHanh, "MaBH", "HinhThucBH", chiTietBH.MaBH); ViewBag.MaNV = new SelectList(db.NhanVien, "MaNV", "TenNV"); ViewBag.SerialNumber = new SelectList(db.SanPham, "SerialNumber", "SerialNumber", chiTietBH.SerialNumber); return(View(chiTietBH)); }