private void SaveForm_Click(object sender, RoutedEventArgs e) { // input to an Customer object CustomerEntry customerEntry = new CustomerEntry(); customerEntry.Id = CustomerRepository.Count() + 1; customerEntry.FirstName = FirstNameInput.Text; customerEntry.LastName = LastNameInput.Text; customerEntry.Telephone = PhoneInput.Text; customerEntry.Email = EmailInput.Text; // integer variable to pass Party Size integer in the if condition int partySize; // validate if an int was entered into the Party Size field // if not an integer was filled in... if (!int.TryParse(PartySizeInput.Text, out partySize)) { //...then show error message... MessageBox.Show("Please enter a number for Party Size"); //...and break out of the if statement return; } // otherwise parsed int is passed into the object customerEntry.PartySize customerEntry.PartySize = partySize; // Add above entry to grid CustomerRepository.Add(customerEntry); // Close current window Close(); }
private void customerDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { currentlySelectedCustomer = (CustomerEntry)customerDataGrid.SelectedItem; }