Beispiel #1
0
        private void NewButton_Click(object sender, EventArgs e)
        {
            Article     article     = new Article();
            ArticleForm articleForm = new ArticleForm(article);

            if (articleForm.ShowDialog() == DialogResult.OK)
            {
                _journal.AddArticle(article);
                _journal.CalculateNumOfPagesAndAuthors();
                ListOfArticles.Items.Add(article.ToString());
            }
            else
            {
                MessageBox.Show("Changes was not saved");
            }
        }
Beispiel #2
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = ListOfArticles.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= _journal.Articles.Count)
            {
                MessageBox.Show("Choose article");
                return;
            }
            ArticleForm articleForm = new ArticleForm(_journal.Articles[selectedIndex]);

            if (articleForm.ShowDialog() == DialogResult.OK)
            {
                ListOfArticles.Items[selectedIndex] = _journal.Articles[selectedIndex].ToString();
                _journal.CalculateNumOfPagesAndAuthors();
            }
            else
            {
                MessageBox.Show("Changes was not saved");
            }
        }