Esempio n. 1
0
        // Precondition:  Item, Check Out menu item activated
        // Postcondition: The Checkout dialog box is displayed. If data entered
        //                are OK, an item is checked out from the library by a patron
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <LibraryItem>   items;   // List of library items
            List <LibraryPatron> patrons; // List of patrons

            items   = _lib.GetItemsList();
            patrons = _lib.GetPatronsList();

            if (((items.Count - _lib.GetCheckedOutCount()) == 0) || (patrons.Count() == 0)) // Must have items and patrons
            {
                MessageBox.Show("Must have items and patrons to check out!", "Check Out Error");
            }
            else
            {
                CheckoutForm checkoutForm = new CheckoutForm(items, patrons); // The check out dialog box form

                DialogResult result = checkoutForm.ShowDialog();              // Show form as dialog and store result

                if (result == DialogResult.OK)                                // Only add if OK
                {
                    _lib.CheckOut(checkoutForm.ItemIndex, checkoutForm.PatronIndex);
                }

                checkoutForm.Dispose(); // Good .NET practice - will get garbage collected anyway
            }
        }
Esempio n. 2
0
        //Preconditions: click Item>Check Out
        //Postconditions: pops up dialog box to enter information. then changes book status to checked out
        private void checkOutSubMenuItem_Click(object sender, EventArgs e)
        {
            CheckOutDialogBox checkOutDBox = new CheckOutDialogBox(theLibrary._items, theLibrary._patrons);

            checkOutDBox.ShowDialog();

            theLibrary.CheckOut(checkOutDBox.ItemCheckedOut, checkOutDBox.PatronCheckedOut);
        }
Esempio n. 3
0
        // Precondition:  Item, Check Out menu item activated
        // Postcondition: The Checkout dialog box is displayed. If data entered
        //                are OK, an item is checked out from the library by a patron
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Extra Credit - Only display items that aren't already checked out

            List <LibraryItem>   notCheckedOutList;    // List of items not checked out
            List <int>           notCheckedOutIndices; // List of index values of items not checked out
            List <LibraryItem>   items;                // List of library items
            List <LibraryPatron> patrons;              // List of patrons

            items   = lib.GetItemsList();
            patrons = lib.GetPatronsList();

            items                = lib.GetItemsList();
            patrons              = lib.GetPatronsList();
            notCheckedOutList    = new List <LibraryItem>();
            notCheckedOutIndices = new List <int>();

            for (int i = 0; i < items.Count(); ++i)
            {
                if (!items[i].IsCheckedOut()) // Not checked out
                {
                    notCheckedOutList.Add(items[i]);
                    notCheckedOutIndices.Add(i);
                }
            }

            if ((notCheckedOutList.Count() == 0) || (patrons.Count() == 0)) // Must have items and patrons
            {
                MessageBox.Show("Must have items and patrons to check out!", "Check Out Error");
            }
            else
            {
                CheckoutForm checkoutForm = new CheckoutForm(notCheckedOutList, patrons); // The check out dialog box form

                DialogResult result = checkoutForm.ShowDialog();                          // Show form as dialog and store result

                if (result == DialogResult.OK)                                            // Only add if OK
                {
                    try
                    {
                        int itemIndex;                                            // Index of item from full list of items

                        itemIndex = notCheckedOutIndices[checkoutForm.ItemIndex]; // Look up index from full list
                        lib.CheckOut(itemIndex, checkoutForm.PatronIndex);
                    }
                    catch (ArgumentOutOfRangeException) // This should never happen
                    {
                        MessageBox.Show("Problem with Check Out Index!", "Check Out Error");
                    }
                }

                checkoutForm.Dispose(); // Good .NET practice - will get garbage collected anyway
            }
        }
Esempio n. 4
0
        //Precondition: checkout menu item click
        //Postcondition: show checkout form and pass data to checkout form
        private void checkoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckOutForm checkOutDialog = new CheckOutForm(LibraryData.GetItemsList(), LibraryData.GetPatronsList());
            DialogResult result;

            result = checkOutDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                LibraryData.CheckOut(checkOutDialog.items, checkOutDialog.patrons);
            }
        }
Esempio n. 5
0
        //Precondition: Item -> Checkout item is activated
        //Postcondition: item is checked out
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <LibraryItem>   items;   //List of library items
            List <LibraryPatron> patrons; //List of library patrons

            items   = library.GetItemsList();
            patrons = library.GetPatronsList();

            CheckOutForm checkoutForm = new CheckOutForm(items, patrons); //Check out dialog box form
            DialogResult result       = checkoutForm.ShowDialog();        //Show form as dialog & store the result

            if (result == DialogResult.OK)
            {
                library.CheckOut(checkoutForm.ItemIndex, checkoutForm.PatronIndex);
            }
        }
