Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        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.