Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Event handling in business objects
Message
From
25/06/2008 14:23:56
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
25/06/2008 13:23:39
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01326692
Message ID:
01326717
Views:
11
Hi Tim,


>
>I am just starting out with MM and have a question on event handling. I have read through the documentation, but still am not sure how to handle this.
>
>My database has some tables with FK constraints. When deleting a record may violate a FK constraint in another table (can't delete the parent when there are children) I use a stored procedure to check to see if the constraint will be violated. I do this so that I don't generate a cryptic (to the user) SQL exception. I call this pre delete SP from within the HookPreDeleteEntity method and everything works fine.
>
>However, I would like to be able to raise an event to the user interface to tell the user why the delete failed. Unlike the SaveEntity() method, the DeleteEntity() method returns a bool instead of a RulesBroken enum. Can I use the OnStateChange() method to raise the event I need, or do I need to add another event to my BusinessObject class? Or am I missing something more fundamental?
>
>Thanks in advance.
>
I can't remember, are you working with web forms or windows forms? Are you registering your child business objects with the parent business objects in your form? I would recommend reviewing the MM Dev guide topic:
Mere Mortals .NET Business Objects, Establishing Business Object Relationships.

Also check out the following properties of the business object.
AutoSaveOnParentSaved
AutoCancelOnParentCancel
AutoDeleteOnParentDeleted
AutoEmptyOnParentAdded
ForeignParentKeyField

The following is from the Dev Guide Jump Start Step 8 of Creating Business Ojbects:
The property settings for AutoSaveOnParentSaved , AutoCancelOnParentCancel, AutoDeleteOnParentDeleted, AutoEmptyOnParentAdded, and ForeignParentKeyField go hand in hand. These settings specify that the child business object should automatically save, cancel, and delete when its associated parent business object does. In addition, since a value is specified for ForeignParentKeyField, MM .NET automatically populates the child object's OrderID field with the value of the parent business object's foreign key field when saving the child business object.

I hope this helps
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform