Esempio n. 1
0
        private void btnSearchCEP_Click(object sender, EventArgs e)
        {
            try
            {
                CorreioModel    correio  = new CorreioModel();
                CorreioResponse response = correio.Endereco(txtCEP.Text);

                txtLogradouro.Text  = response.Logradouro;
                txtComplemento.Text = response.Complemento;
                txtBairro.Text      = response.Bairro;
                txtUF.Text          = response.UF;
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Black Fit LTDA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("'nm_Usuario'"))
                {
                    MessageBox.Show("Este nome de usuário já está em uso.", "Black Fit LTDA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show($"Ocorreu um erro não identificado: {ex.Message}", "Black Fit LTDA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 2
0
        private void btnSearchCEP_Click(object sender, EventArgs e)
        {
            try
            {
                CorreioModel    correio  = new CorreioModel();
                CorreioResponse response = correio.Endereco(txtCEP.Text);

                txtLogradouro.Text  = response.Logradouro;
                txtComplemento.Text = response.Complemento;
                txtBairro.Text      = response.Bairro;
                txtUF.Text          = response.UF;
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Black Fit LTDA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MessageBox.Show("Ocorreu um erro não identificado.", "Black Fit LTDA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }