You're basically wanting to create a ReportingFramework ... where you can
dynamically add in new CR's.
First check this out:
12/1/2005
Understanding the Simple Factory Pattern
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!126.entry
Look especially at "Reflection"
You need to code to house "how am I going to show this report?".
public class ReportViewArgs : System.EventArgs
-- ReportAssembly (string)
--ReportFullyQualifiedObjectName (string)
--SourceDataSet (DataSet)
If you do this, you can create what you want.
HOWEVER, you will need to **abandon** writing reports which talk directly to
the database. (which is a good idea of its own right), and go to a dataset
model.
Read this post:
http://groups.google.com/group/micro...059b979636e53e
Read this article:
http://support.businessobjects.com/c...etdatasets.pdf
Here is your code:
private void Go(ReportViewArgs args)
{
CrystalReport rpt = this.LoadUsingReflectionTheReport (args ) ;
rpt.SetDataSource (args.SourceDataSet);
CrystalReportViewer1.ReportSource = rpt;
}
private CrystalReport LoadUsingReflectionTheReport ( ReportViewArgs args )
{
//use the blog code to figure out how to reflectively create your CR
object.
//http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!126.entry
return rpt;
}
Here is mocked example:
ReportViewArgs : System.EventArgs
-- ReportAssembly (string)
--ReportFullyQualifiedObjectName (string)
--SourceDataSet (DataSet)
ReportViewArgs args = new ReportViewArgs ();
args.ReportAssembly "MyReports";// usually you'll have a file called
MyReports.dll, which is a net assembly with your CR defs in it
args.ReportFullyQualifiedObjectName "MyReports.EmployeeSalariesReports";
//full name of the objects, including namespaces
args.SourceDataSet = DAL.SomeMethodToGetTheDataSet();
//then call it
X.Go (args);
If you want to be able to add in reports later, on the fly, this is a good
architecture.
How do I know? I've already done one of these.
Go with datasets with Crystal Reports. And months later when you decide CR
sucks and you want something else, you still have the datasets, and not a
bunch of hidden CR code that you can't reuse.
"Brad" <br************@roche.comwrote in message
news:eO**************@TK2MSFTNGP02.phx.gbl...
I'm developing a CRUD based desktop application and I want to structure
the
design so that I don't need to modify the source code to add additional
reports. I'm planning to use the version of Crystal Reports that comes
with
VS.Net 2005, but I'm a novice with this tool. Can somebody can give me
some
suggestions or point me to some sample code/design?
TIA
Brad