示例#1
0
        protected void gvItens_PreRender(object sender, EventArgs e)
        {
            cpEntities db = new cpEntities();

            foreach (GridViewRow row in gvItens.Rows)
            {
                int codigo = int.TryParse(row.Cells[0].Text, out codigo) ? codigo : 0;

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

                if (stat.Equals("T"))
                {
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).ImageUrl = "~/Imagens/sold.png";
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).Enabled  = false;
                    ((Label)row.Cells[2].FindControl("lblStatus")).Text           = @"Alguém já marcou este presente. Eba! Eu vou adorar :D";
                }
                else
                {
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).ImageUrl = "~/Imagens/gift.png";
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).Enabled  = true;
                    ((Label)row.Cells[2].FindControl("lblStatus")).Text           = "Quero dar este presente";
                }
            }
        }
示例#2
0
        protected void gvItens_PreRender(object sender, EventArgs e)
        {
            cpEntities db = new cpEntities();

            foreach(GridViewRow row in gvItens.Rows)
            {
                int codigo = int.TryParse(row.Cells[0].Text, out codigo) ? codigo : 0;

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

                if (stat.Equals("T"))
                {
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).ImageUrl = "~/Imagens/sold.png";
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).Enabled = false;
                    ((Label)row.Cells[2].FindControl("lblStatus")).Text = @"Alguém já marcou este presente. Eba! Eu vou adorar :D";
                }
                else
                {
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).ImageUrl = "~/Imagens/gift.png";
                    ((ImageButton)row.Cells[2].FindControl("btnStatus")).Enabled = true;
                    ((Label)row.Cells[2].FindControl("lblStatus")).Text = "Quero dar este presente";
                }
            }
        }
示例#3
0
        private void bindarGrid()
        {
            cpEntities db     = new cpEntities();
            var        listas = (from l in db.lista
                                 orderby l.descricao
                                 select l).ToList();

            gvLista.DataSource = listas;
            gvLista.DataBind();
        }
示例#4
0
        private void bindarGrid()
        {
            cpEntities db = new cpEntities();

            var itens = (from i in db.item
                         orderby i.descricao
                         select i).ToList();

            gvItens.DataSource = itens;
            gvItens.DataBind();
        }
示例#5
0
        private void bindarGrid()
        {
            cpEntities db = new cpEntities();

            var itens = (from i in db.item
                         orderby i.descricao
                         select i).ToList();

            gvItens.DataSource = itens;
            gvItens.DataBind();
        }
示例#6
0
        private void bindarListas()
        {
            cpEntities db = new cpEntities();

            var listas = (from l in db.lista
                          orderby l.descricao
                          select l).ToList();

            ddlLista.DataSource     = listas;
            ddlLista.DataTextField  = "descricao";
            ddlLista.DataValueField = "id";
            ddlLista.DataBind();
        }
示例#7
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();
        }
示例#8
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();
        }
示例#9
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();
        }
示例#10
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();
        }
示例#11
0
        private void bindarGrid()
        {
            cpEntities db = new cpEntities();

            var itens = (from i in db.item
                         join l in db.lista on i.idLista equals l.id
                         orderby i.descricao
                         select new
            {
                id = i.id,
                descricao = i.descricao,
                lista = l.descricao
            }).ToList();

            gvItens.DataSource = itens;
            gvItens.DataBind();
        }
示例#12
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();
            }
        }
示例#13
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();
        }
示例#14
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();
            }
        }
示例#15
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();
            }
        }
示例#16
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();
        }
示例#17
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();
            }
        }
示例#18
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();
            }
        }
示例#19
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();
            }
        }
示例#20
0
        private void bindarGrid()
        {
            cpEntities db = new cpEntities();

            var itens = (from i in db.item
                         join l in db.lista on i.idLista equals l.id
                         orderby i.descricao
                         select new
                         {
                            id = i.id,
                            descricao = i.descricao,
                            lista = l.descricao
                         }).ToList();

            gvItens.DataSource = itens;
            gvItens.DataBind();
        }
示例#21
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();
        }
示例#22
0
        private void bindarGrid()
        {
            cpEntities db = new cpEntities();
            var listas = (from l in db.lista
                          orderby l.descricao
                          select l).ToList();

            gvLista.DataSource = listas;
            gvLista.DataBind();
        }
示例#23
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();
        }
示例#24
0
        private void bindarListas()
        {
            cpEntities db = new cpEntities();

            var listas = (from l in db.lista
                          orderby l.descricao
                          select l).ToList();

            ddlLista.DataSource = listas;
            ddlLista.DataTextField = "descricao";
            ddlLista.DataValueField = "id";
            ddlLista.DataBind();
        }