private void EditarFornecedor(object o, EventArgs e)

        {
            Telas.Editar.FrmEdicaoFornecedor fo = new Editar.FrmEdicaoFornecedor();
            fo.txtCodigo.Text      = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value);
            fo.txtFantasia.Text    = Convert.ToString(dataGridView1.CurrentRow.Cells[1].Value);
            fo.txtRazao.Text       = Convert.ToString(dataGridView1.CurrentRow.Cells[2].Value);
            fo.txtCnpj.Text        = Convert.ToString(dataGridView1.CurrentRow.Cells[3].Value);
            fo.txtCep.Text         = Convert.ToString(dataGridView1.CurrentRow.Cells[4].Value);
            fo.txtComplemento.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[5].Value);
            fo.txtNumero.Text      = Convert.ToString(dataGridView1.CurrentRow.Cells[6].Value);
            fo.txtTel.Text         = Convert.ToString(dataGridView1.CurrentRow.Cells[7].Value);
            fo.txtEmail.Text       = Convert.ToString(dataGridView1.CurrentRow.Cells[8].Value);
            fo.BuscarEndereco(o, e);
            this.Close();
            fo.ShowDialog();
        }
Esempio n. 2
0
        private void EditarFornecedor(object o, EventArgs e)

        {
            Telas.Editar.FrmEdicaoFornecedor fo = new Editar.FrmEdicaoFornecedor();
            fo.txtCodigo.Text      = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value);
            fo.txtFantasia.Text    = Convert.ToString(dataGridView1.CurrentRow.Cells[1].Value);
            fo.txtRazao.Text       = Convert.ToString(dataGridView1.CurrentRow.Cells[2].Value);
            fo.txtCnpj.Text        = Convert.ToString(dataGridView1.CurrentRow.Cells[3].Value);
            fo.txtCep.Text         = Convert.ToString(dataGridView1.CurrentRow.Cells[4].Value);
            fo.txtComplemento.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[5].Value);
            fo.txtNumero.Text      = Convert.ToString(dataGridView1.CurrentRow.Cells[6].Value);
            fo.txtTel.Text         = Convert.ToString(dataGridView1.CurrentRow.Cells[7].Value);
            fo.txtEmail.Text       = Convert.ToString(dataGridView1.CurrentRow.Cells[8].Value);



            BLL.CEP Correios = new BLL.CEP();
            Correios.NumeroCep = fo.txtCep.Text;
            System.Data.SqlClient.SqlDataReader ddr;
            ddr = Correios.ConsultarCEP();
            ddr.Read();


            if (ddr.HasRows)
            {
                fo.txtEndereco.Text = Convert.ToString(ddr["Descricao"]);
                fo.txtBairro.Text   = Convert.ToString(ddr["Bairro"]);
                fo.txtCidade.Text   = Convert.ToString(ddr["Cidade"]);
                fo.cbUF.Text        = Convert.ToString(ddr["UF"]);
            }
            else
            {
                MessageBox.Show("Cep incorreto");
                fo.txtCep.Clear();
                fo.txtCep.Focus();
            }

            this.Close();
            fo.ShowDialog();
        }