private void saveNewCustomer_Click(object sender, RoutedEventArgs e) { //CustomerManagement parentWindow = (CustomerManagement)Owner; Customer newCustomer = new Customer(); newCustomer.Id = CustomerRepository.Count() + 1; newCustomer.EntryDate = DateTime.Now; newCustomer.FirstName = firstNameBox.Text; newCustomer.LastName = lastNameBox.Text; newCustomer.TelephoneNumber = telephoneNumberBox.Text; newCustomer.Email = emailBox.Text; newCustomer.Notes = notesBox.Text; CustomerRepository.Add(newCustomer); }
// Event of selection (when grid item clicked it is selected) private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { // row (selected item) within the data grid (dataGrid) cast within // the customer class (adds functionality) SelectedLogEntry = (Customer)dataGrid.SelectedItem; }