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); }
public void ApplyDelta(Element r, bool isObsoleteRecord, bool isAddedRecord, ChangedFieldInfo ci) { if (Dirty) { return; } ManualTotalSummary mt = this; if (isObsoleteRecord) { if (ci.OldValue != null && !(ci.OldValue is DBNull)) { mt.Total -= Convert.ToDouble(ci.OldValue); } } else if (isAddedRecord) { if (ci.NewValue != null && !(ci.NewValue is DBNull)) { mt.Total += Convert.ToDouble(ci.NewValue); } } else { mt.Total += ci.Delta; } }
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); }