Example #1
0
        //add new created book to database event
        private void BtnAddNewBook_Click(object sender, EventArgs e)
        {
            var book = new library_project.Models.Book();



            book.Name          = TxtNBName.Text;
            book.Count         = Convert.ToInt32(TxtNBCount.Text);
            book.PricePerMonth = Convert.ToInt32(TxtNBPrice.Text);

            _context.Books.Add(book);
            _context.SaveChanges();

            PnlNewBook.Visible = false;
            ResetBookList();
            FillBookList();
            ResetNewBookForm();
            MessageBox.Show("New Book Created Successfully!");
        }
Example #2
0
        //selection an existing book event
        private void DgvBooks_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int Id = Convert.ToInt32(DgvBooks.Rows[e.RowIndex].Cells[0].Value.ToString());

            SelectedBook = _context.Books.Find(Id);
        }