示例#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;
                            }
                        }
                    }
                }
            }
        }