public ActionResult DeleteWard(int id) { try { quanhuyen qh = db.quanhuyens.SingleOrDefault(m => m.Maquanhuyen == id); db.quanhuyens.DeleteOnSubmit(qh); db.SubmitChanges(); TempData["message"] = "success"; } catch (Exception ex) { TempData["message"] = "fail"; } TempData["message2"] = "delete"; return(RedirectToAction("Ward")); }
public ActionResult AddWard(quanhuyen qh) { if (Session["LoggedAD"] == null || Session["LoggedAD"].ToString() == "") { return(RedirectToAction("Login", "Admin")); } try { db.quanhuyens.InsertOnSubmit(qh); db.SubmitChanges(); TempData["message"] = "success"; } catch (Exception ex) { TempData["message"] = "fail"; } TempData["message2"] = "add"; return(RedirectToAction("Ward")); }
public ActionResult EditWard(quanhuyen qh) { if (Session["LoggedAD"] == null || Session["LoggedAD"].ToString() == "") { return(RedirectToAction("Login", "Admin")); } try { quanhuyen qhh = db.quanhuyens.SingleOrDefault(n => n.Maquanhuyen == qh.Maquanhuyen); qhh.Tenquanhuyen = qh.Tenquanhuyen == null ? qhh.Tenquanhuyen : qh.Tenquanhuyen; qhh.Matinhtp = qh.Matinhtp; db.SubmitChanges(); TempData["message"] = "success"; } catch (Exception e) { TempData["message"] = "fail"; } TempData["message2"] = "edit"; return(RedirectToAction("Ward")); }