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



How to prevent parent record being deleted?Expand / Collapse
Author
Message
Posted 07/10/2006 5:28:59 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 07/18/2006 7:59:33 PM
Posts: 25, Visits: 46
In my application has two business objects, CustomerBO and OrderBO. CustomerBO  is mapped to customer table and OrderBO is mapped to order table. CustomerBO is the parent business object of OrderBO. The reference integrity of customer and order tables not set in the database.  I want to prevent the application from deleting the record in customerBO if the record is referenced by orderBO records. May I know how the business object can prevent this deletion?
Post #1784
Posted 07/10/2006 8:41:35 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 2 days ago @ 5:02:56 PM
Posts: 2,682, Visits: 1,882
You can write a shared method on the OrdersBO that will get the count of the records within the database that have the given CustomersBO as their parent.  Then, simply handle the BeforeDelete event of the CustomersBO and if the count of the method returns > 0 then, set e.Cancel = True and show an error message.  That's the most efficient way to do it.


www.bungie.net
Post #1789
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 1:53pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.125. 11 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.