Beispiel #1
0
 /// <summary>
 /// Редактировать книгу
 /// </summary>
 private void Button2_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         Book book = (Book)dataGridView1.SelectedRows[0].DataBoundItem;
         using (BookForm dlg = new BookForm(book)) {
             if (dlg.ShowDialog() == DialogResult.OK)
             {
                 SaveBooks();
                 Books.ResetBindings();
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Добавить книгу
        /// </summary>
        private void Button1_Click(object sender, EventArgs e)
        {
            Book book = new Book()
            {
                Year  = DateTime.Today.Year,
                Pages = 100
            };

            using (BookForm dlg = new BookForm(book)) {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Books.Add(book);
                    SaveBooks();
                }
            }
        }