public ActionResult DeleteSection(int id, FormCollection collection) { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { mst_sectionMain stdMain = new mst_sectionMain(); string query = @"SELECT COUNT(*) FROM sr_register a, mst_std_section c WHERE c.section_id = @section_id AND c.sr_num = a.sr_number AND c.session = (SELECT session FROM mst_session WHERE session_finalize = 'Y' AND session_active = 'Y')"; int count = con.Query <int>(query, new { section_id = id }).SingleOrDefault(); if (count == 0) { stdMain.DeleteSection(id); return(RedirectToAction("AllSectionList")); } else { ModelState.AddModelError(String.Empty, "Students assigned cannot delete section"); return(View(stdMain.FindSection(id))); } } }
public ActionResult DeleteSection(int id) { mst_sectionMain stdMain = new mst_sectionMain(); return(View(stdMain.FindSection(id))); }