Exemple #1
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            Telas.Cadastros.FrmCadFornecedor fcu = new Cadastros.FrmCadFornecedor();
            fcu.Text                = "Consultando o Fornecedor";
            fcu.txtFantasia.Text    = Convert.ToString(dataGridView1.CurrentRow.Cells[1].Value);
            fcu.txtRazao.Text       = Convert.ToString(dataGridView1.CurrentRow.Cells[2].Value);
            fcu.txtCnpj.Text        = Convert.ToString(dataGridView1.CurrentRow.Cells[3].Value);
            fcu.txtCep.Text         = Convert.ToString(dataGridView1.CurrentRow.Cells[4].Value);
            fcu.txtComplemento.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[5].Value);
            fcu.txtNumero.Text      = Convert.ToString(dataGridView1.CurrentRow.Cells[6].Value);
            fcu.txtTel.Text         = Convert.ToString(dataGridView1.CurrentRow.Cells[7].Value);
            fcu.txtEmail.Text       = Convert.ToString(dataGridView1.CurrentRow.Cells[8].Value);
            fcu.button1.Visible     = false;
            BLL.CEP Correios = new BLL.CEP();
            if (fcu.txtCep.Text.Length == 0)
            {
                MessageBox.Show("Por favor digite o cep");
                return;
            }
            Correios.NumeroCep = fcu.txtCep.Text;
            System.Data.SqlClient.SqlDataReader ddr;
            ddr = Correios.ConsultarCEP();
            ddr.Read();
            if (ddr.HasRows)
            {
                fcu.txtEndereco.Text = Convert.ToString(ddr["Logradouro"]);
                fcu.txtBairro.Text   = Convert.ToString(ddr["Bairro"]);
                fcu.txtCidade.Text   = Convert.ToString(ddr["Cidade"]);
                fcu.cbUF.Text        = Convert.ToString(ddr["UF"]);
            }
            else
            {
                MessageBox.Show("Cep incorreto");
                fcu.txtCep.Clear();
                fcu.txtCep.Focus();
            }



            fcu.txtFantasia.ReadOnly    = true;
            fcu.txtRazao.ReadOnly       = true;
            fcu.txtCnpj.ReadOnly        = true;
            fcu.txtCep.ReadOnly         = true;
            fcu.txtComplemento.ReadOnly = true;
            fcu.txtNumero.ReadOnly      = true;
            fcu.txtTel.ReadOnly         = true;
            fcu.txtEmail.ReadOnly       = true;
            fcu.txtBairro.ReadOnly      = true;
            fcu.txtCidade.ReadOnly      = true;
            fcu.txtEndereco.ReadOnly    = true;
            fcu.cbUF.Enabled            = false;
            fcu.button1.Visible         = false;

            fcu.Text = "Consultando Fornecedor";



            fcu.ShowDialog();
        }
 private void btnForn_Click(object sender, EventArgs e)
 {
     Telas.Cadastros.FrmCadFornecedor n = new Cadastros.FrmCadFornecedor();
     n.ShowDialog();
 }