Trapping a delete failed
 
Forums / SmartComponent Library - Developer Forum / Trapping a delete failed

Trapping a delete failed

4 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    379 posts
    Registered:
    29 Jun 2018
    16 Jan 2019
    Link to this post
    I have a smartwindowform that contains the following;
    smarttoolbar
    ultratabcontrol with two tabs
    a smartdatabrowser on first tab
    a smartviewer on second tab

    The ultratabcontrol is setup with a style of Wizard. The user will not see tabs and cannot change tabs. Our app controls the tab changing. When the user clicks Add or Update tab 2 is shown and the user can enter field values.

    I am subscribing to the AfterCancelUpdate, AfterDeleteRecord and AfterSaveChanges of the smart viewer where we use the PerformAction of the UltraTab to make sure we are back on the first tab.
      
    THIS-OBJECT:ultraTabControl1:PerformAction(Infragistics.Win.UltraWinTabControl.UltraTabControlAction:SelectFirstTab).
      
     This all works great. The only issue was have found during testing is when trying to DELETE if an error is thrown such as "the record has been changed by another user" we are stuck on the second tab. The AfterCancelUpdate does not fire and there is no AfterCancelDelete /etc. 

    Is there any other way to know the delete failed
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    16 Jan 2019 in reply to Roger Blanchard
    Link to this post
    Hi Roger,

    you'll probably have to override the DisplayError method of the Viewer and handle the delete error there.

    We only have an event on successful delete.
  3. Roger Blanchard
    Roger Blanchard avatar
    379 posts
    Registered:
    29 Jun 2018
    16 Jan 2019 in reply to Mike Fechner
    Link to this post
    Okay, I will take a look.

    Thank you.
  4. Roger Blanchard
    Roger Blanchard avatar
    379 posts
    Registered:
    29 Jun 2018
    17 Jan 2019 in reply to Mike Fechner
    Link to this post
    Hey Mike,

    Thanks for your guidance. The following seems to work.

    I added an AfterDisplayError event to the OspreyViewerControl.

    DEFINE PUBLIC EVENT AfterDisplayError DELEGATE System.EventHandler.

    I then added an OVERRIDE for DisplayError in the OspreyViewerControl that would Publish the AfterDisplayError.

    In my SmartWindowForm I subscribed to that event where I check the SmartTableIostate of the Viewer. If it is FieldsDisabled then we set the FirstTab.

    gain, thanks for the guidance.

    /*------------------------------------------------------------------------------
      Purpose:
      Notes:
     ------------------------------------------------------------------------------*/
     @VisualDesigner.
     METHOD PRIVATE VOID AdjInvViewer_AfterDisplayError( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
      
      /* Roger Blanchard / Osprey Retail Systems Jan 17, 2019
       This would be nice to solve the isseue when trying to delete. However,
       if we are creating new run and an error is returned becuase we are missing required
       info we would not want to SelectTheFirstTab.
       
       The best we can do is check the SmartViewer:SmartTableIOstate and if it
       is FieldsDisabled then select the FirstTab. If the fields are disabled then
       we cannot be updating the data.
      */
      
      IF THIS-OBJECT:AdjInvViewer:SmartTableIOState = "FieldsDisabled" THEN    
       THIS-OBJECT:ultraTabControl1:PerformAction(Infragistics.Win.UltraWinTabControl.UltraTabControlAction:SelectFirstTab).
      
      RETURN.
     END METHOD.




4 posts, 1 answered