public bool ShowReport(string[] reportTitle, string[] reportData, DataTable dataTbl, CrystalDecisions.CrystalReports.Engine.ReportClass myReport) { try { //============================== // Make report //============================== if (this.ExportOutput != Export.ExportFormat.None) { this.ExportData(dataTbl, this.ExportOutput); } else { myReport.SetDataSource(dataTbl); reportViewer.SetReportPara(myReport.ParameterFields, reportTitle, "reportTitle"); reportViewer.SetReportPara(myReport.ParameterFields, reportData, "reportData"); reportViewer.ShowReport(myReport); myReport.Dispose(); } } catch (Exception er) { common.errorHandler.lastErrorMessage = er.Message.ToString(); return(false); } return(true); }
public InvoiceReportForm(int invID, int patID, DateTime startRange, DateTime endRange) { InitializeComponent(); report = new InvoiceReport(); InvoiceViewModelBindingSource.DataSource = Database.InvoiceViewModel.GetInvoices(invID); report.SetDataSource(InvoiceViewModelBindingSource); crystalReportViewer1.ReportSource = report; }
public static void setSX3InvoiceParams(string hoaDonID, CrystalDecisions.CrystalReports.Engine.ReportClass hd) { hd.SetDataSource(DataTier.fillHoaDon(hoaDonID)); hd.SetParameterValue("ngayBatDau", ngayBatDau); hd.SetParameterValue("ngayKetThuc", ngayKetThuc); hd.SetParameterValue("giaDien1", giaDien); hd.SetParameterValue("giaDien2", giaDienSX3_2); hd.SetParameterValue("ngayKyHD", "Ngày " + ngayKy + "/" + thangKy + "/" + namKy); hd.SetParameterValue("ngayKyHD2", "Ngày " + ngayKy + " tháng " + thangKy + " năm " + namKy); hd.SetParameterValue("tongTienBangChu", docChu); }
private void printInvoice(int svno) { InvoicePrinting invoicePrinting = new InvoicePrinting(); DataSet ds = new DataSet(); invoicePrinting.prepareDataSetForInvoiceReport(ds, svno); CrystalDecisions.CrystalReports.Engine.ReportClass report = getCrystalReport(); report.SetDataSource(ds); CrystalDecisions.CrystalReports.Engine.TextObject txtInvoiceType; txtInvoiceType = (CrystalDecisions.CrystalReports.Engine.TextObject)report.ReportDefinition.ReportObjects["txtInvoiceType"]; txtInvoiceType.Text = "Original"; report.PrintToPrinter(1, false, 0, 0); txtInvoiceType.Text = "Duplicate"; report.PrintToPrinter(1, false, 0, 0); }
public ActionResult PrintAssemssment() { try { var cm = new Common(); var A = cm.GetAssessment(); var Ad = cm.GetAssessDetail(); var At = cm.GetAssessType(); var S = cm.GetStudent(); var query = from _A in A from _Ad in Ad from _At in At where _A.ass_id == _Ad.ass_id && _A.ass_type_id == _At.asstype_id.ToString() && _Ad.ass_no == _At.ass_no select new { _At.question, _Ad.answer }; DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add("question"); dt.Columns.Add("answer"); foreach (var aa in query) { dr = dt.NewRow(); dr["question"] = aa.question; dr["answer"] = aa.answer; dt.Rows.Add(dr); } if (dt.Rows.Count > 0) { using (CrystalDecisions.CrystalReports.Engine.ReportClass rptH = new CrystalDecisions.CrystalReports.Engine.ReportClass()) { string path = HttpContext.Server.MapPath("~/App_Data/reportPdf.rpt"); rptH.FileName = path; rptH.Load(); rptH.SetDataSource(dt); // rptH.SetParameterValue("isAdmin", (user.Role.RoleName == RoleName.Admintstrator ? "T" : "F")); System.IO.Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); rptH.Close(); return(File(stream, "application/pdf")); } } return(new EmptyResult()); } catch (Exception ex) { return(new EmptyResult()); } }