public static void printGoodsReturned(Main frmMain, string sSalesCode, string sUserCode, string sAssetNumber, string sReference, string sDocName, DataTable dtReturnedItems) { using (Solsage_Process_Management_System.Documents.crGoodsReturned reportGoodsRet = new Solsage_Process_Management_System.Documents.crGoodsReturned()) { using (Solsage_Process_Management_System.Documents.PrintInvoice frmPrint = new Solsage_Process_Management_System.Documents.PrintInvoice()) { reportGoodsRet.SetDataSource(dtReturnedItems); foreach (CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition forReport in reportGoodsRet.DataDefinition.FormulaFields) { switch (forReport.FormulaName) { case "{@sGlobCompanyName}": forReport.Text = "'" + Global.sCompanyName.Trim() + "'"; break; case "{@sGlobCompanyRegName}": forReport.Text = "'" + Global.sRegName.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 "{@sDocName}": forReport.Text = "'" + sDocName + "'"; break; case "{@sSalesCode}": forReport.Text = "'" + sSalesCode + "'"; break; case "{@sUserCode}": forReport.Text = "'" + sUserCode + "'"; break; case "{@sAssetNumber}": forReport.Text = "'" + sAssetNumber + "'"; break; case "{@sReference}": forReport.Text = "'" + sReference + "'"; break; } } frmPrint.crystalReportViewer1.ReportSource = reportGoodsRet; frmPrint.printThisDocument(); } } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { crGoodsReturned rpt = new crGoodsReturned(); rpt.Site = this.Site; return rpt; }