Ejemplo n.º 1
0
        /// <summary>
        /// elimina un registro seleccionado
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnEliminar_Click(object sender, EventArgs e)
        {
            if (metroGrid1.SelectedRows.Count > 0)
            {
                int idCat = GetId();
                Entities.Categoria categoria = bll.GetById(idCat);

                try
                {
                    DialogResult confirmation = new Notifications.FrmQuestion(Language.SearchValue("preguntaEliminar")).ShowDialog();

                    if (confirmation == DialogResult.OK)
                    {
                        bll.Delete(idCat);
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Delete, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Categoria: " + categoria.categoria, "", ""));

                        RefrescarTabla();
                        Notifications.FrmSuccess.SuccessForm(Language.SearchValue("eliminadoOK"));
                    }
                }
                catch (Exception ex)
                {
                    InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.DeleteError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Categoria: " + categoria.categoria, ex.StackTrace, ex.Message));

                    RefrescarTabla();
                    Notifications.FrmError.ErrorForm(Language.SearchValue("eliminadoError") + "\n" + ex.Message);
                }
            }
            else
            {
                Notifications.FrmInformation.InformationForm(Language.SearchValue("XinfoSelecEliminar"));
            }
        }
 public IHttpActionResult Delete(int id)
 {
     try
     {
         CategoriaBLL.Delete(id);
         return(Ok("Producto eliminado correctamente"));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Ejemplo n.º 3
0
 public static int EliminarCategoria(int idCategoria)
 {
     try
     {
         CategoriaBLL.Delete(idCategoria);
         return(idCategoria);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
 public ActionResult DeleteConfirmed(int id)
 {
     CategoriaBLL.Delete(id);
     return(RedirectToAction("Index"));
 }
 protected void gridCategoria_RowDeleting1(object sender, GridViewDeleteEventArgs e)
 {
     objetoDTO.Id = Convert.ToInt32(e.Values["ID"]);
     objetobll.Delete(objetoDTO);
     carregarGrid();
 }