Пример #1
0
        private void pesquisaMobCep_Click(object sender, EventArgs e)
        {
            textMobResultado.Clear();

            string requiString;

            this.inputUser = textMobEndCep.Text.ToString();
            if (!String.IsNullOrEmpty(inputUser))
            {
                requisicao.UrlCorreios(inputUser);
            }
            else
            {
                textMobResultado.Font      = new Font("Arial", 18, FontStyle.Bold);
                textMobResultado.ForeColor = System.Drawing.Color.DarkRed;
                textMobResultado.AppendText("Preencha o campo de pesquisa");
                return;
            }
            var requis = requisicao.ObterCorreios();

            if (!requis.Dados.Any())
            {
                textMobResultado.Font      = new Font("Arial", 18, FontStyle.Bold);
                textMobResultado.ForeColor = System.Drawing.Color.DarkRed;
                textMobResultado.AppendText("Endereço não encontrado");
                return;
            }
            textMobResultado.Font      = new Font("Microsoft Sans Serif", 12, FontStyle.Regular);
            textMobResultado.ForeColor = System.Drawing.Color.Black;
            foreach (var requi in requis.Dados)
            {
                requiString = $"CEP: {requi.Cep} \r\nLogradouro: {requi.LogradouroDNEC} \r\nBairro: {requi.Bairro} \r\nLocalidade: {requi.Localidade} \r\nUF: {requi.Uf} \r\n-\r\n";
                textMobResultado.AppendText(requiString);
            }
        }