XtraReports - BOs, Datasets or BO-> datasets ? Design time?


Author
Message
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
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
 
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
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();
.

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
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.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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 Crying) 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.

Edhy Rijo

Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
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();



Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
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
Andrew Harper
Andrew Harper
StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)
Group: StrataFrame Users
Posts: 87, Visits: 3.3K
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
Edited 13 Years Ago by Andrew Harper
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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:
  1. Select the base BO that will be inherited.
  2. 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"
  3. Check the "Create a Custom Business Binding Source" so it will create the BBS for the report.
  4. Define a Namespace if you want to.
  5. Click OK button and you will end up with a nice BBS and its BO.
  6. Build the solution
  7. 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 ReportParamsAs 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]

Edhy Rijo

Andrew Harper
Andrew Harper
StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)StrataFrame User (280 reputation)
Group: StrataFrame Users
Posts: 87, Visits: 3.3K
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
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search