Hi Guys,
I'm developing a web site that allows clients to print from a variety of reports. I may have about 15 different reports, and based on what the client selects, only one of them is displayed.
As you know, when you create a Report, the Crystal Reports engine creates a class for such report. At run time, what I do is I (1)instantiate objects of the appropriate report type (based on what the user selects), (2) set a couple of its properties based on what the client has selected, and (3) assign the object to the ReportViewer so that clients can view the report. Since I have 15 different reports, the code I have to write is very lengthy and inefficient.
It's a nightmare!!! I know I could use a switch statement instead of all the if's above but that's not the issue. I was hoping to see if I could create an interface which all my reports could implement so that the above code could be reduced. Can anybody tell me how to do this?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin
I'm developing a web site that allows clients to print from a variety of reports. I may have about 15 different reports, and based on what the client selects, only one of them is displayed.
As you know, when you create a Report, the Crystal Reports engine creates a class for such report. At run time, what I do is I (1)instantiate objects of the appropriate report type (based on what the user selects), (2) set a couple of its properties based on what the client has selected, and (3) assign the object to the ReportViewer so that clients can view the report. Since I have 15 different reports, the code I have to write is very lengthy and inefficient.
Code:
[COLOR=green]// Create a varible for each report[/color]
ReportType1 rpt1;
ReportType2 rpt2;
ReportType3 rpt3;
[COLOR=green]// ...
// All the way to 15 or more
// Now see which report the user wants[/color]
if (selectedRprt == 1)
rpt1 = [COLOR=blue]new[/color] ReportType1();
[COLOR=green] // Do other stuff[/color]
else if (selectedRprt == 2)
rpt2 = [COLOR=blue]new[/color] ReportType2();
[COLOR=green] // Do other stuff[/color]
else if [COLOR=green]// and on and on and on...[/color]
It's a nightmare!!! I know I could use a switch statement instead of all the if's above but that's not the issue. I was hoping to see if I could create an interface which all my reports could implement so that the above code could be reduced. Can anybody tell me how to do this?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin