Architecture
Reporting architecture
Synopsis
Reports are stored in the database. Each report has a unique name, and is associated with a form in the application. When opening a form, a list of report names for that form is loaded.
SQL
Table definition for reports:
CREATE TABLE "REPORTDEFS" (
"ID" INT NOT NULL,
"Name" NVARCHAR(200) NOT NULL,
"Form" NVARCHAR(200) NOT NULL,
"Description" NTEXT NULL,
"Data" NTEXT NOT NULL,
"Design" NTEXT NOT NULL,
"Hidden" BOOL NOT NULL,
PRIMARY KEY ("ID")
);
CREATE UNIQUE INDEX "U_REPORTNAME" ON REPORTDEFS(Name);
Report data
Report data is a structure that is used to describe the report. It consists of: 1. 1 or more named SQL statements. These have the following properties: * Name (string) Must be unique in the report. * SQL (string) SQL statement to execute. * Description (string) optional description. * Master (string) Optional name of master dataset.
- 0 or more report parameters. A report parameter has 3 properties:
- A unique name.
- A data type (string, integer, float, datetime, boolean )
- A default value.
The SQL statement can have parameters, as per the usual delphi convention Select A,B,C from D where (E=:Param) these parameters must be in the list of report parameters.
Additionally, it can have macros:
{Name}
Printing interface in forms:
A protected call PrintReport exists to print a report:
Procedure PrintReport(ReportName : String; Params : TReportParams)
TReportParam = record
Name : String;
Value : String;
end;
The TReportParams list has additional methods to easily add Parameters, corresponding to the data types.
Procedure Add(Const aName : String; AValue : String);
Procedure Add(Const aName : String; AValue : Integer);
Procedure Add(Const aName : String; AValue : Double);
Procedure Add(Const aName : String; AValue : TDateTime);
Procedure Add(Const aName : String; AValue : Boolean);
A public method exists
Procedure PrintReport(ReportName : String; Direct : Boolean = False);
It will call the following virtual protected method to get the parameter list:
Procedure GetReportParameters(Const ReportName : String; aList : TReportParams);
Every form overrides this method to deliver the correct parameters to the report. Report printing can be halted at this point by raising an exception.
System Parameters.
Some special parameters exist:
__name__
__Copies__
Development:
The standard forms are developed and stored in files, checked in in the version system. They are uploaded to the database using a separate tool or in the program itself. * Easier to maintain * Allows to send a new version which can be read into the database.