private void btnReturn_Click(object sender, EventArgs e) { string bookId = dvgBorrowing.CurrentRow.Cells[0].Value.ToString(); BookForUserData dao = new BookForUserData(); bool result = dao.returnBook(this.username, bookId); if (result) { MessageBox.Show("Return Succesful!"); dtAvailable = dao.GetAllBook(); dvgAvailableBook.DataSource = null; dvgAvailableBook.DataSource = dtAvailable; listBorrowBook = dao.GetBorrowBook(this.username); dvgBorrowing.DataSource = null; dvgBorrowing.DataSource = listBorrowBook; } else { MessageBox.Show("Fail!"); } }
private void btnReturnAll_Click(object sender, EventArgs e) { bool result = false; BookForUserData dao = new BookForUserData(); foreach (tempBook book in listBorrowBook) { result = dao.returnBook(this.username, book.bookID); } if (result) { MessageBox.Show("Return All Success!"); dvgAvailableBook.DataSource = null; dvgAvailableBook.DataSource = dtAvailable; listBorrowBook = dao.GetBorrowBook(this.username); dvgBorrowing.DataSource = null; dvgBorrowing.DataSource = listBorrowBook; } else { MessageBox.Show("Fail!"); } }