private void txtCourseId_KeyDown(object sender, KeyEventArgs e) { // Display course info if (e.KeyCode == Keys.Enter) { try { var course = new Course(); course.RefNo = txtCourseId.Text; var record = CoursesDataAccess.findCourseById(course); if (record == null) { MessageBox.Show("Course ID not found. Please check the Course-ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { // display course fee and course name txtCourseName.Text = record.Title; txtFee.Text = record.Fee.ToString(); // display lecturer Id and name var lecturer = CourseEnrollmentDataAccess.findCourseByCourseId(txtCourseId.Text); if (lecturer == null) { MessageBox.Show("Course lecturer details not found. Please check the course-ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { // display lecturer info txtLectuerId.Text = lecturer.LecturerId; txtLecturerName.Text = lecturer.LecturerName; // find student id var registration = new RegistrationIds(); registration.RegistrationId = txtRegistrationId.Text; var studentRecords = RegistrationCodesDataAccess.findStudentByRegistrationId(registration); if (studentRecords == null) { MessageBox.Show("Unable to locate student ID. Please check the registration ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { studentId = studentRecords.StudentId; } } } } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void txt_RegistrationId_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { var registration = new RegistrationIds(); registration.RegistrationId = txt_RegistrationId.Text; var record = RegistrationCodesDataAccess.findStudentByRegistrationId(registration); if (record == null) { MessageBox.Show("Registration ID not found. Please check the registration ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //// get parent contact no. var parentInfo = StudentDataAccess.findParentInfo(record.StudentId); if (parentInfo == null) { return; } else if (parentInfo.Mobile == null) { return; } else { parentContact = parentInfo.Pmobile; // assign phone number } var lecturerInfo = CourseEnrollmentDataAccess.findRegistrationDateByStudentId(record.RegistrationId, record.CourseId); if (lecturerInfo == null) { MessageBox.Show("Unable to locate lecturer details", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { txtStudentId.Text = record.StudentId; txtStudentName.Text = record.StudentName; txt_CourseId.Text = record.CourseId; txt_CourseName.Text = record.CourseName; txtLecturerID.Text = lecturerInfo.LecturerId; txtLecturerName.Text = lecturerInfo.LecturerName; Submit(); // call mark attendance } } } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void gridCourses_MouseDoubleClick(object sender, MouseEventArgs e) { // fill course, lecturer fields and find student Id try { // find course info and lecturer info txtCourseId.Text = gridCourses.SelectedRows[0].Cells[0].Value.ToString(); txtCourseName.Text = gridCourses.SelectedRows[0].Cells[1].Value.ToString(); txtLectuerId.Text = gridCourses.SelectedRows[0].Cells[2].Value.ToString(); txtLecturerName.Text = gridCourses.SelectedRows[0].Cells[3].Value.ToString(); // find course fee var course = new Course(); course.RefNo = txtCourseId.Text; var record = CoursesDataAccess.findCourseById(course); if (record == null) { MessageBox.Show("Course ID not found. Please check the Course-ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { // display course fee txtFee.Text = record.Fee.ToString(); // find student id var registration = new RegistrationIds(); registration.RegistrationId = txtRegistrationId.Text; var studentRecords = RegistrationCodesDataAccess.findStudentByRegistrationId(registration); if (studentRecords == null) { MessageBox.Show("Unable to locate student ID. Please check the registration ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { studentId = studentRecords.StudentId; } // display last paid month var lastRecord = PaymentDataAccess.getLastRecord(txtRegistrationId.Text, txtCourseId.Text); MessageBox.Show(lastRecord.ToString()); } } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtRegistrationId_KeyDown(object sender, KeyEventArgs e) { // fill student name and enrolled courses in dropdown try { if (e.KeyCode == Keys.Enter) { var registrationCode = new RegistrationIds(); registrationCode.RegistrationId = txtRegistrationId.Text; var record = RegistrationCodesDataAccess.findStudentByRegistrationId(registrationCode); if (record == null) { MessageBox.Show("Registration ID not found. Please check the ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { txtStudentName.Text = record.StudentName; // student name gridCourses.DataSource = null; //var source = CourseEnrollmentDataAccess.findCourseByStudentId(record.StudentId).Where(x => x.IsRemoved == false); var source = CourseEnrollmentDataAccess.findCourseByStudentId(record.RegistrationId).Where(x => x.IsRemoved == false); gridCourses.DataSource = source .Select(x => new { CourseId = x.CourseId, CourseName = x.CourseName, LecturerId = x.LecturerId, LecturerName = x.LecturerName }).ToList(); gridCourses.Columns["CourseId"].HeaderText = "Course ID"; gridCourses.Columns["CourseName"].HeaderText = "Course Name"; gridCourses.Columns["LecturerId"].HeaderText = "Lecturer ID"; gridCourses.Columns["LecturerName"].HeaderText = "Lecturer Name"; // setting column width gridCourses.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }