Esempio n. 1
0
        /// <summary>
        /// todoComment
        /// </summary>
        protected void InitColumnCaptions()
        {
            TRptCalculation rptCalculation;
            TRptDataCalcValue rptDataCalcValue;
            int column;

            for (column = 0; column <= Results.GetMaxDisplayColumns() - 1; column += 1)
            {
                rptCalculation = ReportStore.GetCalculation(CurrentReport, Parameters.Get("param_calculation", column).ToString());

                if (rptCalculation != null)
                {
                    if (rptCalculation.strAlign.Length != 0)
                    {
                        Parameters.Add("ColumnAlign", new TVariant(rptCalculation.strAlign), column);
                    }
                    else
                    {
                        if (StringHelper.IsCurrencyFormatString(rptCalculation.strReturnsFormat)
                            || (rptCalculation.strReturnsFormat.ToLower().IndexOf("percentage") != -1))
                        {
                            Parameters.Add("ColumnAlign", new TVariant("right"), column);
                        }
                        else
                        {
                            Parameters.Add("ColumnAlign", new TVariant("left"), column);
                        }
                    }

                    if (rptCalculation.strReturnsFormat.Length != 0)
                    {
                        Parameters.Add("ColumnFormat", new TVariant(rptCalculation.strReturnsFormat), column, -1);
                    }

                    if (rptCalculation.rptGrpCaption != null)
                    {
                        rptDataCalcValue = new TRptDataCalcValue(this, -1, column, -1, 0);
                        FormatCaption("ColumnCaption", rptDataCalcValue.Calculate(rptCalculation.rptGrpCaption), column);
                    }

                    if (rptCalculation.rptGrpShortCaption != null)
                    {
                        rptDataCalcValue = new TRptDataCalcValue(this, -1, column, -1, 0);
                        FormatCaption("ColumnShortCaption", rptDataCalcValue.Calculate(rptCalculation.rptGrpShortCaption), column);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="rptGrpValue"></param>
        /// <param name="rptGrpFieldDetail"></param>
        public void Calculate(List <TRptValue>rptGrpValue, List <TRptFieldDetail>rptGrpFieldDetail)
        {
            TVariant value;
            TRptDataCalcValue rptDataCalcValue;

            if (Depth == -1)
            {
                value = new TVariant();

                // this is only in header; value is directly calculated
                if (rptGrpFieldDetail != null)
                {
                    value = Calculate(rptGrpFieldDetail);
                }
                else
                {
                    if (rptGrpValue != null)
                    {
                        rptDataCalcValue = new TRptDataCalcValue(this);
                        value = rptDataCalcValue.Calculate(rptGrpValue);
                    }
                }

                GetParameters().Add("ControlSource", value, column, Depth);
            }
            else
            {
                if (rptGrpValue != null)
                {
                    GetParameters().Add("ControlSource", new TVariant("rptGrpValue"), column, Depth, null, rptGrpValue, -1);
                }
                else
                {
                    GetParameters().Add("ControlSource", new TVariant("calculation"), column, Depth);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="rptGrpFieldDetail"></param>
        /// <returns></returns>
        public TVariant Calculate(List <TRptFieldDetail>rptGrpFieldDetail)
        {
            TVariant ReturnValue;
            TRptDataCalcValue rptDataCalcValue;
            TRptDataCalcSwitch rptDataCalcSwitch;

            ReturnValue = new TVariant();

            foreach (TRptFieldDetail rptFieldDetail in rptGrpFieldDetail)
            {
                if (EvaluateCondition(rptFieldDetail.strCondition))
                {
                    if (rptFieldDetail.rptGrpValue != null)
                    {
                        rptDataCalcValue = new TRptDataCalcValue(this);
                        ReturnValue.Add(rptDataCalcValue.Calculate(rptFieldDetail.rptGrpValue));
                    }
                    else
                    {
                        rptDataCalcSwitch = new TRptDataCalcSwitch(this);
                        ReturnValue.Add(rptDataCalcSwitch.Calculate(rptFieldDetail.rptSwitch));
                    }
                }
            }

            return ReturnValue;
        }
Esempio n. 4
0
        /// <summary>
        /// calculate the value of a switch
        /// </summary>
        /// <param name="rptSwitch"></param>
        /// <returns></returns>
        public TVariant Calculate(TRptSwitch rptSwitch)
        {
            TVariant ReturnValue;
            TRptDataCalcField rptDataCalcField;
            TRptDataCalcValue rptDataCalcValue;
            TRptDataCalcSwitch rptDataCalcSwitch;
            TRptCase rptCase;

            ReturnValue = new TVariant();
            rptCase = GetFittingCase(rptSwitch);

            if (rptCase == null)
            {
                return ReturnValue;
            }

            if (rptCase.rptSwitch != null)
            {
                rptDataCalcSwitch = new TRptDataCalcSwitch(this);
                ReturnValue.Add(rptDataCalcSwitch.Calculate(rptCase.rptSwitch));
            }
            else
            {
                if (rptCase.rptGrpField != null)
                {
                    rptDataCalcField = new TRptDataCalcField(this);
                    rptDataCalcField.Calculate(rptCase.rptGrpField);
                }

                if (rptCase.rptGrpValue != null)
                {
                    rptDataCalcValue = new TRptDataCalcValue(this);
                    ReturnValue.Add(rptDataCalcValue.Calculate(rptCase.rptGrpValue));
                }
            }

            return ReturnValue;
        }
Esempio n. 5
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="rptCalculation"></param>
        /// <param name="rptGrpParameter"></param>
        /// <param name="rptGrpTemplate"></param>
        /// <param name="rptGrpQuery"></param>
        /// <returns></returns>
        public TVariant EvaluateCalculationAll(TRptCalculation rptCalculation,
            List <TRptParameter>rptGrpParameter,
            List <TRptQuery>rptGrpTemplate,
            List <TRptQuery>rptGrpQuery)
        {
            TVariant ReturnValue;
            TRptDataCalcValue rptDataCalcValue;
            TRptDataCalcSwitch rptDataCalcSwitch;

            ReturnValue = new TVariant();

            if (rptGrpQuery == null)
            {
                return ReturnValue;
            }

            foreach (TRptQuery rptQuery in rptGrpQuery)
            {
                if (EvaluateCondition(rptQuery.strCondition))
                {
                    if (rptQuery.rptGrpValue != null)
                    {
                        rptDataCalcValue = new TRptDataCalcValue(this);

                        if (!ReturnValue.IsZeroOrNull())
                        {
                            ReturnValue.Add(new TVariant(" "));
                        }

                        ReturnValue.Add(rptDataCalcValue.Calculate(rptQuery.rptGrpValue, true));
                    }

                    if (rptQuery.rptGrpParameter != null)
                    {
                        // insert template with parameters
                        ReturnValue.Add(new TVariant(" "));
                        ReturnValue.Add(EvaluateCalculationAll(rptCalculation, rptQuery.rptGrpParameter, null, rptGrpTemplate));
                    }

                    if (rptQuery.rptGrpSwitch != null)
                    {
                        if (!ReturnValue.IsZeroOrNull())
                        {
                            ReturnValue.Add(new TVariant(" "));
                        }

                        rptDataCalcSwitch = new TRptDataCalcSwitch(this);
                        ReturnValue.Add(new TVariant(rptDataCalcSwitch.Calculate(rptQuery.rptGrpSwitch)));
                    }
                }
            }

            if ((ReturnValue.TypeVariant == eVariantTypes.eString) || (ReturnValue.ToString().IndexOf("{") != -1))
            {
                ReturnValue = new TVariant(ApplyParametersToQuery(rptGrpParameter, ReturnValue.ToString()), true); // explicit string
                ReturnValue = ReplaceVariables(ReturnValue.ToString(), true);
            }

            // TLogging.log('Result of TRptDataCalcCalculation.evaluateCalculationAll: '+result.encodetostring());
            return ReturnValue;
        }
Esempio n. 6
0
        /// <summary>
        /// </summary>
        /// <param name="query"></param>
        /// <param name="rptGrpParameter"></param>
        /// <returns></returns>
        public String Calculate(String query, List <TRptParameter>rptGrpParameter)
        {
            String ReturnValue = query;

            foreach (TRptParameter rptParameter in rptGrpParameter)
            {
                string name = rptParameter.strName;
                TVariant value;

                if (rptParameter.strValue.Length != 0)
                {
                    value = new TVariant(rptParameter.strValue);
                    Parameters.Add(name, value, -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                }
                else
                {
                    if (rptParameter.rptGrpValue != null)
                    {
                        TRptDataCalcValue rptDataCalcValue = new TRptDataCalcValue(this);
                        value = rptDataCalcValue.Calculate(rptParameter.rptGrpValue);
                        Parameters.Add(name, value, -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                    }
                    else
                    {
                        value = Parameters.Get(name, column, Depth);
                    }
                }

                if (value.IsNil())
                {
                    TLogging.Log(
                        "Variable " + name + " could not be found (column: " + column.ToString() + "; level: " + Depth.ToString() + ")." + ' ' +
                        ReturnValue);
                }

                ReturnValue = ReturnValue.Replace("{{" + name + "}}", value.ToString());
                ReturnValue = ReturnValue.Replace("{" + name + "}", "'" + value.ToString() + "'");
            }

            return ReturnValue;
        }
Esempio n. 7
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="masterRow"></param>
        /// <param name="condition"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public Boolean SavePrecalculation(int masterRow, String condition, String code)
        {
            Boolean ReturnValue;

            TVariant[] precalculatedColumns;
            TVariant[] precalculatedDescr = new TVariant[2];
            TVariant[] header = new TVariant[2];
            Boolean display;
            Boolean hideRow = false;
            Boolean debit_credit_indicator;
            Boolean param_hide_empty_lines = false;
            int counter;
            String values;
            TRptDataCalcValue rptDataCalcValue;
            List <TRptValue>rptGrpValue;
            int maxDisplayColumns;
            int numberColumns;
            int ColumnPartnerName = -1;
            int ColumnPartnerKey = -1;
            TResult newRow;
            ReturnValue = false;
            condition = condition.ToLower();
            maxDisplayColumns = Results.GetMaxDisplayColumns();
            numberColumns = maxDisplayColumns;

            while (Parameters.Exists("param_calculation", numberColumns, -1))
            {
                numberColumns = numberColumns + 1;
            }

            precalculatedColumns = new TVariant[numberColumns];

            for (counter = 0; counter <= maxDisplayColumns - 1; counter += 1)
            {
                precalculatedColumns[counter] = new TVariant();
            }

            if (!Parameters.Exists("debit_credit_indicator", -1, Depth))
            {
                debit_credit_indicator = true;
            }
            else
            {
                debit_credit_indicator = Parameters.Get("debit_credit_indicator", -1, Depth).ToBool();
            }

            if (Parameters.Get("param_hide_empty_lines").ToString() == "true")
            {
                param_hide_empty_lines = true;
            }

            if (Depth > 0)
            {
                if (debit_credit_indicator)
                {
                    Parameters.Add("debit_credit_indicator", true, -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                }
                else
                {
                    Parameters.Add("debit_credit_indicator", false, -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                }

                values = Parameters.Get("ControlSource", ReportingConsts.ALLCOLUMNS, Depth).ToString();

                if (values == "calculation")
                {
                    // first calculate the invisible helper Columns
                    for (counter = maxDisplayColumns; counter <= numberColumns - 1; counter += 1)
                    {
                        column = counter;
                        precalculatedColumns[column] = Precalculate(precalculatedColumns);
                    }

                    // calculate the visible Columns
                    for (counter = 0; counter <= maxDisplayColumns - 1; counter += 1)
                    {
                        column = counter;
                        precalculatedColumns[column] = Precalculate(precalculatedColumns);

                        if (param_hide_empty_lines)
                        {
                            // if this parameter is set, hide the row when all columns are empty, except
                            // of the column partner name and partner key.
                            TParameter CurrentParameter = Parameters.GetParameter("param_calculation", column, -1, eParameterFit.eExact);

                            if (CurrentParameter.value.ToString() == "Partner Name")
                            {
                                ColumnPartnerName = CurrentParameter.column;
                            }
                            else if (CurrentParameter.value.ToString() == "Partner Key")
                            {
                                ColumnPartnerKey = CurrentParameter.column;
                            }
                        }
                    }

                    if (param_hide_empty_lines)
                    {
                        hideRow = IsRowEmpty(ref precalculatedColumns, ColumnPartnerName, ColumnPartnerKey, 0, maxDisplayColumns - 1);
                    }
                }
                else
                {
                    // first calculate the invisible helper Columns
                    for (counter = maxDisplayColumns; counter <= numberColumns - 1; counter += 1)
                    {
                        CalculateColumnValue(counter, ref precalculatedColumns);
                    }

                    for (counter = 0; counter <= maxDisplayColumns - 1; counter += 1)
                    {
                        CalculateColumnValue(counter, ref precalculatedColumns);
                    }
                }

                rptGrpValue = (List <TRptValue> )Parameters.GetGrpValue("ControlSource",
                    ReportingConsts.HEADERCOLUMN + 1,
                    Depth,
                    eParameterFit.eExact);

                if (rptGrpValue != null)
                {
                    Parameters.Add("headerVISIBLE", new TVariant(true), -1, Depth);
                    column = ReportingConsts.HEADERCOLUMN + 1;
                    rptDataCalcValue = new TRptDataCalcValue(this);
                    header[0] = rptDataCalcValue.Calculate(rptGrpValue);
                }

                rptGrpValue = (List <TRptValue> )Parameters.GetGrpValue("ControlSource",
                    ReportingConsts.HEADERCOLUMN + 2,
                    Depth,
                    eParameterFit.eExact);

                if (rptGrpValue != null)
                {
                    Parameters.Add("headerVISIBLE", new TVariant(true), -1, Depth);
                    column = ReportingConsts.HEADERCOLUMN + 2;
                    rptDataCalcValue = new TRptDataCalcValue(this);
                    header[1] = rptDataCalcValue.Calculate(rptGrpValue);
                }

                for (counter = 0; counter <= 1; counter += 1)
                {
                    column = counter - 10;
                    rptGrpValue = (List <TRptValue> )Parameters.GetGrpValue("ControlSource", column, Depth, eParameterFit.eExact);

                    if (rptGrpValue != null)
                    {
                        rptDataCalcValue = new TRptDataCalcValue(this);
                        precalculatedDescr[counter] = rptDataCalcValue.Calculate(rptGrpValue);
                    }
                }

                debit_credit_indicator = Parameters.Get("debit_credit_indicator", column, Depth).ToBool();
                display = true;
                newRow = Results.AddRow(masterRow,
                    LineId,
                    display,
                    Depth,
                    code,
                    condition,
                    debit_credit_indicator,
                    header,
                    precalculatedDescr,
                    precalculatedColumns);
                ReturnValue = true;

                if (condition.Length != 0)
                {
                    column = -1;
                    display = EvaluateCondition(condition);
                }

                if (Parameters.Exists("DONTDISPLAYROW") && (Parameters.Get("DONTDISPLAYROW").ToBool() == true))
                {
                    display = false;
                }

                if ((newRow != null) && ((!display) || hideRow))
                {
                    newRow.display = false;
                    ReturnValue = false;
                }
            }

            return ReturnValue;
        }
Esempio n. 8
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="col"></param>
        /// <param name="precalculatedColumns"></param>
        protected void CalculateColumnValue(System.Int32 col, ref TVariant[] precalculatedColumns)
        {
            TRptDataCalcValue rptDataCalcValue;

            List <TRptValue>rptGrpValue;
            TParameter parameter;
            String ColumnFormat;
            TVariant value;

            column = col;
            parameter = Parameters.GetParameter("ControlSource", column, Depth, eParameterFit.eExact);

            if (parameter == null)
            {
                parameter = Parameters.GetParameter("ControlSource", column, -1, eParameterFit.eExact);
            }

            if (parameter == null)
            {
                parameter = Parameters.GetParameter("ControlSource", ReportingConsts.ALLCOLUMNS, Depth, eParameterFit.eBestFit);
            }

            if ((parameter != null) && (parameter.value.ToString() == "rptGrpValue") && (parameter.pRptGroup != null))
            {
                rptGrpValue = (List <TRptValue> )parameter.pRptGroup;
                rptDataCalcValue = new TRptDataCalcValue(this);
                ColumnFormat = "";

                if (Parameters.Exists("ColumnFormat", column, Depth))
                {
                    ColumnFormat = GetParameters().Get("ColumnFormat", column, Depth).ToString();
                }

                value = rptDataCalcValue.Calculate(rptGrpValue);
                value.ApplyFormatString(ColumnFormat);

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