ReportConnection.pas 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. unit ReportConnection;
  2. interface
  3. uses
  4. ADODB, ProjectData, ReportManager, rpgGatherControl, rpgZoneGatherControl;
  5. type
  6. TReportConnection = class
  7. private
  8. FProjectData: TProjectData;
  9. FConnection: TADOConnection;
  10. FCommonGather: TrpgGatherControl;
  11. FZoneGather: TrpgZoneGatherControl;
  12. public
  13. constructor Create(AProjectData: TProjectData);
  14. destructor Destroy; override;
  15. procedure RefreshConnection(ATemplate: TTemplateNode);
  16. property Connection: TADOConnection read FConnection;
  17. end;
  18. implementation
  19. { TReportConnection }
  20. constructor TReportConnection.Create(AProjectData: TProjectData);
  21. begin
  22. FProjectData := AProjectData;
  23. FCommonGather := TrpgGatherControl.Create(AProjectData);
  24. FZoneGather := TrpgZoneGatherControl.Create(AProjectData);
  25. FConnection := AProjectData.ADOConnection;
  26. end;
  27. destructor TReportConnection.Destroy;
  28. begin
  29. FCommonGather.Free;
  30. FZoneGather.Free;
  31. inherited;
  32. end;
  33. procedure TReportConnection.RefreshConnection(ATemplate: TTemplateNode);
  34. begin
  35. case ATemplate.DataBaseFlag of
  36. 0: FConnection := FProjectData.ADOConnection;
  37. 1: FConnection := FCommonGather.RefreshConnection(ATemplate);
  38. 2: FConnection := FZoneGather.RefreshConnection(ATemplate);
  39. end;
  40. end;
  41. end.