private void InsertButton_Click(object sender, RoutedEventArgs e) { Person newPerson = new Person { FirstName = FirstNameInsText.Text, LastName = LastNameText.Text, EmailAddress = EmailAddressInsText.Text, PhoneNumber = PhoneNumberInsText.Text }; try { db.People.Add(newPerson); db.SaveChanges(); MessageBox.Show("Person save in database."); // Clear txtBox; FirstNameInsText.Clear(); LastNameInsText.Clear(); EmailAddressInsText.Clear(); PhoneNumberInsText.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void InsertButton_Click(object sender, RoutedEventArgs e) { DataAccess db = new DataAccess(); try { db.InsertPerson(FirstNameInsText.Text, LastNameInsText.Text, EmailAddressInsText.Text, PhoneNumberInsText.Text); MessageBox.Show("Person save in database."); // Clear txtBox; FirstNameInsText.Clear(); LastNameInsText.Clear(); EmailAddressInsText.Clear(); PhoneNumberInsText.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }