/
MainWindow.xaml.cs
138 lines (125 loc) · 5.2 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System.Windows;
using System.Windows.Data;
namespace SqlReportConstructor
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
public MainWindow()
{
this.InitializeComponent();
}
private MeteoStationsReferenceDataSet _windowDataSet;
private MeteoStationsReferenceDataSetTableAdapters.meteo_stations_referenceTableAdapter _windowTableAdapter;
private CollectionViewSource _windowViewSource;
private void StationReferenceWindow_Loaded(object sender, RoutedEventArgs e)
{
this._windowDataSet = ((MeteoStationsReferenceDataSet)(this.FindResource("MeteoStationsReferenceDataSet")));
// Load data into the table meteo_stations_reference. You can modify this code as needed.
this._windowTableAdapter = new MeteoStationsReferenceDataSetTableAdapters.meteo_stations_referenceTableAdapter();
var meteoStationsReferenceDataSet = this._windowDataSet ;
if ( meteoStationsReferenceDataSet != null )
{
this._windowTableAdapter.Fill(
meteoStationsReferenceDataSet.meteo_stations_reference);
}
this._windowViewSource = ((CollectionViewSource)(this.FindResource("MeteoStationsReferenceViewSource")));
var collectionViewSource = this._windowViewSource ;
collectionViewSource?.View?.MoveCurrentToFirst();
}
private void BackButton_Click(object sender, RoutedEventArgs e)
{
var windowViewSource = this._windowViewSource ;
var windowViewSourceView = windowViewSource?.View ;
if (windowViewSourceView?.CurrentPosition > 0)
{
windowViewSourceView.MoveCurrentToPrevious();
}
}
private void NextButton_Click(object sender, RoutedEventArgs e)
{
var collectionViewSource = this._windowViewSource ;
var collectionView = ( CollectionView ) collectionViewSource?.View ;
var some = collectionView?.Count - 1;
if (collectionView?.CurrentPosition < some )
{
collectionView.MoveCurrentToNext();
}
}
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
var meteoStationsReferenceDataSet = this._windowDataSet ;
if ( meteoStationsReferenceDataSet != null )
{
this._windowTableAdapter?.Update(meteoStationsReferenceDataSet.meteo_stations_reference);
}
}
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
var v = false;
var m = this._windowViewSource != null ;
System.Data.DataRowView dataRowView = null ;
if (m)
{
v = this._windowViewSource.View != null;
}
if (v)
{
dataRowView = (System.Data.DataRowView)this._windowViewSource.View.CurrentItem;
}
var d = dataRowView != null ;
System.Data.DataRow row = null ;
object [ ] valuesArray = { } ;
if (d)
{
row = dataRowView.Row;
}
var r = row != null ;
if (r)
{
valuesArray = row.ItemArray;
}
var value = valuesArray[0];
long recordIndex = 0 ;
var i = value != null ;
if (i)
{
recordIndex = (long)value ;
}
var meteoStationsReferenceTableAdapter = this._windowTableAdapter;
if (( meteoStationsReferenceTableAdapter != null )
&& i)
{
meteoStationsReferenceTableAdapter.Delete(recordIndex);
this.RefreshButton_Click
(
sender ,
e ) ;
//var meteoStationsReferenceDataGrid = this.MeteoStationsReferenceDataGrid ;
//if ( meteoStationsReferenceDataGrid?.ItemsSource != null )
//{
// var collectionView = CollectionViewSource.GetDefaultView(
// meteoStationsReferenceDataGrid.ItemsSource) ;
// collectionView?.Refresh();
//}
}
}
private void RefreshButton_Click(object sender, RoutedEventArgs e)
{
var meteoStationsReferenceTableAdapter = this._windowTableAdapter;
if ( meteoStationsReferenceTableAdapter != null )
{
meteoStationsReferenceTableAdapter.ClearBeforeFill = true;
var meteoStationsReferenceDataSet = this._windowDataSet;
if (meteoStationsReferenceDataSet != null)
{
meteoStationsReferenceTableAdapter.Fill
(
meteoStationsReferenceDataSet.meteo_stations_reference);
}
}
}
}
}