protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            string            descr   = txtDescricao.Text;
            string            dten    = txtDataentrada.Text;
            string            nomecli = txtNomecliente.Text;
            string            telef   = txtTelefone.Text;
            string            val     = txtValor.Text;
            TB_ESTACIONAMENTO v       = new TB_ESTACIONAMENTO()
            {
                descricao = descr, dataentrada = dten, nomecliente = nomecli, telefone = telef, valor = val
            };
            EstacionamentoDBEntities contextEstacionamento = new EstacionamentoDBEntities();

            string valor = Request.QueryString["iditem"];

            if (string.IsNullOrEmpty(valor))
            {
                contextEstacionamento.TB_ESTACIONAMENTO.Add(v);
                lblmsg.Text = "Registro inserido";
                Clear();
            }
            else
            {
                int id = Convert.ToInt32(valor);
                TB_ESTACIONAMENTO est = contextEstacionamento.TB_ESTACIONAMENTO.First(c => c.id == id);
                est.descricao   = v.descricao;
                est.dataentrada = v.dataentrada;
                est.nomecliente = v.nomecliente;
                est.telefone    = v.telefone;
                est.valor       = v.valor;
                lblmsg.Text     = "Registro alterado";
            }
            contextEstacionamento.SaveChanges();
        }
Example #2
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            string   anfa   = txtAnofabric.Text;
            string   anmo   = txtAnomodelo.Text;
            string   cor    = txtCor.Text;
            string   marca  = txtMarca.Text;
            string   modelo = txtModelo.Text;
            TB_CARRO v      = new TB_CARRO()
            {
                anofabric = anfa, anomodelo = anmo, cor = cor, marca = marca, modelo = modelo
            };
            EstacionamentoDBEntities contextEstacionamento = new EstacionamentoDBEntities();

            string valor = Request.QueryString["iditem"];

            if (string.IsNullOrEmpty(valor))
            {
                contextEstacionamento.TB_CARRO.Add(v);
                lblmsg.Text = "Registro inserido";
                Clear();
            }
            else
            {
                int      id    = Convert.ToInt32(valor);
                TB_CARRO carro = contextEstacionamento.TB_CARRO.First(c => c.id == id);
                carro.anofabric = v.anofabric;
                carro.anomodelo = v.anomodelo;
                carro.cor       = v.cor;
                carro.marca     = v.marca;
                carro.modelo    = v.modelo;
                lblmsg.Text     = "Registro alterado";
            }
            contextEstacionamento.SaveChanges();
        }
Example #3
0
        protected void GVESTAENTRADA_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int iditem = Convert.ToInt32(e.CommandArgument.ToString());
            EstacionamentoDBEntities contextEsta = new EstacionamentoDBEntities();
            TB_ESTACIONAMENTO        carro       = new TB_ESTACIONAMENTO();

            carro = contextEsta.TB_ESTACIONAMENTO.First(c => c.id == iditem);
            if (e.CommandName == "Alterar")
            {
                Response.Redirect("EstacionamentoEntrada.aspx?iditem=" + iditem);
            }
            else if (e.CommandName == "Exluir")
            {
                contextEsta.TB_ESTACIONAMENTO.Remove(carro);
                contextEsta.SaveChanges();
                string msg    = "Viagem excluida";
                string titulo = "informação";
                CarregarLista();
                DisplayAlert(titulo, msg, this);
            }
        }