Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving with business rule validation
Message
From
02/03/2000 08:37:11
Rex Mahel
Realm Software, Llc
Ohio, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Title:
Saving with business rule validation
Miscellaneous
Thread ID:
00340486
Message ID:
00340486
Views:
65
All

Here the story:

I am creating an inventory form using the cBizObjMaintenanceForm.

My business objects are:

Inventory,
InventoryDetail,
InventoryLot,
InventoryLotLookUp,
VaccineAlias

The relations are:
Inventory => InventoryDetail - One to Many
InventoryLot => InventoryDetail - One to Many
VaccineAlias=>InventoryDetail - One to Many


InventoryDetail view has the following fields:

InventoryAlias.cName AS cAliasName, ;
InventoryLot.cLotNumber, ;
InventoryDetail.iQuantity,;
InventoryLot.yCostPerDose, ;
InventoryLot.dExpiration, ;
InventoryDetail.iQuantity, ;
InventoryDetail.iId, ;
InventoryDetail.iInventoryId, ;
InventoryDetail.iInventoryLotId, ;
InventoryLot.iInventoryAliasId, ;


Entry goes like this:
1) VaccineAlias is a lookup, select an existing Vaccine
2) When VaccineAlias is selected, requery InventoryLot business object to show lots for this vaccine
3) Select an InventoryLot from the combobox or enter a new lot number
4) The system fills the yCostPerDose and dExpiration fields
5) Enter the quantity
6) yCostPerDose and dExpiration can be edited.

When I save, I need to requery the InventoryLot view to retrieve the lot information for each lot used in this transaction. I then loop through the InventoryDetail view. If the iInventoryLotId is empty, I add a new record to the InventoryLot view and add the information. If the iInventoryLotId is not empty and any lot information field has changed, locate the InventoryLot view record and update the information.
The InventoryDetail.iInventoryLotId is filled with the InventoryLot view iId field.

My problem is this:

I am using an event to update all the information. I should be able to run this from the InventoryDetail.PreSaveHook, but since I am using a Requery, and using a Requery under a transaction is not allowed, I needed to run the event from the Inventory.PreSaveHook.

I am also using business rule validation before saving. If I have a rule failure in the InventoryDetail, fix it, then try to save, I get an error stating that there are uncommitted changes for the InventoryLot view.

I could solve this is several ways:

I could write a method to do all the rule checking first and run it from the InventoryPreSaveHook.
If I could tell if the view had been requeried, I could just not requery it again.
Take to code from the view and put the appropriate pieces in the appropriate PreSaveHook methods

Comments?

Preferences?

Better ideas?

TIA

Rex
Next
Reply
Map
View

Click here to load this message in the networking platform