-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
38 lines (33 loc) · 1.36 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.ObjectModel;
using System.Windows;
using DevExpress.Xpf.Core;
using DevExpress.Xpf.PivotGrid;
namespace HowToEditCell {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : ThemedWindow {
public ObservableCollection<MyOrderRow> OrderSourceList { get; set; }
public MainWindow() {
InitializeComponent();
}
void Window_Loaded(object sender, RoutedEventArgs e) {
OrderSourceList = DatabaseHelper.CreateData();
pivotGridControl1.DataSource = OrderSourceList;
pivotGridControl1.BestFit();
}
void pivotGridControl1_OnCellEdit(DependencyObject sender, PivotCellEditEventArgs args) {
PivotGridControl pivotGrid = (PivotGridControl)sender;
PivotGridField fieldExtendedPrice = pivotGrid.Fields.GetFieldByName("fieldSales");
PivotDrillDownDataSource ds = args.CreateDrillDownDataSource();
decimal difference = args.NewValue - args.OldValue;
decimal factor = (difference == args.NewValue) ? (difference / ds.RowCount) : (difference / args.OldValue);
for(int i = 0; i < ds.RowCount; i++) {
decimal value = Convert.ToDecimal(ds[i][fieldExtendedPrice]);
decimal newValue = (value == 0m) ? factor : value * (1m + factor);
ds.SetValue(i, fieldExtendedPrice, newValue);
}
}
}
}