Example #1
0
        private void alterar()
        {
            cpEntities db = new cpEntities();

            int id    = int.Parse(hfID.Value);
            var lista = (from l in db.lista
                         where l.id.Equals(id)
                         select l).FirstOrDefault();

            lista.descricao = txtDescricao.Text;

            db.SaveChanges();
        }
Example #2
0
        private void alterar()
        {
            cpEntities db = new cpEntities();

            int id = int.Parse(hfID.Value);
            var lista = (from l in db.lista
                         where l.id.Equals(id)
                         select l).FirstOrDefault();

            lista.descricao = txtDescricao.Text;

            db.SaveChanges();
        }
Example #3
0
        private void alterar()
        {
            cpEntities db = new cpEntities();

            int id = int.Parse(hfID.Value);

            var item = (from i in db.item
                        where i.id.Equals(id)
                        select i).FirstOrDefault();

            item.descricao = txtDescricao.Text;
            item.idLista   = int.Parse(ddlLista.SelectedValue);
            item.status    = chkStatus.Checked.Equals(true) ? "T" : "F";

            db.SaveChanges();
        }
Example #4
0
        protected void gvItens_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if(e.CommandName.Equals("status"))
            {
                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id = int.TryParse(gvItens.Rows[index].Cells[0].Text, out id) ? id : 0;

                var edit = (from i in db.item
                            where i.id.Equals(id)
                            select i).FirstOrDefault();

                if(edit.status.Equals("F"))
                    edit.status = "T";

                db.SaveChanges();

                bindarGrid();
            }
        }
Example #5
0
        private void salvar()
        {
            cpEntities db      = new cpEntities();
            item       objItem = new item();
            int        lista   = int.TryParse(ddlLista.SelectedValue, out lista) ? lista : lista;

            int id = (from i in db.item
                      orderby i.id descending
                      select i.id).FirstOrDefault();

            id++;

            objItem.id = id;

            objItem.descricao = txtDescricao.Text;
            objItem.idLista   = lista;
            objItem.status    = chkStatus.Checked.Equals(true) ? "T" : "F";

            db.item.Add(objItem);
            db.SaveChanges();
        }
Example #6
0
        protected void gvItens_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if(e.CommandName.Equals("Editar"))
            {
                hfOperacao.Value = "E";

                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id = int.TryParse(gvItens.Rows[index].Cells[2].Text, out id) ? id : 0;

                var item = (from i in db.item
                            where i.id.Equals(id)
                            select i).FirstOrDefault();

                txtDescricao.Text = item.descricao;
                ddlLista.SelectedValue = item.idLista.ToString();
                chkStatus.Checked = item.status.Equals("T") ? true : false;
                hfID.Value = item.id.ToString();

                mvItem.SetActiveView(vwCadastro);
            }
            else if(e.CommandName.Equals("Excluir"))
            {
                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id = int.TryParse(gvItens.Rows[index].Cells[2].Text, out id) ? id : 0;

                var item = (from i in db.item
                            where i.id.Equals(id)
                            select i).FirstOrDefault();

                db.item.Remove(item);
                db.SaveChanges();

                bindarGrid();
            }
        }
Example #7
0
        protected void gvItens_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("Editar"))
            {
                hfOperacao.Value = "E";

                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id    = int.TryParse(gvItens.Rows[index].Cells[2].Text, out id) ? id : 0;

                var item = (from i in db.item
                            where i.id.Equals(id)
                            select i).FirstOrDefault();

                txtDescricao.Text      = item.descricao;
                ddlLista.SelectedValue = item.idLista.ToString();
                chkStatus.Checked      = item.status.Equals("T") ? true : false;
                hfID.Value             = item.id.ToString();

                mvItem.SetActiveView(vwCadastro);
            }
            else if (e.CommandName.Equals("Excluir"))
            {
                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id    = int.TryParse(gvItens.Rows[index].Cells[2].Text, out id) ? id : 0;

                var item = (from i in db.item
                            where i.id.Equals(id)
                            select i).FirstOrDefault();

                db.item.Remove(item);
                db.SaveChanges();

                bindarGrid();
            }
        }
