protected void gsReporteVentas_Item_ItemNeedCalculation(object sender, PivotGridCalculationEventArgs e)
        {
            if (e.DataField.ToString() == "PUnitario_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "PUnitarioPPT_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "PUnitarioAnterior_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }


            if (e.DataField.ToString() == "CUnitario_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "CUnitarioAnterior_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }



            if (e.DataField.ToString() == "Margen_2017_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }



            if (e.DataField.ToString() == "Margen_2016_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            //----------------------------------------------------
            if (e.DataField.ToString() == "VPU_2016_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "VPU_PPTO_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "VMg17_16_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
        }
Esempio n. 2
0
        protected void gsReporteVentas_Zonas_ItemNeedCalculation(object sender, PivotGridCalculationEventArgs e)
        {
            //if (e.GroupName.ToString() == "Forecast for 1999")
            //{
            //    //Calculation of AggregateSummaryValue for our CalculatedItem, based on the values from other items
            //    try
            //    {
            //        LagrangeInterpolate interpolate = new LagrangeInterpolate();
            //        interpolate.Add(1996, double.Parse(e.GetAggregateSummaryValue(1996).GetValue().ToString()));
            //        interpolate.Add(1997, double.Parse(e.GetAggregateSummaryValue(1997).GetValue().ToString()));
            //        interpolate.Add(1998, double.Parse(e.GetAggregateSummaryValue(1998).GetValue().ToString()));

            //        //Set new calulated value for given field.
            //        e.CalculatedValue = new DoubleAggregateValue(Math.Max(interpolate.InterpolateX(1998.5), 0));
            //    }
            //    catch (Exception)
            //    {
            //        //If unable to predict the forecast, leave the cell empty.
            //        e.CalculatedValue = null;
            //    }
            //}
            //else
            if (e.DataField.ToString() == "Cumplimiento")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "Crecimiento")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "CumplimientoKL")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "CrecimientoKL")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "PrecioUnitario")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "PrecioUnitario2016")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            //////
            if (e.DataField.ToString() == "PrecioUnitarioPPTO")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "VP_Real")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "VP_PPTO")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "EfectoPr_2017x2016")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            ////////

            if (e.DataField.ToString() == "EfectoPr_2017xPPTO")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "EfectoVol_Real")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "EfectoVol_PPTO")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
        }
        protected void gsReporteVentas_Zonas_ItemNeedCalculation(object sender, PivotGridCalculationEventArgs e)
        {
            if (e.DataField.ToString() == "MargenPorcentaje")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "MargenGASTOD")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "MargenGASTOI")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "MargenGASTO")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "UtilidadOperativaP")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "GastoAdministrativoD_P")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "UtilidadGAP")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "GastoFinanDolares_P")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "GastoOtrosDolares_P")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            //------------

            if (e.DataField.ToString() == "UtilidadNeta_P")
            {
                //The data calculated by CalculationExpression="{0}/{1}" added in the markup is additionally modified here
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        //case when "Sum of TotalPrice" is 0 and "Sum of Quantity" is 0
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
        }
Esempio n. 4
0
 //protected void gsContadorAccesos_ItemNeedCalculation(object sender, PivotGridCalculationEventArgs e)
 //{
 //    //if (e.DataField.ToString() == "Margen_cal")
 //    //{
 //    //    if (e.CalculatedValue != null)
 //    //    {
 //    //        if (double.IsNaN((double)e.CalculatedValue.GetValue()))
 //    //        {
 //    //            e.CalculatedValue = new DoubleAggregateValue(0);
 //    //        }
 //    //        else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
 //    //        {
 //    //            e.CalculatedValue = new DoubleAggregateValue(0);
 //    //        }
 //    //    }
 //    //}
 //}
 protected void gsContadorSinAccesos_ItemNeedCalculation(object sender, PivotGridCalculationEventArgs e)
 {
 }
        protected void gsReporteVentas_Familia_ItemNeedCalculation(object sender, PivotGridCalculationEventArgs e)
        {
            if (e.DataField.ToString() == "Margen_cal")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "Margen_PPTO_cal")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }


            if (e.DataField.ToString() == "Variacion_P_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
            if (e.DataField.ToString() == "PUnitario_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }


            if (e.DataField.ToString() == "PUnitarioPPT_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "CUnitario_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }

            if (e.DataField.ToString() == "CUnitarioPPTO_c")
            {
                if (e.CalculatedValue != null)
                {
                    if (double.IsNaN((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                    else if (double.IsInfinity((double)e.CalculatedValue.GetValue()))
                    {
                        e.CalculatedValue = new DoubleAggregateValue(0);
                    }
                }
            }
        }