Example #1
0
        private void ChequeReport_Load(object sender, EventArgs e)
        {
            ReportDocument rdoc = new rptDFCC_CHEQUE();

            rdoc.SetDataSource(reportds);
            crystalReportViewer1.ReportSource = rdoc;
        }
Example #2
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptDFCC_CHEQUE rpt = new rptDFCC_CHEQUE();

            rpt.Site = this.Site;
            return(rpt);
        }
Example #3
0
        private void PrintChequeReport(String Date, String Pay, String Rupees, String Rs)
        {
            //Create new table in a dataset
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable("tblCheque");

            dt.Columns.Add(new DataColumn("Date", typeof(string)));
            dt.Columns.Add(new DataColumn("Pay", typeof(string)));
            dt.Columns.Add(new DataColumn("Rupees", typeof(string)));
            dt.Columns.Add(new DataColumn("Rs", typeof(string)));
            //inserting new record to the table
            DataRow dr = dt.NewRow();

            dr["Date"]   = BuildDateToPrint(Date);
            dr["Pay"]    = Pay;
            dr["Rupees"] = Rupees;
            dr["Rs"]     = Rs;
            dt.Rows.Add(dr);
            ds.Tables.Add(dt);//inserted record is now ready to view in crystal report (ds)

            PrinterSettings settings    = new PrinterSettings();
            string          printerName = settings.PrinterName;

            if (!isPrinteroffline(printerName))
            {
                //direct print!
                rptDFCC_CHEQUE cr = new rptDFCC_CHEQUE(); // here rptDFCC_CHEQUE is the Crystal Report
                System.Drawing.Printing.PrintDocument doctoprint = new System.Drawing.Printing.PrintDocument();
                doctoprint.PrinterSettings.PrinterName = printerName;
                int rawKind = 0;
                for (int i = 0; i <= doctoprint.PrinterSettings.PaperSizes.Count - 1; i++)
                {
                    if (doctoprint.PrinterSettings.PaperSizes[i].PaperName == "DFCC-CHEQUE") // "DFCC-CHEQUE : Paper Size"
                    {
                        rawKind = Convert.ToInt32(doctoprint.PrinterSettings.PaperSizes[i].GetType().GetField
                                                      ("kind",
                                                      System.Reflection.BindingFlags.Instance |
                                                      System.Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes[i]));
                        break;
                    }
                }
                cr.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
                cr.SetDataSource(ds);
                cr.PrintToPrinter(1, false, 1, 2);
                MessageBox.Show("Cheque is sent to the " + printerName);
            }
            else
            {
                MessageBox.Show(printerName + " is workoffline!");
            }
            btnPrint.Text    = "Print";
            btnPrint.Enabled = true;

            //Show in cristal report viewer!
            //ChequeReport chkrpt = new ChequeReport(ds);
            //chkrpt.Show();
        }