RAD Studio |  |

Creating Business Rules in a Data Module
See Also
Collapse All

Besides writing event handlers for the components in a data module, you can code methods directly in the unit file for a data module. These methods can be applied to the forms that use the data module as business rules. For example, you might write a procedure to perform month-, quarter-, or year-end bookkeeping. You might call the procedure from an event handler for a component in the data module.

The prototypes for the procedures and functions you write for a data module should appear in the module's type declaration:

Copy Code

    type
      TCustomerData = class(TDataModule)
        Customers: TClientDataSet;
        Orders: TClientDataSet;
        .
        .
        .
      private
        { Private declarations }
      public
        { Public declarations }
        procedure LineItemsCalcFields(DataSet: TDataSet); { A procedure you add }
      end;
    var
      CustomerData: TCustomerData;

The procedures and functions you write should follow in the implementation section of the code for the module.

See Also

Designing Database Applications

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!