Example #1
0
    static void Main()
    {
        //declare necessary variables
        uint MenuSelect;
        bool Continue = true;
        //display menu
        InventoryManagement Inv = new InventoryManagement();

        // use the code below for setting up a test inventory
        ///*
        Inv.AddItem(323, "Green Pens", 1.50m, 20, 0.75m, 30m);
        Inv.AddItem(657, "Red Pens", 1.50m, 20, 0.75m, 30m);
        Inv.AddItem(846, "Orange Pens", 1.50m, 30, 0.75m, 45m);
        Inv.AddItem(325, "Purple Pens", 1.50m, 45, 0.75m, 67.5m);
        Inv.AddItem(987, "Yellow Pens", 1.50m, 33, 0.75m, 49.5m);
        Inv.AddItem(654, "Black Pens", 1.00m, 100, 0.50m, 100m);
        //*/

        while (Continue)
        {
            Inv.DisplayMenu();
            //read input for menu selection
            string MenuStr = Console.ReadLine();
            MenuSelect = uint.Parse(MenuStr);

            //set cases to call appropriate frunction from InventoryManagement
            switch (MenuSelect)
            {
            case 1:                                                                     //Add an item
            {
                Console.Write("Please enter the item number(3 digits): ");              //intruction 1
                uint Inum = uint.Parse(Console.ReadLine());                             //take user input

                Console.Write("Please enter the item's description (20 characters): "); //intruction 2
                string IDesc = Console.ReadLine();                                      //take user input

                Console.Write("Please enter the item's sale price: ");                  //intruction 3
                decimal IPrice = decimal.Parse(Console.ReadLine());                     //take user input

                Console.Write("Please enter the quantity of items: ");                  //intruction 4
                uint IQuant = uint.Parse(Console.ReadLine());                           //take user input

                Console.Write("Please enter the cost per item: ");                      //intruction 5
                decimal ICost = decimal.Parse(Console.ReadLine());                      //take user input
                decimal IVal  = IPrice * IQuant;                                        //calculate the item value
                Inv.AddItem(Inum, IDesc, IPrice, IQuant, ICost, IVal);                  //store the item value
                break;
            }

            case 2:                                                                     //change an item
            {
                Console.Write("Please enter the item number(3 digits): ");              //intruction 1
                uint Inum = uint.Parse(Console.ReadLine());                             //take user input

                Console.Write("Please enter the item's description (20 characters): "); //intruction 2
                string IDesc = Console.ReadLine();                                      //take user input

                Console.Write("Please enter the item's sale price: ");                  //intruction 3
                decimal IPrice = decimal.Parse(Console.ReadLine());                     //take user input

                Console.Write("Please enter the quantity of items: ");                  //intruction 4
                uint IQuant = uint.Parse(Console.ReadLine());                           //take user input

                Console.Write("Please enter the cost per item: ");                      //intruction 5
                decimal ICost = decimal.Parse(Console.ReadLine());                      //take user input
                decimal IVal  = IPrice * IQuant;                                        //calculate the item value
                Inv.ChangeItem(Inum, IDesc, IPrice, IQuant, ICost, IVal);               //store the item value
                break;
            }

            case 3:                                                        //delete an item
            {
                Console.Write("Please enter the item number(3 digits): "); //intruction 1
                uint Inum = uint.Parse(Console.ReadLine());                //take user input
                Inv.DeleteItem(Inum);
                break;
            }

            case 4:     //list all items from inventory
            {
                //Display Entire Inventory
                Console.WriteLine("Item#  ItemID  Description           Price   QOH  Cost    Value     ");
                Console.WriteLine("-----  ------  --------------------  ------  ---  ------  ----------");
                Inv.PrintItems();
                Console.WriteLine("");
                break;
            }

            case 5:     //quit the application
            {
                //execute Menu item 5
                Continue = false;
                break;
            }

            default:
            {
                //Invalid selection handling
                Console.WriteLine("Please select a valid menu option...");
                break;
            }
            }
        }
    }