private void AddStudent() { if (!String.IsNullOrEmpty(nameTextBox.Text)) { Student newStudent = new Student { Id = Convert.ToInt32(idTextBox.Text), Name = nameTextBox.Text, }; RegistrationDatabase.Students.Add(newStudent); try { RegistrationDatabase.SaveChanges(); } catch (DbUpdateException ex) { MessageBox.Show(ex.Message); } BindStudentList(); } }
private void AddSection() { if (!String.IsNullOrEmpty(facultyIDTextBox.Text) && !String.IsNullOrEmpty(numberTextBox.Text) && !String.IsNullOrEmpty(courseIDTextBox.Text)) { Section newSection = new Section { Number = Convert.ToInt32(numberTextBox.Text), Course_Id = Convert.ToInt32(courseIDTextBox.Text), Faculty_Id = Convert.ToInt32(facultyIDTextBox.Text), Monday = daysBox.GetItemChecked(0), Tuesday = daysBox.GetItemChecked(1), Wednesday = daysBox.GetItemChecked(2), Thursday = daysBox.GetItemChecked(3), Friday = daysBox.GetItemChecked(4), Time = timeTextBox.Text, Semester = semesterTextBox.Text }; RegistrationDatabase.Sections.Add(newSection); try { RegistrationDatabase.SaveChanges(); } catch (DbUpdateException ex) { MessageBox.Show(ex.Message); } BindSectionList(); } }
private void AddGrade() { if (!String.IsNullOrEmpty(sectionIDTextBox.Text)) { Grade newGrade = new Grade { Section_Id = Convert.ToInt32(sectionIDTextBox.Text), A_Grade = Convert.ToInt32(ATextBox.Text), Aminus_Grade = Convert.ToInt32(AMinusTextBox.Text), Bplus_Grade = Convert.ToInt32(BPlusTextBox.Text), B_Grade = Convert.ToInt32(BTextBox.Text), Bminus_Grade = Convert.ToInt32(BMinusTextBox.Text), Cplus_Grade = Convert.ToInt32(CPlusTextBox.Text), C_Grade = Convert.ToInt32(CTextBox.Text), Cminus_Grade = Convert.ToInt32(CMinusTextBox.Text), F_Grade = Convert.ToInt32(FTextBox.Text) }; RegistrationDatabase.Grades.Add(newGrade); try { RegistrationDatabase.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } BindGradeList(Convert.ToInt32(sectionIDTextBox.Text)); } }
private void DeleteCourse() { if (!String.IsNullOrEmpty(courseIdTextBox.Text)) { Course selectedcourse = CourseListBox.SelectedItem as Course; RegistrationDatabase.Courses.Remove(selectedcourse); try { RegistrationDatabase.SaveChanges(); } catch (DbUpdateException ex) { MessageBox.Show(ex.ToString()); } BindCourseList(); } }
private void AddMajor() { if (!String.IsNullOrEmpty(majorNameTextBox.Text)) { Major newMajor = new Major { Name = majorNameTextBox.Text }; RegistrationDatabase.Majors.Add(newMajor); try { RegistrationDatabase.SaveChanges(); } catch (DbUpdateException ex) { MessageBox.Show(ex.Message); } BindMajorList(); } }
private void AddDeclaration() { if (!String.IsNullOrWhiteSpace(majorIDTextBox.Text) && !String.IsNullOrWhiteSpace(studentIDTextBox.Text)) { Student_Major newDeclaration = new Student_Major { Major_Id = Convert.ToInt32(majorIDTextBox.Text), Student_Id = Convert.ToInt32(studentIDTextBox.Text) }; RegistrationDatabase.Student_Major.Add(newDeclaration); try { RegistrationDatabase.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } BindDeclarationList(); } }
private void AddEnrollment() { if (!String.IsNullOrEmpty(sectionIDTextBox.Text) && !String.IsNullOrEmpty(studentIDTextBox.Text)) { Enrollment newEnrollment = new Enrollment { Section_Id = Convert.ToInt32(sectionIDTextBox.Text), Student_Id = Convert.ToInt32(studentIDTextBox.Text) }; RegistrationDatabase.Enrollments.Add(newEnrollment); try { RegistrationDatabase.SaveChanges(); } catch (DbUpdateException ex) { MessageBox.Show(ex.Message); } BindEnrollmentsList(); } }
private void AddFaculty() { if (!String.IsNullOrEmpty(facultyNameTextBox.Text) && !String.IsNullOrEmpty(facultyPhoneTextBox.Text) && !String.IsNullOrEmpty(facultyOfficeTextBox.Text)) { Faculty newFaculty = new Faculty { Name = facultyNameTextBox.Text, Phone = facultyPhoneTextBox.Text, Office = facultyOfficeTextBox.Text }; RegistrationDatabase.Faculties.Add(newFaculty); try { RegistrationDatabase.SaveChanges(); } catch (DbUpdateException ex) { MessageBox.Show(ex.Message); } BindFacultyList(); } }