private void DeleteDeclaration() { if (!String.IsNullOrWhiteSpace(declarationIDTextBox.Text)) { Student_Major selectedDeclaration = declarationListBox.SelectedItem as Student_Major; RegistrationDatabase.Student_Major.Remove(selectedDeclaration); try { RegistrationDatabase.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } BindDeclarationList(); } }
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 DeclarationListBox_SelectedIndexChanged(object sender, EventArgs e) { Student_Major selectedDeclaration = declarationListBox.SelectedItem as Student_Major; declarationIDTextBox.Text = selectedDeclaration.Id.ToString(); }