public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            penerimaanBarangPrintOut rpt = new penerimaanBarangPrintOut();

            rpt.Site = this.Site;
            return(rpt);
        }
        private void penerimaanBarangPrintOutForm_Load(object sender, EventArgs e)
        {
            DataSet dsTempReport = new DataSet();

            try
            {
                string appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.penerimaanBarangXML;
                dsTempReport.ReadXml(@appPath);

                //prepare report for preview
                penerimaanBarangPrintOut rptXMLReport = new penerimaanBarangPrintOut();
                CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2;
                txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject;
                txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject;
                String nama, alamat, telepon, email;
                if (!gUtil.loadinfotoko(2, out nama, out alamat, out telepon, out email))
                {
                    //reset default optsi = 1
                    if (!gUtil.loadinfotoko(1, out nama, out alamat, out telepon, out email))
                    {
                        nama    = "TOKO DEFAULT";
                        alamat  = "ALAMAT DEFAULT";
                        telepon = "0271-XXXXXXX";
                        email   = "*****@*****.**";
                    }
                }
                txtReportHeader1.Text = nama;
                txtReportHeader2.Text = alamat + Environment.NewLine + telepon + Environment.NewLine + email;
                rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]);

                globalPrinterUtility gPrinter = new globalPrinterUtility();
                rptXMLReport.PrintOptions.PrinterName = gPrinter.getConfigPrinterName(2);
                if (gUtil.getPaper() == 1)
                {
                    rptXMLReport.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.HALF_KUARTO_PAPER_SIZE);
                }
                else
                {
                    rptXMLReport.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.LETTER_PAPER_SIZE);
                }
                rptXMLReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                crystalReportViewer1.ReportSource = rptXMLReport;
                crystalReportViewer1.Refresh();

                if (gUtil.getPaper() == 1)
                {
                    rptXMLReport.PrintToPrinter(1, false, 0, 0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }