private void txtendcep_Leave(object sender, EventArgs e) { Conexao.Active(true); if (txtendcep.Text != "") { string strConsulta = "SELECT E.ENDENDE, B.BAINOME," + " M.MUNNOME, ES.ESTUF, P.PAINOME" + " FROM ENDERECO E" + " INNER JOIN BAIRRO B ON B.BAICODI = E.BAICODI" + " INNER JOIN MUNICIPIO M ON M.MUNCODI = B.MUNCODI" + " INNER JOIN ESTADO ES ON ES.ESTCODI = M.ESTCODI" + " INNER JOIN PAIS P ON P.PAICODI = ES.PAICODI" + " WHERE E.ENDCEP = " + txtendcep.Text; try { FbCommand cmd = new FbCommand(strConsulta, Conexao.FbCnn); FbDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { //ConsultaFuncionario(dr); lblendereco.Text = dr["ENDENDE"].ToString(); lblbairro.Text = dr["BAINOME"].ToString(); lblmunicipio.Text = dr["MUNNOME"].ToString(); lbluf.Text = dr["ESTUF"].ToString(); lblpais.Text = dr["PAINOME"].ToString(); txtfunnume.Focus(); btnincluir.Enabled = false; } else { if ((MessageBox.Show("Registro não encontrado. \n Deseja cadastrar?", "Cadastrar de CEP", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)) { lblendereco.Text = " "; lblbairro.Text = " "; lblmunicipio.Text = " "; lbluf.Text = " "; lblpais.Text = " "; txtendcep.Text = " "; frmendereco end = new frmendereco(); end.ShowDialog(); //limpar(); } /*else * { * btngravar.Enabled = false; * btnexcluir.Enabled = false; * txtfunnome.Text = ""; * txtfunnome.Focus(); * }*/ } } catch (Exception ex) { MessageBox.Show(ex.Message); } Conexao.Active(false); } }
private void endereçoToolStripMenuItem_Click(object sender, EventArgs e) { frmendereco endereco = new frmendereco(); endereco.ShowDialog(); }