StrataFrame Forum
Back
Login
Login
Home
»
StrataFrame Application Framework - V1
»
Business Objects and Data Access (How do I?)
»
How to check Business Rules from a parent BO into a Child BO
How to check Business Rules from a parent BO into a Child BO
Post Reply
Like
1
How to check Business Rules from a parent BO into a Child BO
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Ger Cannoll
Ger Cannoll
posted 15 Years Ago
ANSWER
Topic Details
Share Topic
Group: StrataFrame Users
Posts: 430,
Visits: 507
I have a Parent BO and a Child BO (using a Chikd Dialog) . I am at the point where I want to save the Parent and the child out to the Database and want to check the rules first. So I have code like:
if (this.ParentBO1.CheckRules(true) && this.childBO1.CheckRules(true) )
{
this.childBo1.Save();
this.parentBO1.Save();
MessageBox.Show("Document has been saved", "Kernel Software",MessageBoxButtons.OK, MessageBoxIcon.Information);
}
All works fine. But I want to put validation code into the Parent Business object which will be dependent on what's in the child buisness object. e.g. Particular Customers (on the Parent Bo) can only purchase certain Products (on the child BO). So at the stage I am validating the Parent BO, I need to loop through the Child BO . I would like to put this valididation code into the CheckRulesOnCurrentRow on the parent BO but am not clear on how I will access the Child Business Object on the Parent Business Object. ( It cant really be done from the ChildBO because the Customer could be changed after a whole pile of products have been added ).
Reply
Like
1
Replies
Greg McGuffey
Greg McGuffey
posted 15 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 2K,
Visits: 6.6K
Not sure why I did it VB.NET...
DirectCast is a cast:
MyChildBO
childBO = (
MyChildBO)
Me.ChildBusinessObjects[0];
Yes, ChildBusinessObjects is code only. It is a List<BusinessLayer> property. You don't set the children, just access them. This list is filled via the setting of the ParentBusinessObject on the children. Again, if you have just one child, then it'll be easy. If you have more than on child BO at a time, then you'd just need to check the type.
My ideas are just suggestions. There are many ways to get this done. You'll figure out what works for you. I'm just trying to point out some things I've learned along the way that have really helped improve my code.
Reply
Like
1
Ger Cannoll
Ger Cannoll
posted 15 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Users
Posts: 430,
Visits: 507
Hi Greg
I have that working very well now checking the Child Business Object from the Parent. Many thanks for all your help.
I will definitely revisit this when I have a bit more time , and have a look at a more purist approach as per your suggestions
Reply
Like
1
Greg McGuffey
Greg McGuffey
posted 15 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 2K,
Visits: 6.6K
Glad it helped and you have it working. I'll be glad to continue the discussion and hear what you'll have learned by then regarding where to put validation/business rules.
Reply
Like
1
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
How to check Business Rules from a parent BO into a Child BO
Ger Cannoll
-
15 Years Ago
Hi Gerard, Since you are using a ChildForm dialog, the StrataFlix...
Edhy Rijo
-
15 Years Ago
Hi Edhy. Just checking the ChildBo will not be sufficient in my case...
Ger Cannoll
-
15 Years Ago
Edhy's suggestion will work really well to check rules before...
Greg McGuffey
-
15 Years Ago
Hi Greg. Many thnaks for your very detailed and informative reply...
Ger Cannoll
-
15 Years Ago
Hi Gerald, I'd tend to be more modular. I.e. I'd likely have methods...
Greg McGuffey
-
15 Years Ago
Hi Greg. From the purist point of view I can sort of see what youare...
Ger Cannoll
-
15 Years Ago
Not sure why I did it VB.NET... DirectCast is a cast:...
Greg McGuffey
-
15 Years Ago
Hi Greg I have that working very well now checking the Child Business...
Ger Cannoll
-
15 Years Ago
Glad it helped and you have it working. I'll be glad to continue the...
Greg McGuffey
-
15 Years Ago
Post Reply
Like
1
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search