private void create_article_Click(object sender, EventArgs e) { Article newArticle = new Article(); ArticleInfo articleModal = new ArticleInfo(newArticle); if (articleModal.ShowDialog() == DialogResult.OK) { journalInfo.AddArticle(newArticle); journalInfo.CalculatePagesAndAuthors(); articles_list.Items.Add(newArticle.ToString()); total_pages_label.Text = journalInfo.TotalPagesNumber.ToString(); } else { MessageBox.Show("Changes was not saved"); } }
private void edit_Article_Click(object sender, EventArgs e) { int selectedIndex = articles_list.SelectedIndex; if (selectedIndex < 0 || selectedIndex >= journalInfo.Articles.Count) { MessageBox.Show("You need to choose article!"); return; } ArticleInfo articleModal = new ArticleInfo(journalInfo.Articles[selectedIndex]); if (articleModal.ShowDialog() == DialogResult.OK) { articles_list.Items[selectedIndex] = journalInfo.Articles[selectedIndex].ToString(); journalInfo.CalculatePagesAndAuthors(); total_pages_label.Text = journalInfo.TotalPagesNumber.ToString(); } else { MessageBox.Show("Changes was not saved"); } }