FastReport VCL报表开发人员手册:查询组件

我们检查最后一个组件TfrxIBXQuery. 它继承自TfrxCustomQuery基本类,其中已经定义了必要的属性。

最后,让我们检查最后一个组件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慧正在网火热销售中!>>查看价格详情

标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年6月18日
下一篇 2021年6月18日

相关推荐

发表回复

登录后才能评论