Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            OrderDetails order1    = new OrderDetails("20181005001", "John", "Apple", 2.5, 3);
            OrderDetails order2    = new OrderDetails("20181005002", "Anna", "Apple", 2.5, 4);
            OrderDetails order3    = new OrderDetails("20181005003", "John", "Pear", 3.5, 3);
            OrderDetails order4    = new OrderDetails("20181005004", "Peter", "Orange", 3, 3);
            OrderDetails order5    = new OrderDetails("20181005004", "Peter", "Watermelen", 10, 1000);
            OrderService MyService = new OrderService();

            try
            {
                MyService.addOrder(order1);
                MyService.addOrder(order2);
                MyService.addOrder(order3);
                MyService.addOrder(order4);
                MyService.addOrder(order5);

                //MyService.showAll();

                //MyService.changeOrder(order4);

                //MyService.showAll();

                MyService.searchOrder("订单号", "20181005004");
                MyService.searchOrder("订单总额", "10000");

                MyService.deleteOrder(order4);

                //MyService.showAll();
            }
            catch (MyException e)
            {
                Console.WriteLine(e.Message);
            }

            string xmlFileName = MyService.Export();

            MyService.Import(xmlFileName);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Order> orders = new List <Order>();
            //初始化客户
            Custom custom1 = new Custom(1, "mayun");
            Custom custom2 = new Custom(2, "mahuateng");
            Custom custom3 = new Custom(3, "wangjianlin");

            //初始化订单订单
            OrderService.addOrder(orders, new Order(1, custom1));
            OrderService.addOrder(orders, new Order(2, custom2));
            OrderService.addOrder(orders, new Order(3, custom3));
            orders[0].addOrderDetails(new OrderDetails("001", "Taobao", 7000));
            orders[0].addOrderDetails(new OrderDetails("002", "Alipay", 3001));
            orders[1].addOrderDetails(new OrderDetails("007", "Tecent", 5000));
            orders[1].addOrderDetails(new OrderDetails("003", "WeChat", 4999));
            orders[2].addOrderDetails(new OrderDetails("004", "Wanda", 10001));
            //删除第二个订单
            //OrderService.removeOrder(orders, orders[1]);
            //查找订单
            //int i = OrderService.findOrderByString(orders, "Taobao");
            //int x = orders[i].findOrderDetailsByString("Taobao");
            //修改订单
            //OrderService.changeOrder(orders, i, x, 1, "huichuangali");
            //展示订单
            foreach (Order order in orders)
            {
                Console.WriteLine("订单" + order.id);
                Console.WriteLine(order);
            }
            OrderService.showOrderByCustom(orders, "mayun");
            OrderService.showOrderByGoodsName(orders, "Alipay");
            OrderService.showOrderByGoodsId(orders, "004");
            OrderService.showOrderMoreThanNum(orders, 10000);
            Console.ReadKey();
        }