Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sherry Ann Hernandez 320 posts 344 karma points
    Jul 10, 2011 @ 13:32
    Sherry Ann Hernandez
    0

    prevent delete of media

    Hi,

    I have this code that search the tables if the media is use inside the content. but my problem is the delete transaction is not cancelled even if I set it to true.

     

     

    string sql = string.Format(@"

    SELECT TOP 1 A.[id] from cmsPropertyData AS A

    LEFT JOIN cmsPropertyType AS B ON A.propertytypeid = b.id

    where B.dataTypeId IN ('5697','5698','6397','6410','6411','6419','6420','6421')

    and (A.[dataNvarchar] = '%{0}%') order by A.[id]"

     

     

    , sender.Id);

     

     

    using (IRecordsReader dr = SqlHelper.ExecuteReader(sql))

    {

     

     

    try

    {

     

     

    if (dr.HasRecords)

    {

    e.Cancel =

     

    true;

     

     

    //Log.Add(LogTypes.Delete, sender.Id, "This item cannot be deleted because it is currently used in the content section");

     

     

    //ShowErrorBubble("Error deleting item", "This item cannot be deleted because it is currently used in the content section");

    }

    }

     

     

    catch (Exception ex)

    {

     

     

    Log.Add(LogTypes.Custom, sender.Id, "Error deleting a media " + ex.Message + "-" + sender.Text);

    }

     

    }

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 11, 2011 @ 00:58
    Tom Fulton
    0

    Hi,

    What event are you running this code in?

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft