//hiển thị form sửa nước uống public ActionResult fromsualoainuocuong(string id) { Models.LoaiNuocUong x = dc.LoaiNuocUongs.Find(id); if (x != null) { return(View(x)); } return(RedirectToAction("LstLoaiNuocUong")); }
public ActionResult actThemLoaiNuocUong(Models.LoaiNuocUong lmu) { Models.LoaiNuocUong x = dc.LoaiNuocUongs.Find(lmu.loainuocuong_id); if (x == null) { dc.LoaiNuocUongs.Add(lmu); dc.SaveChanges(); return(RedirectToAction("LstLoaiNuocUong")); } return(View("formThemloainuocuong")); }
public ActionResult actsualoainuocuong(Models.LoaiNuocUong lmu) { if (ModelState.IsValid) { Models.LoaiNuocUong x = dc.LoaiNuocUongs.Find(lmu.loainuocuong_id); if (x != null) { x.loainuocuong_id = lmu.loainuocuong_id; x.loainuocuong_ten = lmu.loainuocuong_ten; dc.SaveChanges(); } return(Redirect("/Admin/admin/LstLoaiNuocUong")); } return(View("formsualoainuocuong")); }
//action xóa loại nước uống public ActionResult actxoaloainuocuong(string id) { Models.LoaiNuocUong x = dc.LoaiNuocUongs.Find(id); //kiemtrasql var kt = new Models.db_totnghiepEntities(); var ktnuocuong = kt.NuocUongs.SqlQuery("Select * from NuocUong where loainuocuong_id=@id", new SqlParameter("@id", id)).FirstOrDefault(); if (ktnuocuong == null) { if (x != null) { dc.LoaiNuocUongs.Remove(x); dc.SaveChanges(); return(Redirect("/Admin/admin/LstLoaiNuocUong")); } } return(Redirect("/Admin/admin/LstLoaiNuocUong")); }