void CalculateTotal() { total = 0; if (group.Details is RecordsDetails) { foreach (Record r in group.Records) { object obj = r.GetValue(field); if (obj != null && !(obj is DBNull)) { double d = Convert.ToDouble(obj); total += d; } } } else { foreach (Group g in group.Groups) { IManualTotalSummaryArraySource tsa = g as IManualTotalSummaryArraySource; ManualTotalSummary mt = tsa.GetManualTotalSummaryArray()[this.FieldIndex]; if (mt == null) { mt = new ManualTotalSummary(g, field); } double d = mt.Total; total += d; } } }
protected override void OnPrepareItemAdded(object row) { // Get new values for which delta information is needed IManualTotalSummaryArraySource tsa = this.TopLevelGroup as IManualTotalSummaryArraySource; if (tsa != null) { TableDescriptor td = TableDescriptor; foreach (string name in this.totalSummaries) { FieldDescriptor fd = td.Fields[name]; if (fd.IsPropertyField()) { PropertyDescriptor pd = fd.GetPropertyDescriptor(); object value = GetValue(row, pd); ChangedFieldInfo ci = new ChangedFieldInfo(td, pd.Name, null, value); this.AddChangedField(ci); } } } base.OnPrepareItemAdded(row); }
protected override void OnPrepareRemoving(object row) { // Save values for all fields where we need to be able to access the // old value (e.g. Delta for TotalSummaries). TableDescriptor td = TableDescriptor; IManualTotalSummaryArraySource tsa = this.TopLevelGroup as IManualTotalSummaryArraySource; if (tsa != null) { foreach (string name in this.totalSummaries) { FieldDescriptor fd = td.Fields[name]; if (fd.IsPropertyField()) { PropertyDescriptor pd = fd.GetPropertyDescriptor(); object value = GetValue(row, pd); ChangedFieldInfo ci = new ChangedFieldInfo(td, pd.Name, value, null); this.AddChangedField(ci); } } } base.OnPrepareRemoving(row); }
protected override void OnRecordChanged(Element r, bool isObsoleteRecord, bool isAddedRecord) { TableDescriptor td = TableDescriptor; Group g = r.ParentGroup; while (g is IManualTotalSummaryArraySource) { OnGroupSummaryInvalidated(new GroupEventArgs(g)); IManualTotalSummaryArraySource tsa = g as IManualTotalSummaryArraySource; foreach (ChangedFieldInfo ci in this.ChangedFieldsArray) { ManualTotalSummary mt = tsa.GetManualTotalSummaryArray()[ci.FieldIndex]; if (mt != null) { mt.ApplyDelta(r, isObsoleteRecord, isAddedRecord, ci); } } g = g.ParentGroup; } } // Fix ManualTotalSummary of parent groups.