Exemplo n.º 1
0
 private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
     if (e.DataField == fieldProductAmount1 && e.Value != null)
     {
         List <object> rowValues = new List <object>();
         foreach (PivotGridField field in e.GetRowFields())
         {
             rowValues.Add(UpdateValue(field, e.RowIndex, e));
         }
         List <object> columnValues = new List <object>();
         foreach (PivotGridField field in e.GetColumnFields())
         {
             columnValues.Add(UpdateValue(field, e.ColumnIndex, e));
         }
         decimal previousValue = Convert.ToDecimal(e.GetCellValue(columnValues.ToArray(), rowValues.ToArray(), fieldProductAmount));
         decimal value         = Convert.ToDecimal(e.GetCellValue(fieldProductAmount));
         if (previousValue == 0m || e.Value == null)
         {
             e.Value = null;
         }
         else
         {
             e.Value = ((decimal)e.Value / previousValue - 1);
         }
     }
 }
 private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
     if (e.DataField == fieldQuantityPercent)
     {
         e.Value = Convert.ToDecimal(e.Value) * 100;
     }
 }
Exemplo n.º 3
0
 void pivotGridControl_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
     if (e.Value != null && (decimal)e.Value < 2000)
     {
         e.Value = "Too low to show";
     }
 }
 private void PivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
     if (e.DataField == fieldDiscount && e.RowValueType == FieldValueType.GrandTotal)
     {
         e.Value = String.Empty;
     }
 }
 // some custom logic to demonstrate the approach in action
 private void OnPivotCustomCellValue(object sender, PivotCellValueEventArgs e)
 {
     if (e.DataField == fieldExtendedPriceUnbound)
     {
         PivotDrillDownDataSource ds = e.CreateDrillDownDataSource();
         decimal value = 0;
         Dictionary <PivotGridField, object> columnFieldValues = new Dictionary <PivotGridField, object>();
         PivotGridField[] columnFields = e.GetColumnFields();
         foreach (PivotGridField field in columnFields)
         {
             columnFieldValues[field] = e.GetFieldValue(field);
         }
         for (int i = 0; i < ds.RowCount; i++)
         {
             bool skip = false;
             foreach (PivotGridField field in columnFields)
             {
                 if (!Comparer.Equals(ds[i][field], columnFieldValues[field]))
                 {
                     skip = true;
                     break;
                 }
             }
             if (skip)
             {
                 continue;
             }
             decimal v1 = Convert.ToDecimal(ds[i][e.DataField]);
             value += v1;
         }
         e.Value = value;
     }
 }
        private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
        {
            // Calculates the 'Percent' field values.
            if (e.DataField.Name == "PercentOfBeverages")
            {
                // Do not display grand total values.
                if (e.RowValueType == PivotGridValueType.GrandTotal)
                {
                    e.Value = null;
                    return;
                }

                var     rowValues      = e.GetRowFields().Select(f => f.FieldName == "CategoryName" ? "Beverages" : e.GetFieldValue(f)).ToArray();
                var     columnValues   = e.GetColumnFields().Select(f => f.FieldName == "CategoryName" ? "Beverages" : e.GetFieldValue(f)).ToArray();
                decimal beveragesValue = Convert.ToDecimal(e.GetCellValue(columnValues, rowValues, e.DataField));
                if (beveragesValue == 0)
                {
                    e.Value = null;
                }
                else
                {
                    e.Value = Convert.ToDecimal(e.Value) / beveragesValue;
                }
            }
            else
            {
                return;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// отобразим сумму ФОТ по проекту только в итоговой строке
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void PV_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
     if (e != null && e.DataField != null && e.DataField.FieldName == "SumFOT" && e.ColumnValueType != PivotGridValueType.Value && e.RowValueType == PivotGridValueType.Value)
     {
         e.Value = 0;
     }
 }
Exemplo n.º 8
0
        // Returns a list of summary values against which
        // a Custom Total will be calculated.
        private ArrayList GetSummaryValues(PivotCellValueEventArgs e)
        {
            ArrayList values = new ArrayList();

            // Creates a summary data source.
            PivotSummaryDataSource sds = e.CreateSummaryDataSource();

            // Iterates through summary data source records
            // and copies summary values to an array.
            for (int i = 0; i < sds.RowCount; i++)
            {
                object value = sds.GetValue(i, e.DataField);
                if (value == null)
                {
                    continue;
                }
                values.Add(value);
            }

            // Sorts summary values.
            values.Sort();

            // Returns the summary values array.
            return(values);
        }
Exemplo n.º 9
0
        private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
        {
            //if (fieldAMOUNT1.Equals(e.DataField))
            //{
            //    if (e.ColumnCustomTotal == null && e.RowCustomTotal == null) return;

            //    // Obtains a list of summary values against which
            //    // the Custom Total will be calculated.
            //    ArrayList summaryValues = GetSummaryValues(e);

            //    // Obtains the name of the Custom Total that should be calculated.
            //    string customTotalName = GetCustomTotalName(e);

            //    // Calculates the Custom Total value and assigns it to the Value event parameter.
            //    e.Value = GetCustomTotalValue(summaryValues, customTotalName);


                //PivotDrillDownDataSource ds = e.CreateDrillDownDataSource();
                //decimal summary = 0;
                //decimal dval = 0;
                //decimal cval = 0;
                //for (int i = 0; i < ds.RowCount; i++)
                //{
                //    string name = Convert.ToString(ds[i][fieldCashName1]);
                //    decimal value = Convert.ToDecimal(ds[i][fieldAMOUNT1]);
                //    if (name.Substring(0, name.Length) == "1" || name.Substring(0, name.Length) == "2" || name.Substring(0, name.Length) == "3" || name.Substring(0, name.Length) == "5")
                //        dval += value;
                //    else
                //        cval += value;
                //}
                //if (cval == 0)
                //    e.Value = -1 * dval;
            //}
        }
Exemplo n.º 10
0
 private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
     if (e.DataField == fieldLowLevel)
     {
         PivotGridField lastLevelField = pivotGridControl1.GetFieldsByArea(PivotArea.RowArea).Last();
         if (e.RowValueType == PivotGridValueType.Total ||
             e.RowValueType == PivotGridValueType.GrandTotal ||
             e.RowField != lastLevelField)
         {
             e.Value = null;
         }
     }
 }
Exemplo n.º 11
0
        private void pvt_datos2_CustomCellValue(object sender, PivotCellValueEventArgs e)
        {
            if (e.RowValueType == PivotGridValueType.Total)
            {
                e.Value = null;

                /*  for (int index = e.RowIndex - 1; index >= 0 && e.Value == null; index--)
                 * {
                 *    if (!Comparer.Equals(pvt_datos2.GetFieldValueType(false, index), PivotGridValueType.Value))  break;
                 *    e.Value = e.GetCellValue(e.ColumnIndex, index);
                 * }
                 */
            }
        }
Exemplo n.º 12
0
        // Handles the CustomCellValue event.
        // Fires for each data cell. If the processed cell is a Custom Total,
        // provides an appropriate Custom Total value.
        private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
        {
            // Exits if the processed cell does not belong to a Custom Total.
            if (e.ColumnCustomTotal == null && e.RowCustomTotal == null)
            {
                return;
            }

            // Obtains a list of summary values against which
            // the Custom Total will be calculated.
            ArrayList summaryValues = GetSummaryValues(e);

            // Obtains the name of the Custom Total that should be calculated.
            string customTotalName = GetCustomTotalName(e);

            // Calculates the Custom Total value and assigns it to the Value event parameter.
            e.Value = GetCustomTotalValue(summaryValues, customTotalName);
        }
Exemplo n.º 13
0
        object UpdateValue(PivotGridField field, int index, PivotCellValueEventArgs e)
        {
            object value = e.GetFieldValue(field, index);

            if (field == fieldOrderDate)
            {
                int currentPosition = YearValues.IndexOf(value);
                if (currentPosition > 0)
                {
                    value = YearValues[currentPosition - 1];
                }
                else
                {
                    value = "0000";
                }
            }
            return(value);
        }
