Example #1
0
        /// <summary>
        /// recalculate row after all the columns have been calculated already,
        /// but now the functions based on other columns are calculated.
        /// </summary>
        /// <param name="situation"></param>
        /// <param name="row"></param>
        public static void RecalculateRow(TRptSituation situation, TResult row)
        {
            int counter;
            string strCalculation;
            TVariant ColumnCalc;
            TVariant levelCalc;
            TRptDataCalcResult rptDataCalcResult;
            String ColumnFormat;
            TVariant value;

            for (counter = 0; counter <= row.column.Length - 1; counter += 1)
            {
                // calculation is used for display in the GUI, formula is used for adding ledgers
                ColumnCalc = situation.GetParameters().Get("param_formula", counter, -1, eParameterFit.eExact);

                if (ColumnCalc.IsZeroOrNull())
                {
                    ColumnCalc = situation.GetParameters().Get("param_calculation", counter, -1, eParameterFit.eExact);
                }

                levelCalc = situation.GetParameters().Get("param_formula", ReportingConsts.ALLCOLUMNS, row.depth, eParameterFit.eExact);

                if (levelCalc.IsZeroOrNull())
                {
                    levelCalc = situation.GetParameters().Get("param_calculation", ReportingConsts.ALLCOLUMNS, row.depth, eParameterFit.eExact);
                }

                strCalculation = "";

                if ((!ColumnCalc.IsZeroOrNull() && situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), ColumnCalc.ToString())))
                {
                    // e.g. add(Column(1), Column(2))
                    strCalculation = ColumnCalc.ToString();
                }
                else if ((!levelCalc.IsZeroOrNull()
                          && situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), levelCalc.ToString())))
                {
                    // e.g. getSumLowerReport
                    strCalculation = levelCalc.ToString();
                }

                if (situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), strCalculation))
                {
                    rptDataCalcResult = new TRptDataCalcResult(situation, row.depth, counter, row.childRow, row.masterRow);
                    ColumnFormat = "";

                    if (situation.GetParameters().Exists("ColumnFormat", counter, row.depth))
                    {
                        ColumnFormat = situation.GetParameters().Get("ColumnFormat", counter, row.depth).ToString();
                    }

                    value = rptDataCalcResult.Precalculate(row.column);
                    value.ApplyFormatString(ColumnFormat);

                    if (value.ToFormattedString().Length > 0)
                    {
                        row.column[counter] = value;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// recalculate row after all the columns have been calculated already,
        /// but now the functions based on other columns are calculated.
        /// </summary>
        /// <param name="situation"></param>
        /// <param name="row"></param>
        public static void RecalculateRow(TRptSituation situation, TResult row)
        {
            int                counter;
            string             strCalculation;
            TVariant           ColumnCalc;
            TVariant           levelCalc;
            TRptDataCalcResult rptDataCalcResult;
            String             ColumnFormat;
            TVariant           value;

            for (counter = 0; counter <= row.column.Length - 1; counter += 1)
            {
                // calculation is used for display in the GUI, formula is used for adding ledgers
                ColumnCalc = situation.GetParameters().Get("param_formula", counter, -1, eParameterFit.eExact);

                if (ColumnCalc.IsZeroOrNull())
                {
                    ColumnCalc = situation.GetParameters().Get("param_calculation", counter, -1, eParameterFit.eExact);
                }

                levelCalc = situation.GetParameters().Get("param_formula", ReportingConsts.ALLCOLUMNS, row.depth, eParameterFit.eExact);

                if (levelCalc.IsZeroOrNull())
                {
                    levelCalc = situation.GetParameters().Get("param_calculation", ReportingConsts.ALLCOLUMNS, row.depth, eParameterFit.eExact);
                }

                strCalculation = "";

                if ((!ColumnCalc.IsZeroOrNull() && situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), ColumnCalc.ToString())))
                {
                    // e.g. add(Column(1), Column(2))
                    strCalculation = ColumnCalc.ToString();
                }
                else if ((!levelCalc.IsZeroOrNull() &&
                          situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), levelCalc.ToString())))
                {
                    // e.g. getSumLowerReport
                    strCalculation = levelCalc.ToString();
                }

                if (situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), strCalculation))
                {
                    rptDataCalcResult = new TRptDataCalcResult(situation, row.depth, counter, row.childRow, row.masterRow);
                    ColumnFormat      = "";

                    if (situation.GetParameters().Exists("ColumnFormat", counter, row.depth))
                    {
                        ColumnFormat = situation.GetParameters().Get("ColumnFormat", counter, row.depth).ToString();
                    }

                    value = rptDataCalcResult.Precalculate(row.column);
                    value.ApplyFormatString(ColumnFormat);

                    if (value.ToFormattedString().Length > 0)
                    {
                        row.column[counter] = value;
                    }
                }
            }
        }