Пример #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     app.Order order = orderBindingSource.Current as app.Order;
     if (order == null)
     {
         MessageBox.Show("请选择一个订单进行删除");
         return;
     }
     orderService.RemoveOrder(order.Id);
     QueryAll();
 }
Пример #2
0
        private void EditOrder()
        {
            app.Order order = orderBindingSource.Current as app.Order;
            if (order == null)
            {
                MessageBox.Show("请选择一个订单进行修改");
                return;
            }
            FormEdit form2 = new FormEdit(order, true);

            if (form2.ShowDialog() == DialogResult.OK)
            {
                app.OrderService.UpdateOrder(form2.CurrentOrder);
                QueryAll();
            }
        }
Пример #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
            case 0:    //所有订单
                orderBindingSource.DataSource = app.OrderService.GetAllOrders();
                break;

            case 1:    //根据ID查询
                app.Order        order  = app.OrderService.GetOrder(Keyword);
                List <app.Order> result = new List <app.Order>();
                if (order != null)
                {
                    result.Add(order);
                }
                orderBindingSource.DataSource = result;
                break;
            }
            orderBindingSource.ResetBindings(true);
        }
Пример #4
0
        private void button5_Click(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
            case 0:    //所有订单
                orderBindingSource.DataSource = orderService.Orders;
                break;

            case 1:    //根据ID查询
                int.TryParse(Keyword, out int id);
                app.Order        order  = orderService.GetOrder(id);
                List <app.Order> result = new List <app.Order>();
                if (order != null)
                {
                    result.Add(order);
                }
                orderBindingSource.DataSource = result;
                break;
            }
            orderBindingSource.ResetBindings(false);
        }
Пример #5
0
        public Form1()
        {
            InitializeComponent();
            orderService = new OrderService();
            OrderDetails        detail_1 = new OrderDetails(2, 2, "apple");
            OrderDetails        detail_2 = new OrderDetails(3, 3, "pear");
            List <OrderDetails> dets     = new List <OrderDetails>();

            dets.Add(detail_1); dets.Add(detail_2);
            app.Order order1 = new app.Order(1, "王五", dets);
            detail_1 = new OrderDetails(3, 2, "banana");
            detail_2 = new OrderDetails(4, 1, "orange");
            dets.Clear();
            dets.Add(detail_1); dets.Add(detail_2);
            app.Order order2 = new app.Order(2, "李四", dets);
            orderService.addOrder(order1);
            orderService.addOrder(order2);
            orderBindingSource.DataSource = orderService.Orders;
            //comboBox1.SelectedIndex = 0;
            textBox1.DataBindings.Add("text", this, "keyword");//数据绑定
        }