public static void printSupplDocs(Main frmMain, string sDocumentNumber, string sMessage01, string sMessage02, string sDocName) { using (Solsage_Process_Management_System.Documents.PurchaseOrder reportDelivery = new Solsage_Process_Management_System.Documents.PurchaseOrder()) { using (Solsage_Process_Management_System.Documents.PrintInvoice frmPrint = new Solsage_Process_Management_System.Documents.PrintInvoice()) { frmPrint.crystalReportViewer1.SelectionFormula = "{HistoryHeader.DocumentNumber} = \"" + sDocumentNumber + "\""; foreach (CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition forReport in reportDelivery.DataDefinition.FormulaFields) { switch (forReport.FormulaName) { case "{@sGlobCompanyName}": forReport.Text = "'" + Global.sCompanyName.Trim() + "'"; break; case "{@sGlobCompanyRegName}": forReport.Text = "'" + Global.sRegName.Trim() + "'"; break; case "{@sGlobVat}": forReport.Text = "'" + Global.sVAT.Trim() + "'"; break; case "{@sGlobReg}": forReport.Text = "'" + Global.sReg.Trim() + "'"; break; case "{@sGlobTel}": forReport.Text = "'" + Global.sCompanyTel.Trim() + "'"; break; case "{@sGlobFax}": forReport.Text = "'" + Global.sCompanyFax.Trim() + "'"; break; case "{@sGlobPost1}": forReport.Text = "'" + Global.sCompanyPostAd1.Trim() + "'"; break; case "{@sGlobPost2}": forReport.Text = "'" + Global.sCompanyPostAd2.Trim() + "'"; break; case "{@sGlobPost3}": forReport.Text = "'" + Global.sCompanyPostAd3.Trim() + "'"; break; case "{@sGlobAdd1}": forReport.Text = "'" + Global.sCompanyAd1.Trim() + "'"; break; case "{@sGlobAdd2}": forReport.Text = "'" + Global.sCompanyAd2.Trim() + "'"; break; case "{@sGlobAdd3}": forReport.Text = "'" + Global.sCompanyAd3.Trim() + "'"; break; case "{@sInvoiceMessage01}": forReport.Text = sMessage01; break; case "{@sInvoiceMessage02}": forReport.Text = sMessage02; break; case "{@sDocName}": forReport.Text = "'" + sDocName + "'"; break; } } frmPrint.crystalReportViewer1.ReportSource = reportDelivery; frmPrint.printThisDocument(); } } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { PurchaseOrder rpt = new PurchaseOrder(); rpt.Site = this.Site; return rpt; }