Пример #1
0
        DialogResult result;  // Holds the results of the dialog box

        // Precondition: None
        // Postcondition: GUI is initialized and items are added
        public Program2Form()
        {
            InitializeComponent();

            _lib = new Library(); //Creates Library
            //Adds Test Data
            _lib.AddLibraryBook("How to Read", "Book Inc.", 1990, 14, "000015683", "John Fisher");
            _lib.AddLibraryBook("How to do Things", "Publisher Inc.", 1995, 14, "000015615", "Bill Bo Baggings");
            _lib.AddLibraryJournal("New Math Theories", "Publisher Inc.", 1500, 18, "000012348", 1, 1, "Math Stuff", "Dukey");
            _lib.AddLibraryJournal("Revolutionary Sciencey Stuff", "Publisher Corp", 1904, 21, "000015846", 1, 3, "Science Stuff", "Dr. Grizzwald");
            _lib.AddLibraryMagazine("The Subscription", "Magazines Corp", 2050, 7, "000098761", 1, 2);
            _lib.AddLibraryMagazine("The Subscription", "Magazines Corp", 2051, 7, "000098762", 2, 9);
            _lib.AddLibraryMovie("The Revenge of Count Walter", "Koon Pictures Inc", 2024, 4, "000012845", 240,
                                 "Moose Meat the Third", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG13);
            _lib.AddLibraryMovie("Black Wasp", "Cynical Juice Box Inc", 2019, 5, "000098514", 180, "Mouse Fish, the Second",
                                 LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.R);
            _lib.AddLibraryMusic("Squash Those Mushrooms", "Music Inc", 2020, 6, "000063541", 51, "Stephan Smith",
                                 LibraryMediaItem.MediaType.VINYL, 15);
            _lib.AddLibraryMusic("Seven In and 4 out", "Loud & Right Company", 2025, 5, "000065482", 60, "7 Snails",
                                 LibraryMediaItem.MediaType.SACD, 16);
            _lib.AddPatron("Billy Bo", "12345");
            _lib.AddPatron("Milly Bo", "12346");
            _lib.AddPatron("Sally Bo", "12347");
            _lib.AddPatron("Silly Bo", "12348");
            _lib.AddPatron("Gilly Bo", "12349");
        }
Пример #2
0
        private FileStream input;                                  //Stream for reading from a file


        // 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", 2017, 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", 2019, 14, "MA53 9A", 16, 7);
            _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2019, 14, "MA53 9B", 16, 8);
            _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2019, 14, "MA53 9C", 16, 9);
            _lib.AddLibraryMagazine("     VB Magazine    ", "    UofL Mags   ", 2018, 14, "MA21 5V", 1, 1);

            // Add 5 Patrons
            _lib.AddPatron("Ima Reader", "12345");
            _lib.AddPatron("Jane Doe", "11223");
            _lib.AddPatron("   John Smith   ", "   654321   ");
            _lib.AddPatron("James T. Kirk", "98765");
            _lib.AddPatron("Jean-Luc Picard", "33456");
        }
        private Library _lib; //The Library Object
        //Precondition: None
        //Postcondition: Books and Patrons will be displayed in the GUI
        public Program2()
        { //Precondition: none
          //Postcondition: The Program2 Form GUI is initialized
            InitializeComponent();
            _lib = new Library();

            //Insert Test Data
            _lib.AddLibraryBook("The Hills Have Eyes", "UofL Press", 2010, 20, "44RTW", "Dr.Wright");
            _lib.AddLibraryBook("To Kill a Mockingbird", "NY Press", 1998, 20, "46RYW", "Moll Happerns");
            _lib.AddLibraryMovie("The Color Purple", "Movies Press", 1987, 21, "TT432", 1.23, "Logan Jones", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.PG13);
            _lib.AddLibraryMovie("101 Dalmations", "Kids Movies Press", 1956, 21, "HE321", 2.15, "Jessie James", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.G);
            _lib.AddLibraryJournal("Journal of Teen Fashion", "Teen Press", 2019, 14, "PPO98", 4, 6, "Fashion", "Jimmy Richards");
            _lib.AddLibraryJournal("Journal of Calculus", "Math Press", 2001, 14, "DEO48", 10, 7, "Math", "Caroline Henderson");
            _lib.AddLibraryMagazine("Vogue", "Fashion Press", 2013, 20, "IU74W", 3, 12);
            _lib.AddLibraryMagazine("NascarRaces", "Cars Press", 2004, 20, "FG487", 5, 7);
            _lib.AddLibraryMusic("The Sound of Music", "Broadway Classics", 1996, 14, "890TR", 4.67, "Various Artists", LibraryMediaItem.MediaType.CD, 4);
            _lib.AddLibraryMusic("The Story of My Life", "Music Producers Inc.", 2007, 14, "CCS23", 1.55, "One Direction", LibraryMediaItem.MediaType.CD, 12);

            //Add 5 Patrons
            _lib.AddPatron("Emily Robertson", "987EE");
            _lib.AddPatron("Molly Baldock", "PP901");
            _lib.AddPatron("Jessie Hehn", "87TRE");
            _lib.AddPatron("Akansha Gupta", "3WQ12");
            _lib.AddPatron("Maddie Bloemer", "54RFC1");
        }
Пример #4
0
        private void addPatronToolStripMenuItem_Click(object sender, EventArgs e)
        {                                                           //precondition: result must be ok
            //postcondition: adds patron
            PatronInputForm patronInputBox = new PatronInputForm(); //form instance

            DialogResult result;

            result = patronInputBox.ShowDialog();

            if (result == DialogResult.OK)
            {
                item.AddPatron(patronInputBox.patronNameInput, patronInputBox.patronIdInput);
            }
            //adds patron
        }
Пример #5
0
        //Precondition: Report -> Patron menu item is activated
        //Postcondition: List of patrons is displayed
        private void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PatronForm   patronForm = new PatronForm();        //New patron dialog box fomr
            DialogResult result     = patronForm.ShowDialog(); //Show form and store result

            if (result == DialogResult.OK)
            {
                library.AddPatron(patronForm.PatronName, patronForm.PatronID); //Get patron info and send to library
            }
        }
Пример #6
0
        Library LibraryData = new Library(); // gives access to Library class



        public LibraryForm()
        {
            InitializeComponent();


            // hard coded list of patrons and items

            LibraryData.AddPatron("James Hunt", "001");
            LibraryData.AddPatron("Jessica Jones", "002");
            LibraryData.AddPatron("James Bond", "003");



            LibraryData.AddLibraryBook("Sample B0ok", "Sample Publisher", 2017, 31, "Q111", "Sample Auth0r");
            LibraryData.AddLibraryBook("Samp1e Book", "Sample Publisher", 2017, 31, "Q121", "Samp1e Author");
            LibraryData.AddLibraryBook("2ample Book", "Sample Publisher", 2017, 31, "Q126", "2ample Author");
            LibraryData.AddLibraryBook("Sampl3 Book", "Sample Publisher", 2017, 31, "Q129", "Sampl3 Author");
            LibraryData.AddLibraryBook("S4mple Book", "Sample Publisher", 2017, 31, "Q122", "Sample 4uthor");
            LibraryData.AddLibraryBook("5ample Book", "Sample Publisher", 2017, 31, "Q023", "5ample Author");
        }
        //Precondition: none
        //Postcondition: This will use the Patron form to allow users to input new patrons and return them onto a report.
        private void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PatronForm   inputForm = new PatronForm();
            DialogResult result    = inputForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                string name = inputForm.PatronName;
                string ID   = inputForm.PatronID;
                _lib.AddPatron(name, ID);
            }
        }
Пример #8
0
        private Library lib; // The library

        #endregion Fields

        #region Constructors

        // 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, "ZZ225 3G", "Andrew Wright");
            lib.AddLibraryBook("Harriet Pooter", "Stealer Books", 2000, 21, "AG773 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", 2011, 10,
                "MO93 4S", 122.5, "Steven Stealberg", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.G);
            lib.AddLibraryMusic("C# - The Album", "UofL Music", 2011, 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", 2011, 14,
                "JJ12 7M", 1, 2, "Information Systems", "Andrew Wright");
            lib.AddLibraryJournal("Journal of VB Goodness", "UofL Journals", 2007, 14,
                "JJ34 3F", 8, 4, "Information Systems", "Alexander Williams");
            lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2010, 14,
                "MA53 9A", 16, 7);
            lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2010, 14,
                "MA53 9B", 16, 8);
            lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2010, 14,
                "MA53 9C", 16, 9);
            lib.AddLibraryMagazine("VB Magazine", "UofL Mags", 2011, 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");
        }
Пример #9
0
        // Precondition:  Insert, Patron menu item activated
        // Postcondition: The Patron dialog box is displayed. If data entered
        //                are OK, a LibraryPatron is created and added to the library
        private void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PatronForm patronForm = new PatronForm();      // The patron dialog box form

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

            if (result == DialogResult.OK)                 // Only add if OK
            {
                // Use form's properties to get patron info to send to library
                _lib.AddPatron(patronForm.PatronName, patronForm.PatronID);
            }

            patronForm.Dispose(); // Good .NET practice - will get garbage collected anyway
        }
Пример #10
0
        // Precondition:   Patron menuitem activated
        // Postcondition: The patron dialog box is displayed. If data entered
        //                are OK, a patron is created and added to the list
        //                of Patrons
        private void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PatronForm Patron = new PatronForm(); //The dialog box form, that interacts with patronm form

            result = Patron.ShowDialog();
            string PatronName;
            string ID;

            if (result == DialogResult.OK)  //// Only update if user chose OK from dialog box
            {
                PatronName = Patron.NameValue;
                ID         = Patron.IDValue;
                _lib.AddPatron(PatronName, ID);
            }
        }
