Пример #1
0
        private void Inquire_Click(object sender, EventArgs e)
        {
            if (InquiryChoose.SelectedItem != null)
            {
                if (inquiryBox.Text == "")
                {
                    warning.Text = "";
                }
                else
                {
                    this.inquiryState   = true;                          //进入查询模式
                    quitInquiry.Enabled = true;
                    Add.Enabled         = false;                         //查询模式下无法添加订单
                    switch (InquiryChoose.SelectedIndex)
                    {
                    case 0:
                        if (OrderService.InquireNo(orderList, inquiryBox.Text) != null)
                        {
                            inquiryResultList          = orderList.Where(s => s.OrderNo == inquiryBox.Text).ToList();
                            OrderDataSource.DataSource = inquiryResultList;     //更新查询结果
                            this.OrderDataSource.ResetBindings(false);
                        }
                        else
                        {
                            OrderDataSource.DataSource = null; ItemDataSource.DataSource = null;
                        }                                                                                 //未找到则显示为空
                        break;

                    case 1:
                        if (OrderService.InquireClientName(orderList, inquiryBox.Text) != null)
                        {
                            inquiryResultList          = OrderService.InquireClientName(orderList, inquiryBox.Text);
                            OrderDataSource.DataSource = inquiryResultList;
                            this.OrderDataSource.ResetBindings(false);
                        }
                        else
                        {
                            OrderDataSource.DataSource = null; ItemDataSource.DataSource = null;
                        }
                        break;

                    case 2:
                        if (OrderService.InquireProductName(orderList, inquiryBox.Text) != null)
                        {
                            inquiryResultList          = OrderService.InquireProductName(orderList, inquiryBox.Text);
                            OrderDataSource.DataSource = inquiryResultList;
                            this.OrderDataSource.ResetBindings(false);
                        }
                        else
                        {
                            OrderDataSource.DataSource = null; ItemDataSource.DataSource = null;
                        }
                        break;
                    }
                }
            }
            else
            {
                warning.Text = "请选择查询方式";
            }
        }