Exemplo 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
            }
        }
Exemplo n.º 2
0
        //Preconditions: click report>checked out items
        //Postconditions: goes through a loop and displays all items that are checked out
        private void checkedOutItemsSubMenuItem_Click(object sender, EventArgs e)     //REPORT - LIST CHECKED OUT
        {
            outputTextBox.Text = "";

            outputTextBox.Text = "Count of checked out items: " + theLibrary.GetCheckedOutCount() + System.Environment.NewLine +
                                 System.Environment.NewLine;

            foreach (LibraryItem item in theLibrary._items)
            {
                if (item.IsCheckedOut())
                {
                    outputTextBox.Text += item + System.Environment.NewLine + System.Environment.NewLine;
                }
            }
        }
Exemplo n.º 3
0
        private void checkedOutItemsToolStripMenuItem_Click(object sender, EventArgs e)
        {                                              //precondition: none
            //postcondition: prints checked out items
            StringBuilder start = new StringBuilder(); //to use stringbuilder

            start.Append("count:" + item.GetCheckedOutCount().ToString() + Environment.NewLine);
            mainTxt.Clear();//clear textbox prior
            foreach (LibraryBook book in item._items)
            {
                if (book.IsCheckedOut())
                {
                    start.Append(book.ToString() + Environment.NewLine);
                    mainTxt.Text = start.ToString();
                }
            }//show all checked out books
        }
Exemplo n.º 4
0
        //Precondition: checkedOutItems menu item click
        //Postcondition: display checkedOutItems
        private void checkedOutItemsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            reportRichTxtBox.Clear();

            reportRichTxtBox.Text += "Number of Items Checked Out: " + LibraryData.GetCheckedOutCount() + Environment.NewLine;



            foreach (LibraryItem i in LibraryData.GetItemsList())
            {
                if (i.IsCheckedOut())                               // displays items if checked out
                {
                    reportRichTxtBox.Text += Environment.NewLine + i + Environment.NewLine;
                }
            }
        }
Exemplo n.º 5
0
        // Precondition:  None
        // Postcondition: Displays the list of items that have been checkedout from the library.
        private void checkedOutListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            outputTextBox.Clear();
            string results          = "";    //Placeholder
            var    checkedoutReport = new StringBuilder();
            string NL = Environment.NewLine; // Adds new line

            checkedoutReport.Append($"Checked Out Report :{_lib.GetCheckedOutCount()} items {NL}");

            foreach (var item in _lib._items)
            {
                if (item.IsCheckedOut())
                {
                    results += $"{item}{NL}{NL}";
                }
            }
            outputTextBox.Text = $"{checkedoutReport}" +
                                 $"{results}{NL}";
        }
Exemplo n.º 6
0
        // Precondition:  The checked out item list menu button is clicked.
        // Postcondition: Checked out item list is displayed in form
        //
        private void checkedOutItemsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckedOutItemsForm checkedoutform = new CheckedOutItemsForm(); // Checked out form is created

            //Checked out count is shown and spaced
            checkedoutform.checkedOutTextBox.Text = AppendLine("Number of Checked Out Items: " + newLibrary.GetCheckedOutCount().ToString());

            //Walking through the array to print out each item in the list that is checkedout
            foreach (LibraryItem i in newLibrary.GetItemsList())
            {
                if (i.IsCheckedOut())
                {
                    checkedoutform.checkedOutTextBox.Text += AppendLine((i.ToString()));
                }
            }
            checkedoutform.ShowDialog(); // Checked out form is displayed
        }