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慧正在网火热销售中!>>查看价格详情
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [https://www.fastreportcn.com/]
本文地址:https://www.fastreportcn.com/post/3168.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [https://www.fastreportcn.com/]
本文地址:https://www.fastreportcn.com/post/3168.html