/
MainWindow.xaml.cs
112 lines (94 loc) · 2.82 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
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.Navigation;
using System.Windows.Shapes;
using MahApps.Metro.Controls;
namespace Final_Project
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : MetroWindow
{
List<Game>game = new List<Game>();
public MainWindow()
{
InitializeComponent();
Initialize();
}
void Initialize()
{
using (var db = new GamesDBEntities())
{
game = db.Games.ToList();
}
}
private void Tile_Click(object sender, RoutedEventArgs e)
{
FlyData.IsOpen = true;
}
private void Tile_Click_1(object sender, RoutedEventArgs e)
{
Window1 _ver = new Window1();
this.Close();
_ver.ShowDialog();
}
private void Tile_Click_2(object sender, RoutedEventArgs e)
{
Window2 _san = new Window2();
this.Close();
_san.ShowDialog();
}
private void Tile_Click_3(object sender, RoutedEventArgs e)
{
Window3 _sa = new Window3();
this.Close();
_sa.ShowDialog();
}
private void Tile_Click_4(object sender, RoutedEventArgs e)
{
Window4 _sr = new Window4();
this.Close();
_sr.ShowDialog();
}
private void Sign_btn_Click_1(object sender, RoutedEventArgs e)
{
if (Ply2_txt.Text == "" || Ply1_txt.Text == "")
{
MessageBox.Show("Please enter name");
}
else
{
string Py1name = Ply1_txt.Text;
string Py2name = Ply2_txt.Text;
using (var db = new GamesDBEntities())
{
Game newgame = new Game();
newgame.Name = Ply1_txt.Text;
newgame.PingPong = 0;
newgame.Quiz = 0;
newgame.Catch = 0;
db.Games.Add(newgame);
db.SaveChanges();
Game newgame1 = new Game();
newgame1.Name = Ply2_txt.Text;
newgame1.PingPong = 0;
newgame1.Quiz = 0;
newgame1.Catch = 0;
db.Games.Add(newgame1);
db.SaveChanges();
}
}
}
}
}