Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BusinessRules between different BOs
Message
De
05/10/2010 08:17:20
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01483404
Message ID:
01483951
Vues:
20
>>>>Hi,
>>>>
>>>>I may have asked this before, my apologies if I have, but I can't work out how to do this.
>>>>
>>>>I have a Receipt BO and a ReceiptDetails BO which is a child of the Receipt BO. For data entry validation, the user has to enter a total amount received at the Receipt BO level and then the sum of the amounts entered at the Receipt Detail BO level must equal the Receipt BO's total amount received.
>>>>
>>>>How should I approach writing such a Business Rule?
>>>>
>>>>I guess it should be at the Receipt BO level, but how would I refer to the child BO to sum all the amounts?
>>>Frank,
>>>In your Receipt BO Rules method, create a ReceiptDetail BO, call the method to sum the details and check that amount against the amount in the Receipt BO.
>>
>>Linda,
>>
>>but at the point in time when the Receipt BO is being saved, the Receipt Detail would not yet have been saved, so I need to sum what is currently in memory, not what is stored in the database. Or am I thinking too hard about this?
>
>Sorry. What you probably need to do is use a foreach statement to cycle through the rows in the detail dataset and sum the amounts.
>
>int detailSum = 0;
>foreach(DataRow dr in oReceiptDetail.GetCurrentDataSet().Tables[oReceiptDetail.TableName].Rows)
>{
>     detailSum += dr["DetailAmount"];
>}
>
>If it's in a grid, you can also use "foreach(DataGridViewRow dgvr in this.grdReceiptDetail.Rows)".
>Is this closer to what you need?

That's what I am currently doing, but it is at the form level, whereas I really want this to be a business rule so that if/when I change my UI I don't have to code it a gain.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform