private void botaoExcluir_Click(object sender, EventArgs e) { var produtoBusiness = new ProdutoBusiness(); produtoBusiness.ExcluirProduto(labelID.Text); Dispose(); }
//método para excluir um produto public JsonResult ExcluirProduto(int id) { try { ProdutoBusiness business = new ProdutoBusiness(); business.ExcluirProduto(id); return(Json("Produto excluído com sucesso.")); } catch (Exception e) { Response.StatusCode = 500; //INTERNAL SERVER ERROR return(Json(e.Message)); //mensagem de erro } }
public ActionResult Exclusao(int id) { try { ProdutoBusiness business = new ProdutoBusiness(); business.ExcluirProduto(id); TempData["Mensagem"] = "Produto Excluído com sucesso"; } catch (Exception e) { TempData["Mensagem"] = e.Message; } return(RedirectToAction("Consulta")); }
protected void gvwProduto_RowDeleting(object sender, GridViewDeleteEventArgs e) { DicaPrecoEntity.Produto Produto = new DicaPrecoEntity.Produto(); ProdutoBusiness business = new ProdutoBusiness(); Int32 codUnidMed = (Int32)gvwProduto.DataKeys[e.RowIndex].Value; if (business.ExcluirProduto(codUnidMed)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "sucesso", "alert('Produto excluida com sucesso')", true); loadGrid(Produto); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "erro", "alert('Não foi possivel excluir o produto')", true); } }