Example #1
0
        private void NewButton_Click(object sender, EventArgs e)
        {
            Journal     journal     = new Journal();
            JournalForm journalForm = new JournalForm(journal);

            if (journalForm.ShowDialog() == DialogResult.OK)
            {
                ListOfJournals.Items.Add(journal.ToShortString());
                _journals.Add(journal);
            }
            else
            {
                MessageBox.Show("Changes was not saved");
            }
        }
Example #2
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = ListOfJournals.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= _journals.Count)
            {
                MessageBox.Show("Choose journal");
                return;
            }
            JournalForm journalForm = new JournalForm(_journals[ListOfJournals.SelectedIndex]);

            if (journalForm.ShowDialog() == DialogResult.OK)
            {
                ListOfJournals.Items[selectedIndex] = _journals[ListOfJournals.SelectedIndex].ToShortString();
            }
            else
            {
                MessageBox.Show("Changes was not saved");
            }
        }