public void Salvar()
 {
     try
     {
         if (iId == 0)
         {
             this.iId = aClienteDAO.Incluir(this);
             this.vEnderecoEntidade.iIdTbCliente = this.iId;
             this.vEnderecoEntidade.iId          = aEnderecoDAO.Incluir(this.vEnderecoEntidade);
         }
         else
         {
             aClienteDAO.Alterar(this);
             aEnderecoDAO.Alterar(this.vEnderecoEntidade);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("salvar o registro");
     }
     finally
     {
         Conexao.CloseConnection();
     }
 }
Exemple #2
0
        public IActionResult AlterarEndereco(int id)
        {
            Endereco endereco = _enderecoDAO.ReceberDado(id);

            _enderecoDAO.Alterar(endereco);
            return(Created("", endereco));
        }
Exemple #3
0
        protected void gridGeral_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            EnderecoDAO dao      = new EnderecoDAO();
            Endereco    endereco = new Endereco()
            {
                Id          = Convert.ToInt32(gridGeral.DataKeys[e.RowIndex].Value.ToString()),
                Rua         = (gridGeral.Rows[e.RowIndex].FindControl("txtRua") as TextBox).Text,
                Numero      = (gridGeral.Rows[e.RowIndex].FindControl("txtNumero") as TextBox).Text,
                Bairro      = (gridGeral.Rows[e.RowIndex].FindControl("txtBairro") as TextBox).Text,
                Cep         = (gridGeral.Rows[e.RowIndex].FindControl("txtCep") as TextBox).Text,
                Complemento = (gridGeral.Rows[e.RowIndex].FindControl("txtComplemento") as TextBox).Text
            };


            if (dao.Alterar(endereco) != null)
            {
                gridGeral.EditIndex = -1;
                ListarTodos();
                lblResultado.Text = "Alterado com sucesso";
            }
            else
            {
                lblResultado.Text = "Falha ao alterar";
            }
        }
Exemple #4
0
        public bool Gravar(Endereco instancia)
        {
            EnderecoDAO endDAO = new EnderecoDAO();

            if (instancia.Id == 0)
            {
                return(endDAO.Inserir(instancia));
            }

            return(endDAO.Alterar(instancia));
        }
        public ActionResult Insert(Endereco endereco)
        {
            EnderecoDAO dao = new EnderecoDAO();

            if (endereco.ID == 0)
            {
                dao.Adiciona(endereco);
            }
            else
            {
                dao.Alterar(endereco);
            }


            return(RedirectToAction("Index", "Localidade"));
        }
        public IActionResult Salvar(EnderecoViewModel endereco, string Operacao)
        {
            try
            {
                EnderecoDAO dao = new EnderecoDAO();
                if (Operacao == "I")
                {
                    dao.Inserir(endereco);
                }
                else
                {
                    dao.Alterar(endereco);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception erro)
            {
                return(View("Error", new ErrorViewModel(erro.ToString())));
            }
        }
        protected void BtnAlterar_Click(object sender, EventArgs e)
        {
            EnderecoDAO endDao = new EnderecoDAO();

            int    cod;
            string rua         = TxtRua.Text;
            string bairro      = TxtBairro.Text;
            string cep         = TxtCep.Text;
            string complemento = TxtComp.Text;
            int    numero;

            Int32.TryParse(TxtNumero.Text, out numero);

            if (!Int32.TryParse(HiddenCod.Value, out cod) || rua.Equals("") || rua.Length > 45 || bairro.Equals("") || bairro.Length > 45 || cep.Equals("") || cep.Length > 9 || numero < 1 || TxtNumero.Text.Length > 45)
            {
                LblResultado.Text = "Dados não foram inseridos ou estão inseridos de forma incorreta!!";
            }
            else
            {
                Endereco endereco = new Endereco()
                {
                    Cod         = cod,
                    Rua         = rua,
                    Bairro      = bairro,
                    CEP         = cep,
                    Complemento = complemento,
                    Numero      = numero,
                    Cliente     = c
                };

                Endereco end = endDao.Alterar(endereco);

                if (end != null)
                {
                    LblResultado.Text = "Endereco Alterado com Sucesso";
                    PopularGrid();
                }
            }
        }
Exemple #8
0
 public IActionResult Alterar(Endereco endereco)
 {
     _enderecoDAO.Alterar(endereco);
     return(RedirectToAction("Inicial"));
 }
 public IActionResult Alterar(Endereco endereco)
 {
     _enderecoDAO.Alterar(endereco);
     return(Ok(endereco));
 }