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

21
Integrating Crystal Reports Into .Net 2.0 Applications Reggie Gentle, Data Management Group

Upload: daisy-malone

Post on 06-Jan-2018

215 views

Category:

Documents


0 download

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

Page 1: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

Integrating Crystal Reports Into .Net 2.0 Applications

Reggie Gentle, Data Management Group

Page 2: 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

Page 3: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 4: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 5: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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.

Page 6: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 7: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 8: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Modifying Log On Info DemoDemo using Winforms

Page 9: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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.

Page 10: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 11: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 12: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 13: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 14: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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.

Page 15: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 16: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Page 17: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Modifying The ReportViewer DemoDemo using Winforms and Web

Page 18: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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.

Page 19: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

Customizing report at runtime Formatting sections Customizing report formulas

Using the CrystalReports Engine

Page 20: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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

CrystalReport Engine DemoDemo using Winforms

Page 21: Integrating Crystal Reports Into.Net 2.0 Applications Reggie Gentle, Data Management Group

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: [email protected]

Q&A