private void create_button_Click(object sender, EventArgs e) { Journal newJournal = new Journal(); JournalInfo journalModal = new JournalInfo(newJournal); if (journalModal.ShowDialog() == DialogResult.OK) { journals_List.Items.Add(newJournal.ToShortString()); journals.Add(newJournal); } else { MessageBox.Show("Changes was not saved"); } }
private void edit_button_Click(object sender, EventArgs e) { int selectedIndex = journals_List.SelectedIndex; if (selectedIndex < 0 || selectedIndex >= journals.Count) { MessageBox.Show("You need to choose journal!"); return; } JournalInfo journalModal = new JournalInfo(journals[journals_List.SelectedIndex]); if (journalModal.ShowDialog() == DialogResult.OK) { journals_List.Items[selectedIndex] = journals[journals_List.SelectedIndex].ToShortString(); } else { MessageBox.Show("Changes was not saved"); } }