private void AddTotalsIfRowSupports(ReportRow row) { foreach (RowField field in row.Fields) { if (field.ShowTotals) { decimal value = Convert.ToDecimal(row[field]); if (_decTotals.ContainsKey(field)) { _decTotals[field] += value; } else { _decTotals[field] = value; } } //// TODO: Fix totals for all numeric types //if (field.DataType == typeof(decimal) || field.DataType == typeof(int) || field.DataType == typeof(short)) //{ //} } }
private void AddFooterRow(ReportRowCollection rows) { if (_decTotals.Count > 0) { var footerRow = new ReportRow(ReportRowType.FooterRow, DataFields, Source, null); foreach (KeyValuePair <RowField, decimal> total in _decTotals) { footerRow[total.Key] = string.Format(total.Key.DataFormatString, total.Value); } foreach (ReportField field in DataFields) { if (!string.IsNullOrEmpty(field.FooterText)) { footerRow[field.Name] = field.FooterText; } } rows.Add(footerRow); } }
public virtual ReportRowCollection GetRows() { var rows = new ReportRowCollection(); rows.RowAdding += RenderingRow; var headerRow = new ReportRow(ReportRowType.HeaderRow, DataFields, Source, null); rows.Add(headerRow); foreach (object dataItem in Source.GetItems()) { var row = new ReportRow(ReportRowType.DataRow, DataFields, Source, dataItem); AddTotalsIfRowSupports(row); rows.Add(row); } AddFooterRow(rows); return(rows); }
public ReportRowEventArgs(ReportRow row) { Row = row; }