示例#1
0
        static void Main()
        {
            OrderService orderService = new OrderService();


            List <OrderItem> items1 = new List <OrderItem>()
            {
                new OrderItem("1", "basketball", 80, 2),
                new OrderItem("2", "tennis", 5, 20)
            };



            Order order1 = new Order("001", "小明", items1);



            List <OrderItem> items2 = new List <OrderItem>()
            {
                new OrderItem("3", "volleyball", 50, 2),
                new OrderItem("4", "football", 100, 5)
            };

            Order order2 = new Order("002", "小李", items2);



            orderService.Add(order1);
            orderService.Add(order2);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
示例#2
0
        static void Main(string[] args)
        {
            OrderService orderService = new OrderService();
            //orderService.Delete("001");

            List <OrderItem> orderDetails = new List <OrderItem>()
            {
                new OrderItem("apple", "1", 10.0),
                new OrderItem("egg", "2", 2.2)
            };

            Order order = new Order("001", "jia", 112, orderDetails);

            orderService.Add(order);

            Order order2 = new Order("001", "jia2", 22, orderDetails);

            orderService.ModifyOrder(order2);


            List <Order> orders = orderService.QueryByCustormer("jia2");

            orders.ForEach(
                o => Console.WriteLine($"{o.Id},{o.Customer}"));
        }
示例#3
0
        private void FrmAddOdMsg_FormClosed(object sender, FormClosedEventArgs e)
        {
            os.Add(order);
            orderID++;
            List <Order> orders = os.SaveOrders;

            ShowMessage.showOrderMessages(orders, orderList);//显示信息
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                OrderService     orderService = new OrderService();
                List <OrderItem> items        = new List <OrderItem>()
                {
                    new OrderItem(textBox1.Text, textBox2.Text, double.Parse(textBox3.Text), int.Parse(textBox4.Text))
                };

                Order order = new Order(textBox9.Text, textBox5.Text, items);
                orderService.Add(order);
                MessageBox.Show("订单添加成功!");
            }
            catch
            {
                MessageBox.Show("请正确输入订单信息信息!");
            }
        }
示例#5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            OrderService orderService = new OrderService();

            List <OrderItem> items1 = new List <OrderItem>()
            {
                new OrderItem("1", "iPhone XR", 6499, 1),
                new OrderItem("2", "iPhone XS", 8699, 1),
                new OrderItem("3", "Airpords", 1199, 2)
            };

            List <OrderItem> items2 = new List <OrderItem>()
            {
                new OrderItem("4", "iPad Pro", 6499, 1),
                new OrderItem("5", "Airpords", 1199, 1)
            };

            //添加订单
            Order order1 = new Order("20181124001", "Alan", "18788888888", items1);

            orderService.Add(order1);

            Order order2 = new Order("20181124002", "Bob", "18777777777", items2);

            orderService.Add(order2);

            //修改订单
            Order order3 = new Order("20181124001", "Iggie", "18766666666", items1);

            orderService.Update(order3);

            //得到所有订单
            List <Order> orders = orderService.GetAllOrders();

            Console.WriteLine("所有订单:");
            orders.ForEach(o => Console.WriteLine(o.OrderNumber + " " + o.Client + " " + o.PhoneNumber + " " + o.TotalPrice));

            //Id查询
            Order order = orderService.QueryById("20181124002");

            Console.WriteLine("ID查询:");
            orders.ForEach(o => Console.WriteLine(o.OrderNumber + " " + o.Client + " " + o.PhoneNumber + " " + o.TotalPrice));

            //客户名查询
            orders = orderService.QueryByClient("Iggie");
            Console.WriteLine("客户名查询:");
            orders.ForEach(o => Console.WriteLine(o.OrderNumber + " " + o.Client + " " + o.PhoneNumber + " " + o.TotalPrice));

            //商品名查询
            orders = orderService.QueryByGoods("Airpords");
            Console.WriteLine("商品名查询:");
            orders.ForEach(o => Console.WriteLine(o.OrderNumber + " " + o.Client + " " + o.PhoneNumber + " " + o.TotalPrice));

            //总价大于10000元查询
            orders = orderService.QueryBigOrder();
            Console.WriteLine("总价大于10000元查询:");
            orders.ForEach(o => Console.WriteLine(o.OrderNumber + " " + o.Client + " " + o.PhoneNumber + " " + o.TotalPrice));

            //序列化
            string path = @"../../MyOrderList.xml";

            orderService.Export(path);

            //删除订单
            orderService.Delete("20181124002");
        }