private void checkOutButton_Click(object sender, EventArgs e) { try { //Declare variables int isbn = 0, empID = 0, memID = 0; //Set int values isbn = SetISBN(isbnTextbox); if (isbn != 0) { empID = SetEmployeeID(employeeIDTextbox); if (empID != 0) { memID = SetMemberID(memberIDTextbox); } } //Create table adapters for data validation LibraryDataSetTableAdapters.TransactionsTableAdapter transactionsTableAdapter1; transactionsTableAdapter1 = new LibraryDataSetTableAdapters.TransactionsTableAdapter(); LibraryDataSetTableAdapters.BooksTableAdapter booksTableAdapter1; booksTableAdapter1 = new LibraryDataSetTableAdapters.BooksTableAdapter(); //If the book is checked out it will ask for a book that is not and vice versa if (booksTableAdapter1.AvailabilityISBN(isbn) == true) { MessageBox.Show("Please bring your book back within three weeks." + "\n" + "Thank You."); transactionsTableAdapter1.InsertQuery(isbn, empID, memID); booksTableAdapter1.UpdateQueryCheckOut(isbn, isbn); } else { MessageBox.Show("Please enter a valid checked in ISBN."); } } //Catches incorrectly formated input catch (FormatException) { MessageBox.Show("A format exception has occured.", "Entry error."); } //Catches overflow values catch (OverflowException) { MessageBox.Show("An overflow exception has occured.", "Entry error."); } //Catches all other exceptions catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.GetType().ToString() + "\n" + ex.StackTrace, "Exception"); } }
/* * FOCUS LEAVE EVENTS */ //Checks if the ISBN exists after the user leaves the ISBN textbox private void isbnTextbox_Leave(object sender, EventArgs e) { //Declare variables int isbn = 0; isbn = SetISBN(isbnTextbox); //Create table adapters needed to verify if ISBN exists LibraryDataSetTableAdapters.BooksTableAdapter booksTableAdapter1; booksTableAdapter1 = new LibraryDataSetTableAdapters.BooksTableAdapter(); //Determines if the ISBN exists if (isbn != 0) { if (booksTableAdapter1.ExistingISBN(isbn) == isbn) { } else { MessageBox.Show("Please enter an existing ISBN."); isbnTextbox.Focus(); } } }