private void AddButton_Click(object sender, RoutedEventArgs e) { if(StudentListBox.SelectedItem == null) { var sID = int.TryParse(StudentIDTB.Text, out int studentID); if (sID == false) { MessageBox.Show("Invalid Entry. Please enter a valid number"); } var sFirstName = FirstNameTB.Text; var sLastName = LastNameTB.Text; var age = int.TryParse(AgeTB.Text, out int sAge); var allergies = AllergiesTB.Text; var parentName = ParentNameTB.Text; var parentContact = ParentContactNoTB.Text; var parentEmail = ParentEmailTB.Text; var classID = int.TryParse(ClassIDTB.Text, out int sClassID); _crudManager.AddStudent(studentID, sFirstName, sLastName, sAge, allergies, parentName, parentContact, parentEmail, sClassID); } PopulateStudentListBox(); StudentIDTB.Clear(); FirstNameTB.Clear(); LastNameTB.Clear(); AgeTB.Clear(); AllergiesTB.Clear(); ParentNameTB.Clear(); ParentContactNoTB.Clear(); ParentEmailTB.Clear(); ClassIDTB.Clear(); }
private void ResetBt_Click(object sender, RoutedEventArgs e) { StudentIDTB.Clear(); FirstNameTB.Clear(); LastNameTB.Clear(); AgeTB.Clear(); AllergiesTB.Clear(); ParentNameTB.Clear(); ParentContactNoTB.Clear(); ParentEmailTB.Clear(); ClassIDTB.Clear(); }
private void DeleteBt_Click(object sender, RoutedEventArgs e) { _crudManager.DeleteStudent(int.Parse(StudentIDTB.Text)); StudentIDTB.Clear(); FirstNameTB.Clear(); LastNameTB.Clear(); AgeTB.Clear(); AllergiesTB.Clear(); ParentNameTB.Clear(); ParentContactNoTB.Clear(); ParentEmailTB.Clear(); ClassIDTB.Clear(); StudentListBox.ItemsSource = null; PopulateStudentListBox(); }