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(); }
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(); }
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(); } }
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(); }
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(); } }
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(); } }
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(); }
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(); } }
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(); } }
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(); } }
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(); }