-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm2.cs
More file actions
executable file
·333 lines (295 loc) · 11.5 KB
/
Form2.cs
File metadata and controls
executable file
·333 lines (295 loc) · 11.5 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
using System;
using System.Collections.Generic;
using System.ComponentModel;
<<<<<<< HEAD
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Turniket_OOP
=======
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using Turniket_OOP;
using System.Text.RegularExpressions;
using System.Threading;
using System.Drawing;
namespace OOP_Turniket
>>>>>>> Work Project
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
<<<<<<< HEAD
}
private void button1_Click(object sender, EventArgs e)
{
Form1 PrevForm = new Form1();
PrevForm.Show();
}
}
}
=======
InitializeTimer();
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(220, 180);
}
private int counter;
private void InitializeTimer()
{
// Run this procedure in an appropriate event.
counter = 0;
timer1.Interval = 1000;
timer1.Enabled = true;
// Hook up timer's tick event handler.
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if (counter >= 1000)
{
string path_present = "D:\\Turniket_OOP/Turniket_OOP/Present.txt";
string path_late = "D:\\Turniket_OOP/Turniket_OOP/Late.txt";
File.WriteAllText(path_present, String.Empty);
File.WriteAllText(path_late, String.Empty);
// Exit loop code.
timer1.Enabled = false;
counter = 0;
}
else
{
// Run your procedure here.
// Increment counter.
counter = counter + 1;
label1.Text = "Procedures Run: " + counter.ToString();
}
}
private void button_Prev_Click(object sender, EventArgs e)
{
Form1 Prev_Form = new Form1();
Prev_Form.Show();
Hide();
}
private void button1_group1_Click(object sender, EventArgs e)
{
//HashCode
if (listBox1.Text != " " || textBox_Mess2.Text != " ")
{
listBox1.Items.Clear();
textBox_Mess2.Clear();
}
string group = "IS-81";
GetStudentsFromGroupDate(group);
}
private void button1_group2_Click(object sender, EventArgs e)
{
if (listBox1.Text != " " || textBox_Mess2.Text != " ")
{
listBox1.Items.Clear();
textBox_Mess2.Clear();
}
string group = "IS-82";
GetStudentsFromGroupDate(group);
}
private void button1_Clear_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
textBox_Mess2.Clear();
}
private void button1_All_Click(object sender, EventArgs e)
{
if (listBox1.Text != " ")
{
listBox1.Items.Clear();
}
listBox1.Items.AddRange(File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/groups.txt", encoding: Encoding.GetEncoding(1251)));
}
private void button_Sort_by_Missed_Click(object sender, EventArgs e)
{
string allPresent = File.ReadAllText("D:\\Turniket_OOP/Turniket_OOP/Present.txt", encoding: Encoding.GetEncoding(1251)) + "\n" +
File.ReadAllText("D:\\Turniket_OOP/Turniket_OOP/Late.txt", encoding: Encoding.GetEncoding(1251));
int countMissing = 1;
try
{
string[] file_Missing = File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Missing.txt");
countMissing = Convert.ToInt32(file_Missing[file_Missing.Length - 1].Split('.')[0]);
}
catch (Exception ex)
{
}
using (StreamWriter fstream = new StreamWriter("D:\\Turniket_OOP/Turniket_OOP/Missing.txt", true, Encoding.GetEncoding(1251)))
{
foreach (Student student in Facultet.Students)
{
//Decanat.GetDecanat().IsStudentLate();
if (!allPresent.Contains(student.ToString()))
{
//if (!missingText.Contains(student.ToString()))
//{
fstream.WriteLine(countMissing++ + ". " + student + " " + DateTime.Now.ToShortDateString());
//}
}
}
}
if (listBox1.Text != " ")
{
listBox1.Items.Clear();
}
listBox1.Items.AddRange(File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Missing.txt", encoding: Encoding.GetEncoding(1251)));
}
private void button_Cheak_student_Click(object sender, EventArgs e)
{
/*string student = "D:\\Turniket_OOP/Turniket_OOP/Missing.txt";
string regex = (@"[\d. ]*" + @"(?<name>[a-я A-Я]+)" + @"- [\d]+ пропусків, " + @"(?<date>\d{2}\.\d{2}\.\d{4})");
Regex rgx = new Regex(regex);
DateTime dt = dateTimePicker1.Value;
Regex picker = new Regex(dt.ToString());*/
int countMissing = 1;
if (listBox1.Text != " " || textBox_Mess2.Text != " ")
{
listBox1.Items.Clear();
textBox_Mess2.Clear();
}
string path = "D:\\Turniket_OOP/Turniket_OOP/Missing.txt";
using (StreamReader sr = new StreamReader(path, encoding: Encoding.GetEncoding(1251)))
{
string line;
while ((line = sr.ReadLine()) != null)
{
string[] data = line.Split(' ');
DateTime missingDate = DateTime.Parse(data[3]);
string dt = dateTimePicker1.Value.ToShortDateString();
if (dt == data[3])
{
data[0] = "" + countMissing + ".";
countMissing++;
line = "";
foreach (String str in data)
{
line += str + " ";
}
listBox1.Items.Add(line);
}
else
{
textBox_Mess2.Text = "Спільного не знайдено";
}
}
}
}
private void button_Clear_file_Click(object sender, EventArgs e)
{
//public void cheak_time()
//{
//int hour = 01;
//int minute = 42;
//int second = 00;
//if (hour == DateTime.Now.Hour && minute == DateTime.Now.Minute && second == DateTime.Now.Second)
//{
string path_present = "D:\\Turniket_OOP/Turniket_OOP/Present.txt";
string path_late = "D:\\Turniket_OOP/Turniket_OOP/Late.txt";
File.WriteAllText(path_present, String.Empty);
File.WriteAllText(path_late, String.Empty);
//}
//}
}
private List<Student> GetStudentsFromGroupDate(string group)
{
List<Student> students = Facultet.GetStudentsFromGroup(group);
string path = "D:\\Turniket_OOP/Turniket_OOP/Missing.txt";
int countMissing = 1;
using (StreamReader sr = new StreamReader(path, encoding: Encoding.GetEncoding(1251)))
{
string line;
while ((line = sr.ReadLine()) != null)
{
foreach (Student student in students)
{
if (!line.Contains(student.ToString()))
continue;
string[] data = line.Split(' ');
DateTime missingDate = DateTime.Parse(data[3]);
string dt = dateTimePicker1.Value.ToShortDateString();
if (dt == data[3])
{
data[0] = "" + countMissing + ".";
countMissing++;
line = "";
foreach (String str in data)
{
line += str + " ";
}
listBox1.Items.Add(line);
}
else
{
textBox_Mess2.Text = "Спільного не знайдено";
}
}
}
return students;
}
}
private void button_Late_Student_Click(object sender, EventArgs e)
{
if (listBox1.Text != " ")
{
listBox1.Items.Clear();
}
listBox1.Items.AddRange(File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Late.txt", encoding: Encoding.GetEncoding(1251)));
}
private void button_Present_Student_Click(object sender, EventArgs e)
{
if (listBox1.Text != " ")
{
listBox1.Items.Clear();
}
listBox1.Items.AddRange(File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Present.txt", encoding: Encoding.GetEncoding(1251)));
}
private void button_Found_Student_Click(object sender, EventArgs e)
{
int countMissing = 1;
if (listBox1.Text != " " || textBox_Mess2.Text != " ")
{
listBox1.Items.Clear();
textBox_Mess2.Clear();
}
string path = "D:\\Turniket_OOP/Turniket_OOP/Missing.txt";
using (StreamReader sr = new StreamReader(path, encoding: Encoding.GetEncoding(1251)))
{
string line;
while ((line = sr.ReadLine()) != null)
{
string[] data = line.Split(' ');
//DateTime missingDate = DateTime.Parse(data[3]);
string text = textBox_Found_Student.Text;
//string dt = dateTimePicker1.Value.ToShortDateString();
string line1;
line1 = data[1] + " " + data[2];
if (text == line1)
{
data[0] = "" + countMissing + ".";
countMissing++;
line = "";
foreach (String str in data)
{
line += str + " ";
}
listBox1.Items.Add(line);
}
else
{
textBox_Mess2.Text = "Спільного не знайдено";
}
}
}
}
}
}
>>>>>>> Work Project