>Hi Frank,
>
>>Here's the code:
>>
>>
public string ValidateSumAssuredMaxMin(Guid? planPK, decimal? sumAssured)
>> {
>> string message = null;
>> Plan oPlan = new Plan();
>> oPlan.GetPlanByPlanPK((Guid)planPK);
>> // check that the sum assured meets the min and max sum assured requirements
>> if (oPlan.Entity.MinSumAssured > (decimal)sumAssured
>> || oPlan.Entity.MaxSumAssured < (decimal)sumAssured)
>> {
>> message = "Rider Sum Assured must be between " + oPlan.Entity.MinSumAssured.ToString() + " and " + oPlan.Entity.MaxSumAssured.ToString();
>> this.AddErrorProviderBrokenRule("SumAssured", message);
>> }
>> return message;
>> }
>>
>>This is called from a textbox that is in a grid displaying/editing the child business object.
>
>This is a bit of an odd answer, so bear with me. The business rules object is normally accessed via the business object and in this case you are accessing the rules object this way but then in the rules object you are creating a new business object. I did not trace through this to see what happens, but I would recommend a different approach. Maybe this.
>
>Put a method in your business object that you call instead of your rules object that can begin the validation process. What that method would do is GetPlanByPlanPK and then once the record is retrieved, let that method call the rules.ValidateSumAssuredMaxMin method. I would take the code out of the validate method which creates a business object and retrieves data.
>
>I hope that made sense, and let me know how that turns out.
>Tim
Tim,
if I am doing something out of the ordinary I would prefer to do it the recommended way. So rather than trying it your suggested way, what would be the normal way to validate a field based on another field? In this case can I assume the Min and MaxSumassured are available without having to get them by creating a new BO?