public void InsertStudentCourse(ClassStudentDetails s) { try { int sid = s.StudentId, cid = s.CourseId; bool status = false; status = CheckIfExists(sid, cid); if (status == false) { SqlCommand com = new SqlCommand("Sp_InsertStudentCourse", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@prmsid", s.StudentId); com.Parameters.AddWithValue("@prmcid", s.CourseId); con.Open(); com.ExecuteNonQuery(); con.Close(); } else { } } catch (Exception e) { Console.WriteLine("Catch error: " + e); } }
public ActionResult StudentCourseInsert(FormCollection f) { ClassStudentDetails s = new ClassStudentDetails(); s.StudentId = Convert.ToInt32(f["StudentId"]); s.CourseId = Convert.ToInt32(f["CourseId"]); dblayer.InsertStudentCourse(s); return(RedirectToAction("StudentCourseDisplay")); }