private void AddBtn_Click(object sender, RoutedEventArgs e) { AddPrompt addPrompt = new AddPrompt(); addPrompt.IDBox.Text = customers.GetCount().ToString(); addPrompt.ShowDialog(); if (addPrompt.FirstNameBox.Text == "" || addPrompt.LastNameBox.Text == "" || addPrompt.IDBox.Text == "" || addPrompt.AddressBox.Text == "") { return; } customers.AddCustomer(new Customer(addPrompt.FirstNameBox.Text, addPrompt.LastNameBox.Text, int.Parse(addPrompt.IDBox.Text), addPrompt.AddressBox.Text)); this.SaveCustomers(); UpdateDisplay(); //This function opens a new window to add a new customer to the listbox source }
private void EditBtn_Click(object sender, RoutedEventArgs e) { if (CustomersDisplay.SelectedIndex < 0) { return; } Customer selected = customers.GetCustomerAtIndex(CustomersDisplay.SelectedIndex); customers.RemoveCustomerAtIndex(CustomersDisplay.SelectedIndex); AddPrompt addPrompt = new AddPrompt(selected.FirstName, selected.LastName, selected.Id, selected.Address); addPrompt.ShowDialog(); customers.AddCustomer(new Customer(addPrompt.FirstNameBox.Text, addPrompt.LastNameBox.Text, int.Parse(addPrompt.IDBox.Text), addPrompt.AddressBox.Text)); this.SaveCustomers(); UpdateDisplay(); //this function will open the add window with the variables from the selected listbox member //It will probably have to delete the old member and just make a copy of it }