Skip to main content

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 CrystalImageHandler errors
  • Add a new .rpt and viewer page for a module

How It Works

Architecture

Runtime version

Web.config registers Crystal assemblies at 13.0.2000.0:

AssemblyPurpose
CrystalDecisions.CrystalReports.EngineCore report engine
CrystalDecisions.ReportSourceReport source binding
CrystalDecisions.SharedShared types and enums
CrystalDecisions.WebWeb viewer controls
CrystalDecisions.ReportAppServer.ClientDocClient 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:

ModuleViewer path (example)
PayrollAreas/Payroll/PayRollViewerForm/PayRollReportsForm.aspx
BillsAreas/Bills/BillReportViewerForm/BillReportsForm.aspx
StockAreas/Stock/StockReportViewer/StockReportViewerForm.aspx
SalesAreas/Sales/SalesReportViewer/SalesReportViewer.aspx
RegistrationAreas/Registration/CrReportsViewer/CrReportViewerForm.aspx
Attendance PunchingAreas/AttendancePunching/AttReportsViewer/AttReportViewerForm.aspx
ESSAreas/ESS/ESSReportViewer/EssReportViewer.aspx
OperationAreas/Operation/ReportViewerForm/ReportsViewer.aspx
Management DashboardAreas/ManagmentDashBoard/ManagementReportViewer/ManagementReportViewer.aspx
RootReportViewers/ReportViews.aspx

Code-behind pattern (PayRollReportsForm.aspx.cs):

  1. Verify Session["CompID"]
  2. Parse RptTag and parameter query keys (p1, p2, … SalStatus, etc.)
  3. Call module ReportService or DAL to fill DataTable
  4. Load .rpt into ReportDocument
  5. SetDataSource and export/display via Crystal viewer control

Report templates (.rpt)

  • .rpt files define layout, grouping, and formula fields
  • Templates are loaded at runtime by path or embedded resource depending on module implementation
  • .rpt files may not appear in Git depending on deployment packaging — verify your build output includes report templates for the modules you deploy
Dual export paths

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 ReportDocument in Page_Unload where 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 uses MyConnectionString through DAL/services.
Mixed pipeline

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

Important Notes

Runtime mismatch

If server GAC/assemblies differ from 13.0.2000.0, viewers fail at load with assembly binding errors. Align installer version with Web.config.

CrystalImageHandler

If report images break, verify CrystalImageHandler.aspx handler registration and that MVC routes ignore the handler path.

Common Mistakes

MistakeSymptom
Opening .aspx without sessionBlank report or redirect to login
Wrong query parameter index (p2 vs p3)Wrong month/year on print
Missing .rpt in publish outputReport file not found exception
64-bit app pool without 64-bit CrystalClass not registered errors
Loading huge datasets unfilteredTimeout; memory spike on server

Next Steps

  1. Inspect the module-specific *ReportService class alongside the viewer .aspx.cs for your report.
  2. Confirm Crystal runtime installation on target IIS server before UAT sign-off.