1
- using System . Text ;
1
+ using Lesson01 . Models ;
2
2
using System . Windows ;
3
- using System . Windows . Controls ;
4
- using System . Windows . Data ;
5
- using System . Windows . Documents ;
6
- using System . Windows . Input ;
7
- using System . Windows . Media ;
8
- using System . Windows . Media . Imaging ;
9
- using System . Windows . Navigation ;
10
- using System . Windows . Shapes ;
11
3
12
4
namespace Lesson01
13
5
{
@@ -16,9 +8,55 @@ namespace Lesson01
16
8
/// </summary>
17
9
public partial class MainWindow : Window
18
10
{
11
+ List < Student > students ;
19
12
public MainWindow ( )
20
13
{
21
14
InitializeComponent ( ) ;
15
+
16
+ students = new List < Student > ( ) ;
17
+ students . Add ( new Student ( 1 , "Shoxbox" , 2 ) ) ;
18
+ students . Add ( new Student ( 2 , "Javlon" , 1 ) ) ;
19
+ students . Add ( new Student ( 3 , "Davlatshox" , 4 ) ) ;
20
+
21
+ StudentsDataGrid . ItemsSource = students ;
22
+ }
23
+
24
+ private void Add_Student_Clicked ( object sender , RoutedEventArgs e )
25
+ {
26
+ var addModal = new AddStudentModal ( students ) ;
27
+
28
+ addModal . ShowDialog ( ) ;
29
+
30
+ StudentsDataGrid . ItemsSource = null ;
31
+ StudentsDataGrid . ItemsSource = students ;
32
+ }
33
+
34
+ private void Edit_Student_Clicked ( object sender , RoutedEventArgs e )
35
+ {
36
+ if ( StudentsDataGrid . SelectedItem is not Student selectedStudent )
37
+ {
38
+ return ;
39
+ }
40
+
41
+ var editModal = new EditStudentModal ( selectedStudent ) ;
42
+
43
+ editModal . ShowDialog ( ) ;
44
+
45
+ StudentsDataGrid . ItemsSource = null ;
46
+ StudentsDataGrid . ItemsSource = students ;
47
+ }
48
+
49
+ private void Delete_Student_Clicked ( object sender , RoutedEventArgs e )
50
+ {
51
+ if ( StudentsDataGrid . SelectedItem is not Student selectedStudent )
52
+ {
53
+ return ;
54
+ }
55
+
56
+ students . Remove ( selectedStudent ) ;
57
+
58
+ StudentsDataGrid . ItemsSource = null ;
59
+ StudentsDataGrid . ItemsSource = students ;
22
60
}
23
61
}
24
62
}
0 commit comments