StrataFrame Forum

THE Definitive Guide for using DevExpress XtraReport with SF 1.7.6

http://forum.strataframe.net/Topic32444.aspx

By Charles Thomas Blankenship - 2/21/2014

I always like to make sweeping claims like this as there is always someone (or somebodies) that know more than I do and can provide additional information that makes the tutorial even better. 
  • Dynamically configuring a report based upon an SQL Server table (ReportEngine)
  • Methodology for abstracting business objects (three layers are illustrated)
  • Class Diagrams for Business Layer, BOL and Report BO classes
  • Description of the Business Binding Source as it relates to Generics
  • Creating a simple Customer List
  • Filtering the contents of that Customer List by collecting information from the user
  • Adding custom properties to Report Business Objects
  • Illustrating how powerful the Report Engine table can be
  • How to subclass an XtraReport so that common processing can be consumed over every report in your application
  • Creating an Inherited Report
  • Create a Master-Detail using the data "Flattening" methodology
  • Create a Master-Detail report by using multiple Data Sources and Sub-reports
Here it is ... https://www.dropbox.com/s/1e82qqb7h96pfu6/DXStrataFlix.zip

DevExpress 13.2.7

Free, web based, UML Modeling tool (FREE)
By Edhy Rijo - 2/21/2014

Hi Charles,

Nice to see you getting deep into the DevExpress SF integration. 

46 pages document seems interesting, so I will print it out and read it carefully.  I have been very busy with no much time to spare in the forums, but definitely will get back to you as soon as I can.

Thanks for the tutorial.
By Terry Bottorff - 2/21/2014

I would love to read your paper but I tried downloading it twice and I get a corrupt file. I am not sure whether that happens on my end or whether it is on your end. FYI.

I will try it on another machine later and let you know what happens.

You are a stellar person to make this available to us. Thank you.
By Terry Bottorff - 2/21/2014

I had no issue on my Win 7 machine. Just on my Win 8.1 machine. Not sure why but at least I got it. I thank you again.
By Edhy Rijo - 2/21/2014

Hi Terry,

I am Win 8.1 and opened up without issues from the DropBox link.
By Charles Thomas Blankenship - 2/21/2014

I was reading through all of the posts on the topic and ran into several referencing having to use DataTables and other structures outside of StrataFrame ... as it turns out ... you can use everything in DevExpress XtraReports without having to exit the StrataFrame environment at all.  You don't even have to make any modifications to the SF source code either (initially I thought I might have to).

I wouldn't have even known DevExpress had a report engine if it weren't for you ... THANKS!

C. T.
By Terry Bottorff - 2/21/2014

I'll reset my wireless adapters because I think I am having an issue with it. Glad to know it works with Win 8.1 with no issues. I'll also try the Dropbox side.

Thanks.....
By Edhy Rijo - 2/21/2014

You Are welcome Charles.

The only thing I have not been able to do with DevExpress Reports and SF is to preview the report in the VS IDE since I am using SF BBS, but have not had the time to look for a solution and the upcoming SF2.0 have a much better Business Object class that would be able to talk to any 3rd party tool like all DevExpress controls without the need to use the SF Business Binding Source and then I almost sure we will be able to preview the report while designing it.
By Edhy Rijo - 2/22/2014

Hi Charles,
Your DDT package DXStrataFlixDDT.pkg does not contain any metadata with your fixed data to test your reports. 

All tables are empty, specially your  ReportEngine.

Please provide a DDT package with the Deployment Data or include a copy of your MS-SQL Database in your DropBox so we can test it.
By Edhy Rijo - 2/22/2014

Hi Charles,

I have review your  code and have couple of suggestions:
  • When creating SqlCommand objects, try using the "using" command to speed up your code and allow the .Net garbage collection to dispose the object more efficiently.

        public void fillAll()
        {
            using (SqlCommand oSqlCmd = new SqlCommand())
            {
                oSqlCmd.CommandText = "SELECT * FROM Customers ORDER BY cust_LastName";
                FillDataTable(oSqlCmd);
            }
        }
  • When creating Sql CommandText, take advantage of the String.Format to build your SQL string and use Parameters instead of adding the value to the string, here is a sample of your CustomersBO.fillByLastName method:

        public void fillByLastName(string lastName)
        {
            using (SqlCommand oSqlCmd = new SqlCommand())
            {
                oSqlCmd.CommandText = String.Format("SELECT * FROM {0} WHERE UPPER(cust_LastName) LIKE '{1}'% ORDER BY cust_LastName", this.TableNameAndSchema, "@LastName");
                oSqlCmd.Parameters.AddWithValue("@LastName", lastName.ToUpper()).SqlDbType = SqlDbType.VarChar;
                FillDataTable(oSqlCmd);
            }
        }


