示例#1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            try
            {
                switch (toolStripComboBox1.SelectedIndex)
                {
                case 0:
                    if (Double.TryParse(toolStripTextBox1.Text, out double id))
                    {
                        bindingSourceOrder.DataSource = OrderService.QueryByID(id);
                    }
                    else
                    {
                        throw new ApplicationException("输入ID格式错误");
                    }
                    BindingOrderRefresh(false);
                    break;

                case 1:
                    bindingSourceOrder.DataSource = OrderService.QueryByName(toolStripTextBox1.Text);
                    BindingOrderRefresh(false);
                    break;

                default:
                    break;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }