Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string orderPath = @"order.xml";

            service.Import(orderPath);

            Console.WriteLine("---订单管理系统---");
            string operate = "";

            while (operate.ToUpper() != "E")
            {
                Console.WriteLine(@"请选择您的操作:
查询订单-Q 添加订单-A 更新订单-U 删除订单-D 退出-E");
                operate = Console.ReadLine();
                switch (operate)
                {
                case "Q":
                    DoQuery();
                    break;

                case "A":
                    DoAdd();
                    break;

                case "U":
                    DoUpdate();
                    break;

                case "D":
                    DoDelete();
                    break;

                default:
                    operate = "E";
                    break;
                }
            }
            service.Export(orderPath);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //create the first order
            List <Cargo> cargos1 = new List <Cargo>
            {
                new Cargo("Perfume", 2, 340),
                new Cargo("Shoes", 3, 780),
                new Cargo("Lipstick", 1, 180.5)
            };

            OrderDetails orderDetails1 = new OrderDetails(cargos1);
            Order        order1        = new Order(new Client("JK"), orderDetails1);

            //create the second order
            List <Cargo> cargos2 = new List <Cargo>();

            cargos2.Add(new Cargo("Flower", 6, 5.2));
            cargos2.Add(new Cargo("Book", 2, 15.8));

            OrderDetails orderDetails2 = new OrderDetails(cargos2);
            Order        order2        = new Order(new Client("V"), orderDetails2);

            OrderService orderService = new OrderService();

            orderService.AddOrder(order1);
            orderService.AddOrder(order2);

            Console.WriteLine(order1);
            Console.WriteLine(order2);
            orderService.Orders.Sort();

            orderService.ModifyOrder(1, "Lipstick", 10);

            orderService.Export("orders.xml");
            orderService.Import("orders.xml");

            Console.Read();
        }
Exemplo n.º 3
0
        public static void startMenu(List <Goods> shopgoods, OrderService obj)
        {
            do
            {
                Console.Clear();
                Console.WriteLine("--订单管理程序--");
                Console.WriteLine("按提示选择你想进行的操作:");
                Console.WriteLine("1.添加订单");
                Console.WriteLine("2.修改订单");
                Console.WriteLine("3.删除订单");
                Console.WriteLine("4.查询订单");
                Console.WriteLine("5.将已有订单序列化为XML格式");
                Console.WriteLine("6.将xml文件导入到订单");
                Console.WriteLine("请输入:");
                char op;
                char.TryParse(Console.ReadLine(), out op);

                switch (op)
                {
                case '1':
                    UI.addingOrderUI(shopgoods, obj);
                    break;

                case '2':
                    UI.modifyOrderUI(shopgoods, obj);
                    break;

                case '3':
                    UI.deleteOrderUI(shopgoods, obj);
                    break;

                case '4':
                    UI.inquiryOrderUI(shopgoods, obj);
                    break;

                case '5':
                    obj.Export();
                    Console.WriteLine("已导出xml文件\n");
                    Console.ReadKey();
                    break;

                case '6':
                    Console.Write("请输入您想导入的xml文件名\n");
                    string fileName = Console.ReadLine();
                    try
                    {
                        obj.Import(fileName);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    Console.WriteLine("已导入");
                    Console.ReadKey();
                    break;

                default:
                    Console.WriteLine("请键入数字1—6!");
                    char.TryParse(Console.ReadLine(), out op);
                    break;
                }
            } while (true);
        }