forked from zachtaylor1/SWProj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.cs
More file actions
180 lines (159 loc) · 6.97 KB
/
Student.cs
File metadata and controls
180 lines (159 loc) · 6.97 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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.Input;
using System.Windows.Media;
namespace SWProjv1
{
public class Student : User
{
public static Student selectedStudent { get; set; }
public String studentNum { get; set; }
public bool isBlacklisted { get; set; }
public String roommateID { get; set; }
public String roommateName { get; set; }
public String roomID { get; set; }
public String username { get; set; }
public String password { get; set; }
public Grid grid;
CheckBox blacklist_chk;
Button edit_btn;
Button save_btn;
public ListBoxItem listboxitem;
public Student(String studentNum, bool isBlacklisted, String roommateID, String roomID, String firstName, String lastName, String otherName, String username, String password, String DOB) : base(firstName, lastName, otherName, username, password, DOB)
{
this.studentNum = studentNum;
if (studentNum.Equals(15)) this.isBlacklisted = true;
else this.isBlacklisted = isBlacklisted;
this.roommateID = roommateID;
this.roomID = roomID;
this.username = username;
this.password = password;
grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition());
/*TextBox textBox = new TextBox();
textBox.Text = firstName + " " + lastName + "\n Student Number: " + studentNum;
Grid.SetRow(textBox, 0);
Grid.SetColumn(textBox, 0);
grid.Children.Add(textBox);*/
}
public Student() { }
private void Item_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
setGrid();
selectedStudent = this;
}
public void setListBoxItem()
{
listboxitem = new ListBoxItem();
listboxitem.Content = firstName + " " + lastName + " " + studentNum;
listboxitem.PreviewMouseDown += Item_PreviewMouseDown;
}
public void setGrid()
{
grid.Children.Clear();
DockPanel basicInfo = GetBasicInfo();
Grid.SetRow(basicInfo, 0);
Grid.SetColumn(basicInfo, 0);
grid.Children.Add(basicInfo);
edit_btn = new Button();
Grid.SetRow(edit_btn, 0);
Grid.SetColumn(edit_btn, 1);
edit_btn.Content = "Edit";
edit_btn.Click += edit_btn_click;
edit_btn.VerticalAlignment = VerticalAlignment.Top;
edit_btn.HorizontalAlignment = HorizontalAlignment.Right;
save_btn = new Button();
Grid.SetRow(save_btn, 0);
Grid.SetColumn(save_btn, 1);
save_btn.Content = "Save";
save_btn.Visibility = Visibility.Hidden;
save_btn.VerticalAlignment = VerticalAlignment.Top;
save_btn.HorizontalAlignment = HorizontalAlignment.Right;
save_btn.Click += save_btn_click;
grid.Children.Add(edit_btn);
grid.Children.Add(save_btn);
}
private void save_btn_click(object sender, RoutedEventArgs e)
{
edit_btn.Visibility = Visibility.Visible;
save_btn.Visibility = Visibility.Hidden;
blacklist_chk.IsEnabled = false;
}
private void edit_btn_click(object sender, RoutedEventArgs e)
{
edit_btn.Visibility = Visibility.Hidden;
save_btn.Visibility = Visibility.Visible;
blacklist_chk.IsEnabled = true;
}
//query for student history
//SELECT * FROM RoomHistory, Student WHERE RoomHistory.studentID = Student.studentID and RoomHistory.studentID=1;
public DockPanel GetBasicInfo()
{
DockPanel basicInfo = new DockPanel();
StackPanel labels = new StackPanel();
TextBox stdName_lbl = new TextBox();
stdName_lbl.IsReadOnly = true;
stdName_lbl.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
stdName_lbl.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
stdName_lbl.Text = "Name:";
labels.Children.Add(stdName_lbl);
TextBox stdNum_lbl = new TextBox();
stdNum_lbl.Text = "Student Number:";
stdNum_lbl.IsReadOnly = true;
stdNum_lbl.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
stdNum_lbl.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
labels.Children.Add(stdNum_lbl);
TextBox roommate_lbl = new TextBox();
roommate_lbl.IsReadOnly = true;
roommate_lbl.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
roommate_lbl.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
roommate_lbl.Text = "Roommate:";
labels.Children.Add(roommate_lbl);
TextBox blacklist_lbl = new TextBox();
blacklist_lbl.IsReadOnly = true;
blacklist_lbl.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
blacklist_lbl.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFE5E5E5"));
blacklist_lbl.Text = "Blacklisted:";
labels.Children.Add(blacklist_lbl);
basicInfo.Children.Add(labels);
StackPanel spacer = new StackPanel();
for (int i = 0; i < labels.Children.Count; i++)
{
TextBlock block = new TextBlock();
block.Text = " ";
spacer.Children.Add(block);
}
basicInfo.Children.Add(spacer);
StackPanel data = new StackPanel();
TextBox stdName_txt = new TextBox();
stdName_txt.IsReadOnly = true;
stdName_txt.Text = firstName + " "+otherName+" "+lastName;
data.Children.Add(stdName_txt);
TextBox stdNum_txt = new TextBox();
stdNum_txt.IsReadOnly = true;
stdNum_txt.Text = studentNum;
data.Children.Add(stdNum_txt);
TextBox roommateName_txt = new TextBox();
roommateName_txt.IsReadOnly = true;
roommateName_txt.Text = Server.getRoommateName(roommateID);
data.Children.Add(roommateName_txt);
basicInfo.Children.Add(data);
blacklist_chk = new CheckBox();
blacklist_chk.IsChecked = isBlacklisted;
blacklist_chk.IsEnabled = false;
data.Children.Add(blacklist_chk);
Grid.SetRow(basicInfo, 0);
Grid.SetColumn(basicInfo, 0);
Grid.SetColumnSpan(basicInfo, 2);
return basicInfo;
}
}
}