-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStudentCourseWindow.xaml.cs
More file actions
84 lines (74 loc) · 2.45 KB
/
StudentCourseWindow.xaml.cs
File metadata and controls
84 lines (74 loc) · 2.45 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
using EveryDatabaseTeacherLovesStudentSystem.Constraint;
using EveryDatabaseTeacherLovesStudentSystem.Constraint.Utils;
using EveryDatabaseTeacherLovesStudentSystem.Model;
using System;
using System.Collections.Generic;
using System.Text;
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 EveryDatabaseTeacherLovesStudentSystem
{
/// <summary>
/// StudentCourseWindow.xaml 的交互逻辑
/// </summary>
public partial class StudentCourseWindow : Window, IStudentCourseView
{
private IStudentCourseController controller;
public StudentCourseWindow(Student stu)
{
InitializeComponent();
LbCls.Content = stu.Cls.ToString();
LbNumber.Content = stu.Number.ToString();
LbName.Content = stu.Name;
LbSex.Content = stu.Sex;
LbAge.Content = stu.Age.ToString();
LbDept.Content = stu.Dept.ToString();
controller = new StudentCourseController(this, stu);
controller.LoadAllStudentCoursesAsync();
}
public void ShowEditStudentCourseView(NewOrEdit mode, StudentCourse stuCourse, Student student)
{
EditStudentCourseWindow view = new EditStudentCourseWindow(mode, stuCourse, student, null);
view.Closed += async (sender, e) =>
{
await controller.LoadAllStudentCoursesAsync();
};
view.ShowDialog();
}
public void UpdateStudentCourseData(IEnumerable<StudentCourse> data)
{
DgCourse.ItemsSource = data;
}
private async void BtnRefresh_Click(object sender, RoutedEventArgs e)
{
await controller.LoadAllStudentCoursesAsync();
}
private async void BtnAdd_Click(object sender, RoutedEventArgs e)
{
controller.AddStudentCourse();
await controller.LoadAllStudentCoursesAsync();
}
private async void BtnEdit_Click(object sender, RoutedEventArgs e)
{
if (DgCourse.SelectedIndex != -1)
{
controller.EditStudentCourse((StudentCourse)DgCourse.SelectedItem);
await controller.LoadAllStudentCoursesAsync();
}
}
private async void BtnRemove_Click(object sender, RoutedEventArgs e)
{
if (DgCourse.SelectedIndex != -1)
{
await controller.RemoveStudentCourseAsync((StudentCourse)DgCourse.SelectedItem);
await controller.LoadAllStudentCoursesAsync();
}
}
}
}