Your project is pretty good organized, that is important, as well as your naming convention too.  In my case for SF Custom Field Properties I would prefix the property with "cfp_", so when using it in the field builders of DevExpress, I can clearly know this is a Custom Field Property:

        [Browsable(false),
        BusinessFieldDisplayInEditor,
        Description("Customer Last, First and Middle Name"),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public string cfp_cust_LastFirstMiddle
        {
            get
            {
                return string.Format("{0}, {1} {2}", this.cust_LastName, this.cust_FirstName, this.cust_MiddleName);
            }
        }


Also, I would always use a Base Business Object class, to hold common methods and properties like the FillAll() method which it is mostly used by every BO.

Again, those are just suggestions, which means, there is nothing wrong with your original code.

Oh, I almost forgot, in your document to said:
"Alsoanother big thanks to Edhy for ignoring my request to help with regards to mycomplete and total ignorance of using this tool."

Not quite true based on the number of post I have here Hehe I probably missed a post due to a lot of work with my customers, fortunately since last November 2013 I have been pretty busy working on several project and not having too much time to share with my peers.

Now where is your version of the StrataFlix database so I can test your would project? BigGrin   Let's the fun begin.....w00t
By Charles Thomas Blankenship - 2/22/2014

BigGrin ... ha, ha, ha ... I was hoping you would take that as a subtle poke in the ribs ... but in all honesty ... if you did jump in and fix my problem I would have never gotten to the point where ended ... IOW ... discovering all the idiosyncrasies for myself was a much better approach.  No offence intended.

I didn't provide a .DDT file because I included the .bak for the entire StrataFlix database ... I thought it would be easier just to let people restore it over their existing StrataFlix.mdf

Thanks for the USING suggestion ... I'll make those changes and then repost the .zip file.

As for including deployment data from the Database Deployment Toolkit ... the only data I know how to deploy from that is the Security and Messaging files.   How do I get the Customers, Customer Orders, Customer Order Items and Report Engine table data inside the DDT?

Thanks,

CT
By Charles Thomas Blankenship - 2/22/2014

BigGrin ... ha, ha, ha ... I was hoping you would take that as a subtle poke in the ribs ... but in all honesty ... if you did jump in and fix my problem I would have never gotten to the point where ended ... IOW ... discovering all the idiosyncrasies for myself was a much better approach.  No offence intended.

I didn't provide a .DDT file because I included the .bak for the entire StrataFlix database ... I thought it would be easier just to let people restore it over their existing StrataFlix.mdf

Thanks for the USING suggestion ... I'll make those changes and then repost the .zip file.

As for including deployment data from the Database Deployment Toolkit ... the only data I know how to deploy from that is the Security and Messaging files.   How do I get the Customers, Customer Orders, Customer Order Items and Report Engine table data inside the DDT?

Thanks,

CT
By Charles Thomas Blankenship - 2/22/2014

BigGrin ... ha, ha, ha ... I was hoping you would take that as a subtle poke in the ribs ... but in all honesty ... if you did jump in and fix my problem I would have never gotten to the point where ended up ... IOW ... discovering all the idiosyncrasies for myself was a much better approach.  No offence intended.

I didn't provide a .DDT file because I included the .bak for the entire StrataFlix database ... I thought it would be easier just to let people restore it over their existing StrataFlix.mdf

Thanks for the USING suggestion ... I'll make those changes and then repost the .zip file.

As for including deployment data from the Database Deployment Toolkit ... the only data I know how to deploy from that is the Security and Messaging files.   How do I get the Customers, Customer Orders, Customer Order Items and Report Engine table data inside the DDT?

Thanks,

CT
By Charles Thomas Blankenship - 2/22/2014

Does anyone know how to delete duplicate posts Crazy
By Charles Thomas Blankenship - 2/22/2014

Maybe I should have been more clear about the nature of this tutorial ... so here goes!

This tutorial is not meant to be a "best practices" for StrataFrame Development.  It is only meant to illustrate how to make a simple listing report and master-detail report (using a data flattening approach as well as a sub-report approach) using DevExpress XtraReports control and SF Custom Business Binding source.  Project structure, class naming preferences, whether to or not to use stored procedures and sub-classing methodology were meant to be mere suggestions.

I hope you do find some benefit from it.

By Edhy Rijo - 2/22/2014

Hi Charles,
Charles Thomas Blankenship (2/22/2014)
BigGrin ... ha, ha, ha ... I was hoping you would take that as a subtle poke in the ribs ... but in all honesty ... if you did jump in and fix my problem I would have never gotten to the point where ended up ... IOW ... discovering all the idiosyncrasies for myself was a much better approach.  No offence intended.

None taken.  Your document is pretty good and very detailed, so I am sure it will help others here.

I didn't provide a .DDT file because I included the .bak for the entire StrataFlix database ... I thought it would be easier just to let people restore it over their existing StrataFlix.mdf

Sorry I missed the .bak file in your project, it is there and I restored it just fine.

As for including deployment data from the Database Deployment Toolkit ... the only data I know how to deploy from that is the Security and Messaging files.   How do I get the Customers, Customer Orders, Customer Order Items and Report Engine table data inside the DDT?

It is very easy, take a look at the "Deployment Data Package Properties" in the SF help file.  There you can import data from any table in any database and deploy that to specific table in your application's database.  It is good for static lookup data, or when initially deploying an application to upload this data with every new installation pretty much like they do when you install StrataFrame and they deploy the StrataFrameSample database.

After many years working with StrataFrame, I learned (sometimes the hard way BigGrin) that things are simpler than I expected in StrataFrame and once you learn to work with the framework and not fight it, then you can become very productive.  One example is the Business Object class, looks so simple and for some probably outdated, but in reality very, very powerful class and in my experience rock solid, I don't get calls from my customers because my applications crashed, it just keep working, I get calls for enhancements and new stuff. 

Because of that experience I have no doubt StrataFrame 2.0 will be a great for us and from what I have heard about the new Business Objects and DDT in 2.0 it will easy to bind to any 3rd party tools like DevExpress controls without the need of the SF Business Binding Source.
By Charles Thomas Blankenship - 2/24/2014

My final post with regards to how I implemented everything I learned above into the Reporting Layer of my current project.

Chapter 2: The Final Solution

So long and thanks for all the Fish!
By Terry Bottorff - 2/28/2014

I know you said that you have had your last post on this topic but I am following along ad I got to the spot where you talk about dragging the xrReportEngineBBS onto the report and then you say Name it oXRReportEngineBBS. How do you name it or rename it?
TIA.
If you choose not to answer I understand since you stated your the prior was your last post.
By Edhy Rijo - 2/28/2014

Hi Terry,
I noticed that the BBS dropped to the report at least in DX version 13.2 will not be shown as in the forms, so you have serveral ways to access this object to rename it or work with it.
  1. From the Properties combobox, select the xrReportEngineBBS and then you can rename it.
  2. Using the "Document Outline" window from the View->Other Windows menu you can also select any object in the report or form to access its properties.
Terry Bottorff (2/28/2014)
I know you said that you have had your last post on this topic....If you choose not to answer I understand since you stated your the prior was your last post.
Terry, Charles is just kidding, he loves this topic Whistling
By Terry Bottorff - 2/28/2014

Thanks Edhy, I will look into this over the weekend.
By Terry Bottorff - 3/1/2014

Edhy, I changed the name using the property window and it seemed to change the references to it also.
Thanks again. 
Now I am going to continue to try the example. I am sure I will return.
By Edhy Rijo - 3/1/2014

Hi Terry,

Great, glad you were able to rename the BBS.  This is a very detail example and I am sure you will find it very interesting the approach Charles used to get this done.
By Terry Bottorff - 3/1/2014

Edhy, do you use Views for your reports or Custom Fields?

I am not sure why I have stayed away from Views but maybe it is time to start using them.

TIA.
By Edhy Rijo - 3/1/2014

Hi Terry,

Terry Bottorff (3/1/2014)
Edhy, do you use Views for your reports or Custom Fields?


I use both.  Mostly views, I tend to prepare the SQL statement as close as needed by the report, or as generic as possible to be re-used with more than one report.  The rule for me to use Custom Field Properties is if the data to be shown in the report is just couple of hundred records, then CFP performance should not be a problem, but if the report may output more than 500 records, then I create a virtual column in my SQL statement (view) to have the data there.

That is one of the main reason the SF builder would give you the option to create a BO for the report