示例#1
0
        private void RequestCommand()
        {
            Console.Write("cmd> ");
            parameters = Console.ReadLine().ToLower().Split(' ');

            bool quit = false;

            switch (parameters[0])
            {
            case "li":
            case "listitems":
                inventoryCmd.ListItems();
                break;

            case "ldb":
            case "loaddb":
                if (IsValidPameter(1))
                {
                    managementCmd.LoadDb(parameters[1]);
                    inventoryCmd.Inventories = managementCmd.Inventories;
                }
                break;

            case "sdb":
            case "savedb":
                if (IsValidPameter(1))
                {
                    managementCmd.SaveDb(parameters[1]);
                }
                break;

            case "icd":
            case "incomed":
                if (IsValidPameter(1))
                {
                    managementCmd.FindByDay(parameters[1]);
                }
                break;

            case "fi":
            case "findi":
                if (IsValidPameter(1))
                {
                    managementCmd.FindInventory(parameters[1]);
                }
                break;

            case "q":
            case "quit":
                managementCmd.Quit();
                quit = true;
                break;

            case "?":
            case "help":
                inventoryCmd.Help();
                managementCmd.Help();
                break;

            default:
                Console.WriteLine("Command {0} is not recongnized. Please try again.", parameters[0]);
                break;
            }

            managementCmd.Inventories = inventoryCmd.Inventories;
            if (!quit)
            {
                RequestCommand();
            }
        }
示例#2
0
        /*
         * execute commands according with user
         */
        private void RequestCommand()
        {
            Console.Write("cmd> ");
            parameters = Console.ReadLine().ToLower().Split(' ');

            bool quit = false;

            // send the inventories array from management to inventory class
            inventoryCmd.Inventories = managementCmd.Inventories;

            // perform each command based on user input
            switch (parameters[0])
            {
            case "lf":
            case "lstfiles":
                managementCmd.ListFiles(System.IO.Directory.GetCurrentDirectory());     //AppDomain.CurrentDomain.BaseDirectory
                break;

            case "ldb":
            case "loaddb":
                if (IsValidPameter(1))
                {
                    managementCmd.LoadDb(parameters[1]);
                    inventoryCmd.Inventories = managementCmd.Inventories;
                }
                break;

            case "sdb":
            case "savedb":
                if (IsValidPameter(1))
                {
                    managementCmd.SaveDb(parameters[1]);
                }
                break;

            case "li":
            case "listitems":
                inventoryCmd.ListItems();
                break;

            case "+":
            case "inc":
                if (IsValidPameter(1) && IsValidPameter(2))
                {
                    inventoryCmd.IncreaseStock(parameters[1], parameters[2]);
                }
                break;

            case "-":
            case "dec":
                if (IsValidPameter(1) && IsValidPameter(2))
                {
                    inventoryCmd.DecreaseStock(parameters[1], parameters[2]);
                }
                break;

            case "lw":
            case "low":
                inventoryCmd.LowItems();
                break;

            case "pk":
            case "prek":
                if (IsValidPameter(1))
                {
                    inventoryCmd.PreOrderQnt(parameters[1]);
                }
                break;

            case "q":
            case "quit":
                managementCmd.Quit();
                quit = true;
                break;

            case "?":
            case "help":
                inventoryCmd.Help();
                managementCmd.Help();
                break;

            default:
                Console.WriteLine("Command {0} is not recongnized. Please try again.", parameters[0]);
                break;
            }

            // send back inventory array from inventory class to management class
            managementCmd.Inventories = inventoryCmd.Inventories;

            if (!quit)
            {
                RequestCommand();
            }
        }