protected void Page_Load(object sender, EventArgs e) { if (Session["InvoiceID"] != null) { int id = Convert.ToInt32(Session["InvoiceID"]); InvoiceCR report = new InvoiceCR(); report.Load(Server.MapPath("InvoiceCR.rpt")); ClubDBEntities club = new ClubDBEntities(); report.SetDataSource(club.getInvoiceHeader(id)); CrystalReportViewer1.ReportSource = report; } else if (Session["WithID"] != null) { int id = Convert.ToInt32(Session["WithID"]); WithdrawCR report = new WithdrawCR(); report.Load(Server.MapPath("WithdrawCR.rpt")); ClubDBEntities club = new ClubDBEntities(); report.SetDataSource(club.getWithReport(id)); CrystalReportViewer1.ReportSource = report; } else if (Session["depID"] != null) { int id = Convert.ToInt32(Session["depID"]); DepositCR report = new DepositCR(); report.Load(Server.MapPath("DepositCR.rpt")); ClubDBEntities club = new ClubDBEntities(); report.SetDataSource(club.getDepositReport(id)); CrystalReportViewer1.ReportSource = report; } }
protected void btnPrintV_Click(object sender, EventArgs e) { if (VoucherID != 0) { using (ClubDBEntities club = new ClubDBEntities()) { var result = club.getDepositReport(VoucherID); ReportDocument report = new ReportDocument(); report.Load(Server.MapPath("DepositCR.rpt")); report.SetDataSource(result); string printer = ClubWebApp.Properties.Settings.Default.InvoicePrinter; report.PrintOptions.PrinterName = printer; report.PrintToPrinter(1, false, 0, 0); } } }