public override void ShowReport() { ReportContainer rc = (ReportContainer)_object; ReportParameter[] p = new ReportParameter[1]; p[0] = new ReportParameter("Year", rc.Year.ToString(), true); //p[1] = new ReportParameter("Month", rc.Month.ToString(), true); ReportDataSource dataSource = new ReportDataSource(); dataSource.Name = "ResidentRollCall"; List <ResidentYearlyCallSummaryByMonth> listNew = rc.RollCallSummaryList.ConvertAll(x => x as ResidentYearlyCallSummaryByMonth); listNew.ForEach(x => x.UpdateMonthName()); listNew = listNew.OrderBy(x => x.MonthNumber).ToList(); dataSource.Value = listNew;// rc.RollCallSummaryList.ConvertAll(x=>x as ResidentYearlyCallSummaryByMonth); _reportViewer.LocalReport.ReportEmbeddedResource = "RanfurlyCentre.Reports.RDLCReports.YearlyResidentRollCallReportByMonth.rdlc"; _reportViewer.LocalReport.SetParameters(p); _reportViewer.LocalReport.DataSources.Clear(); _reportViewer.LocalReport.DataSources.Add(dataSource); _reportViewer.LocalReport.DisplayName = "Yearly Resident Roll Call Report by Month for - " + rc.Year.ToString() + "'"; _reportViewer.RefreshReport(); //_reportViewer.RefreshReport(); }
private void ReportViewer_Load(object sender, EventArgs e) { try { ReportViewerBase rb; if (_object is Student) { Student student = (Student)_object; rb = new IndividualStudentReport(this.reportViewer1, student); } else if (_object is ReportContainer) { ReportContainer obj = (ReportContainer)_object; if (obj.RollCallSummaryList[0] is ResidentMonthlyCallSummary) { rb = new MonthlyResidentRollCall(this.reportViewer1, obj); } else if (obj.RollCallSummaryList[0] is ResidentYearlyCallSummaryByResident) { rb = new YearlyResidentRollCallByResident(this.reportViewer1, obj); } else if (obj.RollCallSummaryList[0] is ResidentYearlyCallSummaryByMonth) { rb = new YearlyResidentRollCallByMonth(this.reportViewer1, obj); } else { throw new Exception("Cannot find report type"); } } Byte[] mybytes = this.reportViewer1.LocalReport.Render("PDF"); string filename = Jarvis.OutputFileLocation + this.reportViewer1.LocalReport.DisplayName + ".pdf"; using (FileStream fs = File.Create(filename)) { fs.Write(mybytes, 0, mybytes.Length); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGenerateReport_Click(object sender, EventArgs e) { try { ResidentRollCall call = _residentCalls[0]; ReportContainer rc = new ReportContainer(); rc.Month = call.GetMonthName(); rc.Year = call.YearNumber.ToString();; rc.RollCallSummaryList = _residentYearlyCallSummarySummaryList; ReportViewer rv = new ReportViewer(rc); rv.Jarvis = _mdiForm.Jarvis; rv.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override void ShowReport() { ReportContainer rc = (ReportContainer)_object; ReportParameter[] p = new ReportParameter[2]; p[0] = new ReportParameter("Year", rc.Year.ToString(), true); p[1] = new ReportParameter("Month", rc.Month.ToString(), true); ReportDataSource dataSource = new ReportDataSource(); dataSource.Name = "ResidentRollCall"; dataSource.Value = rc.RollCallSummaryList.ConvertAll(x => x as ResidentMonthlyCallSummary); _reportViewer.LocalReport.ReportEmbeddedResource = "RanfurlyCentre.Reports.RDLCReports.MonthlyResidentRollCallReport.rdlc"; _reportViewer.LocalReport.SetParameters(p); _reportViewer.LocalReport.DataSources.Clear(); _reportViewer.LocalReport.DataSources.Add(dataSource); _reportViewer.LocalReport.DisplayName = "Monthly Resident Roll Call Report for - " + rc.Month.ToString() + "_'" + rc.Year.ToString() + "'"; _reportViewer.RefreshReport(); //_reportViewer.RefreshReport(); }