///PROCURAR private void btnProcurar_Click(object sender, EventArgs e) { if (cmbPesquisa.SelectedIndex == 0) { int var = Convert.ToInt32(txtPesquisa.Text); CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient(); oProxy.Open(); if (oProxy.Selecionar(var) != null) { ALUNO oAluno = oProxy.Selecionar(var); txtNome.Text = oAluno.NOME; txtSobreNome.Text = oAluno.SOBRENOME; dtpNasc.Value = oAluno.NASC; txtCPF.Text = oAluno.CPF; txtEnd.Text = oAluno.ENDERECO; txtBairro.Text = oAluno.BAIRRO; txtCidade.Text = oAluno.CIDADE; cmbUF.SelectedItem = oAluno.UF; cmbPais.SelectedItem = oAluno.PAIS; txtCEP.Text = oAluno.CEP; txtTelRes.Text = oAluno.TEL_RES; txtTelCel.Text = oAluno.TEL_CEL; txtEmail.Text = oAluno.EMAIL; txtID.Text = oAluno.ID_ALUNO.ToString(); DesabilitaCampos(); btnAlterar.Enabled = true; btnDeletar.Enabled = true; btnSalvar.Enabled = false; } else { MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient(); oProxy.Open(); if (oProxy.SelecionarNome(txtPesquisa.Text) != null) { ALUNO oAluno = oProxy.SelecionarNome(txtPesquisa.Text); txtNome.Text = oAluno.NOME; txtSobreNome.Text = oAluno.SOBRENOME; dtpNasc.Value = oAluno.NASC; txtCPF.Text = oAluno.CPF; txtEnd.Text = oAluno.ENDERECO; txtBairro.Text = oAluno.BAIRRO; txtCidade.Text = oAluno.CIDADE; cmbUF.SelectedItem = oAluno.UF; cmbPais.SelectedItem = oAluno.PAIS; txtCEP.Text = oAluno.CEP; txtTelRes.Text = oAluno.TEL_RES; txtTelCel.Text = oAluno.TEL_CEL; txtEmail.Text = oAluno.EMAIL; txtID.Text = oAluno.ID_ALUNO.ToString(); DesabilitaCampos(); btnAlterar.Enabled = true; btnDeletar.Enabled = true; btnSalvar.Enabled = false; } else { MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnProcurar_Click(object sender, EventArgs e) { if (cmbPesquisa.SelectedIndex == 0) { dtgAlunos.DataSource = AlunoMetod.SelecionarTodos(); } else if (cmbPesquisa.SelectedIndex == 1) { int var = Convert.ToInt32(txtPesquisa.Text); CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient(); oProxy.Open(); if (oProxy.Selecionar(var) != null) { List <ALUNO> oAlunos = new List <ALUNO>(); oAlunos.Add(oProxy.Selecionar(var)); dtgAlunos.DataSource = oAlunos; dtgAlunos.Refresh(); } else { MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (cmbPesquisa.SelectedIndex == 2) { CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient(); oProxy.Open(); if (oProxy.SelecionarNome(txtPesquisa.Text) != null) { List <ALUNO> oAlunos = new List <ALUNO>(); oAlunos.Add(oProxy.SelecionarNome(txtPesquisa.Text)); dtgAlunos.DataSource = oAlunos; dtgAlunos.Refresh(); } else { MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (cmbPesquisa.SelectedIndex == 3) { CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient(); oProxy.Open(); if (oProxy.SelecionarCPF(txtPesquisa.Text) != null) { List <ALUNO> oAlunos = new List <ALUNO>(); oAlunos.Add(oProxy.SelecionarCPF(txtPesquisa.Text)); dtgAlunos.DataSource = oAlunos; dtgAlunos.Refresh(); } else { MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }