Esempio n. 1
0
        static void Main(string[] args)
        {
            OrderService orderService = new OrderService();
            int          flag         = 0;

            while (true)
            {
                Console.WriteLine("请选择需要执行的操作(输入数字):");
                Console.WriteLine("1.添加新订单");
                Console.WriteLine("2.删除订单");
                Console.WriteLine("3.查询订单");
                Console.WriteLine("4.修改订单");
                Console.WriteLine("5.查看订单列表");
                Console.WriteLine("6.退出");
                try
                {
                    flag = Int32.Parse(Console.ReadLine());
                    if (flag < 1 || flag > 6)
                    {
                        throw new OrderException();
                    }
                    else
                    {
                        switch (flag)
                        {
                        case 1:
                            orderService.AddOrder();
                            break;

                        case 2:
                            orderService.DeleteOrder();
                            break;

                        case 3:
                            orderService.Search();
                            break;

                        case 4:
                            orderService.EditOrder();
                            break;

                        case 5:
                            orderService.DisplayOrderList();
                            break;

                        case 6:
                            return;
                        }
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("输入有误!");
                }
            }
        }