Exemple #1
0
        protected void gvCliente_SelectedIndexChanged(object sender, EventArgs e)
        {
            PessoaDAL dbPessoa = new PessoaDAL();

            Pessoa objPessoa = dbPessoa.ObterPessoaID(Convert.ToInt32(gvCliente.SelectedDataKey.Value), ref erro);

            Pessoa objPessoaPorTipo = new Pessoa();

            if (objPessoa != null && objPessoa.TipoPessoa == "F")
            {
                objPessoaPorTipo = dbPessoa.ObterPessoaFisicaPorID(Convert.ToInt32(gvCliente.SelectedDataKey.Value), ref erro);
                if (erro != "")
                {
                    Session.Add("danger", "Não foi possível Carregar o Cliente selecionado!" + erro);
                    return;
                }
            }
            else if (objPessoa != null && objPessoa.TipoPessoa == "J")
            {
                objPessoaPorTipo = dbPessoa.ObterPessoaJuridicaPorID(Convert.ToInt32(gvCliente.SelectedDataKey.Values), ref erro);
                if (erro != "")
                {
                    Session.Add("danger", "Não foi possível Carregar o Cliente selecionado!" + erro);
                    return;
                }
            }

            bindCliente(objPessoaPorTipo);
        }