Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        // Precondition:  Report, Patron List menu item activated
        // Postcondition: The list of patrons is displayed in the reportTxt
        //                text box
        private void patronListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <LibraryPatron> patrons;    // List of patrons
            string NL = Environment.NewLine; // NewLine shortcut

            patrons = _lib.GetPatronsList();

            reportTxt.Text = $"Patron List - {patrons.Count} patrons{NL}{NL}";

            foreach (LibraryPatron p in patrons)
            {
                reportTxt.AppendText($"{p}{NL}{NL}");
            }

            // Put cursor at start of report
            reportTxt.SelectionStart = 0;
        }
Exemplo n.º 3
0
        //Precondition: patron list menu item click
        //Postcondition: display patrons information
        private void patronListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            reportRichTxtBox.Clear();

            reportRichTxtBox.Text += "Number of Patrons: " + LibraryData.GetPatronCount() + Environment.NewLine;

            foreach (LibraryPatron i in LibraryData.GetPatronsList())
            {
                reportRichTxtBox.Text += Environment.NewLine + i + Environment.NewLine;
            }
        }
Exemplo n.º 4
0
        // Precondition:  Report, Patron List menu item activated
        // Postcondition: The list of patrons is displayed in the reportTxt
        //                text box
        private void patronListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder result = new StringBuilder(); // Holds text as report being built
                                                        // StringBuilder more efficient than String
            List <LibraryPatron> patrons;               // List of patrons
            string NL = Environment.NewLine;            // NewLine shortcut

            patrons = _lib.GetPatronsList();

            result.Append($"Patron List - {patrons.Count} patrons{NL}{NL}");

            foreach (LibraryPatron p in patrons)
            {
                result.Append($"{p}{NL}{NL}");
            }

            reportTxt.Text = result.ToString();

            // Put cursor at start of report
            reportTxt.SelectionStart = 0;
        }
Exemplo n.º 5
0
        // Precondition:  Report, Patron List menu item activated
        // Postcondition: The list of patrons is displayed in the reportTxt
        //                text box
        private void patronListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder result = new StringBuilder(); // Holds text as report being built
                                                        // StringBuilder more efficient than String
            List <LibraryPatron> patrons;               // List of patrons

            patrons = lib.GetPatronsList();
            result.Append(String.Format("Patron List - {0} patrons", lib.GetPatronCount()));
            result.Append(System.Environment.NewLine); // Remember, \n doesn't always work in GUIs
            result.Append(System.Environment.NewLine);

            foreach (LibraryPatron p in patrons)
            {
                result.Append(p.ToString());
                result.Append(System.Environment.NewLine);
                result.Append(System.Environment.NewLine);
            }

            reportTxt.Text = result.ToString();

            // Put cursor at start of report
            reportTxt.SelectionStart = 0;
        }
Exemplo n.º 6
0
        // Precondition:  None
        // Postcondition: Displays list of patrons.
        private void patronListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            outputTextBox.Clear();
            string results      = "";                  // Placeholder text
            var    patronReport = new StringBuilder(); //stringbuilder that holds the count
            string NL           = Environment.NewLine; // Adds a new line

            patronReport.Append($"Patrons: {_lib.GetPatronCount()} Patrons{NL}");

            foreach (var patron in _lib.GetPatronsList())
            {
                results += $"Patron Name: {patron.PatronName} Patron ID:{patron.PatronID}{NL}";
            }
            outputTextBox.Text = patronReport + results;
        }
Exemplo n.º 7
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);
            }
        }
Exemplo 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
                    }
                }
            }
        }