Trying to bind to an XtraReport


Author
Message
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Well, Paul, when you get those specific questions, send them to us and we'll certainly try to get them answered.
Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Thanks Trent that helps somewhat and answers alot of the issues I have been knocking around. I defiinatly would rather use the BO's but was not sure on the joined query's .

One of the issues I have is that I HATE doing reports.. When I first started in IT that is all I did for many years.

I want to be able to set up the query and any grouping on the report and have one of the girls do the tedious pretty work. This does require that the fields be bound to something at design time.

I will probably have specific questions on how to set up a bo to support a joined query and provide the strongly typed fileds required to make design time report binding possible. I just havent had a chance to try it so don't know. 

Paul


 

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi guys.

Trent L. Taylor (10/13/2006)
Well if it were me I would not venture too far from the business objects. 

This is exactly what I keep in mind. I realize there's a whole attention built inside the BOs, and for a start I want to take advantage of not having to worry about it. And then, there's the back end, and the Middle Tier. I will stick to the BOs.

You can create any type of JOIN query from within a BO to return any fields that you want.  You can create a view, as you mentioned, to pull back all of the fields you want in a flat format.  If you need to create custom fields or a BO that supports a special DDT layout and then your FillDataTable(...) method pulls data using the inner join, you can.

This is where I need to get proficiency at. But seeing you say it is possible, is already a good incentive.

So, Paul, I think we will be safer under the wings of the BOs. Guess we just have to find our way in it.

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Well if it were me I would not venture too far from the business objects.  You can create any type of JOIN query from within a BO to return any fields that you want.  You can create a view, as you mentioned, to pull back all of the fields you want in a flat format.  If you need to create custom fields or a BO that supports a special DDT layout and then your FillDataTable(...) method pulls data using the inner join, you can.  When you start dealing with typed data sets you are heading for frustrations the first time you want to make a change.  There are a lot of different ways to "skin the cat" so to speak...but you also want to make sure that you are not painting yourself into a corner down the road.

Any of these options, including the typed data set, will work.  But when you start pulling connection strings and talking directly to the data you are breaking encapsulation so if some day you want to change your back end...including the Middle Tier Enterprise Server, your reports will break.  If you work inside the confines of the business object you can change your backend database or connect to the Enterprise Server interchangeably without having to change this code.

Note: Any custom connection you make outside of the logic of the framework will prevent the data access layer from being interchangable without having dramatic side-effects within your application...this includes the Middle Tier Enterprise Server that will be released by the end of the year.

Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Ivan,

I have been struggling with the concept of how I want to deal with Reports and Data Access for the last few days and I can't seem to decide how best to implement it.

I guess it would be nicer to have all the data access come from a bus object library. But at the same time with joined queries for reporting it makes it a bit trickier. I guess you would have to create a view and base a bo off the view.

At the same time it is simple enough to create the typed DS right in the report. but you need watch connection strings etc.

I guess it really doesnt matter.

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Paul.

Thanks for your help!

I will study your code.

I have created an XtraReport abstract class, and in the inherited ones I've being writing code to bind the controls at runtime.

I've been able to run the reports using the BOs, but I've been creating them at runtime. I'm not binding the report controls at design time. So, I use the BOs to populate the information I need, then add them to a DataSet, working with the results there. So far, I haven't created very complex reports, yesterday I managed to make a Master-Detail report to work using the BOs in this way. But you are right, I wonder what the best practice will be when a more complex situation arrives. As usual, I think I will let Trent, Ben and Steve worry for me. BigGrin

I bet they are gonna jump in and say something.Wink

Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Ivan,

I was able to trick the Xtra Report into allowing you to drop a BusBinding Source and Bus object onto it. first create a base class report that implements IContainer. I still need to figure a few things out to make it better but below is what I have so far and seems to work. The Preview won't work but you can bind all the fields etc. But to be honest i am wondering if I even wnat to use BO's for the reports as it seems like most reports i have are base on query's with joins. But here is what I did maybe it will be helpful

Public Class XtraReportBase

Implements MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl 'Add This Line

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

