private void btnSearchAuthor_Click(object sender, EventArgs e) { if (txtSearchAuthor == null) { return; } else { BookForUserData dao = new BookForUserData(); dtAvailable = dao.searchByAuthor(txtSearchAuthor.Text); dvgAvailableBook.DataSource = null; dvgAvailableBook.DataSource = dtAvailable; } }
private void btnSearchLikeName_Click(object sender, EventArgs e) { BookForUserData dao = new BookForUserData(); if (txtSearchLikeName == null) { return; } else { dtAvailable = dao.searchByLikeName(txtSearchLikeName.Text); dvgAvailableBook.DataSource = null; dvgAvailableBook.DataSource = dtAvailable; } }
public void loadData() { lbUser.Text = this.fullname; BookForUserData dao = new BookForUserData(); dtAvailable = dao.GetAllBook(); dvgAvailableBook.DataSource = null; dvgAvailableBook.DataSource = dtAvailable; listBorrowBook = dao.GetBorrowBook(this.username); dvgBorrowing.DataSource = null; dvgBorrowing.DataSource = listBorrowBook; txtId.DataBindings.Clear(); txtName.DataBindings.Clear(); txtPrice.DataBindings.Clear(); txtId.DataBindings.Add("Text", dtAvailable, "BookID"); txtName.DataBindings.Add("Text", dtAvailable, "name"); txtPrice.DataBindings.Add("Text", dtAvailable, "price"); }
private void btnBorrow_Click(object sender, EventArgs e) { List <tempBook> list = this.getTempBook; BookForUserData dao = new BookForUserData(); foreach (tempBook item in list) { bool result = dao.isBorrowBook(item.bookID, this.username); } listBorrowBook = dao.GetBorrowBook(this.username); dvgBorrowing.DataSource = null; dvgBorrowing.DataSource = listBorrowBook; selectedBook = new List <tempBook>(); dvgSelected.DataSource = null; dvgSelected.DataSource = selectedBook; dvgAvailableBook.DataSource = null; dvgAvailableBook.DataSource = dtAvailable; }
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!"); } }