示例#1
0
        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
            }
        }
示例#3
0
        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"));
        }
示例#4
0
        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);
            }
        }