Crystal Reports
Introduction
Damsy ERP generates printable PDFs and on-screen reports using SAP Crystal Reports integrated through legacy ASP.NET Web Forms viewer pages (.aspx). Report templates (.rpt files) bind to DataTable results from DAL/report service classes. The application targets Crystal Reports runtime version 13.0.2000.0.
MVC Razor views handle most UI; reporting is a deliberate exception that uses Web Forms for the Crystal viewer control.
Purpose
This page explains how reports are hosted, invoked, and configured so you can add or troubleshoot print outputs without breaking routing or runtime dependencies.
When to Use
Consult this page when you:
- Open a payroll payslip, bill print, or MIS report from the UI
- Deploy to a server missing Crystal runtime assemblies
- Debug blank reports, missing images, or
CrystalImageHandlererrors - Add a new
.rptand viewer page for a module
How It Works
Architecture
Runtime version
Web.config registers Crystal assemblies at 13.0.2000.0:
| Assembly | Purpose |
|---|---|
CrystalDecisions.CrystalReports.Engine | Core report engine |
CrystalDecisions.ReportSource | Report source binding |
CrystalDecisions.Shared | Shared types and enums |
CrystalDecisions.Web | Web viewer controls |
CrystalDecisions.ReportAppServer.ClientDoc | Client document API |
HTTP handler registration:
<add path="CrystalImageHandler.aspx" verb="GET"
type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, ..." />
RouteConfig ignores routes matching CrystalImageHandler so MVC does not swallow image requests.
Viewer pages (.aspx)
Each major module hosts report viewers under its Area:
| Module | Viewer path (example) |
|---|---|
| Payroll | Areas/Payroll/PayRollViewerForm/PayRollReportsForm.aspx |
| Bills | Areas/Bills/BillReportViewerForm/BillReportsForm.aspx |
| Stock | Areas/Stock/StockReportViewer/StockReportViewerForm.aspx |
| Sales | Areas/Sales/SalesReportViewer/SalesReportViewer.aspx |
| Registration | Areas/Registration/CrReportsViewer/CrReportViewerForm.aspx |
| Attendance Punching | Areas/AttendancePunching/AttReportsViewer/AttReportViewerForm.aspx |
| ESS | Areas/ESS/ESSReportViewer/EssReportViewer.aspx |
| Operation | Areas/Operation/ReportViewerForm/ReportsViewer.aspx |
| Management Dashboard | Areas/ManagmentDashBoard/ManagementReportViewer/ManagementReportViewer.aspx |
| Root | ReportViewers/ReportViews.aspx |
Code-behind pattern (PayRollReportsForm.aspx.cs):
- Verify
Session["CompID"] - Parse
RptTagand parameter query keys (p1,p2, …SalStatus, etc.) - Call module
ReportServiceor DAL to fillDataTable - Load
.rptintoReportDocument SetDataSourceand export/display via Crystal viewer control
Report templates (.rpt)
.rptfiles define layout, grouping, and formula fields- Templates are loaded at runtime by path or embedded resource depending on module implementation
.rptfiles may not appear in Git depending on deployment packaging — verify your build output includes report templates for the modules you deploy
Some modules also use ClosedXML for Excel exports from MVC actions. Crystal is primarily for formatted print/PDF layouts.
Invocation from MVC views
Views typically open reports via JavaScript:
window.open('/Payroll/PayRollViewerForm/PayRollReportsForm.aspx?RptTag=PAYSLIP&p1=' + empCode + '&p2=' + month, '_blank');
Parameter names are contractual between the Razor view and the .aspx code-behind — document new parameters in both places.
Session and security
Report viewers check Session["CompID"] before loading data. They inherit the same session as MVC — no separate report authentication token.
Company scope (Compid from session) is passed into report service methods that call filtered SPs.
Developer Notes
- IIS application pool: Use 32-bit or 64-bit consistently with installed Crystal runtime bitness.
- Install Crystal runtime on deployment servers matching 13.0.2000.0 references.
- Dispose reports: Code-behind should dispose
ReportDocumentinPage_Unloadwhere implemented to avoid memory pressure under load. - Error redirect: Failed report loads may redirect to module
ManageError/Index(e.g. Bills viewer). - Legacy connection strings: Some Crystal scenarios reference alternate connection strings in
Web.config; routine data fetch usesMyConnectionStringthrough DAL/services.
Web Forms and MVC coexist in one app. Do not enable route rules that block .aspx paths under Areas.
Examples
Payroll statutory report flow
User clicks "PF Form 3A" in PayRollStatutoryReport view
→ window.open PayRollReportsForm.aspx?RptTag=...&p2=month&p3=year
→ Page_Load reads Session CompID
→ PayrollReportService fills DataTable
→ ReportDocument loads PF Form 3A.rpt
→ Crystal viewer renders PDF
Bills invoice print
CreateBills view → BillReportsForm.aspx
→ Bill report service
→ IRN details optional from bill tables
→ Print layout .rpt
Related Pages
- MVC Architecture
- Request Pipeline — CrystalImageHandler route ignore
- Data Access Layer
- Error Handling
Important Notes
If server GAC/assemblies differ from 13.0.2000.0, viewers fail at load with assembly binding errors. Align installer version with Web.config.
If report images break, verify CrystalImageHandler.aspx handler registration and that MVC routes ignore the handler path.
Common Mistakes
| Mistake | Symptom |
|---|---|
Opening .aspx without session | Blank report or redirect to login |
Wrong query parameter index (p2 vs p3) | Wrong month/year on print |
Missing .rpt in publish output | Report file not found exception |
| 64-bit app pool without 64-bit Crystal | Class not registered errors |
| Loading huge datasets unfiltered | Timeout; memory spike on server |
Next Steps
- Inspect the module-specific
*ReportServiceclass alongside the viewer.aspx.csfor your report. - Confirm Crystal runtime installation on target IIS server before UAT sign-off.