private void btnBooking_Click(object sender, EventArgs e) { int BookID = 0; int qty = 0; List <Book> books = DBConnection.findBook(txtISBN.Text); foreach (var item in books) { BookID = item.BookID; qty = item.Qty; } if (qty >= Convert.ToInt32(numQty.Value)) { DBConnection.bookingBook(customer.CustomerID, BookID, Convert.ToInt32(numQty.Value), dateOfOreder.Value); DBConnection.updateBookQty(Convert.ToInt32(numQty.Value), BookID); MessageBox.Show("Book is booked"); } else { MessageBox.Show("The Book's quantity is not enough"); } }