Exemplo n.º 1
0
        private void Txt_CEP_Leave(object sender, EventArgs e)
        {
            string vCep = Txt_CEP.Text;

            if (vCep != "")
            {
                if (vCep.Length == 8)
                {
                    if (Information.IsNumeric(vCep))
                    {
                        var      vJson = Cls_Uteis.GeraJSONCEP(vCep);
                        Cep.Unit CEP   = new Cep.Unit();
                        CEP = Cep.DesSerializedClassUnit(vJson);
                        Txt_Logradouro.Text = CEP.logradouro;
                        Txt_Bairro.Text     = CEP.bairro;
                        Txt_Cidade.Text     = CEP.localidade;

                        Cmb_Estados.SelectedIndex = -1;
                        for (int i = 0; i <= Cmb_Estados.Items.Count - 1; i++)
                        {
                            var vPos = Strings.InStr(Cmb_Estados.Items[i].ToString(), "(" + CEP.uf + ")");
                            if (vPos > 0)
                            {
                                Cmb_Estados.SelectedIndex = i;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void txtCEP_Leave(object sender, EventArgs e)
 {
     if (txtCEP.Text != "")
     {
         if (txtCEP.Text.Length == 8)
         {
             if (Information.IsNumeric(txtCEP.Text))
             {
                 var vJson = Cls_Uteis.GeraJSONCEP(txtCEP.Text);
                 var CEP   = new Cep.Unit();
                 CEP = Cep.DesSerializedClassUnit(vJson);
                 txtLogradouro.Text       = CEP.logradouro;
                 txtCidade.Text           = CEP.localidade;
                 txtComplemento.Text      = CEP.complemento;
                 txtBairro.Text           = CEP.bairro;
                 cbbEstados.SelectedIndex = -1;
                 for (int i = 0; i <= cbbEstados.Items.Count - 1; i++)
                 {
                     var vPos = Strings.InStr(cbbEstados.Items[i].ToString(), $"({CEP.uf})");
                     if (vPos > 0)
                     {
                         cbbEstados.SelectedIndex = i;
                         break;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        private void MskTxtBox_CEP_Leave(object sender, EventArgs e)
        {
            string vCep = MskTxtBox_CEP.Text.Replace("-", "");

            if (vCep != "")
            {
                if (vCep.Length == 8)
                {
                    if (Information.IsNumeric(vCep))
                    {
                        var      vJson = Uteis.GeraJSONCEP(vCep);
                        Cep.Unit CEP   = new Cep.Unit();
                        CEP = Cep.DesSerializedClassUnit(vJson);

                        TxtBox_Logradouro.Text = CEP.logradouro;
                        TxtBox_Bairro.Text     = CEP.bairro;
                        TxtBox_Cidade.Text     = CEP.localidade;

                        CmbBox_UF.SelectedItem = CEP.uf;
                    }
                }
            }
        }