public nhomhang nhomhang(int id) { banhangDataContext context = new banhangDataContext(); nhomhang nh = context.nhomhangs.FirstOrDefault(x => x.manhom == id); return(nh); }
public ActionResult DeleteConfirmed(int id) { nhomhang nhomhang = db.nhomhang.Find(id); db.nhomhang.Remove(nhomhang); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "manhomhang,maloai,tennhomhang")] nhomhang nhomhang) { if (ModelState.IsValid) { db.Entry(nhomhang).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.maloai = new SelectList(db.loaihang, "maloai", "tenloai", nhomhang.maloai); return(View(nhomhang)); }
public ActionResult Create([Bind(Include = "manhomhang,maloai,tennhomhang")] nhomhang nhomhang) { if (ModelState.IsValid) { db.nhomhang.Add(nhomhang); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.maloai = new SelectList(db.loaihang, "maloai", "tenloai", nhomhang.maloai); return(View(nhomhang)); }
// GET: Areas/Nhomhang/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } nhomhang nhomhang = db.nhomhang.Find(id); if (nhomhang == null) { return(HttpNotFound()); } return(View(nhomhang)); }
// GET: Areas/Nhomhang/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } nhomhang nhomhang = db.nhomhang.Find(id); if (nhomhang == null) { return(HttpNotFound()); } ViewBag.maloai = new SelectList(db.loaihang, "maloai", "tenloai", nhomhang.maloai); return(View(nhomhang)); }
public bool themnhomhang(string maloai, string tennhom) { try { banhangDataContext context = new banhangDataContext(); nhomhang lhmoi = new nhomhang(); lhmoi.maloai = maloai; lhmoi.tennhom = tennhom; context.nhomhangs.InsertOnSubmit(lhmoi); context.SubmitChanges(); return(true); } catch { } return(false); }
public bool xoanhomhang(int manhom) { try { banhangDataContext context = new banhangDataContext(); nhomhang xoalh = context.nhomhangs.FirstOrDefault(x => x.manhom == manhom); if (xoalh != null) { context.nhomhangs.DeleteOnSubmit(xoalh); context.SubmitChanges(); return(true); } } catch { } return(false); }
public bool suanhomhang(int manhom, string maloai, string tennhom) { try { banhangDataContext context = new banhangDataContext(); nhomhang sualh = context.nhomhangs.FirstOrDefault(x => x.manhom == manhom); if (sualh != null) { sualh.maloai = maloai; sualh.tennhom = tennhom; context.SubmitChanges(); return(true); } } catch { } return(false); }