Paul,
I have a cReport class that has this Execute() method maybe it'll stir some ideas:
lparameter pnDestination, plSummary
this.mnDestination = m.pnDestination
this.mlSummary = m.plSummary
this.Setup()
this.SQL()
if ( ( type( "m.glReportDesign" ) == 'L' ) and m.glReportDesign )
modi repo (this.mcReportForm)
endif
this.Report()
this.ShutDown()
Setup(), and Shutdown() are abstract methods of the class so each report supplies the code they need there. The SQL() method can be the method where the actual cursor is created or it calls a contained object cSelect.Execute(). The Report() method wraps the REPORT FORM command.
In my framework one of these report objects is put into a container for each report of the system. I haven't had a client yet that's needed business objects that know how to Print() themselves so I've never gone down that design path.
>I'm trying to decide where I should put reports I create. I've got a few different classes that handle different aspects of my program. As an example, I have an "Invoice" class that handles all of the invoices in the system. I've got a number of reports that will need to use this class to generate reports.
>
> Should I create a new class for each report? Or should I create a "Report" class that handles all of my reports? Currently in the Invoice class I have a Print() method, a "ReportType" property, and a "ReportName" property. The ReportType can accept a report #, the ReportName has the actual FoxPro report file name (this is just for expandability - I haven't actually passed the file names to this object). This seems OK for reports that directly use the Invoice class - for instance, printing the invoice :) but doesn't seem quite right for more generalized reports - like a list of all the Invoices during a period.
>
> What if I created a new class for each "Specialized" report type. This class would create any objects it needs to generate the report, then create a cursor (or temp table) and calls the Report form (or Crystal Reports). Does this seem reasonable? What else should I consider?