protected void grvCategorias_RowDeleting(object sender, GridViewDeleteEventArgs e) { idCategoria = int.Parse(grvCategorias.DataKeys[e.RowIndex].Value.ToString()); categoria = categorias.Find(cat => cat.IDT_CATEGORIA == idCategoria).First<CATEGORIA>(); categorias.Delete(categoria); categorias.SaveChanges(); categorias = null; categoria = null; BuscarCategorias(); }
public void AtualizarCategoria() { idCategoria = int.Parse(txtIdCategoria.Text); categoria = categorias.Find(cat => cat.IDT_CATEGORIA == idCategoria).First<CATEGORIA>(); categoria.NOME = txtCategoria.Text; categorias.Update(categoria); categorias.SaveChanges(); BuscarCategorias(); categorias = null; categoria = null; LimparCampos(); }
protected void btnSalvar_Click(object sender, EventArgs e) { if (txtIdCategoria.Text != string.Empty) { AtualizarCategoria(); } else { categoria.NOME = txtCategoria.Text; categoriasBLL.Add(categoria); categoriasBLL.SaveChanges(); BuscarCategorias(); categoriasBLL = null; categoria = null; LimparCampos(); } }
protected void btnSalvar_Click(object sender, EventArgs e) { if (txtIdCategoria.Text != string.Empty) { AtualizarCategoria(); } else { //categoria.NOME = txtCategoria.Text; //categoriasBLL.Add(categoria); LOJAEntities teste = new LOJAEntities(); teste.SP_CATEGORIA(txtCategoria.Text); //categoriasBLL.SaveChanges(); BuscarCategorias(); categoriasBLL = null; categoria = null; LimparCampos(); } }
/// <summary> /// Create a new CATEGORIA object. /// </summary> /// <param name="iDT_CATEGORIA">Initial value of the IDT_CATEGORIA property.</param> public static CATEGORIA CreateCATEGORIA(global::System.Int32 iDT_CATEGORIA) { CATEGORIA cATEGORIA = new CATEGORIA(); cATEGORIA.IDT_CATEGORIA = iDT_CATEGORIA; return cATEGORIA; }
/// <summary> /// Deprecated Method for adding a new object to the CATEGORIA EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCATEGORIA(CATEGORIA cATEGORIA) { base.AddObject("CATEGORIA", cATEGORIA); }
protected void grvCategorias_SelectedIndexChanged(object sender, EventArgs e) { btnSalvar.Text = "Atualizar"; idCategoria = (int)grvCategorias.SelectedValue; categoria = categorias.Find(cat => cat.IDT_CATEGORIA == idCategoria).First<CATEGORIA>(); txtIdCategoria.Text = categoria.IDT_CATEGORIA.ToString(); txtCategoria.Text = categoria.NOME; categorias = null; categoria = null; }
/// <summary> /// Create a new CATEGORIA object. /// </summary> /// <param name="iDT_CATEGORIA">Initial value of the IDT_CATEGORIA property.</param> /// <param name="nOME">Initial value of the NOME property.</param> public static CATEGORIA CreateCATEGORIA(global::System.Int32 iDT_CATEGORIA, global::System.String nOME) { CATEGORIA cATEGORIA = new CATEGORIA(); cATEGORIA.IDT_CATEGORIA = iDT_CATEGORIA; cATEGORIA.NOME = nOME; return cATEGORIA; }