private void fBooks_Load(object sender, EventArgs e) { BooksSettings.GetSettings(); lblLeftBooks.Text = "You have " + Convert.ToString(BooksSettings.BooksLeftPerYear) + " books left to read this year"; lblLeftBooks.Show(); OpenBooks(); }
private void btnSaveNewAmountOfBooksPerYear_Click(object sender, EventArgs e) { BooksSettings.BooksLeftPerYear += Convert.ToInt32(tbBooksPerYear.Text) - BooksSettings.BooksPerYear; BooksSettings.BooksPerYear = Convert.ToInt32(tbBooksPerYear.Text); BooksSettings.SaveSettings(); this.Close(); }
private void btnAddBook_Click(object sender, EventArgs e) { string s; s = "• " + tbNewBook.Text.ToString(); lbBooks.Items.Add(s); StreamWriter file = File.AppendText("Books.rtf"); file.WriteLine(s); file.Close(); tbNewBook.Clear(); BooksSettings.BooksLeftPerYear--; BooksSettings.SaveSettings(); lblLeftBooks.Text = "You have " + Convert.ToString(BooksSettings.BooksLeftPerYear) + " books left to read this year"; lblLeftBooks.Show(); }
private void btnDeleteBook_Click(object sender, EventArgs e) { if (lbBooks.SelectedItem != null) { lbBooks.Items.Remove(lbBooks.SelectedItem); BooksSettings.BooksLeftPerYear++; string s; File.WriteAllText("Books.rtf", ""); StreamWriter file = File.AppendText("Books.rtf"); for (int i = 0; i < lbBooks.Items.Count; i++) { s = Convert.ToString(lbBooks.Items[i]); file.WriteLine(s); } file.Close(); BooksSettings.SaveSettings(); lblLeftBooks.Text = "You have " + Convert.ToString(BooksSettings.BooksLeftPerYear) + " books left to read this year"; lblLeftBooks.Show(); } }