handling events

Posts   
 
    
Posts: 11
Joined: 02-Aug-2005
# Posted on: 17-Oct-2005 16:38:35   

Self servicing, VB .NET, Win Forms ...

I have a _ reservation_ entity which has a field _ accountId_

How can I handle an event for _ accountId_ changed in both the GUI and in the entity class?

omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 17-Oct-2005 19:28:27   

FunkyMonkey wrote:

Self servicing, VB .NET, Win Forms ...

I have a _ reservation_ entity which has a field _ accountId_

How can I handle an event for _ accountId_ changed in both the GUI and in the entity class?

BL

  • If your BL class extends the reservationEntity class, then you can handle the accountId changed event by overriding OnAccountId in the BL's reservation class. Example, extended templates and JCL in 3rd party downloads
  • if you are using the manager class architecture, then when you declare your object variable for the accountId entity, add code to handle its AccountId changed event: AddHandler m_reservation.AccountIdChanged, addressof handleAccountIdChanged But remeber to do the reverse (RemveHandler) when you have no more use for the m_reservation variable.

UI

In your UI you would use an approach similar to that in the BL-Manager class architecture. Your reservation variable can be declared with Events or you could use AddHandler/RemoveHandler to assign a routine to handle the accountIdChanged event.

Posts: 11
Joined: 02-Aug-2005
# Posted on: 18-Oct-2005 18:19:27   

Thanks Omar. Things become so simple when someone points you in the right direction!

I think I'm finally beginning to get to grips with event handling.

smile