protected void AtualizarPessoa(object sender, EventArgs e)
        {
            try
            {
                Pessoa p = new Pessoa();
                p.Residencia = new Endereco();

                p.IdPessoa = Convert.ToInt32(txtIdPessoa.Text);
                p.Nome     = txtNome.Text;
                p.Email    = txtEmail.Text;
                p.Residencia.Logradouro = txtLogradouro.Text;
                p.Residencia.Cidade     = txtCidade.Text;
                p.Residencia.Estado     = txtEstado.Text;

                PessoaDal d = new PessoaDal();
                d.Atualizar(p);

                painel.Visible     = true;
                lblMensagemOk.Text = "Cadastro atualizado com sucesso !";
            }
            catch
            {
                lblMensagemFail.Text = "Erro ao tentar atualizar p cadastro !";
            }
        }
        protected void btnAtualizarCliente(object sender, EventArgs e)
        {
            try
            {
                Pessoa p = new Pessoa();
                p.Codigo   = Convert.ToInt32(txtCodigo.Text);
                p.Nome     = Convert.ToString(txtNome.Text);
                p.Endereco = Convert.ToString(txtEndereco.Text);
                p.Email    = Convert.ToString(txtEmail.Text);

                PessoaDal d = new PessoaDal();
                d.Atualizar(p);
                lblMensagem.Visible = true;
                lblMensagem.Text    = "Cliente " + p.Nome + " Atualizado com Sucesso!!";

                txtCodigo.Text   = string.Empty;
                txtNome.Text     = string.Empty;
                txtEndereco.Text = string.Empty;
                txtEmail.Text    = string.Empty;
            }
            catch (Exception ex)
            {
                lblMensagemErro.Visible = true;
                lblMensagemErro.Text    = ex.Message;
            }
        }
Example #3
0
        protected void btnCadastrarCliente(object sender, EventArgs e)
        {
            try
            {
                Pessoa p = new Pessoa();
                p.Nome     = txtNome.Text;
                p.Endereco = txtEndereco.Text;
                p.Email    = txtEmail.Text;

                PessoaDal d = new PessoaDal();

                d.Gravar(p);// gravando

                lblMensagem.Visible = true;
                lblMensagem.Text    = "Cliente " + p.Nome + " Cadastrado com Sucesso!";
                txtNome.Text        = string.Empty;
                txtEndereco.Text    = string.Empty;
                txtEmail.Text       = string.Empty;
            }
            catch (Exception ex)
            {
                lblMensagem.Visible = true;
                lblMensagem.Text    = ex.Message;
            }
        }
Example #4
0
        protected void CadastrarCliente(object sender, EventArgs e)
        {
            try
            {
                Pessoa p = new Pessoa();
                p.Residencia = new Endereco();

                p.Nome                  = txtNome.Text;
                p.Email                 = txtEmail.Text;
                p.DataHoraCadastro      = DateTime.Now;
                p.Residencia.Logradouro = txtLogradouro.Text;
                p.Residencia.Cidade     = txtCidade.Text;
                p.Residencia.Estado     = txtEstado.Text;

                PessoaDal d = new PessoaDal();
                d.Salvar(p);

                txtNome.Text       = null;
                txtEmail.Text      = null;
                txtLogradouro.Text = null;
                txtCidade.Text     = null;
                txtEstado.Text     = null;

                lblMensagemOk.Text = "Cliente cadastrado com sucesso !";
            }
            catch
            {
                lblMensagemFail.Text = "Erro ao tentar cadastrar cliente !";
            }
        }