Esempio n. 6
0
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //sends the items, and patrons list to the checkout subform
            CheckoutForm checkoutForm = new CheckoutForm(newLibrary._items, newLibrary._patrons);
            DialogResult result; //holds the dialog result
            int          item;   //holds the item index
            int          patron; //holds the patron index


            result = checkoutForm.ShowDialog();

            if (result == DialogResult.OK)// Only update if user chose OK from dialog box
            {
                item   = checkoutForm.ITEM;
                patron = checkoutForm.PATRON;
                newLibrary.CheckOut(item, patron);
            }
        }
Esempio n. 7
0
        // Precondition:  None
        // Postcondition: Checkouts the items and updates the mainform.
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //sends the items, and patrons list to the checkout subform
            CheckOutForm checkoutForm = new CheckOutForm(_lib._items, _lib._patrons);
            DialogResult result;          //holds the dialog result
            int          itemIndx;        //holds the item index
            int          patron;          //holds the patron index


            result = checkoutForm.ShowDialog();

            if (result == DialogResult.OK)        //  updates when checkout is selected from dialog box
            {
                itemIndx = checkoutForm.ItemIndex;
                patron   = checkoutForm.PatronIndex;
                _lib.CheckOut(itemIndx, patron);
                MessageBox.Show("You just checked out a library item!");
            }
        }
Esempio n. 8
0
        // Precondition:  The checked out item list menu button is clicked.
        // Postcondition: Checked out item list is displayed in form
        //
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <LibraryItem> notcheckedoutitems = new List <LibraryItem>(); //creating an array of items not checked out
            DialogResult       result;                                        //the result of the dialog box

            // Each library item is added to the array of items not checked out
            foreach (LibraryItem i in newLibrary._items)
            {
                if (!i.IsCheckedOut())
                {
                    notcheckedoutitems.Add(i);
                }
            }

            //creating the checkout form (dialog)
            CheckOut checkout = new CheckOut(notcheckedoutitems, newLibrary.GetPatronsList());

            // Checkout form is shown
            result = checkout.ShowDialog();

            if (result == DialogResult.OK)
            {
                //This is the actual item selected by the user to return
                var selecteditem = notcheckedoutitems.ElementAt(checkout.ItemSelected);

                // Walking through the array looking for the item to return
                // When found, the item is returned.
                foreach (LibraryItem i in newLibrary.GetItemsList())
                {
                    if (i == selecteditem)
                    {
                        int positionOfItem = newLibrary.GetItemsList().IndexOf(i);    //position of the selected item

                        newLibrary.CheckOut(positionOfItem, checkout.PatronSelected); //returning the item
                    }
                }
            }
        }
        //Precondition: none
        //Postcondition: This will check out any books and output the information onto the Checked Out Report.
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckOut     inputForm = new CheckOut(_lib._items, _lib._patrons);
            DialogResult result    = inputForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                int    patronIndex = inputForm.PatronIndex;
                string callNo      = inputForm.CallNumber;
                int    itemindex   = -1;
                for (int x = 0; x < _lib._items.Count; ++x) // this for loop is used to make sure the user can't check out a book that is checked out by another patron.
                {
                    if (_lib._items[x].CallNumber == callNo)
                    {
                        itemindex = x;
                    }
                }
                if (itemindex > -1)
                {
                    _lib.CheckOut(itemindex, patronIndex);
                }
            }
        }
Esempio n. 10
0
        // Precondition: None
        // Postcondition: Opens a dialog box that will check out an item in the library
        private void checkoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckoutForm Checkout = new CheckoutForm(); // Variable that interacts with the checkout form

            foreach (var item in _lib.GetItemsList())
            {
                Checkout.itemCombobox.Items.Add($"{item.Title},{item.CallNumber}");
            }

            foreach (var patron in _lib.GetPatronsList())
            {
                Checkout.patronCombobox.Items.Add($"{patron.PatronName},{patron.PatronID}");
            }
            result = Checkout.ShowDialog();
            int itemindex;
            int patronindex;

            if (result == DialogResult.OK)
            {
                itemindex   = Checkout.itemCombobox.SelectedIndex;
                patronindex = Checkout.patronCombobox.SelectedIndex;
                _lib.CheckOut(itemindex, patronindex);
            }
        }