/// <summary> /// 填充报表 /// </summary> /// <param name="Report"></param> public static void FillReport(BaseReport Report) { try { if (OnReportProcessing != null) { ReportProcessingEventArgs e = new ReportProcessingEventArgs( ); e.Status = "数据查询中。。。"; OnReportProcessing(e); } Report.BaseReportData = oleDb.GetDataTable(Report.DataSQL); if (Report is PatientFeeReport) { DataRow drTotal = Report.BaseReportData.NewRow(); drTotal[0] = "合 计"; for (int i = 3; i < Report.BaseReportData.Columns.Count; i++) { string colName = Report.BaseReportData.Columns[i].ColumnName; object obj = Report.BaseReportData.Compute("Sum(" + colName + ")", ""); drTotal[colName] = obj; } Report.BaseReportData.Rows.Add(drTotal); Report.DataResult = Report.BaseReportData; return; } ConvertCodeToName(Report); Report.DataResult = SetReportStyle(Report, Report.Reportstyle); } catch (Exception err) { throw err; } }
/// <summary> /// 设置数据表样式 /// </summary> /// <param name="report"></param> /// <returns></returns> private static DataTable SetReportStyle(BaseReport report, ReportStyle reportStyle) { if (OnReportProcessing != null) { ReportProcessingEventArgs e = new ReportProcessingEventArgs( ); e.Status = "数据排列中。。。"; OnReportProcessing(e); } DataTable tbResult = new DataTable( ); if (reportStyle == ReportStyle.科目为标题列) { tbResult = RebuildDataWithItemInColumn(report); } else { tbResult = RebuildDataWithItemInRow(report); } if (OnReportProcessing != null) { ReportProcessingEventArgs e = new ReportProcessingEventArgs( ); e.Status = "完成"; OnReportProcessing(e); } return(tbResult); }