Пример #11
0
        // Precondition: None
        // Postcondition: Opens a dialog box that will add a patron's name and id
        private void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PatronForm Patron = new PatronForm(); // variable that interacts with the patron form

            result = Patron.ShowDialog();
            string Name; // Name of the patron
            string ID;   // The id of the patron

            if (result == DialogResult.OK)
            {
                Name = Patron.NameTextBox.Text;
                ID   = Patron.IDTextBox.Text;
                _lib.AddPatron(Name, ID);
            }
        }
Пример #12
0
        // Precondition:  User clicks on Patron Form
        // Postcondition: Modal box displays.  User submits patron name,
        //                and patron ID.  User can submit, or exit the form.
        //                the user input is validated before changing control focus.
        public void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PatronForm   patronform = new PatronForm(); // Patron form creation
            DialogResult result;                        // Dialog result is created

            result = patronform.ShowDialog();           // Displays the modal patronform

            if (result == DialogResult.OK)
            {
                string patronID   = patronform.PatronID;     // PatronID from user
                string patronName = patronform.PatronName;   // PatronName from user
                newLibrary.AddPatron(patronName, patronID);  // Patron is added to the library.
            }
        }
Пример #13
0
        // Precondition:  None
        // Postcondition: Adds new patron to the list of patron's in the library's linq list.
        private void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Creates the patron subform and opens it
            PatronForm   patronForm = new PatronForm();
            DialogResult result; // Holds dialog result
            string       name;   // Holds the name of the new patron
            string       id;     // Holds the ID of the new patron

            result = patronForm.ShowDialog();

            if (result == DialogResult.OK) // Update when user clicks OK
            {
                name = patronForm.NAME;
                id   = patronForm.ID;
                newLibrary.AddPatron(name, id);
            }
        }
Пример #14
0
        // Precondition:  None
        // Postcondition: Adds new patron to the list of patron's in the library's linq list.
        private void patronToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Creates the patron subform and opens it.
            PatronForm   patronForm = new PatronForm();
            DialogResult result; //Holds the dialog result
            string       name;   //holds the name of the new patron name
            string       id;     //holds the name of the new patron's id

            result = patronForm.ShowDialog();

            if (result == DialogResult.OK)// Only update if user chose OK from dialog box
            {
                name = patronForm.NameValue;
                id   = patronForm.IDValue;
                newLibrary.AddPatron(name, id);
            }
        }
Пример #15
0
        DialogResult result;  //  holds dialog result
        public MainForm()
        {
            InitializeComponent();
            _lib = new Library();  // creates the library

            //Adding library items
            _lib.AddLibraryBook("The Wright Guide to C#", "UofL Press", 2010, 14,
                                "ZZ25 3G", "Andrew Wright");
            _lib.AddLibraryBook("Harry Potter", " Bloomsbury Publishing ", 1997, 14,
                                "ZZ25 3G", " J. K. Rowling");

            //Adding 2 two LibraryMovie objects to the list
            _lib.AddLibraryMovie("   Andrew's Super-Duper Movie   ", "   UofL Movies   ", 2019, 7,
                                 "MM33 2D", 92.5, "   Andrew L. Wright   ", LibraryMediaItem.MediaType.BLURAY,
                                 LibraryMovie.MPAARatings.PG); // Trims?
            _lib.AddLibraryMovie("  Frozen 2 ", "   Disney   ", 2019, 7,
                                 "MM33 2D", 92.5, "  Jennifer Lee   ", LibraryMediaItem.MediaType.BLURAY,
                                 LibraryMovie.MPAARatings.PG);

            //Adding 2 two LibraryMusic objects to the list
            _lib.AddLibraryMusic("C# - The Album", "UofL Music", 2020, 14,
                                 "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10);
            _lib.AddLibraryMusic("Lover", "Jack Antonoff", 2019, 14,
                                 "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10);

            //Adding 2 two LibraryJournal objects to the list
            _lib.AddLibraryJournal("Journal of C# Goodness", "UofL Journals", 2018, 14,
                                   "JJ12 7M", 1, 2, "Information Systems", "Andrew Wright");
            _lib.AddLibraryJournal("Physics", "UofL Journals", 2018, 14,
                                   "JJ12 7M", 1, 2, "Science", "XYZ");

            //Adding 2 two LibraryMagazine objects to the list
            _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2017, 14,
                                    "MA53 9A", 16, 7);
            _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2017, 14,
                                    "MA53 9A", 9, 10);

            // Adding patrons to the patrons list
            _lib.AddPatron("Ima Reader", "12345");
            _lib.AddPatron("Jane Doe", "11223");
            _lib.AddPatron("   John Smith   ", "   654321   "); // Trims?
            _lib.AddPatron("Joe John", "12003");
            _lib.AddPatron("Jake", "60890");
            _lib.AddPatron(" Steve ", "   70623   ");
        }
Пример #16
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();
        }