public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { ReportStockPecahBarang rpt = new ReportStockPecahBarang(); rpt.Site = this.Site; return(rpt); }
private void crystalReportViewer1_Load(object sender, EventArgs e) { DataSet dsTempReport = new DataSet(); globalPrinterUtility gPrinter = new globalPrinterUtility(); try { string appPath = Directory.GetCurrentDirectory() + "\\" + globalConstants.stockPecahBarangXML; dsTempReport.ReadXml(@appPath); CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader1, txtReportHeader2; //prepare report for preview ReportStockPecahBarang rptXMLReport = new ReportStockPecahBarang(); txtReportHeader1 = rptXMLReport.ReportDefinition.ReportObjects["NamaTokoLabel"] as TextObject; txtReportHeader2 = rptXMLReport.ReportDefinition.ReportObjects["InfoTokoLabel"] as TextObject; rptXMLReport.Database.Tables[0].SetDataSource(dsTempReport.Tables[0]); rptXMLReport.PrintOptions.PrinterName = gPrinter.getConfigPrinterName(2); rptXMLReport.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)gPrinter.getReportPaperSize(globalPrinterUtility.LETTER_PAPER_SIZE); rptXMLReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait; crystalReportViewer1.ReportSource = rptXMLReport; //baca database untuk nama toko 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.SetDataSource(dsTempReport); //crystalReportViewer1.DisplayGroupTree = false; crystalReportViewer1.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }