private void NewButton_Click(object sender, EventArgs e) { Performer newPerformer = new Performer(); PerformerForm performerForm = new PerformerForm(newPerformer); if (performerForm.ShowDialog() == DialogResult.OK) { ListOfPerformers.Items.Add(newPerformer.ToString()); _performers.Add(newPerformer); Performer.WritePerformersToFile("performers", _performers); } else { MessageBox.Show("Changes was not saved"); } }
private void EditButton_Click(object sender, EventArgs e) { int selectedIndex = ListOfPerformers.SelectedIndex; if (selectedIndex < 0 || selectedIndex >= _performers.Count) { MessageBox.Show("Choose performer"); return; } PerformerForm performerModal = new PerformerForm(_performers[selectedIndex]); if (performerModal.ShowDialog() == DialogResult.OK) { ListOfPerformers.Items[selectedIndex] = _performers[selectedIndex].ToString(); Performer.WritePerformersToFile("performers", _performers); } else { MessageBox.Show("Changes was not saved"); } }