public static void printAvgCustTurnover(DataTable dtCustTurnover) { using (Solsage_Process_Management_System.Documents.avgSalesPerCust reportAvgSalesPerCust = new Solsage_Process_Management_System.Documents.avgSalesPerCust()) { using (Solsage_Process_Management_System.Documents.PrintInvoice frmPrint = new Solsage_Process_Management_System.Documents.PrintInvoice()) { reportAvgSalesPerCust.SetDataSource(dtCustTurnover); foreach (CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition forReport in reportAvgSalesPerCust.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 "{@sGlobAdd1}": forReport.Text = "'" + Global.sCompanyAd1.Trim() + "'"; break; case "{@sGlobAdd2}": forReport.Text = "'" + Global.sCompanyAd2.Trim() + "'"; break; case "{@sGlobAdd3}": forReport.Text = "'" + Global.sCompanyAd3.Trim() + "'"; break; case "{@CompanyCell}": forReport.Text = "'" + Global.sInvoiceContactNumber + "'"; break; //case "{@sCustomer}": // forReport.Text = "'" + sCustomer + "'"; // break; //case "{@sCustCode}": // forReport.Text = "'" + sCustCode + "'"; // break; //case "{@sCustPhone}": // forReport.Text = "'" + sCustPhone + "'"; // break; //case "{@sCustFax}": // forReport.Text = "'" + sCustFax + "'"; // break; //case "{@sCustContact}": // forReport.Text = "'" + sCustContact + "'"; // break; } } frmPrint.crystalReportViewer1.ReportSource = reportAvgSalesPerCust; // frmPrint.printThisDocument(); frmPrint.ShowDialog(); } } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { avgSalesPerCust rpt = new avgSalesPerCust(); rpt.Site = this.Site; return rpt; }