Example #5
0
        protected void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                int Codigo = Convert.ToInt32(txtCodigo.Text);

                Pessoa p = new Pessoa();

                p.Codigo = Codigo;

                PessoaDal d = new PessoaDal();

                d.Excluir(p.Codigo);


                lblMessagem.Text = " Cliente excluido com sucesso!! ";

                txtCodigo.Text   = string.Empty;
                txtNome.Text     = string.Empty;
                txtEndereco.Text = string.Empty;
                txtEndereco.Text = string.Empty;
            }
            catch (Exception ex)
            {
                lblMessagem.Text = ex.Message;
            }
        }
        protected void btnPesquisarCliente(object sender, EventArgs e)
        {
            try
            {
                int       Codigo = Convert.ToInt32(txtCodigo.Text);
                PessoaDal d      = new PessoaDal();
                Pessoa    p      = d.PequisarPorCodigo(Codigo);

                if (p != null)
                {
                    pnlDados.Visible = true;
                    txtNome.Text     = p.Nome;
                    txtEndereco.Text = p.Endereco;
                    txtEmail.Text    = p.Email;
                }
                else
                {
                    lblMensagemErro.Text = " Cliente não Encontrado!";
                    txtCodigo.Text       = string.Empty;
                }
            }
            catch (Exception ex)
            {
                lblMensagemErro.Text = ex.Message;
            }
        }
        protected void ObterPorId(object sender, EventArgs e)
        {
            try
            {
                int       idPessoa = Convert.ToInt32(txtIdPessoa.Text);
                PessoaDal d        = new PessoaDal();
                Pessoa    p        = d.BuscarPorId(idPessoa);

                if (p != null)
                {
                    txtNome.Text       = p.Nome;
                    txtEmail.Text      = p.Email;
                    txtLogradouro.Text = p.Residencia.Logradouro;
                    txtCidade.Text     = p.Residencia.Cidade;
                    txtEstado.Text     = p.Residencia.Estado;

                    painel.Visible   = true;
                    lblMensagem.Text = string.Empty;
                }
                else
                {
                    lblMensagem.Text = "Pessoa não encontrada !";
                }
            }
            catch
            {
                lblMensagem.Text = "Erro ao buscar pessoa !";
            }
        }
        public List <Pessoa> buscarPorNome(string pesquisa)
        {
            List <Pessoa> resultadosList = new List <Pessoa>();

            foreach (Pessoa p in PessoaDal.listarPessoas())
            {
                if (p.Nome.ToLower().Contains(pesquisa.ToLower()))
                {
                    resultadosList.Add(p);
                }
            }
            return(resultadosList);
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                PessoaDal d = new PessoaDal();

                gridPessoas.DataSource = d.ListarTodas();
                gridPessoas.DataBind();
            }
            catch
            {
                lblMensagem.Text = "Erro ao consultar pessoa";
            }
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                PessoaDal d = new PessoaDal();

                gridClientes.DataSource = d.Listar(); //popular o grid view
                gridClientes.DataBind();              //exibir o conteudo da grid
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMensagem.Visible = false;
            try
            {
                PessoaDal p = new PessoaDal();

                gridClientes.DataSource = p.Listar(); //Popular
                gridClientes.DataBind();              //Exibir
            }
            catch (Exception ex)
            {
                lblMensagem.Visible = true;
                lblMensagem.Text    = "Error ao Consultar Cliente " + ex.Message;
            }
        }
        protected void ExcluirPessoa(object sender, EventArgs e)
        {
            try
            {
                int       idPessoa = Convert.ToInt32(txtIdPessoa.Text);
                PessoaDal d        = new PessoaDal();
                d.Excluir(idPessoa);

                painel.Visible   = false;
                lblMensagem.Text = "Pessoa excluida com sucesso !";
            }
            catch
            {
                painel.Visible       = true;
                lblMensagemFail.Text = "Erro ao tentar excluir pessoa !";
            }
        }
        //GENERICS
        public Pessoa buscarPorId(int id)
        {
            Pessoa resultado = new Pessoa();

            foreach (Pessoa p in PessoaDal.listarPessoas())
            {
                if (p.Id == id)
                {
                    resultado.Id              = id;
                    resultado.Nome            = p.Nome;
                    resultado.SobreNome       = p.SobreNome;
                    resultado.DataAniversario = p.DataAniversario;
                    break;
                }
            }
            return(resultado);
        }
 public ActionResult Delete(int id, Pessoa pessoa)
 {
     try
     {
         foreach (Pessoa pesquisa in PessoaDal.listarPessoas())
         {
             if (pesquisa.Id == id)
             {
                 PessoaDal.removePessoa(pesquisa);
                 break;
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        protected void btnExcluirCliente(object sender, EventArgs e)
        {
            try
            {
                int       Codigo = Convert.ToInt32(txtCodigo.Text);
                Pessoa    p      = new Pessoa();
                PessoaDal d      = new PessoaDal();

                d.Excluir(Codigo);
                lblMensagem.Visible = true;
                lblMensagem.Text    = "Cliente Excluido com Sucesso!";

                txtCodigo.Text   = string.Empty;
                txtNome.Text     = string.Empty;
                txtEndereco.Text = string.Empty;
                txtEmail.Text    = string.Empty;
            }
            catch (Exception ex)
            {
                lblMensagemErro.Text = ex.Message;
            }
        }
 public ActionResult Edit(int id, Pessoa pessoa)
 {
     try
     {
         Pessoa p = pessoa;
         foreach (Pessoa pesquisa in PessoaDal.listarPessoas())
         {
             if (pesquisa.Id == id)
             {
                 pesquisa.Nome            = p.Nome;
                 pesquisa.SobreNome       = p.SobreNome;
                 pesquisa.DataAniversario = p.DataAniversario;
                 break;
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(Pessoa pessoa)
 {
     pessoa.Id = this.createId();
     PessoaDal.addPessoa(pessoa);
     return(RedirectToAction("Index"));
 }
Example #18
0
        public Pessoa LerPessoa(long id)
        {
            PessoaDal _DaoPessoa = new PessoaDal();

            return(_DaoPessoa.LerPessoa(id));
        }
Example #19
0
        public void Deletar(long id)
        {
            PessoaDal _DaoPessoa = new PessoaDal();

            _DaoPessoa.Deletar(id);
        }
Example #20
0
        public List <Pessoa> ListPessoa()
        {
            PessoaDal _DaoPessoa = new PessoaDal();

            return(_DaoPessoa.ListPessoa());
        }
Example #21
0
        public void Atualizar(Pessoa pessoa)
        {
            PessoaDal _DaoPessoa = new PessoaDal();

            _DaoPessoa.Atualizar(pessoa);
        }
Example #22
0
        public long Incluir(Pessoa pessoa)
        {
            PessoaDal _DaoPessoa = new PessoaDal();

            return(_DaoPessoa.Incluir(pessoa));
        }
Example #23
0
 public PessoaBL()
 {
     this.pessoaDal = new PessoaDal();
 }
        //LISTA
        public ActionResult Index()
        {
            List <Pessoa> pessoaList = PessoaDal.listarPessoas();

            return(View(pessoaList));
        }