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 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!"); } }