private void AddBtn_Click(object sender, RoutedEventArgs e) { if (zipCode.BorderBrush == Brushes.Red || birthDate.BorderBrush == Brushes.Red || zipCode.Text == "" || birthDate.Text == "") { MessageBox.Show("Not all text boxes contain valid information.\n" + "Please revise contact information and try again!"); } else { if (contactToEdit != null) { ContactsInformation.RemoveContact(contactToEdit); } Person contact = new Person(); contact.FirstName = firstName.Text; contact.LastName = lastName.Text; contact.BirthDate = DateTime.Parse(birthDate.Text); contact.PhoneNumber = phone.Text; contact.Address.Street = street.Text; contact.Address.HouseNumber = houseNum.Text; contact.Address.ZipCode = int.Parse(zipCode.Text); contact.Address.City = city.Text; contact.Address.Country = country.Text; ContactsInformation.AddContact(contact); mainWindow.UpdateContactsList(); InitializeBoxes(); } }
private void ContactsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { personInfo.Document.Blocks.Clear(); if (contacts.SelectedItem != null) { personInfo.AppendText(ContactsInformation.GetContactInfo(contacts.SelectedItem.ToString())); } }
private void AddOrEditBtn_Click(object sender, RoutedEventArgs e) { if (sender == add) { AddContactWindow contactWindow = new AddContactWindow(this); contactWindow.Show(); add.IsEnabled = false; edit.IsEnabled = false; } else if (sender == edit) { if (contacts.SelectedItem != null) { AddContactWindow contactWindow = new AddContactWindow(this, ContactsInformation.GetContact(contacts.SelectedItem.ToString())); contactWindow.Show(); add.IsEnabled = false; edit.IsEnabled = false; } } }
private void RemoveBtn_Click(object sender, RoutedEventArgs e) { ContactsInformation.RemoveContact(contacts.SelectedItem.ToString()); UpdateContactsList(); }