-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
36 lines (31 loc) · 1.3 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
using System;
using System.Windows;
using DevExpress.Xpf.PivotGrid;
using HowToEditCell.NwindDataSetTableAdapters;
namespace HowToEditCell {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
NwindDataSet.SalesPersonDataTable salesPersonDataTable = new NwindDataSet.SalesPersonDataTable();
SalesPersonTableAdapter salesPersonDataAdapter = new SalesPersonTableAdapter();
public MainWindow() {
InitializeComponent();
pivotGridControl1.DataSource = salesPersonDataTable;
}
void Window_Loaded(object sender, RoutedEventArgs e) {
salesPersonDataAdapter.Fill(salesPersonDataTable);
}
void pivotGridControl1_OnCellEdit(DependencyObject sender, PivotCellEditEventArgs agrs) {
PivotGridControl pivotGrid = (PivotGridControl)sender;
PivotGridField fieldExtendedPrice = pivotGrid.Fields["Extended Price"];
PivotDrillDownDataSource ds = agrs.CreateDrillDownDataSource();
decimal difference = agrs.NewValue - agrs.OldValue;
decimal factor = (difference == agrs.NewValue) ? (difference / ds.RowCount) : (difference / agrs.OldValue);
for(int i = 0; i < ds.RowCount; i++) {
decimal value = Convert.ToDecimal(ds[i][fieldExtendedPrice]);
ds[i][fieldExtendedPrice] = (value == 0m) ? factor : value * (1m + factor);
}
}
}
}