Пример #1
0
        //Precondition: item list menu item click
        //Postcondition: display items list
        private void itemListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            reportRichTxtBox.Clear();

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

            foreach (LibraryBook i in LibraryData.GetItemsList())
            {
                reportRichTxtBox.Text += Environment.NewLine + i + Environment.NewLine;
            }
        }
Пример #2
0
        // Precondition:  None
        // Postcondition: Returns items using return form
        private void returnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReturnForm   retrnForm = new ReturnForm(_lib.GetItemsList());
            DialogResult result;

            result = retrnForm.ShowDialog();

            if (result == DialogResult.OK) // Checks out item based on validated user selection
            {
                _lib.ReturnToShelf(retrnForm.ItemsValue);
                MessageBox.Show("You have returned this library item!");
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        // Precondition:  Report, Item List menu item activated
        // Postcondition: The list of items is displayed in the reportTxt
        //                text box
        private void itemListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <LibraryItem> items;                    // List of library items
            string             NL = Environment.NewLine; // NewLine shortcut

            items = _lib.GetItemsList();

            reportTxt.Text = $"Item List - {items.Count} items{NL}{NL}";

            foreach (LibraryItem item in items)
            {
                reportTxt.AppendText($"{item}{NL}{NL}");
            }

            // Put cursor at start of report
            reportTxt.SelectionStart = 0;
        }
Пример #5
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
        }
Пример #6
0
        // Precondition:  Report, Item List menu item activated
        // Postcondition: The list of items is displayed in the reportTxt
        //                text box
        private void itemListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder result = new StringBuilder();  // Holds text as report being built
                                                         // StringBuilder more efficient than String
            List <LibraryItem> items;                    // List of library items
            string             NL = Environment.NewLine; // NewLine shortcut

            items = _lib.GetItemsList();

            result.Append($"Item List - {items.Count} items{NL}{NL}");

            foreach (LibraryItem item in items)
            {
                result.Append($"{item}{NL}{NL}");
            }

            reportTxt.Text = result.ToString();

            // Put cursor at start of report
            reportTxt.SelectionStart = 0;
        }
Пример #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);
            }
        }
Пример #8
0
        // Precondition:  Report, Item List menu item activated
        // Postcondition: The list of items is displayed in the reportTxt
        //                text box
        private void itemListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder result = new StringBuilder(); // Holds text as report being built
                                                        // StringBuilder more efficient than String
            List <LibraryItem> items;                   // List of library items

            items = lib.GetItemsList();

            result.Append(String.Format("Item List - {0} items", lib.GetItemCount()));
            result.Append(System.Environment.NewLine); // Remember, \n doesn't always work in GUIs
            result.Append(System.Environment.NewLine);

            foreach (LibraryItem item in items)
            {
                result.Append(item.ToString());
                result.Append(System.Environment.NewLine);
                result.Append(System.Environment.NewLine);
            }

            reportTxt.Text = result.ToString();

            // Put cursor at start of report
            reportTxt.SelectionStart = 0;
        }
Пример #9
0
        private Library _lib; // The library

        // Precondition:  None
        // Postcondition: The form's GUI is prepared for display. A few test items and patrons
        //                are added to the library
        public Prog2Form()
        {
            InitializeComponent();

            _lib = new Library(); // Create the library

            // Insert test data - Magic numbers allowed here
            _lib.AddLibraryBook("The Wright Guide to C#", "UofL Press", 2010, 14, "ZZ25 3G", "Andrew Wright");
            _lib.AddLibraryBook("Harriet Pooter", "Stealer Books", 2000, 21, "AB73 ZF", "IP Thief");
            _lib.AddLibraryMovie("Andrew's Super-Duper Movie", "UofL Movies", 2011, 7,
                                 "MM33 2D", 92.5, "Andrew L. Wright", LibraryMediaItem.MediaType.BLURAY,
                                 LibraryMovie.MPAARatings.PG);
            _lib.AddLibraryMovie("Pirates of the Carribean: The Curse of C#", "Disney Programming", 2012, 10,
                                 "MO93 4S", 122.5, "Steven Stealberg", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.G);
            _lib.AddLibraryMusic("C# - The Album", "UofL Music", 2014, 14,
                                 "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10);
            _lib.AddLibraryMusic("The Sounds of Programming", "Soundproof Music", 1996, 21,
                                 "VI64 1Z", 65.0, "Cee Sharpe", LibraryMediaItem.MediaType.VINYL, 12);
            _lib.AddLibraryJournal("Journal of C# Goodness", "UofL Journals", 2000, 14,
                                   "JJ12 7M", 1, 2, "Information Systems", "Andrew Wright");
            _lib.AddLibraryJournal("Journal of VB Goodness", "UofL Journals", 2008, 14,
                                   "JJ34 3F", 8, 4, "Information Systems", "Alexander Williams");
            _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2016, 14, "MA53 9A", 16, 7);
            _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2016, 14, "MA53 9B", 16, 8);
            _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2016, 14, "MA53 9C", 16, 9);
            _lib.AddLibraryMagazine("VB Magazine", "UofL Mags", 2017, 14, "MA21 5V", 1, 1);

            // Add 5 Patrons
            _lib.AddPatron("Ima Reader", "12345");
            _lib.AddPatron("Jane Doe", "11223");
            _lib.AddPatron("John Smith", "54321");
            _lib.AddPatron("James T. Kirk", "98765");
            _lib.AddPatron("Jean-Luc Picard", "33456");

            string NEW = Environment.NewLine; // Constant string holder for new lines

            Console.WriteLine("Original List" + NEW);
            foreach (LibraryItem i in _lib.GetItemsList()) // walking thru library
            {
                Console.WriteLine(i + NEW);                // print
            }
            Console.WriteLine("Please press a key to continue...");
            Console.ReadLine();

            // Sorting by title
            _lib.GetItemsList().Sort();
            Console.WriteLine("Sorted Items" + NEW);
            foreach (LibraryItem i in _lib.GetItemsList())
            {
                Console.WriteLine(i + NEW);
            }
            Console.WriteLine("Please press a key to continue...");
            Console.ReadLine();


            // Sorting in desc order by copyright year
            _lib.GetItemsList().Sort(new DescendingCopyRightYear());
            Console.WriteLine("Descending Order by Copyright Year" + NEW);
            foreach (LibraryItem i in _lib.GetItemsList())
            {
                Console.WriteLine(i + NEW);
            }
            Console.WriteLine("Please press a key to continue...");
            Console.ReadLine();
        }