How to check Business Rules from a parent BO into a Child BO


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
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
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Edhy.

Just checking the ChildBo will not be sufficient in my case (Unless I can do it from the ParentBO).

Say my 'Logical'  Business Rules stipulate that Customer 'A' is allowed Products 'X' and 'Y', and Customer 'B' is only allowed Proucts 'Z'.    Customer A is input on the Parent BO..passes all validation. Products X and Y are input on the Child BO...pass all validation and focus passes back to the parent Form . Everything ok so far...........

Now , the customer is changed , on the parent form,  from Cusrtomer 'A'  to Customer 'B' . This now should not pass validation as Customer 'B' is only allowed product 'Z',   ... but at this stage products 'X'  and 'Y' have been entered on the Child BO.

What I am trying to do,  is set up , on the Business Object , the Business Rule that Customer 'B' is only allowed Product 'Z'. My issue is how do I do this from within a Business Object, i.e. set up a Business Rule on say a Parent BO which will also require access to another BO (the child).

The scenario above is just one example, but the same would apply where 'Rules' will cross Business Objects.  Another example would be where a date is entered on the Parent Business Object which might control what Product Discounts ara llowed. Initially , when the lines are being entered on the child, they will pass validation, but the problem may arise if the date is subsequently changed on the Parent, causing the child rules then to be broken
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search