Public Sub AddBusinessObject(ByVal BusinessObject As MicroFour.StrataFrame.Business.BusinessLayerBase) Implements MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddBusinessObject

End Sub

Public Sub AddObjectToInitOnLoad(ByVal ObjectToInit As MicroFour.StrataFrame.UI.IInitOnFormLoad) Implements MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddObjectToInitOnLoad

End Sub

Public Sub AddObjectToPreInitOnLoad(ByVal ObjectToPreInit As MicroFour.StrataFrame.UI.IPreInitOnFormLoad) Implements MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddObjectToPreInitOnLoad

End Sub

Public Sub RemoveBusinessObject(ByVal BusinessObject As MicroFour.StrataFrame.Business.BusinessLayerBase) Implements MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.RemoveBusinessObject

End Sub

End Class

Now go into the designer.vb file of the base report and change

Friend WithEvents Detail As DevExpress.XtraReports.UI.DetailBand

Friend WithEvents PageHeader As DevExpress.XtraReports.UI.PageHeaderBand

Friend WithEvents PageFooter As DevExpress.XtraReports.UI.PageFooterBand

to

Protected WithEvents Detail As DevExpress.XtraReports.UI.DetailBand

Protected WithEvents PageHeader As DevExpress.XtraReports.UI.PageHeaderBand

Protected WithEvents PageFooter As DevExpress.XtraReports.UI.PageFooterBand

 

Next create a new class that looks like below

Public Class InheritedReport

Inherits ReportBase.XtraReportBase ' The base class from above

Public Sub New()

InitializeComponent()

End Sub

Private Sub InitializeComponent()

End Sub

End Class

Rebuild and you should be able to get into the designer of your new subclassd report

Drop a business binding source and bus object on the form set the data source of the report to be the business binding source. The type editor of the business binding source will not work so you need to set it manually in the init component. Maybe this can figured out

Public Class InheritedReport

Inherits ReportBase.XtraReportBase

Friend WithEvents XrLabel1 As DevExpress.XtraReports.UI.XRLabel

Friend WithEvents BusinessBindingSource1 As MicroFour.StrataFrame.Business.BusinessBindingSource

Friend WithEvents BusinessObject11 As TEstBO.BusinessObject1

Private components As System.ComponentModel.IContainer

Public Sub New(Lcname as String)

InitializeComponent()

I also added the fill method here ? works

Me.BusinessObject11.FillByName(LcName)

End Sub

Private Sub InitializeComponent()

Me.components = New System.ComponentModel.Container

Me.XrLabel1 = New DevExpress.XtraReports.UI.XRLabel

Me.BusinessBindingSource1 = New MicroFour.StrataFrame.Business.BusinessBindingSource(Me.components)

Me.BusinessObject11 = New TEstBO.BusinessObject1(Me.components)

CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()

'

'Detail

'

Me.Detail.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.XrLabel1})

'

'XrLabel1

'

Me.XrLabel1.Location = New System.Drawing.Point(33, 8)

Me.XrLabel1.Name = "XrLabel1"

Me.XrLabel1.Padding = New DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100.0!)

Me.XrLabel1.Size = New System.Drawing.Size(100, 25)

Me.XrLabel1.Text = "XrLabel1"

'

'BusinessBindingSource1

'

Me.BusinessBindingSource1.ParentForm = Nothing

'Manually add Line Below

Me.BusinessBindingSource1.BusinessObject = Me.BusinessObject11

'

'BusinessObject11

'

Me.BusinessObject11.ParentContainer = Me

Me.BusinessObject11.SynchronizingObject = Nothing

CType(Me, System.ComponentModel.ISupportInitialize).EndInit()

End Sub

End Class

 

Now to call the report...

Dim rpt As New TestAppReports.InheritedReport("TEST")

rpt.ShowPreview()

 

 

 

 


StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Glad you got it working, Ivan Smile
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
I know it sounds stupid. But I'm extremely happy I put a simple report to work!

Thanks a lot Trent.

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Thanks Trent.

I'm in a client right now, I will try it later.

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