Example #8
0
        private void salvar()
        {
            cpEntities db       = new cpEntities();
            lista      objLista = new lista();

            int id = (from l in db.lista
                      orderby l.id descending
                      select l.id).FirstOrDefault();

            if (id > 0)
            {
                objLista.id = id;
            }
            else
            {
                objLista.id = 1;
            }

            objLista.descricao = txtDescricao.Text;

            db.lista.Add(objLista);
            db.SaveChanges();
        }
Example #9
0
        protected void gvLista_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("Editar"))
            {
                cpEntities db = new cpEntities();

                hfTipoOperacao.Value = "E";

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id = int.TryParse(gvLista.Rows[index].Cells[2].Text, out id) ? id : 0;

                var lista = (from l in db.lista
                             where l.id.Equals(id)
                             select l).FirstOrDefault();

                hfID.Value = lista.id.ToString();
                txtDescricao.Text = lista.descricao;

                mvLista.SetActiveView(vwCadastro);
            }
            else if(e.CommandName.Equals("Excluir"))
            {
                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id = int.TryParse(gvLista.Rows[index].Cells[2].Text, out id) ? id : 0;

                var lista = (from l in db.lista
                             where l.id.Equals(id)
                             select l).FirstOrDefault();

                db.lista.Remove(lista);
                db.SaveChanges();

                bindarGrid();
            }
        }
Example #10
0
        protected void gvLista_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("Editar"))
            {
                cpEntities db = new cpEntities();

                hfTipoOperacao.Value = "E";

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id    = int.TryParse(gvLista.Rows[index].Cells[2].Text, out id) ? id : 0;

                var lista = (from l in db.lista
                             where l.id.Equals(id)
                             select l).FirstOrDefault();

                hfID.Value        = lista.id.ToString();
                txtDescricao.Text = lista.descricao;

                mvLista.SetActiveView(vwCadastro);
            }
            else if (e.CommandName.Equals("Excluir"))
            {
                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id    = int.TryParse(gvLista.Rows[index].Cells[2].Text, out id) ? id : 0;

                var lista = (from l in db.lista
                             where l.id.Equals(id)
                             select l).FirstOrDefault();

                db.lista.Remove(lista);
                db.SaveChanges();

                bindarGrid();
            }
        }
Example #11
0
        protected void gvItens_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("status"))
            {
                cpEntities db = new cpEntities();

                int index = int.TryParse(e.CommandArgument.ToString(), out index) ? index : 0;
                int id    = int.TryParse(gvItens.Rows[index].Cells[0].Text, out id) ? id : 0;

                var edit = (from i in db.item
                            where i.id.Equals(id)
                            select i).FirstOrDefault();

                if (edit.status.Equals("F"))
                {
                    edit.status = "T";
                }


                db.SaveChanges();

                bindarGrid();
            }
        }
Example #12
0
        private void salvar()
        {
            cpEntities db = new cpEntities();
            lista objLista = new lista();

            int id = (from l in db.lista
                      orderby l.id descending
                      select l.id).FirstOrDefault();

            if (id > 0)
                objLista.id = id;
            else
                objLista.id = 1;

            objLista.descricao = txtDescricao.Text;

            db.lista.Add(objLista);
            db.SaveChanges();
        }
Example #13
0
        private void alterar()
        {
            cpEntities db = new cpEntities();

            int id = int.Parse(hfID.Value);

            var item = (from i in db.item
                        where i.id.Equals(id)
                        select i).FirstOrDefault();

            item.descricao = txtDescricao.Text;
            item.idLista = int.Parse(ddlLista.SelectedValue);
            item.status = chkStatus.Checked.Equals(true) ? "T" : "F";

            db.SaveChanges();
        }
Example #14
0
        private void salvar()
        {
            cpEntities db = new cpEntities();
            item objItem = new item();
            int lista = int.TryParse(ddlLista.SelectedValue, out lista) ? lista : lista;

            int id = (from i in db.item
                      orderby i.id descending
                      select i.id).FirstOrDefault();
            id++;

            objItem.id = id;

            objItem.descricao = txtDescricao.Text;
            objItem.idLista = lista;
            objItem.status = chkStatus.Checked.Equals(true) ? "T" : "F";

            db.item.Add(objItem);
            db.SaveChanges();
        }