BLL.Metas.Eliminar C# (CSharp) Method

Eliminar() public method

public Eliminar ( ) : bool
return bool
        public override bool Eliminar()
        {
            bool retorno = false;

            try
            {
                retorno = conexion.Ejecutar(String.Format("Alter table MetasDetalle NOCHECK constraint ALL ;"
                                      + "Delete from Metas where MetaId = {0};"
                                      + "Delete from MetasDetalle where MetaId = {0};"
                                      + "Alter table MetasDetalle CHECK constraint ALL ;", this.MetaId));
            }
            catch (Exception)
            {
                retorno = false;
            }

            return retorno;
        }

Usage Example

 protected void EliminarButton_Click(object sender, EventArgs e)
 {
     int Id = 0;
     Metas meta = new Metas();
     int.TryParse(MetaIdTextBox.Text, out Id);
     if (Id > 0)
     {
         meta.MetaId = Id;
         if (meta.Buscar(meta.MetaId))
         {
             if (meta.Eliminar())
             {
                 ShowToast("success", "Eliminado", "Eliminado Correctamente");
                 Limpiar();
             }
             else
             {
                 ShowToast("error", "Error", "Error al Eliminado");
             }
         }
         else
         {
             ShowToast("warning", "Incorrecto", "Id No Existe");
         }
     }
     else
     {
         ShowToast("warning", "Incorrecto", "Id Incorrecto");
     }
 }
All Usage Examples Of BLL.Metas::Eliminar