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;
     }
 }
Example #2
0
        private void print(int id)
        {
            InvoiceCR report = new InvoiceCR();

            report.Load(Server.MapPath("InvoiceCR.rpt"));
            using (ClubDBEntities club = new ClubDBEntities())
            {
                var result = club.getInvoiceHeader(id);
                report.SetDataSource(result);
            }
            // get printer name
            string printer = ClubWebApp.Properties.Settings.Default.InvoicePrinter;

            report.PrintOptions.PrinterName = printer;
            report.PrintToPrinter(1, false, 0, 0);
        }