static void Main(string[] args) { try { //客户 Customer customer1 = new Customer(20181123, "Tom"); Customer customer2 = new Customer(20185462, "Bob"); Customer customer3 = new Customer(20184762, "Cindy"); //添加几种商品 CommodityList.AddCommodity(new Commodity("pencil", 1)); CommodityList.AddCommodity(new Commodity("pen", 10)); CommodityList.AddCommodity(new Commodity("cellPhone", 1000)); CommodityList.AddCommodity(new Commodity("pants", 100)); CommodityList.AddCommodity(new Commodity("skirt", 150)); //订单明细实例,由商品组成 OrderDetail orderDetails1 = new OrderDetail(CommodityList.commodities[0], 10); OrderDetail orderDetails2 = new OrderDetail(CommodityList.commodities[1], 5); OrderDetail orderDetails3 = new OrderDetail(CommodityList.commodities[2], 15); OrderDetail orderDetails4 = new OrderDetail(CommodityList.commodities[3], 6); OrderDetail orderDetails5 = new OrderDetail(CommodityList.commodities[4], 9); //实列化订单 Order order1 = new Order(4, customer1); Order order2 = new Order(5, customer1); Order order3 = new Order(6, customer2); order1.AddCommodity(orderDetails1); order1.AddCommodity(orderDetails2); order2.AddCommodity(orderDetails2); order2.AddCommodity(orderDetails4); order3.AddCommodity(orderDetails3); order3.AddCommodity(orderDetails5); OrderService orderService = new OrderService(); string fileName = "D:\\code\\C#\\CSharpWork\\sixthWork\\M_OrderProgram\\bin\\Debug\\OrderXmlFile.xml"; orderService.Import(fileName); //添加订单 orderService.AddOrder(order1); orderService.AddOrder(order2); orderService.AddOrder(order3); orderService.Export(); //移除订单 } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { //添加几种商品 CommodityList.AddCommodity(new Commodity("pencil", 1)); CommodityList.AddCommodity(new Commodity("pen", 10)); CommodityList.AddCommodity(new Commodity("cellPhone", 1000)); CommodityList.AddCommodity(new Commodity("pants", 100)); CommodityList.AddCommodity(new Commodity("skirt", 150)); //订单明细实例,由商品组成 OrderDetails orderDetails1 = new OrderDetails(CommodityList.commodities[0], 10); OrderDetails orderDetails2 = new OrderDetails(CommodityList.commodities[1], 5); OrderDetails orderDetails3 = new OrderDetails(CommodityList.commodities[2], 15); OrderDetails orderDetails4 = new OrderDetails(CommodityList.commodities[3], 6); OrderDetails orderDetails5 = new OrderDetails(CommodityList.commodities[4], 9); //订单明细组成订单 List <OrderDetails> orderDetailsList1 = new List <OrderDetails> { orderDetails1, orderDetails2 }; List <OrderDetails> orderDetailsList2 = new List <OrderDetails> { orderDetails1, orderDetails2, orderDetails5 }; List <OrderDetails> orderDetailsList3 = new List <OrderDetails> { orderDetails2 }; List <OrderDetails> orderDetailsList4 = new List <OrderDetails> { orderDetails4, orderDetails3, orderDetails5 }; //实列化订单 Order order1 = new Order(1234567, "Tom", orderDetailsList1); Order order2 = new Order(12345, "Bob", orderDetailsList2); Order order3 = new Order(123002, "Alice", orderDetailsList3); Order order4 = new Order(123008, "Dare", orderDetailsList4); OrderService orderService = new OrderService(); //添加订单 orderService.AddOrder(order1); orderService.AddOrder(order2); orderService.AddOrder(order3); //删除订单 orderService.DeleteOrder(order1); //修改订单 orderService.ModifyOrder(order2); }