private async void btnGiveBook_Click(object sender, EventArgs e) { _searchedFor = SearchedFor.BookIssue; var userId = txtUserId.Text; var bookId = txtBookId.Text; //var days = int.Parse((string) cboDays.SelectedItem); var dueDate = txtDueDate.Text; if (userId.IsNullOrEmpty() || bookId.IsNullOrEmpty()) { return; } try { Cursor = Cursors.WaitCursor; var bookIssue = new BookIssueEntity() { Id = Guid.Parse(bookId), UserId = Guid.Parse(userId), BookId = Guid.Parse(bookId), IssuerId = Store.CurrentUser.Id, DueDate = DateTime.Parse(dueDate) }; var createdBookIssue = await BookIssueRepository.GiveBookAsync(bookIssue); ctlDataGridView.PopulateDataGridView(createdBookIssue, true, true); LocalizeDataGridView(); btnClear.PerformClick(); } catch (Exception exception) { Debug.WriteLine(exception.Message); MessageBox.Show(Resource_Localization.ErrorUnknown); } finally { Cursor = Cursors.Default; } }
private async void btnBookSearch_Click(object sender, EventArgs e) { _searchedFor = SearchedFor.Book; var searchText = txtBookSearch.Text; _searchText = searchText; _page = 1; if (searchText.IsNullOrEmpty()) { return; } try { Cursor = Cursors.WaitCursor; var books = await BookRepository.SearchAsync(searchText, radbBookAZ.Checked, 1, ctlDataGridView.PageLimit(), false, true); if (books.Count > 0) { ctlDataGridView.EnableBtnPreviousPage(); ctlDataGridView.EnableBtnNextPage(); ctlDataGridView.PopulateDataGridView(books, true, true); } else { ctlDataGridView.ClearRows(); } LocalizeDataGridView(); } catch (Exception exception) { Debug.WriteLine(exception.Message); MessageBox.Show(Resource_Localization.ErrorUnknown); } finally { Cursor = Cursors.Default; } }