示例#1
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            switch (cbxField.SelectedIndex)
            {
            case 0:    //所有订单
                orderbindingSource.DataSource = orderService.Orders;
                break;

            case 1:    //根据ID查询
                int.TryParse(Keyword, out int id);
                Order        order  = orderService.GetOrder(id);
                List <Order> result = new List <Order>();
                if (order != null)
                {
                    result.Add(order);
                }
                orderbindingSource.DataSource = result;
                break;

            case 2:    //根据客户查询
                orderbindingSource.DataSource = orderService.QueryOrdersByCustomerName(Keyword);
                break;

            case 3:    //根据货物查询
                orderbindingSource.DataSource = orderService.QueryOrdersByGoodsName(Keyword);
                break;

            case 4:    //根据总价格查询(大于某个总价)
                float.TryParse(Keyword, out float totalPrice);
                orderbindingSource.DataSource =
                    orderService.QueryByTotalAmount(totalPrice);
                break;
            }
            orderbindingSource.ResetBindings(false);
        }
示例#2
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            switch (cmb_search.Text)
            {
            case "订单号":
                Service.GetById(Int32.Parse(tb_search.Text));
                break;

            case "顾客名称":
                Service.QueryByCustomerName(tb_search.Text);
                break;

            case "总金额":
                Service.QueryByTotalAmount(float.Parse(tb_search.Text));
                break;

            case "商品名称":
                Service.QueryByGoodsName(tb_search.Text);
                break;

            default:
                break;
            }
        }