By Charles R Hankey - 11/9/2010
XtraReports 10.1.7
I would like to use SPs for all data retrieval for over 100 reports, many involving parent-child and even grandchild relationships and using detail bands rather than subreports.
I have a lot of questions, so bear with me and I'll be very grateful.
In VFP, we were mostly limited to one detail band and the common practice was to flat-file the data and use grouping.
It looks like XtraReports, offering multiple detail bands, is happiest with actual parent child relational data, just as we would pull it for CRUD.
I love the idea of pulling all data for a report with one SP. I send params defining set of parent records and use the list of pks of the selected parents to pull all relevant children - all in one trip using fullmultipledatatables(). ( in actual CRUD, of course, I usually just pull one parent at a time with its associated children, but in reports it would seem multiple parents and filterchildrecords() would be more common )
My first big decision seems to be : BOs or datasets or datasets filled from BOs
My main concern is how to have the structure available at design time for laying out the reports.
If I'm just going to use the standard ADO stuff, I see I can use the dataexplorer in VS2010 and pick the sp as a datasource. But it seems only the first table of a multitable sproc will get its structure into the treeview. Is there a way to have the structure of a multitable sproc populate the treeview? I would certainluy like to avoid manually designing each datatable in the dataset for each report.
If I use BOs, using fillmultipledatatables, can I see their structure at design time to design my reports?
Do I need to make the child bos properties of the parent as in the RSS example ? Wouldn't filterchildrecords() work?
Does XtraReports see a SF BO as an iList object? What is the best way to handle SF BOs in Xtrareports?
I have considered the best way might be to use SF to deal with the sp, fill multiple BOs and then just grab their data at run-time to populate the dataset I will past to the report object, but that still leaves the question of design time what do I use for data in the designer when telling the report controls what they will be bound to?
I'm sure there is a lot more to ask but perhaps Peter and Bill and others who've been down this road can clear up some of my thinking so I can ask more intelligent questions on this. I'm starting a really big project with it and I want to resolve some conceptual issues before going to far in the wrong direction
Thanks in advance
|
By Ger Cannoll - 11/9/2010
Hi Charles. I am going down similar route right now . I am inclined to go the route of datasets (outside of SF) for a no. of reasons, however if there is a better way I am open to it.
1. Datasets seem to be the default datasource in Xtrareports
2. There does not seem to be a direct option to set a BO as a datasource for Xtrareports. I have seen a few examples where a BO is created and then data extracted out of the BO into a dataset. This seems to me to be Double Selecting and would take twice as long
3. Its not a big deal to create the dataset , and in our reports, there tends to be a certain amount of Pre-processing anyway
4. It seems to be easy enough also to set up multiple databases into a Dataset and then add a relation to relate parent to child
5. See sample below (only uses one Table and command string whereas a SP may be better). This more or less worked first time. In design mode, there is a certain amount of duplication in that I had to connect to my version of SQL in design mode, but this does not take that much time. I have the following code in the click event of a button on a form which will 'Run the Report' . I also plan on setting all my XtraReport up in a separate DLL, just to segragagte them out.
(Hopefully in the case of Multi Table reports, the above scenario will not go out the window !!)
// Instantiate Report and Show It string connect; string command; connect = MicroFour.StrataFrame.Data.DataLayer.DataSources[""].ConnectionString; command = "Select * from SMA Order by SMA_CUSREF"; SqlDataAdapter da = new SqlDataAdapter(command, connect); DataSet ds = new DataSet(); da.Fill(ds); CustomerDetails01 rep = new CustomerDetails01(); rep.DataSource = ds; rep.DataMember = "SMA"; rep.ShowPreview(); .
|
By Charles R Hankey - 11/9/2010
I was thinking the same thing about datasets but here is the problem :
I want to use the same methodology for all my reports and use stored procedures.
I will have a lot of reports where the dataset will hold more than one table.
I don't want to bring anymore records and columns than necessary over the wire and don't want to make any more trips to the server than i have to (some of my sql tables are quite large)
I also *really* don't want to have to manually build the datasets if I can get the schema from the SP in the Add Datasource thingy in VS. I'd prefer to pull parent-children-grandchildren in one sp if I can and still get the schema at design time from the sproc
Soooo ....
I'm really looking for a best practice way that is not going to involve writing 200 lines of code just to hook up the data for a report and is going to allow me to use the visual designer at design time.
How are you creating the datasets? Are they strongly typed (does it matter?) I'm thinking you may be right about the way to do this. I'm not really that tempted by the BOs as from forum traffic at DevExpress I'm getting that hooking up iList stuff has its own challenges and datasets seem to be the native format.
I did find this post interesting :
http://forum.strataframe.net/Topic8417-6-1.aspx
and plan to study it more.
|
By Edhy Rijo - 11/9/2010
Hi Charles, Gerard,
Hmmm, what a coincidence, 2 days ago I downloaded DexExpress to start testing their reporting engine, even though in version 10.2 they will have the MDI controller which will allow you to work with multiple reports at the same time.
The SF Business Binding Source wizard was designed with reporting in mind. Reports don't read from a BO, but from a BusinessBindingSource (BBS) which is attached to a SF BO. The wizard will also create a subclass of the BO you want to work with in case you need to add special coding just for reporting purpose and not to mix BOs created for forms.
With that in mind, I have been able to create a very simple report (not one2many yet) with a BBS and it works just fine, the only problem is that within the designer I am not able to preview the data since this needs to be generated by one of the FillBy methods in my BO. I still need to figure out if there is a way to have the data available during the design.
I kind a like the approach used by DevExpress since they have a class file for the report. Even though I am currently using RSS, I sill consider them not to be user friendly (at least at my level ) and also it looks like DexExpress has more resources to the development cycle to keep up with their tools. They also have very good reviews and awards for their tools.
I am currently busy, but will continue to explore the DevExpress report and when I am able to generate at least a more complicate report I will try to post a sample.
|
By Ger Cannoll - 11/9/2010
The first few reprots I did , I used plain old selects. Have now set up a report which uses a SP as the source and it worked fine. Advantage here is that , you still create a dataset, but you dont have to enter the Select stuff twice, just use the Stored procedure at design time and in the final Runtime app. You still need to put a bit of code to 'Run' the app '. The code I have used is below. Also, I have tested using just one table but it 'Should' work for multiple tables......my next project when I get a bit of time...
// Instantiate Report and Show It using a Stored procedure string connect; SqlCommand command = new SqlCommand("dbo.sp_KmaSelectAll"); command.CommandType = CommandType.StoredProcedure; connect = MicroFour.StrataFrame.Data.DataLayer.DataSources[""].ConnectionString; command.Connection = new SqlConnection(connect); SqlDataAdapter da = new SqlDataAdapter(command); DataSet ds = new DataSet(); da.Fill(ds); StockDetails01 rep = new StockDetails01(); rep.DataSource = ds; rep.DataMember = "KMA"; rep.ShowPreview();
|
By Aaron Young - 11/23/2010
There is a lot of overhead that comes with using datasets for reports and I would avoid them if you potentially have large recordsets. As Edhy has mentioned, you can use a custom binding source instead which can be filled with all data in one pass for multiple enclosed business objects. If you allow your end-users to modify the reports, you can call one of the DevExpress End-User Report Designers and supply your filled custom business object as the data source. You can even re-use the custom binding source with grids to obtain parent child layouts which can then be printed via the DevExpress reporting system straight from the grid. This also gives the end user some control as they can filter the grid data, change sort, choose columns and even hide child bands before invoking a report from the grid itself.
Aaron
|
By Andrew Harper - 10/18/2011
Hi Edhy,
I have just started to look at Xtra reports and have a few queries about using a BBS. I have been able to get them to work with datasets and have also explored the sqladapter approach referred to by Charles. I am hoping that you can clarify a few things for me.
I can add a BBS to an Xtra report in the designer but I am unable to add a BO - I get an error "The object that the business object is dropped on must implement microfour.strataframe.ui.windows.forms.iContainerControl". As a result I am unable to specify text.binding properties for the report labels at design time as you can't specify a BO for the BBS. Have you been able to do this in the designer or are you specifying the BO for the BBS and doing the databinding in code at run time? I am using VS2010 and XtraReports 11.
I suspect I am missing something obvious,
Best regards,
Andy
|
By Edhy Rijo - 10/18/2011
Hi Andy,
That is a great question!!!
StrataFrame has a special BBS wizard for reports called "SF Custom Business Binding Source" You can call it by adding an item to your project and choose the "SF Custom Business Binding Source".
The wizard will simply create a BBS based on a business object that you select, it can also create an inherited BO to be used by the report in case you need to add specific code like custom field properties that are only used by the report and the regular BO used for the forms.
When the wizard start do the following:
- Select the base BO that will be inherited.
- If you will need custom code for the report at the BO level. I do this always because it separates the report's BO form the form's BO, then check the option to "Create a Reporting Business Object"
- Check the "Create a Custom Business Binding Source" so it will create the BBS for the report.
- Define a Namespace if you want to.
- Click OK button and you will end up with a nice BBS and its BO.
- Build the solution
- Now your BBS should be in the ToolBox and you can drop it in the XtraReport class. Contrary to a BBS used in the forms, these does no need any BO assignment because that is done by the wizard, so the XtraReport will see your field definitions, but keep in mind that you cannot use the live preview in the designer, since the BO is not filled and there is no event in the designer that will allow us to load some sample data.
I am following the logic used in the StrataFlix sample for getting the data for the reports. To run your reports, simple fill the data for the BBS.Source and show the report. I have a ReportNameDataSource.vb file for each report as needed where I get the data for the report, here is a basic one, but as I said, I am following the StrataFlix logic, so feel free to check that sample out. [codesnippet]
Imports MicroFour.StrataFrame.Business Imports CardTrackingSystem.Business Imports CardTrackingSystem.Business.Enumerations Imports CardTrackingSystem.Reporting.xrReportEngineNew Namespace Reports.CardListing Public Class xrCardListingDataSource Inherits xrReportDataSource(Of ItemsBBS) Public Overrides Function PopulateDataSource(ByRef rptParams As ReportParams) As Boolean '-- Populates the data source using the specified Scheduled Date, Employee PK. Me.PopulateDefinedDataSource(rptParams)
If Me.DataSource.SourceBO.Count > 0 Then With CType(rptParams.ReportObject, xrCardListing) '-- Update the report data source .DataSource = Me.DataSource End With '-- Indicate that the data source was populated Return True Else '-- There is no reason to continue since the browse was cancelled Return False End If End Function
''' <summary> ''' Populates the data source using the specified primary key ''' </summary> ''' <remarks></remarks> Public Sub PopulateDefinedDataSource(ByRef rptParams As ReportParams) BusinessLayer.FillMultipleDataTables(ApplicationQueries.GetCardListing_Report(rptParams.CardCode, rptParams.CardName), Me.DataSource.SourceBO) End Sub End Class End Namespace
[/codesnippet]
|
By Andrew Harper - 10/18/2011
Hi Edhy,
Thanks for the detailed response. Initially I tried creating the sf BBS in the applications BO library project but this resulted in a pile of errors. Creating the BBS in the web application project has worked fine.
I have been able to create the SF Custom BBS but do not know how to make it appear in the Toolbox. I have tried creating a new tab on the toolbox and dragging the bbs from the solution explorer but this hasn't worked.
I have been able to add the SF BBS to the report by adding a standard BBS using the designer and then modifying the report code to use the SF BBS instead but clearly I am missing something here. I can now see the BO field list in the Xtra Report designer and can drag bound fields onto the report surface so I am making progress.
The report is destined to be displayed in a web app - have you had any experience using the reporttoolbar and reportviewer, as well as populating the datasource in a web environment?
Best regards,
Andy
|
By Edhy Rijo - 10/18/2011
Hi Andy,
I have been able to create the SF Custom BBS but do not know how to make it appear in the Toolbox. I have tried creating a new tab on the toolbox and dragging the bbs from the solution explorer but this hasn't worked. Well the trick is to rebuild the solution, so they can show up in the ToolBox.
The report is destined to be displayed in a web app - have you had any experience using the reporttoolbar and reportviewer, as well as populating the datasource in a web environment? Sorry I have not done any web application yet, but there are couple of videos in the DevExpress site that will show you that. As for the datasource, it is the same as in WinForm, you should have a BO project that you can reference in the web application.
|
By Andrew Harper - 10/18/2011
Thanks Edhy,
After rebuilding the solution I have a new tab on the Toolbox "XXX_ web components" where xx-web is the project name containing the newly created SF BBS.
This toolbox tab contains only 1 item - a BO of the same name that I specified when creating the SF BBS. The BBS is not shown in the Toolbox tab.
Hoping you might have some further suggestions,
Best regards,
Andy
|
By Edhy Rijo - 10/18/2011
It is been a while since I create one BBS with the wizard, so probably you need to add the <ToolboxItem(True)> attribute to the class definition, here is a sample:
Imports System.ComponentModel Namespace Reports.CardListing <ToolboxItem(True)> Public Class ItemsBBS Inherits MicroFour.StrataFrame.Business.BusinessBindingSource(Of bizItems) End Class End Namespace
|
By Andrew Harper - 10/18/2011
Adding the toolbox attribute and the "Imports" did the trick,
Thanks for your assistance - much appreciated,
Andy
|
By Edhy Rijo - 10/18/2011
Hi Andy,
Thanks for your assistance - much appreciated Glad it worked!!! and again, if you have access to the StrataFlix sample, the logic used there worked out pretty good for me, even though at first, it wasn't clear how things where wired together, but as I acquire more experience in .Net them it makes more sense. I started using Report SharpShooter which is not a very user friendly report engine, but now recreating all my reports with DevExpress was straight forward and I could re-used all my report data source classes and I was really great seeing that the special BBS wizard class worked perfectly with DevExpress also.
|
By Andrew Harper - 10/23/2011
Hi Edhy,
I have integrated the report into a webform and it all works well - the immediate requirement was to provide an order confirmation print from a web page. I haven't had time to review the strataflix methodology in detail yet but will get to it eventually. My first major development in SF is all web based but about to start looking at rewriting a large app in Winforms. My experience so far has been good, most issues I have come up against have been more with learning .Net and Javascript. Data manipulation with the SF Bo's has been easy and a welcome relief from ADO having come from a Foxpro background,
Best regards,
Andy
|
By Edhy Rijo - 10/23/2011
Hi Andy,
Glad it is working out for you and the web application. I have plans to play with a web application, but have not had the time to get into it.
I love SF, and feel pretty comfortable with their logic and design, specially after starting to use DevExpress controls and seeing they play nicely with the SF framework.
|
|