翻譯|使用教程|編輯:楊鵬連|2021-07-21 09:48:35.930|閱讀 239 次
概述:我們檢查最后一個組件TfrxIBXQuery. 它繼承自TfrxCustomQuery基本類,其中已經定義了必要的屬性。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
FastReport VCL是用于 Delphi、C++ Builder、RAD Studio 和 Lazarus 的報告和文檔創建 VCL 庫。它提供了可視化模板設計器,可以訪問 30 多種格式,并可以部署到云、網站、電子郵件和打印中。
最后,讓我們檢查最后一個組件TfrxIBXQuery. 它繼承自TfrxCustomQuery基本類,其中已經定義了必要的屬性。我們只需要定義Database屬性和覆蓋SetMaster方法。其他方法實現與TfrxIBXTable組件類似。
TfrxIBXQuery = class(TfrxCustomQuery)
private
FDatabase: TfrxIBXDatabase;
FQuery: TIBQuery;
procedure SetDatabase(const Value: TfrxIBXDatabase);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetMaster(const Value: TDataSource); override;
procedure SetSQL(Value: TStrings); override;
function GetSQL: TStrings; override;
public
constructor Create(AOwner: TComponent); override;
constructor DesignCreate(AOwner: TComponent; Flags: Word); override;
class function GetDescription: String; override;
procedure BeforeStartReport; override;
procedure UpdateParams; override;
property Query: TIBQuery read FQuery;
published
property Database: TfrxIBXDatabase read FDatabase write SetDatabase;
end;
constructor TfrxIBXQuery.Create(AOwner: TComponent);
begin
{ create component – query }
FQuery := TIBQuery.Create(nil);
{ assign link to it to DataSet property from basic class – do not forget this line! }
Dataset := FQuery;
{ assign link to connection to DB by default }
SetDatabase(nil);
{ after that basic constructor may be called in }
inherited;
end;
constructor TfrxIBXQuery.DesignCreate(AOwner: TComponent; Flags: Word);
var
i: Integer;
l: TList;
begin
inherited;
l := Report.AllObjects;
for i := 0 to l.Count - 1 do
if TObject(l[i]) is TfrxIBXDatabase then
begin
SetDatabase(TfrxIBXDatabase(l[i]));
break;
end;
end;
class function TfrxIBXQuery.GetDescription: String;
begin
Result := 'IBX Query';
end;
procedure TfrxIBXQuery.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FDatabase) then
SetDatabase(nil);
end;
procedure TfrxIBXQuery.SetDatabase(const Value: TfrxIBXDatabase);
begin
FDatabase := Value;
if Value <> nil then
FQuery.Database := Value.Database
else if IBXComponents <> nil then
FQuery.Database := IBXComponents.DefaultDatabase
else
FQuery.Database := nil;
DBConnected := FQuery.Database <> nil;
end;
procedure TfrxIBXQuery.SetMaster(const Value: TDataSource);
begin
FQuery.DataSource := Value;
end;
function TfrxIBXQuery.GetSQL: TStrings;
begin
Result := FQuery.SQL;
end;
procedure TfrxIBXQuery.SetSQL(Value: TStrings);
begin
FQuery.SQL := Value;
end;
procedure TfrxIBXQuery.UpdateParams;
begin
{ in this method it is sufficient to assign values from Params into FQuery.Params }
{ this is performed via standard procedure }
frxParamsToTParams(Self, FQuery.Params);
end;
procedure TfrxIBXQuery.BeforeStartReport;
begin
SetDatabase(FDatabase);
end;
如果您對 FastReport 感興趣,歡迎加入 FastReport QQ 交流群:702295239
還想要更多嗎?您可以點擊閱讀【FastReport報表2021最新資源盤點】,查找需要的教程資源。上是FastReport .NET慧正在網火熱銷售中!>>查看價格詳情
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: