/// <summary> /// Calcula el valor de la funcion agregada indicada para un conjunto de datos /// </summary> /// <typeparam name="T"></typeparam> /// <param name="propertyName"></param> /// <param name="aggregateType"></param> /// <param name="data"></param> /// <returns></returns> public static object CalculateAggregate <T>(string propertyName, AggregateEnum aggregateType, IEnumerable <T> data) { object result = null; switch (aggregateType) { case AggregateEnum.Sum: result = DataHelper.CalculateAggregateSum <T>(propertyName, data); break; case AggregateEnum.Average: result = DataHelper.CalculateAggregateAverage <T>(propertyName, data); break; case AggregateEnum.Count: result = DataHelper.CalculateAggregateCount <T>(propertyName, data); break; case AggregateEnum.Maximum: result = DataHelper.CalculateAggregateMaximum <T>(propertyName, data); break; case AggregateEnum.Minimum: result = DataHelper.CalculateAggregateMinimum <T>(propertyName, data); break; default: throw new NotSupportedException(); } return(result); }
/// <summary> /// 기본 생성자 /// </summary> /// <param name="aggregateEnum">합계유형</param> /// <param name="level">SubTotal Level(Tree Depth)</param> /// <param name="columnName">컬럼명</param> /// <param name="groupbyColumnName">그룹 컬럼 명</param> /// <param name="caption">그룹 컬럼 명</param> public SubTotalItem(AggregateEnum aggregateEnum, int level, string groupbyColumnName, string columnName, string caption) { this.AggregateEnum = aggregateEnum; this.Level = level; this.GroupbyColumnName = groupbyColumnName; this.ColumnName = columnName; this.Caption = caption; }
//---------------------------------------------------------------- #region ** Before/AfterSubtotal void _btnSubtotal_Click(object sender, EventArgs e) { // remove old totals _flexSubtotals.Subtotal(AggregateEnum.Clear); _lstSubtotal.Items.Clear(); // calculate new totals AggregateEnum aggregate = (AggregateEnum)Enum.Parse(typeof(AggregateEnum), _cmbAggregate.Text); int groupOn = _flexSubtotals.Cols.IndexOf("CategoryID"); int totalOn = _flexSubtotals.Cols.IndexOf("UnitPrice"); _flexSubtotals.Subtotal(aggregate, 0, groupOn, groupOn, totalOn, _cmbAggregate.Text + " for category {0}"); totalOn = _flexSubtotals.Cols.IndexOf("UnitsInStock"); _flexSubtotals.Subtotal(aggregate, 0, groupOn, groupOn, totalOn, _cmbAggregate.Text + " for category {0}"); totalOn = _flexSubtotals.Cols.IndexOf("UnitsOnOrder"); _flexSubtotals.Subtotal(aggregate, 0, groupOn, groupOn, totalOn, _cmbAggregate.Text + " for category {0}"); totalOn = _flexSubtotals.Cols.IndexOf("ReorderLevel"); _flexSubtotals.Subtotal(aggregate, 0, groupOn, groupOn, totalOn, _cmbAggregate.Text + " for category {0}"); }
/// <summary> /// 기본 생성자 /// </summary> /// <param name="aggregateEnum">합계유형</param> /// <param name="columnName">컬럼명</param> public GrandTotalItem(AggregateEnum aggregateEnum, string columnName) { this.AggregateEnum = aggregateEnum; this.ColumnName = columnName; }