コード例 #1
0
        public void Printing()
        {
            posTableAdapter pos = new posTableAdapter();

            dsReport.PosInvoiceDataTable dt         = pos.GetData(posinvoice);
            salesinvoiceTableAdapter     saladapter = new salesinvoiceTableAdapter();

            dsReport.salesinvoiceDataTable satd = saladapter.GetData(Convert.ToString(posinvoice));

            general.particulars = particulars;
            general.voucherno   = Convert.ToString(posinvoice);
            double oldbalance = Convert.ToDouble(general.OldBalance());

            clsprintersettings printing = new clsprintersettings();

            printing.PrintHeader();
            // printing.PrintDetails(posinvoice.ToString(), (DataTable)satd,oldbalance);
            printing.Close();
            streamToPrint = new StreamReader(Application.StartupPath + "\\test.txt");

            try
            {
                printFont = new Font("Arial", 10);
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += new PrintPageEventHandler
                                    (this.pd_PrintPage);
                pd.Print();
                this.Close();
            }
            finally
            {
                streamToPrint.Close();
            }
        }
コード例 #2
0
        private void frmposreport_Load(object sender, EventArgs e)
        {
            try
            {
                string path = Application.StartupPath + "\\CrystalReports\\cryPosreport.rpt";
                if (!File.Exists(path))
                {
                    MessageBox.Show("The Directory CrystalReports or Report File cryPosreport.rpt Not Exists");
                    return;
                }
                posTableAdapter pos = new posTableAdapter();
                dsReport.PosInvoiceDataTable   dt         = pos.GetData(posinvoice);
                salesinvoiceTableAdapter       saladapter = new salesinvoiceTableAdapter();
                dsReport.salesinvoiceDataTable satd       = saladapter.GetData(Convert.ToString(posinvoice));

                general.particulars = particulars;
                general.voucherno   = Convert.ToString(posinvoice);
                double oldbalance = Convert.ToDouble(general.OldBalance());

                //cryPosreport cryReport = new cryPosreport();
                //cryReport.SetDataSource((DataTable)dt);

                //cryPOSView.ReportSource = cryReport;
                ReportDocument rDoc = new ReportDocument();
                rDoc.Load(Application.StartupPath + "\\CrystalReports\\cryPosreport.rpt");
                rDoc.SetDataSource((DataTable)satd);

                ParameterFields        paramfields    = new ParameterFields();
                ParameterField         parameter      = new ParameterField();
                ParameterDiscreteValue discretedvalue = new ParameterDiscreteValue();
                parameter.Name = "oldbalance";

                discretedvalue.Value = oldbalance;
                parameter.CurrentValues.Add(discretedvalue);
                paramfields.Add(parameter);

                //cryPOSView.ParameterFieldInfo = paramfields;

                //cryPOSView.ReportSource = rDoc;
                rDoc.SetParameterValue("oldbalance", oldbalance);
                rDoc.PrintToPrinter(1, true, 1, 1);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }