public List <ViewCourse> GetStudentAllCourseDetailsWithRegistrationNo(StudentMustafa student) { Query = "SELECT * FROM StudentCourseResult WHERE StudentRegNo=@regNo "; Command = new SqlCommand(Query, Connection); Connection.Open(); Command.Parameters.Clear(); Command.Parameters.Add("regNo", SqlDbType.VarChar); Command.Parameters["regNo"].Value = student.RegNo; Reader = Command.ExecuteReader(); List <ViewCourse> studentCoursesInfo = new List <ViewCourse>(); while (Reader.Read()) { ViewCourse studentCourseInfo = new ViewCourse(); studentCourseInfo.Code = Reader["Code"].ToString(); studentCourseInfo.CourseName = Reader["Name"].ToString(); studentCourseInfo.Grade = Reader["Grade"].ToString(); studentCoursesInfo.Add(studentCourseInfo); } Reader.Close(); Connection.Close(); return(studentCoursesInfo); }
public JsonResult GetStudentAllCoursesDetailsWithRegNo(StudentMustafa student) { var studentCourseDetails = aViewResultManager.GetStudentAllCourseDetailsWithRegistrationNo(student); return(Json(studentCourseDetails)); }
public StudentMustafa GetStudentDetailsWithRegistrationNo(StudentMustafa student) { Query = "SELECT * FROM StudentResult WHERE RegistrationNo=@regNo"; Command = new SqlCommand(Query, Connection); Connection.Open(); Command.Parameters.Clear(); Command.Parameters.Add("regNo", SqlDbType.VarChar); Command.Parameters["regNo"].Value = student.RegNo; Reader = Command.ExecuteReader(); StudentMustafa studentInfo = new StudentMustafa(); while (Reader.Read()) { studentInfo.Name = Reader["Name"].ToString(); studentInfo.Email = Reader["Email"].ToString(); // studentInfo.Code = Reader["DeptName"].ToString(); studentInfo.Code = Reader["Code"].ToString(); // studentInfo.CourseName = Reader["CourseName"].ToString(); studentInfo.Grade = Reader["Grade"].ToString(); //studentInfo.RegNo = Reader["StudentRegNo"].ToString(); //studentInfo.DepartmentId = Convert.ToInt32(Reader["DepartmentId"].ToString()); } Reader.Close(); Connection.Close(); return(studentInfo); }
public JsonResult GetStudentDetails(StudentMustafa student) { var studentDetails = anEnrollCourseManager.GetStudentDetailsWithRegistrationNo(student); TempData["std"] = studentDetails; var courses = anEnrollCourseManager.GetAllCoursesByDeptId(studentDetails.DepartmentId); studentDetails.Courses = courses; return(Json(studentDetails)); }
public ActionResult EnrollStudentCourse(StudentMustafa student) { ViewBag.Students = anEnrollCourseManager.GetAllStudentsRegistrationNo(); StudentMustafa aStudent = (StudentMustafa)TempData["std"]; aStudent.CourseId = student.CourseId; aStudent.Date = student.Date; ViewBag.Message = anEnrollCourseManager.Enroll(aStudent); return(View()); }
public string Enroll(StudentMustafa student) { if (anEnrollCourseGateway.IsCourseExists(student)) { return("This Course has been enrolled already"); } else { int isRowAffected = anEnrollCourseGateway.Enroll(student); if (isRowAffected > 0) { return("Enrolled successfully"); } else { return("course enrolled failed"); } } }
public List <StudentMustafa> GetAllStudentsRegistrationNo() { Query = "SELECT * FROM Student"; Command = new SqlCommand(Query, Connection); Connection.Open(); Reader = Command.ExecuteReader(); List <StudentMustafa> students = new List <StudentMustafa>(); while (Reader.Read()) { StudentMustafa student = new StudentMustafa() { Id = (int)Reader["id"], RegNo = Reader["RegistrationNo"].ToString() }; students.Add(student); } Reader.Close(); Connection.Close(); return(students); }
public int Enroll(StudentMustafa student) { Query = "INSERT INTO StudentCourse VALUES(@courseId, @studentRegNo, @date, @departmentId)"; Command = new SqlCommand(Query, Connection); Connection.Open(); Command.Parameters.Clear(); Command.Parameters.Add("courseId", SqlDbType.Int); Command.Parameters["courseId"].Value = student.CourseId; Command.Parameters.Add("studentRegNo", SqlDbType.VarChar); Command.Parameters["studentRegNo"].Value = student.RegNo; Command.Parameters.Add("date", SqlDbType.Date); Command.Parameters["date"].Value = student.Date; Command.Parameters.Add("departmentId", SqlDbType.VarChar); Command.Parameters["departmentId"].Value = student.DepartmentId; int isRowEffected = Command.ExecuteNonQuery(); Connection.Close(); return(isRowEffected); }
public StudentMustafa GetStudentDetailsWithRegistrationNo(StudentMustafa student) { Query = "SELECT s.Name, s.Email, s.DepartmentId,s.RegistrationNo,d.Code from Student s INNER JOIN Department d on d.id = s.DepartmentId where s.id = @id"; Command = new SqlCommand(Query, Connection); Connection.Open(); Command.Parameters.Clear(); Command.Parameters.Add("id", SqlDbType.Int); Command.Parameters["id"].Value = student.Id; Reader = Command.ExecuteReader(); StudentMustafa studentInfo = new StudentMustafa(); while (Reader.Read()) { studentInfo.Name = Reader["Name"].ToString(); studentInfo.Email = Reader["Email"].ToString(); studentInfo.Code = Reader["Code"].ToString(); studentInfo.RegNo = Reader["RegistrationNo"].ToString(); studentInfo.DepartmentId = Convert.ToInt32(Reader["DepartmentId"].ToString()); } Reader.Close(); Connection.Close(); return(studentInfo); }
public bool IsCourseExists(StudentMustafa student) { Query = "SELECT * FROM StudentCourse Where StudentRegNo = @str AND CourseId = @courseId "; Command = new SqlCommand(Query, Connection); Connection.Open(); Command.Parameters.Clear(); Command.Parameters.Add("str", SqlDbType.VarChar); Command.Parameters["str"].Value = student.RegNo; Command.Parameters.Add("courseId", SqlDbType.Int); Command.Parameters["courseId"].Value = student.CourseId; Reader = Command.ExecuteReader(); bool isExist = false; if (Reader.HasRows) { isExist = true; } Reader.Close(); Connection.Close(); return(isExist); }
public ActionResult ViewResult(StudentMustafa student) { ViewBag.Students = aViewResultManager.GetAllStudentsRegistrationNo(); return(View()); }
public List <ViewCourse> GetStudentAllCourseDetailsWithRegistrationNo(StudentMustafa student) { return(aViewResultGateway.GetStudentAllCourseDetailsWithRegistrationNo(student)); }
public StudentMustafa GetStudentDetailsWithRegistrationNo(StudentMustafa student) { return(aViewResultGateway.GetStudentDetailsWithRegistrationNo(student)); }
public StudentMustafa GetStudentDetailsWithRegistrationNo(StudentMustafa student) { return(anEnrollCourseGateway.GetStudentDetailsWithRegistrationNo(student)); }