public void updatePublisherList() { try { publishersList.Clear(); List <bookViewModel> books = auService.getAllBooks(); List <bookViewModel> filteredBooks = new List <bookViewModel>(); foreach (bookViewModel bks in books) { filteredBooks.Add(bks); } foreach (sales sale in _pof.transaction) { foreach (bookViewModel fbks in books) { if (sale.title_id == fbks.TitleId) { filteredBooks.Remove(fbks); } } } if (books.Count == 0) { MessageBox.Show("Connection Timed Out.\nPlease check connection string.", "Error", MessageBoxButtons.OK); return; } ListViewItem lvi = null; foreach (bookViewModel b in filteredBooks) { lvi = new ListViewItem(b.Title); lvi.Tag = b.TitleId; lvi.SubItems.Add(b.Type); lvi.SubItems.Add(b.pubId); lvi.SubItems.Add(b.pubName); lvi.SubItems.Add(b.Price); lvi.SubItems.Add(b.Date); publishersList.Items.Add(lvi); } publisherColumnHead(); } catch { return; } }
private void OrderIDList_Click(object sender, EventArgs e) { BooksOnOrderList.Clear(); try { string selectedOrderNum = OrderIDList.SelectedItems[0].Text; List <bookViewModel> allBooks = bookService.getAllBooks(); List <booksOnOrderViewModel> allBookOrders = bookService.getAllBookOrders(); List <booksOnOrderViewModel> filteredBooks = new List <booksOnOrderViewModel>(); ListViewItem lvi = null; foreach (booksOnOrderViewModel books in allBookOrders) { if (selectedOrderNum == books.OrderNum) { filteredBooks.Add(books); } } foreach (booksOnOrderViewModel orders in filteredBooks) { foreach (bookViewModel bk in allBooks) { if (orders.TitleId == bk.TitleId) { lvi = new ListViewItem(orders.TitleId); lvi.Tag = orders.OrderNum; lvi.SubItems.Add(orders.Title); lvi.SubItems.Add(orders.Quantity); BooksOnOrderList.Items.Add(lvi); PaymentTermsTextBox.Text = orders.Payterms; BooksOnOrderLabel.Text = "Books On Order #: " + orders.OrderNum; } } } if (BooksOnOrderList.Items.Count == 0) { return; } BooksOnOrderColumnHead(); } catch { return; } }