Ejemplo n.º 1
0
        public void Item()
        {
            ShowItems showObject = new ShowItems();

            showObject.Items();
            Console.WriteLine("Select an item:");
            int option = 0;

            while (true)
            {
                try
                {
                    option = Int32.Parse(Console.ReadLine());
                    if (option > 0 || option < Program.serviceProviderObject.listCount())
                    {
                        break;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                catch { Console.WriteLine("Enter Valid Option:"); }
            }
            Program.serviceProviderObject.DeleteItem(option);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("*****WELCOME*****");
            while (true)
            {
                Console.WriteLine("\n\n1.Add Item\n2.Update Item\n3.Delete Item\n4.Show Items\n5.Exit\n");
                Console.Write("Enter Your Choice:");
                int choice = 0, lowerBound = 1, upperBound = 5;
                while (true)
                {
                    try
                    {
                        choice = Int32.Parse(Console.ReadLine());
                        if (choice > upperBound || choice < lowerBound)
                        {
                            throw new Exception();
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch { Console.Write("Enter a valid option:"); }
                }
                switch (choice)
                {
                case (int)options.Add: AddItem addObject = new AddItem();
                    addObject.Item();
                    break;

                case (int)options.Update: UpdateItem updateObject = new UpdateItem();
                    updateObject.Item();
                    break;

                case (int)options.Delete: DeleteItem deleteObject = new DeleteItem();
                    deleteObject.Item();
                    break;

                case (int)options.Show: ShowItems showObject = new ShowItems();
                    showObject.Items();
                    break;

                default:
                    Environment.Exit(0);
                    break;
                }
            }
        }