Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.SessionInfo.Retrieve;

for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do begin

Crpe1.SessionInfo[cnt].UserID := 'Bond'; Crpe1.SessionInfo[cnt].UserPassword := '007';

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SessionInfo UserPassword property

Declaration

property UserPassword: string;

Description

The UserPassword property specifies the password for an MS Access table that has User-Level security.

Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.SessionInfo.Retrieve;

for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do begin

Crpe1.SessionInfo[cnt].UserID := 'Bond'; Crpe1.SessionInfo[cnt].UserPassword := '007';

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

VCL Reference

606

SessionInfo Methods

SessionInfo Add method

Declaration

procedure Add(TableNumber: TCrSessionInfoTable);

Type

TCrSessionInfoTable = integer;

Description

The Add method adds an item to the SessionInfo object and sets the internal index to that item. It requires a Table number as a parameter, which should be a number corresponding to a Table in the Report. Tables are numbered starting from zero. If the Add method is used, the steps to using SessionInfo are:

1Add an item to the SessionInfo object (you must specify the Table number).

2Fill the item's properties (UserID, UserPassword, etc.) with values.

3When Execute is called, the properties will be sent to the Print Engine.

NOTE: It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Table numbers are correct for the current Report.

Example

The Add method can be used to manually add an item to the SessionInfo object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Table Number - must be same as in Report} Crpe1.SessionInfo.Add(0);

Crpe1.SessionInfo.UserID := 'Bond'; Crpe1.SessionInfo.UserPassword := '007'; Crpe1.Output := toWindow;

Crpe1.Execute;

SessionInfo Clear method

Declaration

procedure Clear;

VCL Reference

607

Description

This method can be used to clear the internal memory of the SessionInfo object. It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear method is only applied to the SessionInfo object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the SessionInfo of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear method.

Example

This code clears the SessionInfo properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SessionInfo.Clear;

This code clears the SessionInfo properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do begin

Crpe1.Subreports[cnt];

Crpe1.SessionInfo.Clear; end;

SessionInfo CopyFrom method

Declaration

function CopyFrom(Source: TCrpeSessionInfo): boolean;

Description

The CopyFrom method copies the SessionInfo property values from another TCrpeSessionInfo object. It is similar to Delphi's Assign method. It is useful for transferring or temporary storage of values.

Example

The following example copies all the SessionInfo property values to a temporary TCrpeSessionInfo object:

var

tempSessionInfo : TCrpeSessionInfo; begin

tempSessionInfo := TCrpeSessionInfo.Create; tempSessionInfo.CopyFrom(Crpe1.SessionInfo); {...later, when finished with the temp object...} tempSessionInfo.Free;

end;

VCL Reference

608

SessionInfo Count method

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SessionInfo object. It is handy for setting up loops to make similar changes to each item.

Example

The Count method is useful for looping constructions. You would normally want to call Retrieve first:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.SessionInfo.Retrieve;

for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do begin

Crpe1.SessionInfo[cnt].UserID := 'Bond'; Crpe1.SessionInfo[cnt].UserPassword := '007';

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SessionInfo Create method

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SessionInfo object, and does not need to be called in code.

VCL Reference

609

Соседние файлы в папке crystal