Beispiel #1
0
        static void Main(string[] args)
        {
            Order order1 = new Order("CC", 3, "iPhone");
            Order order2 = new Order("PP", 1, "iPad");
            Order order3 = new Order("EE", 9, "iPhone");

            OrderService service = new OrderService();

            service.AddOrder(order1);
            service.AddOrder(order2);
            service.AddOrder(order3);

            Console.WriteLine("Xml文件");
            service.ExportList();

            List <Order> list = new List <Order>();

            list = service.ImportList();

            Console.WriteLine("原先的订单");
            service.DisplayOrderList();
            Console.WriteLine("新的订单");
            OrderService.DisplayList(list);

            Console.WriteLine("iPhone");
            List <Order> list2 = new List <Order>();

            list2 = service.SearchOrderLinqByGood("iPhone");
            OrderService.DisplayList(list2);

            Console.WriteLine("Change Count of iPhone");
            service.ChangeOrder(order1.ID, 30);
            service.DisplayOrderList();

            Console.WriteLine("Change the Price of Order1 to 9999");
            service.SearchOrderByID(order1.ID).Detail[service.SearchOrderByID(order1.ID).Good, "Price"] = 9999.ToString();
            service.DisplayOrderList();

            Console.ReadLine();
        }
Beispiel #2
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.输出订单");
                Console.WriteLine("7.导入订单");
                Console.WriteLine("8.退出");
                try
                {
                    flag = Int32.Parse(Console.ReadLine());
                    if (flag < 1 || flag > 8)
                    {
                        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:
                            orderService.Export(@"output.xml");
                            break;

                        case 7:
                            orderService.Import(@"output.xml");
                            break;

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