integrating crystal reports into.net 2.0 applications reggie gentle, data management group

Post on 06-Jan-2018

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Slide 3 Copyright © 2006 Business Objects S.A. All rights reserved. Best Practices and.Net 2.0 Compatibility Modifying Database Log On Info at Runtime Modifying Record Selection and Parameters Modifying the Report Viewer Using the Crystal Reports Engine Q&A Topics

TRANSCRIPT

Integrating Crystal Reports Into .Net 2.0 Applications

Reggie Gentle, Data Management Group

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 3

Best Practices and .Net 2.0 CompatibilityModifying Database Log On Info at RuntimeModifying Record Selection and ParametersModifying the Report ViewerUsing the Crystal Reports EngineQ&A

Topics

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 4

The Real World

Typical Usage Scenarios we have used this SDKFull Client ApplicationsDepartmental Web SolutionsLimited Usage / Very Fast Reports Delivered via WebQuick Hit / Evaluation Prototype Development

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 5

Best Practices Keep reports short and the files size small Ensure the report is achieving its best performance by “pushing the

query to the database” Avoid letting the Crystal Report Viewer handle the parameter prompts Understand the difference between Managed and Unmanaged

reporting

.Net 2.0 Compatibility Compatibility with Visual Studio 2005

Best Practices and Gotcha’s

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 6

Modifying Database Log On Info at Runtime

Business Case Client: US Navy Environment: Various ASP and .Net Applications Challenge: Deploying web applications in a highly, secured and

process documented environment, developers had to make report data sources dynamic when moving from development, test, and production.

Solution: Dynamically change the database login information at runtime based on the server environment it is running. This allows one unmodified code line to exist on all environments.

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 7

By Named Tableusing CrystalDecisions.Shared;…TableLogOnInfos infos = new TableLogOnInfos();TableLogOnInfo info = new TableLogOnInfo();ConnectionInfo conn = new ConnectionInfo();

conn.ServerName = "(local)";conn.DatabaseName = “MyDatabase";conn.UserID = "sa";conn.Password = "@ww@rr3"; info.ConnectionInfo = conn;info.TableName = "Customer";infos.Add(info);

crystalReportViewer1.LogOnInfo = infos;

Modifying Database Log On Info at Runtime

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 8

Using The Crystal Reports Engineusing CrystalDecisions.CrystalReports.Engine;MyReport myReport = new MyReport();ConnectionInfo conn = new ConnectionInfo();

conn.ServerName = "(local)";conn.DatabaseName = “MyDatabase";conn.UserID = "sa";conn.Password = "@ww@rr3";

TableLogOnInfo tableLogOnInfo;Tables tables = myReport.Database.Tables;Foreach ( Table t in tables ){

tableLogOnInfo = t.LogOnInfo;tableLogOnInfo.ConnectionInfo = conn;t.ApplyLogOnInfo( tableLogOnInfo );

}

Modifying Database Log On Info at Runtime

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 9

Modifying Log On Info DemoDemo using Winforms

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 10

Modifying Record Selection and Parameters

Business Case Client: FBI Academy Environment: Web Application Challenge: Integrating reports in a contextual way where the reports

data reflects the same records that the user is interacting with in the application. This allows the user run a report without leaving the application and supply parameters to it.

Solution: Call reports from within the application and pass filters that restrict the data.

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 11

Modifying Record Selection SelectionFormula property of the CrystalReportViewer

…String SelFromula = “{Customer.ID} = 2”;CrystalReportViewer1.SelectionFormula = selForumla;…

Modifying Record Selection and Parameters

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 12

Modifying Parameters Discrete parameters Ranged parameters Ranged and Discrete parameters

Modifying Record Selection and Parameters

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 13

Modifying Discrete ParametersParameterFields fields = new ParameterFields();ParameterField field = new ParameterField();ParameterDiscreteValue dvalue = new ParameterDiscreteValue();

field.Name = "OrderDate";DateTime d = DateTime.Parse("9/1/2006");dvalue.Value = "9/1/2006";field.CurrentValues.Add(dvalue);

fields.Add(field);crystalReportViewer1.ParameterFieldInfo = fields;

Modifying Record Selection and Parameters

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 14

Modifying Ranged ParametersParameterFields fields = new ParameterFields();ParameterField field = new ParameterField();ParameterRangedValues rvalue = new ParameterRangedValues();

field.Name = "OrderAmount";

rvalue.StartValue = 500;rvalue.EndValue = 2500;field.CurrentValues.Add(rvalue);

fields.Add(field);crystalReportViewer1.ParameterFieldInfo = fields;

Modifying Record Selection and Parameters

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 15

Modifying The Report Viewer

Business Case Client: FBI Academy Environment: Web Application Challenge: One goal of integrated reports is to blend the report

viewer with the application. It is thus desirable to turn off certain viewer buttons and change other attributes to achieve this.

Solution: When calling reports, modify viewer attributes.

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 16

Showing and Hiding buttons Properties of the CrystalReportViewer

• ShowCloseButton• ShowExportButton• ShowGoToPageButton• ShowGroupTreeButton• ShowPageNavigateButtons• ShowRefreshButton• ShowTextSearchButton• ShowZoomButton• ShowPrintButton

Modifying The Report Viewer

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 17

Using Viewer Methods Methods of the CrystalReportViewer

• PrintReport()• RefreshReport()• ExportReport()• GetCurrentPageNumber()• ShowFirstPage()• ShowLastPage()• ShowNextPage()• ShowPreviousPage()

Modifying The Report Viewer

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 18

Modifying The ReportViewer DemoDemo using Winforms and Web

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 19

Using the CrystalReports Engine

Business Case Client: OEM Software Environment: Hosted Web Application Challenge: Provide customized reports for each clients reports. Solution: Dynamically modify the report using the CrystalReports

engine to change the reports header as well as modify calculations.

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 20

Customizing report at runtime Formatting sections Customizing report formulas

Using the CrystalReports Engine

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 21

CrystalReport Engine DemoDemo using Winforms

Copyright © 2006 Business Objects S.A. All rights reserved.Slide 22

Questions Reggie Gentle, Consultant, Data Management Group I will repeat questions to ensure everyone can hear

Contact information Email: Reggie.Gentle@DataManagementGroup.com

Q&A

top related