private void btnSalvar_Click(object sender, EventArgs e)
        {
            novoAluno = new alunos();

            try
            {
                if (txtCodigo.Text == "0")
                {
                    novoAluno.Salvar(txtNome.Text, txtEndereco.Text, txtBairro.Text, txtCidade.Text, txtCep.Text, txtCpf.Text, txtTelefone.Text, txtCelular.Text, txtObservacao.Text, txtSexo.Text);
                    MessageBox.Show("Salvo aluno com sucesso!!");
                    this.Close();
                }
                else
                {
                    novoAluno.Update(Convert.ToInt32(txtCodigo.Text), txtNome.Text, txtEndereco.Text, txtBairro.Text, txtCidade.Text, txtCep.Text, txtCpf.Text, txtTelefone.Text, txtCelular.Text, txtObservacao.Text, txtSexo.Text);
                    MessageBox.Show("Alterado com Sucesso!!");
                    limpar();
                    this.Close();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void listarAlunos()
 {
     try
     {
         novosAlunos          = new alunos();
         dgvAlunos.DataSource = novosAlunos.Listar();
         estilo();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (txtCodigo.Text == "0")
     {
         MessageBox.Show("Impossivel Excluir");
     }
     else
     {
         novoAluno = new alunos();
         if (MessageBox.Show("Deseja realmente excluir esse aluno??", "Excluir", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
         {
             novoAluno.Delete(Convert.ToInt32(txtCodigo.Text));
             MessageBox.Show("Exclusão feita com sucesso!");
             limpar();
             this.Close();
         }
     }
 }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            novosAlunos = new alunos();
            DataTable dadosTabela = new DataTable();

            try
            {
                if (rbnNome.Checked == true)
                {
                    dgvAlunos.DataSource = novosAlunos.searchNome(txtPesquisaAluno.Text);
                    estilo();
                }
                else
                {
                    dgvAlunos.DataSource = novosAlunos.searchCpf(txtPesquisaAluno.Text);
                    estilo();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }