public ViewStudentInformation GetStudentInfo(string regNo) { try { connection.Open(); string queryString = "select s.name,s.eamil,d.departmentName,s.departmentId from t_StudentInfo s join t_Department d on(s.departmentId=d.departmentId) where s.registationNo=@regNo"; command.CommandText = queryString; command.Parameters.Clear(); command.Parameters.AddWithValue("@regNo", regNo); ViewStudentInformation aViewStudentInformation = new ViewStudentInformation(); SqlDataReader studentReader = command.ExecuteReader(); while (studentReader.Read()) { aViewStudentInformation.Name = studentReader[0].ToString(); aViewStudentInformation.Email = studentReader[1].ToString(); aViewStudentInformation.DepartmentName = studentReader[2].ToString(); aViewStudentInformation.RegistationNo = regNo; aViewStudentInformation.DepartmentId = Convert.ToInt16(studentReader[3]); } return(aViewStudentInformation); } finally { connection.Close(); } }
private void ShowStudentAndCourseInfo() { try { StudentManager aStudentManager = new StudentManager(); string regNo = registationNoTextBox.Text; ViewStudentInformation aViewStudentInformation = new ViewStudentInformation(); aViewStudentInformation = aStudentManager.GetStudentInfo(regNo); if (aViewStudentInformation.Name == null) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Invalid registation Number"; return; } nameTextBox.Text = aViewStudentInformation.Name; emailTextBox.Text = aViewStudentInformation.Email; departmentTextBox.Text = aViewStudentInformation.DepartmentName; Course aCourse = new Course(); List <Course> courses = new List <Course>(); courses = aStudentManager.GetStudentCourses(regNo); enrollsubjectGridView.DataSource = courses; enrollsubjectGridView.DataBind(); List <Course> courseList = new List <Course>(); courseList = aStudentManager.GetAllcourses(aViewStudentInformation); enrollDropDownList.DataSource = courseList; enrollDropDownList.DataBind(); } catch (Exception exception) { throw exception; } }
public List <Course> GetAllcourses(ViewStudentInformation aViewStudentInformation) { int flag; CourseGateway aCourseGateway = new CourseGateway(); List <Course> courseList = new List <Course>(); List <Course> courses = new List <Course>(); List <Course> newCourses = new List <Course>(); courses = GetStudentCourses(aViewStudentInformation.RegistationNo); courseList = aCourseGateway.GetCoursesByDepartment(aViewStudentInformation); foreach (Course deptCourse in courseList) { flag = 0; foreach (Course course in courses) { if (deptCourse.CourseCode == course.CourseCode) { flag = 1; } } if (flag == 0) { newCourses.Add(deptCourse); } } return(newCourses); }
public List <Course> GetCoursesByDepartment(ViewStudentInformation aViewStudentInformation) { try { List <Course> courses = new List <Course>(); connection.Open(); string query = "SELECT * FROM T_COURSE where DepartmentId=@departmentId"; command.CommandText = query; command.Parameters.Clear(); command.Parameters.AddWithValue("@departmentId", aViewStudentInformation.DepartmentId); SqlDataReader courseReader = command.ExecuteReader(); while (courseReader.Read()) { Course aCourse = new Course(); aCourse.CourseId = Convert.ToInt16(courseReader[0].ToString()); aCourse.CourseCode = courseReader[1].ToString(); aCourse.CourseName = courseReader[2].ToString(); aCourse.Credit = float.Parse(courseReader[3].ToString()); aCourse.Description = courseReader[4].ToString(); aCourse.ASemester = new Semester(); aCourse.ADepartment = new Department(); aCourse.ASemester.SemesterId = Convert.ToInt16(courseReader[5].ToString()); aCourse.ADepartment.DepartmentId = Convert.ToInt16(courseReader[6].ToString()); aCourse.CourseStatus = Convert.ToInt16(courseReader[7].ToString()); courses.Add(aCourse); } return(courses); } finally { connection.Close(); } }
private void GetResult(string regNo) { try { StudentManager aStudentManager = new StudentManager(); ResultManager aResultManager = new ResultManager(); ViewStudentInformation aViewStudentInformation = new ViewStudentInformation(); aViewStudentInformation = aStudentManager.GetStudentInformation(regNo); if (aViewStudentInformation.Name == null) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Invalid Registation Number"; return; } nameTextBox.Value = aViewStudentInformation.Name; emailTextBox.Value = aViewStudentInformation.Email; departmentTextBox.Value = aViewStudentInformation.DepartmentName; ViewResult aViewResult = new ViewResult(); List <ViewCourseGradeAndCredit> viewCourseGradeAndCreditList = new List <ViewCourseGradeAndCredit>(); viewCourseGradeAndCreditList = aResultManager.GetCourseResult(regNo); detailsResultGridView.DataSource = viewCourseGradeAndCreditList; detailsResultGridView.DataBind(); aViewResult = aResultManager.GetSubjectCGPA(regNo); noOfEnrolledCoursesTextBox.Value = aViewResult.NoOfEnrolledCourses.ToString(); noOfRemainingCoursesTextBox.Value = (aViewResult.NoOfEnrolledCourses - aViewResult.NoOfCompletedCourses).ToString(); noOfCompletedCoursesTextBox.Value = aViewResult.NoOfCompletedCourses.ToString(); totalCreditEnrolledCoursesTextBox.Value = aViewResult.EnrolledCredit.ToString(); completedCreditTextBox.Value = aViewResult.CompletedCredit.ToString(); remainingCreditTextBox.Value = (aViewResult.EnrolledCredit - aViewResult.CompletedCredit).ToString(); gradeLetterTextBox.Value = aViewResult.GradeLetter; cgpaTextBox.Value = aViewResult.Cgpa.ToString(); if (aViewResult.NoOfEnrolledCourses != aViewResult.NoOfCompletedCourses || aViewResult.NoOfCompletedCourses == 0) { resultLabel.ForeColor = Color.Red; resultLabel.Text = "You are not eligible to get the certificate"; } else { resultLabel.ForeColor = Color.Green; resultLabel.Text = "You are eligible to get the certificate"; } } catch (SqlException sqlException) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Database error.See details error: " + sqlException.Message; } catch (Exception exception) { msgLabel.ForeColor = Color.Red; string errorMessage = "Unknow error occured."; errorMessage += exception.Message; if (exception.InnerException != null) { errorMessage += exception.InnerException.Message; } msgLabel.Text = errorMessage; } }