private void btnPesquisaPessoa_Click(object sender, EventArgs e)
        {
            try
            {
                Views.Funcoes_Basicas.Pesquisas.Pesquisa_Pessoa objPessoa = new Funcoes_Basicas.Pesquisas.Pesquisa_Pessoa();

                objPessoa.ShowDialog();
                if (objPessoa.intCodigoPessoa > 0)
                {
                    Controller.PessoaController pessoaController = new Controller.PessoaController();
                    DataTable dtRetorno = pessoaController.retornaPessoaCod(objPessoa.intCodigoPessoa.ToString());

                    if (dtRetorno != null && dtRetorno.Rows.Count > 0)
                    {
                        DataRow dr = dtRetorno.Rows[0];
                        ttbCodigo.Text = dr["codpessoa"].ToString();
                        ttbPessoa.Text = dr["pes_nome"].ToString();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            _inicializa(false);
            int cod = 0;

            Views.Funcoes_Basicas.Pesquisas.Pesquisa_Pessoa pesquisa_Pessoa = new Funcoes_Basicas.Pesquisas.Pesquisa_Pessoa();
            pesquisa_Pessoa.ShowDialog();
            cod = pesquisa_Pessoa.intCodigoPessoa;
            if (cod > 0)
            {
                DataTable dtPessoa = pc.retornaPessoaCod(cod + "");
                if (dtPessoa != null && dtPessoa.Rows.Count > 0)
                {
                    DataRow drPessoa = dtPessoa.Rows[0];
                    ttbCodigo.Text = drPessoa["codpessoa"].ToString();

                    if (drPessoa["pes_tipopessoa"].ToString().Equals("Física"))
                    {
                        rbFisica.Checked   = true;
                        rbJuridica.Checked = false;
                    }
                    else
                    {
                        rbFisica.Checked   = false;
                        rbJuridica.Checked = true;
                    }
                    if (Convert.ToBoolean(drPessoa["pes_statuspessoa"].ToString()))
                    {
                        rbAtivo.Checked   = true;
                        rbInativo.Checked = false;
                    }
                    else
                    {
                        rbAtivo.Checked   = false;
                        rbInativo.Checked = true;
                    }
                    if (Convert.ToBoolean(drPessoa["pes_fiado"].ToString()))
                    {
                        rbPagaNao.Checked = false;
                        rbPagaSim.Checked = true;
                    }
                    else
                    {
                        rbPagaNao.Checked = true;
                        rbPagaSim.Checked = false;
                    }
                    ttbNome.Text      = drPessoa["pes_nome"].ToString();
                    maskTelefone.Text = drPessoa["pes_fone"].ToString();
                    maskCelular.Text  = drPessoa["pes_cel"].ToString();
                    DataTable dtEndereco = pc.retornaEndereco(cod);
                    if (dtEndereco != null && dtEndereco.Rows.Count > 0)
                    {
                        DataRow drEndereco = dtEndereco.Rows[0];
                        ttbLogradouro.Text      = drEndereco["end_logradouro"].ToString();
                        ttbNumero.Text          = drEndereco["end_numero"].ToString();
                        ttbBairro.Text          = drEndereco["end_bairro"].ToString();
                        ttbComplemento.Text     = drEndereco["edn_complemento"].ToString();
                        mtbCEP.Text             = drEndereco["end_cep"].ToString();
                        cbbEstado.SelectedIndex = Convert.ToInt32(drEndereco["coduf"].ToString()) - 1;
                        DataTable dtCidade = pc.retornaCidCodigo(Convert.ToInt32(drEndereco["codcidade"].ToString()));
                        DataRow   drCidade = dtCidade.Rows[0];
                        cbbCidade.SelectedValue = Convert.ToInt32(drCidade["codcidade"].ToString());
                    }
                    if (rbFisica.Checked)
                    {
                        ttbRazao.Enabled = false;
                        mskCNPJ.Enabled  = false;
                        DataTable dtFisica = pc.retornaPessoaFisicaCod(cod);
                        if (dtFisica != null && dtFisica.Rows.Count > 0)
                        {
                            DataRow drFisica = dtFisica.Rows[0];
                            mskCPF.Text             = drFisica["fis_cpf"].ToString();
                            ttbRg.Text              = drFisica["fis_rg"].ToString();
                            dtpDataNascimento.Value = Convert.ToDateTime(drFisica["fis_datanascimento"].ToString());
                        }
                    }
                    else
                    {
                        mskCPF.Enabled            = false;
                        ttbRg.Enabled             = false;
                        dtpDataNascimento.Enabled = false;
                        DataTable dtJuridica = pc.retornaPessoaJuridica(drPessoa["pes_nome"].ToString());
                        if (dtJuridica != null && dtJuridica.Rows.Count > 0)
                        {
                            DataRow drJuridica = dtJuridica.Rows[0];
                            ttbRazao.Text = drJuridica["jur_razaosocial"].ToString();
                            mskCNPJ.Text  = drJuridica["jur_cnpj"].ToString();
                        }
                    }
                    ttbObservação.Text = drPessoa["pes_obs"].ToString();
                    ttbEmail.Text      = drPessoa["pes_email"].ToString();
                    btnAlterar.Enabled = true;
                    btnExcluir.Enabled = true;
                    btnNovo.Enabled    = false;
                }
            }
        }