Exemplo n.º 14
0
 // Returns the Custom Total name.
 private string GetCustomTotalName(PivotCellValueEventArgs e)
 {
     return(e.ColumnCustomTotal != null?
            e.ColumnCustomTotal.Tag.ToString() :
                e.RowCustomTotal.Tag.ToString());
 }
Exemplo n.º 15
0
 private void xrPivotGrid1_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
 }
Exemplo n.º 16
0
 private void gcDxTiempo_CustomCellValue(object sender, PivotCellValueEventArgs e)
 {
 }
        private void pivotGridControlMain_CustomCellValue(object sender, PivotCellValueEventArgs e)
        {
            try
            {
                int CYear = 0;
                if (bbiStartDate.EditValue != null)
                    CYear = ((DateTime)bbiStartDate.EditValue).Year;

                if (e.DataField == calcCases)
                {
                    if (e.GetFieldValue(fieldYearNo) == null)
                        return;
                    if ((int)e.GetFieldValue(fieldYearNo) == CYear - 1)
                    {
                        if (e.Value == null || e.GetCellValue(8, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(8, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(0, e.RowIndex) / (decimal)e.GetCellValue(8, e.RowIndex);
                    }
                    else if ((int)e.GetFieldValue(fieldYearNo) == CYear)
                    {
                        if (e.Value == null || e.GetCellValue(0, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(0, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(8, e.RowIndex) / (decimal)e.GetCellValue(0, e.RowIndex);
                    }
                }
                else if (e.DataField == calcNPS)
                {
                    if (e.GetFieldValue(fieldYearNo) == null)
                        return;
                    if ((int)e.GetFieldValue(fieldYearNo) == CYear - 1)
                    {
                        if (e.Value == null || e.GetCellValue(10, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(10, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(2, e.RowIndex) / (decimal)e.GetCellValue(10, e.RowIndex);
                    }
                    else if ((int)e.GetFieldValue(fieldYearNo) == CYear)
                    {
                        if (e.Value == null || e.GetCellValue(2, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(2, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(10, e.RowIndex) / (decimal)e.GetCellValue(2, e.RowIndex);
                    }
                }
                else if (e.DataField == calcVolume)
                {
                    if (e.GetFieldValue(fieldYearNo) == null)
                        return;
                    if ((int)e.GetFieldValue(fieldYearNo) == CYear - 1)
                    {
                        if (e.Value == null || e.GetCellValue(12, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(12, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(4, e.RowIndex) / (decimal)e.GetCellValue(12, e.RowIndex);
                    }
                    else if ((int)e.GetFieldValue(fieldYearNo) == CYear)
                    {
                        if (e.Value == null || e.GetCellValue(4, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(4, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(12, e.RowIndex) / (decimal)e.GetCellValue(4, e.RowIndex);
                    }
                }
                else if (e.DataField == calcPPL)
                {
                    if (e.GetFieldValue(fieldYearNo) == null)
                        return;
                    if ((int)e.GetFieldValue(fieldYearNo) == CYear - 1)
                    {
                        if (e.Value == null || e.GetCellValue(14, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(14, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(6, e.RowIndex) / (decimal)e.GetCellValue(14, e.RowIndex);
                    }
                    else if ((int)e.GetFieldValue(fieldYearNo) == CYear)
                    {
                        if (e.Value == null || e.GetCellValue(6, e.RowIndex) == null || e.Value == "0" || e.GetCellValue(6, e.RowIndex) == "0")
                            return;
                        e.Value = (decimal)e.GetCellValue(14, e.RowIndex) / (decimal)e.GetCellValue(6, e.RowIndex);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.Message, ex);
            }
        }
Exemplo n.º 18
0
        private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
        {
            try
            {
                // row wise GrandTotal only
                if (e.DataField == pivotGridField4 && e.RowValueType == PivotGridValueType.GrandTotal && e.ColumnValueType == PivotGridValueType.Value)
                {
                    decimal summaryValue1 = Convert.ToDecimal(e.GetFieldValue(pivotGridField2));
                    decimal summaryValue2 = Convert.ToDecimal(e.GetFieldValue(pivotGridField3));
                    //decimal value=summaryValue1 / summaryValue2;

                    if (summaryValue1 != 0)
                    {
                        if (summaryValue1 != 0 && summaryValue2 != 0)
                        {
                            decimal acc = summaryValue1 / summaryValue2;
                            e.Value = 100 * (1 - acc);
                        }
                    }
                    else
                    {
                        e.Value = 0;
                    }
                }

                // Column wise grand total
                if (e.DataField == pivotGridField4 && e.RowValueType == PivotGridValueType.GrandTotal && e.ColumnValueType == PivotGridValueType.GrandTotal)
                {
                    decimal summaryValue1 = Convert.ToDecimal(e.GetFieldValue(pivotGridField2));
                    decimal summaryValue2 = Convert.ToDecimal(e.GetFieldValue(pivotGridField3));
                    //decimal value=summaryValue1 / summaryValue2;

                    if (summaryValue1 != 0)
                    {
                        if (summaryValue1 != 0 && summaryValue2 != 0)
                        {
                            decimal acc = summaryValue1 / summaryValue2;
                            e.Value = 100 * (1 - acc);
                        }
                    }
                    else
                    {
                        e.Value = 0;
                    }
                }

                // row wise Total
                if (e.DataField == pivotGridField4 && e.RowValueType == PivotGridValueType.Total && e.ColumnValueType == PivotGridValueType.GrandTotal)
                {
                    decimal summaryValue1 = Convert.ToDecimal(e.GetFieldValue(pivotGridField2));
                    decimal summaryValue2 = Convert.ToDecimal(e.GetFieldValue(pivotGridField3));
                    if (summaryValue1 != 0)
                    {
                        if (summaryValue1 != 0 && summaryValue2 != 0)
                        {
                            decimal acc = summaryValue1 / summaryValue2;
                            e.Value = 100 * (1 - acc);
                        }
                    }
                    else
                    {
                        e.Value = 0;
                    }
                }

                // row wise Total and coulmn wise total
                if (e.DataField == pivotGridField4 && e.RowValueType == PivotGridValueType.Total && e.ColumnValueType == PivotGridValueType.Value)
                {
                    decimal summaryValue1 = Convert.ToDecimal(e.GetFieldValue(pivotGridField2));
                    decimal summaryValue2 = Convert.ToDecimal(e.GetFieldValue(pivotGridField3));
                    //decimal value=summaryValue1 / summaryValue2;

                    if (summaryValue1 != 0)
                    {
                        if (summaryValue1 != 0 && summaryValue2 != 0)
                        {
                            decimal acc = summaryValue1 / summaryValue2;
                            e.Value = 100 * (1 - acc);
                        }
                    }
                    else
                    {
                        e.Value = 0;
                    }
                }

                // row wise value and coulmn wise Grand Total
                if (e.DataField == pivotGridField4 && e.RowValueType == PivotGridValueType.Value && e.ColumnValueType == PivotGridValueType.GrandTotal)
                {
                    decimal summaryValue1 = Convert.ToDecimal(e.GetFieldValue(pivotGridField2));
                    decimal summaryValue2 = Convert.ToDecimal(e.GetFieldValue(pivotGridField3));
                    //decimal value=summaryValue1 / summaryValue2;

                    if (summaryValue1 != 0)
                    {
                        if (summaryValue1 != 0 && summaryValue2 != 0)
                        {
                            decimal acc = summaryValue1 / summaryValue2;
                            e.Value = 100 * (1 - acc);
                        }
                    }
                    else
                    {
                        e.Value = 0;
                    }

                    //
                    if (summaryValue1 == 0 && summaryValue1 != null)
                    {
                        if (summaryValue2 != 0)
                        {
                            e.Value = 100;
                        }
                        else if (summaryValue2 == 0)
                        {
                            e.Value = 0;
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Problem With loading records Please check it");
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }
        }