public StudentModel GetStudentInformation(String studentId) { StudentModel studentModel = null; string query = String.Format("spGetTheStudentById"); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString)) { using (SqlCommand command = new SqlCommand(query,connection)) { command.Parameters.Clear(); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@studentId", studentId); connection.Open(); SqlDataReader rdr = command.ExecuteReader(); while (rdr.Read()) { studentModel = new StudentModel(); studentModel.ID = rdr[0].ToString(); studentModel.Name = rdr[1].ToString(); studentModel.Gender = rdr[2].ToString(); studentModel.Nationality = rdr[3].ToString(); studentModel.DepartmentName = rdr[4].ToString(); studentModel.Session = rdr[5].ToString(); studentModel.Email = rdr[6].ToString(); studentModel.Phone = rdr[7].ToString(); studentModel.PresentAddress = rdr[8].ToString(); studentModel.PermanentAddress = rdr[9].ToString(); } connection.Close(); } } return studentModel; }
public void GetDeptIdAndSessionId() { LoginModel loginModel = new LoginModel(); if (Session["loginInformation"] != null) { loginModel = (LoginModel)Session["loginInformation"]; string email = loginModel.Email; string studentId = loginModel.ID; StudentModel studentModel = new StudentModel(); studentModel = studentBll.GetStudentInfirmation(studentId); AddStudentModel addStudentModel = new AddStudentModel(); addStudentModel = studentBll.GetDeptIdAndSessionIdByStudentIdAndEmail(studentId, email); int maxValueOfYearTerm = adminBll.GetMaxValueOfYearTermIdFromRegPermission(addStudentModel.DeptId, addStudentModel.SessionId); if (maxValueOfYearTerm == 0) { registerButton.Enabled = false; headerTextLabel.Text = "Registration not available"; regStatusLabel.Text = "Not registered for first semister"; studentIdLabel.Text = studentId; departmentNameLabel.Text = studentModel.DepartmentName; sessionLabel.Text = studentModel.Session; //yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm); yearTermLabel.Text = "1st year;1st term"; } else { RegistrationPermissionModel registrationPermissionModel = new RegistrationPermissionModel(); registrationPermissionModel.studentId = studentId; registrationPermissionModel.DeptId = addStudentModel.DeptId; registrationPermissionModel.SessionId = addStudentModel.SessionId; registrationPermissionModel.YearTermId = maxValueOfYearTerm; if (adminBll.IsSemisterRegisteredForStudentId(registrationPermissionModel)) { registerButton.Enabled = false; regStatusLabel.Text = "You are registered for the current semister"; studentIdLabel.Text = studentId; departmentNameLabel.Text = studentModel.DepartmentName; sessionLabel.Text = studentModel.Session; yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm); } else { registerButton.Enabled = true; } } } }
public List<StudentModel> GetAllStudentIdByDeptIdSessionIdYearTermId(int deptId, int sessionId, int yearTermId) { List<StudentModel> studentModels = new List<StudentModel>(); string query = String.Format(@"select studentId from tblStudentSemisterRegistration where deptId=@deptId and sessionId=@sessionId and yearTermId=@yearTermId"); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString)) { using (SqlCommand command = new SqlCommand(query, connection)) { command.Parameters.Clear(); command.Parameters.AddWithValue("@deptId", deptId); command.Parameters.AddWithValue("@sessionId",sessionId); command.Parameters.AddWithValue("@yearTermId",yearTermId); connection.Open(); SqlDataReader rdr = command.ExecuteReader(); while (rdr.Read()) { StudentModel studentModel = new StudentModel(); studentModel.ID = rdr[0].ToString(); studentModels.Add(studentModel); } connection.Close(); } } return studentModels; }
public void GetDeptIdAndSessionId() { LoginModel loginModel = new LoginModel(); if (Session["loginInformation"] != null) { loginModel = (LoginModel)Session["loginInformation"]; string email = loginModel.Email; string studentId = loginModel.ID; StudentModel studentModel = new StudentModel(); studentModel = studentBll.GetStudentInfirmation(studentId); AddStudentModel addStudentModel = new AddStudentModel(); addStudentModel = studentBll.GetDeptIdAndSessionIdByStudentIdAndEmail(studentId, email); int maxValueOfYearTerm = adminBll.GetMaxValueOfYearTermIdFromRegPermission(addStudentModel.DeptId, addStudentModel.SessionId); if (maxValueOfYearTerm == 0) { registerButton.Enabled = false; headerTextLabel.Text = "Registration not available now."; headerTextLabel.CssClass = "text-danger"; headerTextLabel.CssClass = "glyphicon glyphicon-hand-right"; regStatusLabel.Text = "Not registered for first semister"; studentIdLabel.Text = studentId; departmentNameLabel.Text = studentModel.DepartmentName; sessionLabel.Text = studentModel.Session; //yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm); yearTermLabel.Text = "1st year;1st term"; } else { RegistrationPermissionModel registrationPermissionModel = new RegistrationPermissionModel(); registrationPermissionModel.studentId = studentId; registrationPermissionModel.DeptId = addStudentModel.DeptId; registrationPermissionModel.SessionId = addStudentModel.SessionId; registrationPermissionModel.YearTermId = maxValueOfYearTerm; if (studentBll.IsSemisterRegisteredForStudentId(registrationPermissionModel)) { registerButton.Enabled = false; regStatusLabel.Text = "You are registered for the current semister"; studentIdLabel.Text = studentId; departmentNameLabel.Text = studentModel.DepartmentName; sessionLabel.Text = studentModel.Session; yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm); } else { registerButton.Enabled = true; studentIdLabel.Text = studentId; departmentNameLabel.Text = studentModel.DepartmentName; sessionLabel.Text = studentModel.Session; yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm); regStatusLabel.Text = "Not registered yet"; List<CourseModel> courseModels = new List<CourseModel>(); courseModels = studentBll.GetAllCoursesByDeptIdAndYearTermId(addStudentModel.DeptId, maxValueOfYearTerm); decimal totalCredit = 0; int totalSubject = 0; foreach (CourseModel courseModel in courseModels) { totalCredit = courseModel.Credit + totalCredit; totalSubject++; } courseGridView.DataSource = courseModels; courseGridView.DataBind(); totalCreditTextBox.Text = Convert.ToString(totalCredit); courseNumberTextBox.Text = Convert.ToString(totalSubject); } } } }