public static bool sqlDelete(Subcategoria subcat)
 {
     String sql = String.Format("DELETE FROM subcategorias WHERE idsubcategorias = '{0}'"
                             , subcat.Id
                             );
     return BD.getInstance().sqlEjecuta(sql);
 }
 // ============= custom ============ //
 public static bool existsName(Subcategoria subcat)
 {
     String sql = String.Format("SELECT * FROM subcategorias WHERE nombre = '{0}'", subcat.Nombre);
     DataTable dt = BD.getInstance().sqlSelect(sql);
     if (dt.Rows.Count == 0)
         return false;
     return true;
 }
        public static bool sqlLeer(Subcategoria subcat)
        {
            String sql = String.Format("SELECT * FROM subcategorias WHERE idsubcategorias = '{0}'"
                                       , subcat.Id);
            DataTable dt = BD.getInstance().sqlSelect(sql);
            if (dt.Rows.Count == 0)
                return false;

            subcat.Nombre = dt.Rows[0]["nombre"].ToString();
            return true;
        }
 public static Boolean sqlInsert(Subcategoria subcat)
 {
     if (!existsName(subcat))
     {
         String sql = String.Format("INSERT INTO subcategorias (nombre) VALUES ('{0}')"
                                 , subcat.Nombre
                                 );
         return BD.getInstance().sqlEjecuta(sql);
     }
     return false;
 }
 public static bool sqlUpdate(Subcategoria subcat)
 {
     if (!existsName(subcat))
     {
         String sql = String.Format("UPDATE subcategorias SET nombre = '{0}' WHERE idsubcategorias = '{1}'"
                                 , subcat.Nombre
                                 , subcat.Id
                                 );
         return BD.getInstance().sqlEjecuta(sql);
     }
     return false;
 }