-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentPage.xaml.cs
More file actions
142 lines (130 loc) · 5.7 KB
/
StudentPage.xaml.cs
File metadata and controls
142 lines (130 loc) · 5.7 KB
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
139
140
141
142
using Microsoft.Data.Sqlite;
using SchoolManagement;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板
namespace StudentManagmentSystem
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class StudentPage : Page
{
public StudentPage()
{
this.InitializeComponent();
ContentFrame.Navigate(typeof(StudentHomePage));
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
//string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "SchoolManagement.db");
//using (var db = new SqliteConnection($"Filename={dbPath}"))
//{
// db.Open();
// var selectCommand = new SqliteCommand("SELECT StudentID,Name,YearOfBirth,MonthOfBirth,DateOfBirth FROM Students WHERE ", db);
// using (var reader = selectCommand.ExecuteReader())
// {
// while (reader.Read())
// {
// StudentID = reader.GetInt32(0);
// Name = reader.GetString(1);
// //BirthYear = reader.GetInt32(2);
// //BirthMonth = reader.GetInt32(3);
// //BirthDate = reader.GetInt32(4);
// }
// }
//}
UserItem.Content = DatabaseHelper.userName;
NavigationViewControl.SelectedItem= homeitem;
}
//private async void NavigationViewControl_SelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
//{
// var selectedItem = NavigationViewControl.SelectedItem as NavigationViewItem;
// if (selectedItem != null)
// {
// Debug.WriteLine(selectedItem.Tag);
// if ((string)selectedItem.Tag == "home")
// ContentFrame.Navigate(typeof(StudentHomePage));
// else if ((string)selectedItem.Tag == "choose")
// ContentFrame.Navigate(typeof(StudentSelectPage));
// else if ((string)selectedItem.Tag == "grade")
// ContentFrame.Navigate(typeof(StudentGradePage));
// else if ((string)selectedItem.Tag == "usr")
// {
// ContentDialog confirmDialog = new ContentDialog
// {
// Title = "确认退出",
// Content = "您确定要退出登录吗?",
// PrimaryButtonText = "确认",
// CloseButtonText = "取消"
// };
// ContentDialogResult result = await confirmDialog.ShowAsync();
// if (result == ContentDialogResult.Primary)
// {
// Frame rootFrame = Window.Current.Content as Frame;
// rootFrame.Navigate(typeof(LoginPage));
// DatabaseHelper.userName = "";
// }
// else;
// }
// }
//}
private async void NavigationViewControl_ItemInvoked_1(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
{
Debug.WriteLine(1111);
var invokedItem = args.InvokedItemContainer as Microsoft.UI.Xaml.Controls.NavigationViewItem;
if (invokedItem != null)
{
switch (invokedItem.Tag.ToString())
{
case "home":
ContentFrame.Navigate(typeof(StudentHomePage));
break;
case "choose":
ContentFrame.Navigate(typeof(StudentSelectPage));
break;
case "grade":
ContentFrame.Navigate(typeof(StudentGradePage));
break;
case "usr":
{
ContentDialog confirmDialog = new ContentDialog
{
Title = "确认退出",
Content = "您确定要退出登录吗?",
PrimaryButtonText = "确认",
CloseButtonText = "取消"
};
ContentDialogResult result = await confirmDialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Navigate(typeof(LoginPage));
DatabaseHelper.userName = "";
}
else;
}
break;
case "Settings":
ContentFrame.Navigate(typeof(SettingPage));
break;
default:
break;
}
}
}
}
}