ReportPrepare.pas 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. unit ReportPrepare;
  2. interface
  3. uses
  4. rdpBillsGatherDm, ProjectData;
  5. type
  6. TReportPrepare = class
  7. private
  8. FProjectData: TProjectData;
  9. FPrepareGclGather: Boolean;
  10. FPrepareLeafXmj: Boolean;
  11. procedure GatherGclAndSave;
  12. procedure UpdateGclGatherTables;
  13. procedure PrepareGclGatherData;
  14. public
  15. constructor Create(AProjectData: TProjectData);
  16. destructor Destroy; override;
  17. procedure PrepareData(AFlag: Integer);
  18. end;
  19. implementation
  20. uses
  21. ScAutoUpdateUnit, rdpTables, ComObj, UtilMethods, ZhAPI, Classes,
  22. ConditionalDefines;
  23. { TReportPrepare }
  24. constructor TReportPrepare.Create(AProjectData: TProjectData);
  25. begin
  26. FProjectData := AProjectData;
  27. FPrepareGclGather := False;
  28. FProjectData.ClearReportPrepareData;
  29. end;
  30. destructor TReportPrepare.Destroy;
  31. begin
  32. FProjectData.ClearReportPrepareData;
  33. end;
  34. procedure TReportPrepare.GatherGclAndSave;
  35. var
  36. DataSaver: TrdpBillsGatherData;
  37. begin
  38. DataSaver := TrdpBillsGatherData.Create(FProjectData);
  39. try
  40. DataSaver.LoadGclBillsGatherData;
  41. finally
  42. DataSaver.Free;
  43. end;
  44. end;
  45. procedure TReportPrepare.PrepareData(AFlag: Integer);
  46. begin
  47. case AFlag of
  48. 1: PrepareGclGatherData;
  49. end;
  50. // For Test
  51. if _IsDebugView then
  52. FProjectData.SaveDebugFile('ReportDataPrepare.dat');
  53. end;
  54. procedure TReportPrepare.PrepareGclGatherData;
  55. begin
  56. if FPrepareGclGather then Exit;
  57. try
  58. UpdateGclGatherTables;
  59. GatherGclAndSave;
  60. FPrepareGclGather := True;
  61. except
  62. FPrepareGclGather := False;
  63. end;
  64. end;
  65. procedure TReportPrepare.UpdateGclGatherTables;
  66. var
  67. Updater: TScUpdater;
  68. begin
  69. Updater := TScUpdater.Create;
  70. try
  71. Updater.ForceUpdate := True;
  72. Updater.Open('', FProjectData.ADOConnection, '', '');
  73. Updater.AddTableDef(S_rdpLeafXmjs, @td_rdpLeafXmjs, Length(td_rdpLeafXmjs), False, False);
  74. Updater.AddTableDef(S_rdpGclBills, @td_rdpGclBills, Length(td_rdpGclBills), False, False);
  75. Updater.AddTableDef(S_rdpDetailGclBills, @td_rdpDetailGclBills, Length(td_rdpDetailGclBills), False, False);
  76. Updater.AddTableDef(S_rdpDetailDealBills, @td_rdpDetailDealBills, Length(td_rdpDetailDealBills), False, False);
  77. Updater.AddTableDef(S_rdpDetailBGLBills, @td_rdpDetailBGLBills, Length(td_rdpDetailBGLBills), False, False);
  78. Updater.ExcuteUpdate;
  79. finally
  80. Updater.Free;
  81. end;
  82. end;
  83. end.