Пример #1
0
        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))
                //{


                //}
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
 public ReportRowEventArgs(ReportRow row)
 {
     Row = row;
 }