StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Problems with BeforeDelete and AfterDelete...Expand / Collapse
Author
Message
Posted 01/21/2008 5:20:40 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 08/26/2008 10:34:32 AM
Posts: 78, Visits: 242
Hi All

I am having problems with the BeforeDelete and AfterDelete events not firing. I have tried setting it up both of the ways shown below.

Private Sub MemberFamily_AfterDelete(ByVal e As MicroFour.StrataFrame.Business.AfterDeleteEventArgs) Handles Me.AfterDelete

       Call Me.SetIncomplete()

End Sub

and as

AddHandler Me.CheckRulesOnCurrentRow, AddressOf MemberFamily_AfterDelete (in the constructor)

Private Sub MemberFamily_AfterDelete(ByVal e As MicroFour.StrataFrame.Business.AfterDeleteEventArgs)

       Call Me.SetIncomplete()

End Sub

When I put a breakbpoint on Call Me.SetIncomplete() it is never reached.

I have quite a bit of code in other events (specifically CheckRulesOnCurrentRow, SetDefaultValues and the AfterSave which is setup with an inline Handles Me.AfterSave) which works just fine. I am deleting the records using DeleteByPrimaryKey(FamilyMemberID) and the records are deleting successfully.

Post #13610
Posted 01/22/2008 10:36:48 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Yesterday @ 10:03:03 PM
Posts: 1,322, Visits: 3,439
Are you handling this at the BO level or at the form level?

If you are handling it at the form level, and you have multiple BOs on the form and this BO isn't the primary bo, it could be a configuration issue. You'd need to configure the BO to be included in Form deletes.

If this is at the BO level....no idea
Post #13618
Posted 01/22/2008 10:38:00 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 08/26/2008 10:34:32 AM
Posts: 78, Visits: 242
Hi Greg

This is all at the BO level...I'm stumped...have you used the BeforeDelete/AfterDelete events before?

Post #13619
Posted 01/22/2008 11:34:01 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Yesterday @ 10:03:03 PM
Posts: 1,322, Visits: 3,439
I've handled them in forms for BOs (the code was in the form)...I.e. I have a form that has a BO (MyBO) and I have handlers for that handle MyBO_BeforeDelete and MyBO_AfterDelete. I've also created inherited business layers that handled the base business layers before and after delete events.

I have not handled the events right in a BO though. I can't think of any reason why it would be different.
Post #13625
Posted 01/23/2008 9:19:30 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 10/21/2008 9:20:58 AM
Posts: 2,685, Visits: 1,887
Actually, it is different... the DeleteByPrimaryKey does not raise the Before- or AfterDelete events... because there is no guarantee that the record is in the business object when you call DeleteByPrimaryKey().  So, if you want those events, you need to have the record selected in the BO and call DeleteCurrentRow() and pass False to the OnlyMarkAsDeleted parameter, which will delete it from the server immediately and not require a save.


www.bungie.net
Post #13671
Posted 01/23/2008 9:27:25 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 08/26/2008 10:34:32 AM
Posts: 78, Visits: 242
Thanks much Ben!
Post #13677
Posted 01/23/2008 10:02:13 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 08/26/2008 10:34:32 AM
Posts: 78, Visits: 242
Are there thoughts to add transactions to the delete routines in a future version? This is something I run up against a lot. I try to still use transactions and just put the delete last so if it fails all else dies...but this model doesn't work if multiple deletes are needed.
Post #13682
Posted 01/23/2008 10:23:21 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Yesterday @ 10:03:03 PM
Posts: 1,322, Visits: 3,439
the DeleteByPrimaryKey does not raise the Before- or AfterDelete events...

Ah, I missed that. Now it makes sense!
Post #13683
Posted 01/23/2008 11:31:21 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 3:20:54 PM
Posts: 4,769, Visits: 4,731
Yeah,  the DeleteByPrimaryKey goes straight to "smoking" the records.   You probably want to use the DeleteCurrentRow method if you do not want the records to be immediately deleted from the database.  The DeletePrimaryKey method does not require that the PK in which you are trying to delete is within the BO itself, whereas the DeleteCurrentRow method is going to delete a record with the BO.
Post #13685