private void txtCourseId_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { var course = new Course(); course.RefNo = txtCourseId.Text; var record = CoursesDataAccess.findCourseById(course); if (record == null) { MessageBox.Show("Unable to locate course. Please check course-ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { txtCourseName.Text = record.Title; } } } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void DisplayCourses() { try { var source = CoursesDataAccess.getCourses() .Select(x => new { CourseId = x.RefNo, Title = x.Title, IsRemoved = x.IsRemoved }).Where(y => y.IsRemoved == false).ToList(); gridCourse.DataSource = null; gridCourse.DataSource = source; gridCourse.Columns["CourseId"].HeaderText = "Course ID"; gridCourse.Columns["Title"].HeaderText = "Course Name"; gridCourse.Columns["IsRemoved"].HeaderText = "Course Removed"; // set column widith gridCourse.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public CourseSettingsPage(Course course, CoursesDataAccess courses) { InitializeComponent(); this.course = course; this.courses = courses; NotificationSwitch.IsToggled = course.ShowNotifications; }
private void btnDelete_Click(object sender, EventArgs e) { // delete course data if (txtTitle.Text != "") { if (MessageBox.Show("Do you want to delete thid record ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { var course = new Course(); course.RefNo = CourseID; course.IsRemoved = true; CoursesDataAccess.deleteCourse(course); MessageBox.Show("Record has been deleted successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); gridRefresh(); // call grid refresh method clearFields(); // call clear field method } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { return; } } else { MessageBox.Show("Please select a course", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnAdd_Click(object sender, EventArgs e) { // add new course try { var course = new Course(); course.Title = txtTitle.Text; course.Fee = Convert.ToDecimal(txtFee.Text); var id = txtTitle.Text.Trim().Substring(0, 3); var miliseconds = DateTime.Now.Millisecond.ToString(); id = miliseconds + id; course.RefNo = id; // course id var result = CoursesDataAccess.addCourses(course); if (result == true) { MessageBox.Show("Record has been added successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); gridRefresh(); // call grid refresh method clearFields(); // call clear field method } else { MessageBox.Show("Unable to add record", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEdit_Click_1(object sender, EventArgs e) { // edit course data if (MessageBox.Show("Do you want to edit thid record ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { var course = new Course(); course.RefNo = CourseID; course.Title = txtTitle.Text; course.Fee = Convert.ToDecimal(txtFee.Text); CoursesDataAccess.editCourse(course); MessageBox.Show("Record has been updated successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); gridRefresh(); // call grid refresh method clearFields(); // call clear field method } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { return; } }
private void txtFind_TextChanged_1(object sender, EventArgs e) { try { gridCourses.DataSource = null; var source = CoursesDataAccess.filterCourses(txtFind.Text); gridCourses.DataSource = source .Select(x => new { RefNo = x.RefNo, Title = x.Title, Fee = x.Fee, isRemoved = x.IsRemoved }).ToList(); gridCourses.Columns["RefNo"].HeaderText = "Course ID"; gridCourses.Columns["Title"].HeaderText = "Course Name"; gridCourses.Columns["Fee"].HeaderText = "Course Fee (Rs.)"; gridCourses.Columns["isRemoved"].HeaderText = "Inactive"; } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); } } }
public CourseDetailPage(Course course, CoursesDataAccess courses) { InitializeComponent(); BindingContext = course; this.course = course; this.courses = courses; CourseNotesEditor.Text = course.Notes; course.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(CourseUpdated); UpdateStatus(); }
public CourseMasterPage(Course course, CoursesDataAccess courses) { InitializeComponent(); BindingContext = course; this.course = course; this.courses = courses; this.Children.Add(new CourseDetailPage(course, courses)); this.Children.Add(new CourseAssessmentsPage(course, courses)); this.Children.Add(new CourseSettingsPage(course, courses)); }
public CourseAssessmentsPage(Course course, CoursesDataAccess courses) { InitializeComponent(); this.course = course; this.courses = courses; assessments.Assessments.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(CollectionChangedMethod); this.PopulateAssessmentList(); AssessmentListView.ItemsSource = assessmentsForCourse; }
public EditCourseModal(Course course, CoursesDataAccess courses) { InitializeComponent(); this.course = course; this.courses = courses; CourseNameEntry.Text = course.Name; StartDatePicker.Date = course.StartDate; EndDatePicker.Date = course.EndDate; InstructorNameEntry.Text = course.InstructorName; InstructorEmailEntry.Text = course.InstructorEmail; InstructorPhoneEntry.Text = course.InstructorPhone; }
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 txtCourseId_KeyDown(object sender, KeyEventArgs e) { // find course name try { if (e.KeyCode == Keys.Enter) { var course = new Course(); course.RefNo = txtCourseId.Text; var record = CoursesDataAccess.findCourseById(course); if (record.RefNo == null) { MessageBox.Show("Course-ID not found", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (record.IsRemoved == true) { // Detect inactive student id MessageBox.Show("Inactive Course-ID found", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { // fill course name textfield txtCourseName.Text = record.Title; gridLecturer.DataSource = null; var source = LecturerCoursesDataAccess.findLectuerersByCourseId(txtCourseId.Text); gridLecturer.DataSource = source.Select(x => new { LecturerId = x.LecturerId, LecturerName = x.LecturerName }).ToList(); gridLecturer.Columns["LecturerId"].HeaderText = "Lecturer ID"; gridLecturer.Columns["LecturerName"].HeaderText = "Lecturer Name"; // setting data grid column width gridLecturer.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void gridRefresh() { // refresh grid try { // grid all courses gridCourses.DataSource = null; gridCourses.DataSource = CoursesDataAccess.getCourses() .Select(x => new { RefNo = x.RefNo, Title = x.Title, Fee = x.Fee, isRemoved = x.IsRemoved }).ToList(); gridCourses.Columns["RefNo"].HeaderText = "Course ID"; gridCourses.Columns["Title"].HeaderText = "Course Name"; gridCourses.Columns["Fee"].HeaderText = "Course Fee (Rs.)"; gridCourses.Columns["isRemoved"].HeaderText = "Inactive"; // grid course gridCourses.DataSource = null; gridCourses.DataSource = CoursesDataAccess.getCourses() .Select(x => new { RefNo = x.RefNo, Title = x.Title, Fee = x.Fee, isRemoved = x.IsRemoved }).ToList(); gridCourses.Columns["RefNo"].HeaderText = "Course ID"; gridCourses.Columns["Title"].HeaderText = "Course Name"; gridCourses.Columns["Fee"].HeaderText = "Course Fee (Rs.)"; gridCourses.Columns["isRemoved"].HeaderText = "Inactive"; } catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }