//Opens the email window and fills it with the data for the selected customer so they can be emailed. private void Email_Click(object sender, RoutedEventArgs e) { if (CustomerList.SelectedItem != null) { //Fetch that row and store it as a CustomerViewmodel so it is easy to manipulate the data. CustomerViewmodel SelectedCustomer = (CustomerViewmodel)CustomerList.SelectedItem; EditFirstnameField.Text = SelectedCustomer.Firstname; EditLastnameField.Text = SelectedCustomer.Lastname; EditEmailField.Text = SelectedCustomer.Email; EmailWindow emailWindow = new EmailWindow(); emailWindow.Show(); EmailWindow.SetContent(SelectedCustomer.Email, SelectedCustomer.Firstname, SelectedCustomer.Lastname); } else { MessageBox.Show("No item selected.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Warning); } }
//Loads the details of the selected customer into the edit box so they can be edited by the user. private void Manage_Click(object sender, RoutedEventArgs e) { if (CustomerList.SelectedItem != null) { //Fetch that row and store it as a PriceItem so it is easy to manipulate the data. CustomerViewmodel SelectedCustomer = (CustomerViewmodel)CustomerList.SelectedItem; EditID.Text = "" + SelectedCustomer.ID + ""; EditFirstnameField.Text = SelectedCustomer.Firstname; EditLastnameField.Text = SelectedCustomer.Lastname; EditEmailField.Text = SelectedCustomer.Email; EditAddressOneField.Text = SelectedCustomer.AddressOne; EditAddressTwoField.Text = SelectedCustomer.AddressTwo; EditCityField.Text = SelectedCustomer.City; EditCountyField.Text = SelectedCustomer.County; EditPostcodeField.Text = SelectedCustomer.Postcode; EditCountryField.Text = SelectedCustomer.Country; EditMobileField.Text = SelectedCustomer.Mobile; } else { MessageBox.Show("No item selected.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Warning); } }