StrataFrame Forum

Which events should I use for auditing?

http://forum.strataframe.net/Topic6794.aspx

By StarkMike - 2/15/2007

Which BO events should I place my auditing code into?



I'm using the AfterAddNew event to place my created by audit info in the proper fields. I believe this is the right event for new records, but I'd like confirmation. ;-)



Private Sub BluePrintsBO1_AfterAddNew(ByVal e As System.EventArgs) Handles BluePrintsBO1.AfterAddNew

Me.BluePrintsBO1.Created = Now

Me.BluePrintsBO1.CreatedBy = SystemInformation.UserName

End Sub



Which event should I use when a record is modified?



Thanks


By Trent L. Taylor - 2/15/2007

It just depends on what you are trying to accomplish and what type of events you are auditing.  You are correct on the Add...this is what I would do.  As for the Edit, I would do this in the BeforeSave or AfterSave event and test on the EditingState of the BO to know if this is a new or existing record.
By StarkMike - 2/15/2007

That'll work. I'll test the editing state on the save. ;-)
By StarkMike - 2/15/2007

Whoops! spoke too soon. I'm using a grid so I'd like to update the Modified fields when they change a row. So if they move to another row if they made any changes to that row I'd need to update those fields before they moved.

So I thought I would use the CheckRulesOnCurrentRow method in the BO.

So... my next questions are...

   Is there a dirty property for each record i could check to determine whether I need to update these fields?

   Am I correct in my approach here?

By Trent L. Taylor - 2/15/2007

You will want to use the Navigating event of the BO.  This event is fired through the BusinessBindingSource when using grids.