Esempio n. 1
0
        private void BtnCheckOut_Click(object sender, EventArgs e)
        {
            if (lstSelectedBooks.SelectedIndex != -1)
            {
                var selectedItems = lstSelectedBooks.SelectedItems;

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

                List <Book> selectedBooks = GetSelectedItems(
                    selectedItems);

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

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

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

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

            cboBooksAvail.Items.Clear();

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

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

            lstSelectedBooks.Items.Clear();
        }