-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonSheets.xaml.cs
90 lines (80 loc) · 2.85 KB
/
CommonSheets.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Bank
{
/// <summary>
/// Логика взаимодействия для CommonSheets.xaml
/// </summary>
public partial class CommonSheets : Window
{
public CommonSheets()
{
InitializeComponent();
}
private void SelectButton_Click(object sender, RoutedEventArgs e)
{
using (Model m=new Model())
{
switch (SelectType.SelectedIndex)
{
case 0:
SheetView.ItemsSource = m.GetCommonTable();
break;
case 1:
SheetView.ItemsSource = m.GetDeposits();
break;
case 2:
SheetView.ItemsSource = m.GetCreditCards();
break;
case 3:
SheetView.ItemsSource = m.GetPresentCards();
break;
}
var a = (from c in SheetView.Columns where (string)c.Header == "Operations" select c).First();
SheetView.Columns.Remove(a);
var b = (from c in SheetView.Columns where (string)c.Header == "Id" select c).First();
b.DisplayIndex = 0;
foreach (DataGridColumn column in SheetView.Columns)
column.IsReadOnly = true;
}
}
private void LogOutButton_Click(object sender, RoutedEventArgs e)
{
new MainWindow().Show();
this.Close();
}
private void Save_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".csv"; // Default file extension
dlg.Filter = "CSV documents (.csv)|*.csv"; // Filter files by extension
if (dlg.ShowDialog().HasValue)
{
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(dlg.FileName))
{
foreach (var r in SheetView.ItemsSource)
{
writer.WriteLine(((Account)r).GetCsvRow());
}
}
}
}
private void ToMainMenu_Click(object sender, RoutedEventArgs e)
{
(new Bank_Application()).Show();
this.Close();
}
}
}