Пример #1
0
        //查询
        private void btnQuery_Click(object sender, EventArgs e)
        {
            switch (cmbQuery.SelectedIndex)
            {
            case 0:
                using (var db = new OrderContext())
                {
                    bindingSource1.DataSource = orderService.Orders;
                    //bindingSource1.ResetBindings(false);
                }
                break;

            case 1:
                int.TryParse(QueryText, out int id);
                bindingSource1.DataSource = orderService.QueryById(id);
                break;

            case 2:
                bindingSource1.DataSource = orderService.QueryByCustomerName(QueryText);
                break;

            case 3:
                bindingSource1.DataSource = orderService.QueryByGoodsName(QueryText);
                break;

            case 4:
                float.TryParse(QueryText, out float totalPrice);
                bindingSource1.DataSource = orderService.QueryByTotalAmount(totalPrice);
                break;
            }
            bindingSource1.ResetBindings(false);
        }