private void cmb_pesquisacad_SelectedIndexChanged(object sender, EventArgs e) { Cls_Cadastro pesquisa = new Cls_Cadastro(); atualizadgv(); pesquisa.Pesquisa = cmb_pesquisacad.Text; if (pesquisa.pesquisar(tipo)) { txt_nome.Text = pesquisa.Nome; msk_rg.Text = pesquisa.Rg; msk_telefone.Text = pesquisa.Telefone; txt_rua.Text = pesquisa.Rua; msk_numero.Text = pesquisa.Numero; txt_bairro.Text = pesquisa.Bairro; txt_cidade.Text = pesquisa.Cidade; txt_estado.Text = pesquisa.Estado; msk_cep.Text = pesquisa.Cep; cmb_ativo.Text = pesquisa.Ativo; txt_usuario.Text = pesquisa.Login; txt_senha.Text = pesquisa.Senha; cmb_tipo.Text = pesquisa.Tipo; } }
private void cmb_pesquisa_cartao_SelectedIndexChanged(object sender, EventArgs e) { Cls_Cadastro pesquisa = new Cls_Cadastro(); pesquisa.Criterio = cmb_pesquisa_cartao.Text; if (pesquisa.pesquisar()) { txt_nome.Text = pesquisa.Nome; msk_rg.Text = pesquisa.Rg; } }
private void btn_pesquisa_Click(object sender, EventArgs e) { Cls_Cadastro pesquisa = new Cls_Cadastro(); if (msk_pesquisa.Text == "") { MessageBox.Show("Campo vazio, preencha!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { pesquisa.Criterio = msk_pesquisa.Text; if (pesquisa.pesquisar()) { txt_nome.Text = pesquisa.Nome; msk_rg.Text = pesquisa.Rg; } else { MessageBox.Show("Usuário não encontrado, ou desativado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btn_pesquisa_Click(object sender, EventArgs e) { Cls_Cadastro pesquisa = new Cls_Cadastro(); NpgsqlConnection pgsqlConnection = null; try { Cls_Conexao objconexao = new Cls_Conexao(); pgsqlConnection = objconexao.getConexao(); pgsqlConnection.Open(); string datagrid = "select usuarioid, nome, rg, telefone, rua, numero, bairro, cidade, estado, cep, login.ativo, login, senha, tipo from usuario, login where usuarioid = fk_usuario;"; NpgsqlCommand cmd = new NpgsqlCommand(datagrid, pgsqlConnection); NpgsqlDataReader dgv = cmd.ExecuteReader(); if (dgv.HasRows) { DataTable dt = new DataTable(); dt.Load(dgv); dgv_usuarios.DataSource = dt; } } finally { pgsqlConnection.Close(); } if (cmb_criterio.Text == "") { MessageBox.Show("Selecione um critério para pesquisa!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); cmb_criterio.Focus(); txt_nome.Text = ""; msk_rg.Text = ""; msk_telefone.Text = ""; txt_rua.Text = ""; msk_numero.Text = ""; txt_bairro.Text = ""; txt_cidade.Text = ""; txt_estado.Text = ""; msk_cep.Text = ""; cmb_ativo.Text = ""; txt_usuario.Text = ""; txt_senha.Text = ""; cmb_tipo.Text = ""; } else if (msk_pesquisa.Text == "") { MessageBox.Show("Preencha o campo de pesquisa!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); msk_pesquisa.Focus(); txt_nome.Text = ""; msk_rg.Text = ""; msk_telefone.Text = ""; txt_rua.Text = ""; msk_numero.Text = ""; txt_bairro.Text = ""; txt_cidade.Text = ""; txt_estado.Text = ""; msk_cep.Text = ""; cmb_ativo.Text = ""; txt_usuario.Text = ""; txt_senha.Text = ""; cmb_tipo.Text = ""; } else if (msk_pesquisa.Text == "( ) -") { MessageBox.Show("Preencha o campo de pesquisa!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); msk_pesquisa.Focus(); txt_nome.Text = ""; msk_rg.Text = ""; msk_telefone.Text = ""; txt_rua.Text = ""; msk_numero.Text = ""; txt_bairro.Text = ""; txt_cidade.Text = ""; txt_estado.Text = ""; msk_cep.Text = ""; cmb_ativo.Text = ""; txt_usuario.Text = ""; txt_senha.Text = ""; cmb_tipo.Text = ""; } else if (msk_pesquisa.Text == " . . -") { MessageBox.Show("Preencha o campo de pesquisa!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); msk_pesquisa.Focus(); txt_nome.Text = ""; msk_rg.Text = ""; msk_telefone.Text = ""; txt_rua.Text = ""; msk_numero.Text = ""; txt_bairro.Text = ""; txt_cidade.Text = ""; txt_estado.Text = ""; msk_cep.Text = ""; cmb_ativo.Text = ""; txt_usuario.Text = ""; txt_senha.Text = ""; cmb_tipo.Text = ""; } else { pesquisa.Criterio = cmb_criterio.Text; pesquisa.Pesquisa = msk_pesquisa.Text; if (pesquisa.pesquisar(tipo)) { txt_nome.Text = pesquisa.Nome; msk_rg.Text = pesquisa.Rg; msk_telefone.Text = pesquisa.Telefone; txt_rua.Text = pesquisa.Rua; msk_numero.Text = pesquisa.Numero; txt_bairro.Text = pesquisa.Bairro; txt_cidade.Text = pesquisa.Cidade; txt_estado.Text = pesquisa.Estado; msk_cep.Text = pesquisa.Cep; cmb_ativo.Text = pesquisa.Ativo; txt_usuario.Text = pesquisa.Login; txt_senha.Text = pesquisa.Senha; cmb_tipo.Text = pesquisa.Tipo; } } }