//UPDATE BOOK DETAILS FROM BOOK TABLE private void BtnUpdate_Click(object sender, RoutedEventArgs e) { if (tbBName.Text != string.Empty && tbBAuthor.Text != string.Empty && tbBISBN.Text != string.Empty && tbBPrice.Text != string.Empty && tbBCopy.Text != string.Empty ) { try { BookBL bookBL = new BookBL(); string isDone = bookBL.UpdateBookBL(this.bookId, tbBName.Text, tbBAuthor.Text, tbBISBN.Text, double.Parse(tbBPrice.Text), int.Parse(tbBCopy.Text)); if (isDone == "true") { MessageBox.Show("Book updated successfuly.."); this.Close(); } else { MessageBox.Show(isDone + " Try later.."); } } catch (FormatException) { MessageBox.Show("Invalid Book price or Book copy!!!,\nThey should not be a string, Try again.."); } catch (Exception) { MessageBox.Show("Some unknown exception is occured!!!, Try again.."); } } else { MessageBox.Show("Enter the fields properly!!!, Every field is required.."); } }
//REQUEST TO BORROW A BOOK FROM BORROW BOOK TABLE =>PL private void btnRequestBook_Click(object sender, EventArgs e) { if (BookId > 0) { if (BookCopy == 0) { MessageBox.Show("Book is empty..."); } else { BookCopy = BookCopy - 1; BookBL bookBL = new BookBL(); UserRequestBL userRequestBL = new UserRequestBL(); bool isDone1 = bookBL.UpdateBookBL(BookId, BookName, BookAuthor, BookISBN, BookPrice, BookCopy); bool isDone2 = userRequestBL.AddRequestBL(BookId, BookName, userId); if (isDone1 == true && isDone2 == true) { MessageBox.Show("Requested successfully.."); } else { MessageBox.Show("Try again.."); } } } else { MessageBox.Show("Select a book to request..."); } }
//REQUEST TO BORROW A BOOK FROM BORROW BOOK TABLE =>PL private void BtnRequest_Click(object sender, RoutedEventArgs e) { try { Book book = dgBorrow.SelectedItem as Book; if (book != null) { if (book.BookCopies == 0) { MessageBox.Show("Book is empty..."); } else { int BookCopy = book.BookCopies - 1; BookBL bookBL = new BookBL(); UserRequestBL userRequestBL = new UserRequestBL(); string isDone1 = bookBL.UpdateBookBL(book.BookId, book.BookName, book.BookAuthor, book.BookISBN, book.BookPrice, BookCopy); bool isDone2 = userRequestBL.AddRequestBL(book.BookId, book.BookName, userId); if (isDone1 == "true" && isDone2 == true) { MessageBox.Show("Requested successfully.."); InitializeUserBorrow(); } else { MessageBox.Show("Try again.."); } } } else { MessageBox.Show("Select a book to request..."); } } catch (Exception) { MessageBox.Show("Some unknown exception is occured!!!, Try again.."); } }
//UPDATE BOOK DETAILS FROM BOOK TABLE private void btnUpdate_Click(object sender, EventArgs e) { try { BookBL bookBL = new BookBL(); bool isDone = bookBL.UpdateBookBL(this.bookId, tbBName.Text, tbBAuthor.Text, tbBISBN.Text, double.Parse(tbBPrice.Text), int.Parse(tbBCopy.Text)); if (isDone) { MessageBox.Show("Book updated successfuly.."); } else { MessageBox.Show("Try later.."); } } catch (Exception) { MessageBox.Show("Enter the fields properly..."); } /*try * { * BookBL bookBL = new BookBL(); * bool isDone = bookBL.UpdateBookBL(this.bookId, tbBName.Text, tbBAuthor.Text, tbBISBN.Text, double.Parse(tbBPrice.Text), int.Parse(tbBCopy.Text)); * if (isDone) * { * MessageBox.Show("Book updated successfuly.."); * } * else * { * MessageBox.Show("Try later.."); * } * } * catch (Exception) * { * * MessageBox.Show("Enter the fields properly..."); * }*/ }