Copyright 2006 by gINT Software. All rights reserved worldwide.
GR013.TXT

gINT Rules Code Samples - 013

Requires gINT version 7 or later.

NOTE:  Code samples are provided free of charge and as-is.  gINT Software makes no claim or warranty as to the accuracy of the samples.  It is the responsibility of the user to ensure that the code performs as it should.  Comments, suggestions, and error reports are appreciated.

Description
===========
This rule deals with a part of a common process in laboratory testing. A project is drilled and some of the field samples are brought into the office where they are stored in a samples storage facility. In gINT the samples are logged and the storage identification is also recorded as an attribute of the sample. A one-to-one child of the sample table records the tests that are to be run on each sample. This rule populates the sample storage location from the sample table into the test scheduling table. This allows the person specifying the testing to know if there is a stored sample corresponding to the field sample and allows the person performing the test to quickly see where the sample is stored.

The rule is run in the sample table and is specified in the "gINT Rules Procedure After Save" property of the table properties dialog, under the "gINT Rules" tab. The reason this rule must be run in the after save event is that the rule populates records in the child scheduling table. When you add new records in the sample table, new records cannot be added in the child until after the sample records are successfully saved.

The sample project is set up like our standard AGS database. If your database structure is different, you will need to change the code appropriately. See the notes within the code for guidance.

If you implement this rule in an existing project that already had sample storage locations specified in the sample table, you can force the program to run the rule for every PointID in the project.

The basic algorithm of the rules is as follows:
1. Clear all values in the Sample Storage Location field in the scheduling table for the current PointID.
2. Extract all key fields and Sample Storage Location field data from the sample table from the current PointID where the Sample Storage Location field has data. This is stored in a recordset.
3. If there are no Sample Storage Location data in sample table for the current PointID, the procedure is exited. There is nothing more to do.
4. If there are Sample Storage Location data, create a writable recordset (dynaset) of all the existing records in the scheduling table.
5. Loop through the sample data and store the Sample Storage Location data into the appropriate records in the scheduling dynaset. If a corresponding record does not exist, create it, otherwise edit it.

The Sample Storage Location field in the scheduling table has the read-only attribute set. This value must only come from the sample table through the rule.

The scheduling table makes use of the "Caption Vertical" property so that more fields can be fit on a screen. In a real project tests like consolidation and compaction would not be boolean fields but text fields with lookups giving a list of allowable test types.

The scheduling table also sets the "Show All Parent Keys" property of the table. This shows all parent records whether they have data or not and sorts the records so that those that have data are shown on top. You are free to unmark this property if you don't want it. It is not necessary for the rule.

Another rule that could be written in conjunction with this rule is to create a validation rule on saving in the scheduling table that does not allow any test specifications if there is no value in the Sample Storage Location field for the record, that is, don't allow testing for a sample that doesn't exist.

Revision History
================
03 June 2006:
Initial upload
*************************************************

INCLUDED FILES:
GR013.GLB:
  gINT Rules code modules:
    GR013                    Main
                             SampleStoreLocation

    GR013 COMMON PROCEDURES  AddBracketsFnS

GR013.GPJ:
  Sample project that makes use of the code modules. To see this rule work you can add new records to the existing samples, change Sample Storage Location values in the sample table or delete all the data in the scheduling table and run gINT Rules:Recalculate Current Table while in the sample table. The Sample Storage Location values in the scheduling table will be changed appropriately.
*************************************************

INSTALLATION PROCEDURE:
Copy the files wherever you prefer.  To see the gINT Rules code modules you must either merge the GLB into your library (Utilities:Lib Merge/Copy) or change to the included library (File:Change Library).
*************************************************

SPECIAL NOTES:
None
*************************************************