예제 #1
0
        private void buttonPesquisar_Click_1(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxPesquisar.Text))
            {
                MessageBox.Show("Digite o ID ou Nome");

                if (string.IsNullOrEmpty(textBoxPesquisar.Text))
                {
                    textBoxPesquisar.Focus();
                }
            }
            else
            if (radioButtonId.Checked == true)
            {
                ClienteNegocios clienteNegocios = new ClienteNegocios();
                ClienteColecao  clienteColecao  = new ClienteColecao();
                clienteColecao = clienteNegocios.ConsultarPorId(int.Parse(textBoxPesquisar.Text));

                dataGridPrincipal.DataSource = null;
                dataGridPrincipal.DataSource = clienteColecao;

                dataGridPrincipal.Update();
                dataGridPrincipal.Refresh();
            }
            else

            if (radioButtonNome.Checked == true)
            {
                ClienteNegocios clienteNegocios = new ClienteNegocios();
                ClienteColecao  clienteColecao  = new ClienteColecao();
                clienteColecao = clienteNegocios.ConsultarPorNome(textBoxPesquisar.Text);

                dataGridPrincipal.DataSource = null;
                dataGridPrincipal.DataSource = clienteColecao;

                dataGridPrincipal.Update();
                dataGridPrincipal.Refresh();
            }

            buttonAtualizar.Enabled = true;
        }