public ActionResult fees_collect(int?rcpt_no) { mst_finMain fin = new mst_finMain(); fees_collect fee = new fees_collect(); DDsession_name(); if (fin.checkFYnotExpired()) { sr_registerMain stdMain = new sr_registerMain(); fee.list = stdMain.AllStudentList(GetDefaultSection()); DDClassWiseSection(); //fee.list = stdMain.AllStudentList(0); ViewBag.recpt_no = rcpt_no; return(View(fee)); } else { ModelState.AddModelError(String.Empty, "Financial Year Expired cannot submit fees create new Financial year."); sr_registerMain stdMain = new sr_registerMain(); fee.list = stdMain.AllStudentList(GetDefaultSection()); DDClassWiseSection(); ViewBag.recpt_no = rcpt_no; return(View(fee)); } }
public ActionResult fees_collect(fees_collect col) { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { mst_finMain fin = new mst_finMain(); if (fin.checkFYnotExpired()) { try { mst_sessionMain sess = new mst_sessionMain(); if (sess.findActive_Session() == col.session) { string query = @"SELECT ifnull(SUM(IFNULL(outstd_amount, 0)) - SUM(IFNULL(rmt_amount, 0)),0) amt FROM out_standing WHERE sr_number = @sr_number AND session != @session"; decimal amt = con.Query <decimal>(query, new { sr_number = col.sr_num, session = col.session }).SingleOrDefault(); if (amt != 0m) { ModelState.AddModelError(string.Empty, "Kindly clear previous session fees first."); fees_collect fee = new fees_collect(); sr_registerMain stdMain = new sr_registerMain(); fee.list = stdMain.AllStudentList(GetDefaultSection()); DDsession_name(); DDClassWiseSection(); return(View(fee)); } } if (col.sr_num > 0) { sr_registerMain reg = new sr_registerMain(); sr_register register = new sr_register(); register = reg.FindStudent(col.sr_num, col.session); if (register == null) { register = reg.FindStudent(col.sr_num, sess.findFinal_Session()); } col.std_Name = register.std_first_name + " " + register.std_last_name; col.std_father_name = register.std_father_name; col.std_mother_name = register.std_mother_name; col.std_contact = register.std_contact; col.std_Email = register.std_email; col.std_Class = register.class_name; col.std_Section = register.section_name; col.std_Pickup_point = register.pickup_point; col.std_aadhar = register.std_aadhar; return(View("submit_fees", col)); } else if (col.reg_num > 0) { std_registrationMain reg = new std_registrationMain(); std_registration registration = new std_registration(); registration = reg.FindRegistrationForFees(col.reg_num); col.std_Name = registration.std_first_name + " " + registration.std_last_name; col.std_father_name = registration.std_father_name; col.std_mother_name = registration.std_mother_name; col.std_contact = registration.std_contact; col.std_Email = registration.std_email; col.std_Class = registration.class_name; col.std_Section = "N/A"; col.std_Pickup_point = "N/A"; return(View("submit_fees", col)); } else { fees_collect fee = new fees_collect(); sr_registerMain stdMain = new sr_registerMain(); fee.list = stdMain.AllStudentList(col.section_id); DDsession_name(); DDClassWiseSection(); return(View(fee)); } } catch { ModelState.AddModelError(string.Empty, "Student record not found"); fees_collect fee = new fees_collect(); sr_registerMain stdMain = new sr_registerMain(); fee.list = stdMain.AllStudentList(GetDefaultSection()); DDsession_name(); DDClassWiseSection(); return(View(fee)); } } else { ModelState.AddModelError(string.Empty, "Financial Year Expired cannot submit fees create new Financial year."); fees_collect fee = new fees_collect(); sr_registerMain stdMain = new sr_registerMain(); fee.list = stdMain.AllStudentList(col.section_id); DDsession_name(); DDClassWiseSection(); return(View(fee)); } } }