Page 1 of 1

Landed Cost. Bookin Activated

PostPosted: Mon Aug 17, 2015 1:46 pm
by DannyC
I need to do something when a bookin has been activated.

So far I have the code
Code: Select all
    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim BookInForm As JiwaLandedCostUI.BookIn.BookIn = DirectCast(JiwaForm, JiwaApplication.IJiwaForm)
      AddHandler BookInForm.Activated, AddressOf BookIn_Activated      
    End Sub
   
   Sub BookIn_Activated (sender As Object, e As System.eventargs)
      Dim BookIn As JiwaLandedCost.BookIn.BookIn = DirectCast( sender , JiwaLandedCost.BookIn.BookIn)
      msgbox(BookIn.BookInNo)
      
   End Sub


But as soon as I load the bookin form, I get an error "Unable to cast object of type JiwaFinancials.Jiwa.JiwaLandedCostUI.BookIn.BookIn to type JiwaFinancials.Jiwa.JiwaLandedCost.BookIn.BookIn.

I know the error lies in the Dim within the Sub but I cannot find the correct syntax to use.

Regards

Danny

Re: Landed Cost. Bookin Activated  Topic is solved

PostPosted: Tue Aug 18, 2015 3:21 pm
by Scott.Pearce
Code: Select all
AddHandler BookInForm.Activated, AddressOf BookIn_Activated



You are hooking into the wrong event. That is the Activated event for the *windows form*. You should be hooking into either the SaveStart, SaveEnding, or SaveEnd event for the business logic (depending on what exactly you will be doing), and examining the objects' .Activated property.

Re: Landed Cost. Bookin Activated

PostPosted: Wed Aug 19, 2015 10:32 am
by DannyC
Ahh I see.
Sussed it out & all good now.

Thanks