Exemple #1
0
        private void BtnCheckOut_Click(object sender, EventArgs e)
        {
            if (lstSelectBook.SelectedIndex != -1)
            {
                var selectedItems = lstSelectBook.SelectedItems;

                List <Book> uncheckedBooks =
                    LibraryHelper.GetAllUncheckedBooks();

                List <Book> selectedBooks = GetSelectedItems(
                    selectedItems);

                if (LibraryHelper.CheckoutBooks(selectedBooks))
                {
                    MessageBox.Show("Check-Out Successful.");

                    LoadBoxes();
                }
                else
                {
                    MessageBox.Show("Check-Out Unsuccessful.");
                }
            }
            else
            {
                MessageBox.Show("Nothing selected.");
            }
        }
Exemple #2
0
        /// <summary>
        /// Clears form and loads list boxes with data.
        /// </summary>
        private void LoadBoxes()
        {
            lstCheckedOut.Items.Clear();

            List <Book> checkedBooks =
                LibraryHelper.GetMemberBooks();

            if (checkedBooks != null)
            {
                foreach (Book b in checkedBooks)
                {
                    lstCheckedOut.Items.Add($"{b.ISBN}, " +
                                            $"{b.Title},  " +
                                            $"{b.Author},  " +
                                            $"{b.PubDate},  " +
                                            $"{b.Category}");
                }
            }

            cboBooksAvailable.Items.Clear();

            List <Book> uncheckedBooks =
                LibraryHelper.GetAllUncheckedBooks();

            if (uncheckedBooks != null)
            {
                foreach (Book b in uncheckedBooks)
                {
                    cboBooksAvailable.Items.Add($"{b.ISBN}, " +
                                                $"{b.Title},  " +
                                                $"{b.Author},  " +
                                                $"{b.PubDate},  " +
                                                $"{b.Category}");
                }
            }

            lstSelectBook.Items.Clear();
        }