-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAttendance.cs
113 lines (94 loc) · 3.15 KB
/
Attendance.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AttendanceSystem
{
public partial class Attendance : Form
{
public Attendance()
{
InitializeComponent();
}
int[] a = {0,0,0,0 };
private void Button1_Click(object sender, EventArgs e)
{
List<string> PresentStudents = new List<string>();
String show = "CourseName:\t\t"+temp.courseName+"\nTotal Students:\t\t4"+"\nStudents Present:\n";
if (a[0]==1)
{
PresentStudents.Add("Manan");
show += "Manan\n";
}
if (a[1] == 1)
{
PresentStudents.Add("Murtaza");
show += "Murtaza\n";
}
if (a[2] == 1)
{
PresentStudents.Add("Imtiaz");
show += "Imtiaz\n";
}
if (a[3] == 1)
{
PresentStudents.Add("Yasir");
show += "Yasir\n";
}
//MessageBox.Show(PresentStudents.Count.ToString(), "Count");
String filePath = @"E:\Sem7\HCI\ProjAttendanceSystem\HCI\AttendanceSheets\"+temp.courseName+".csv";
List<string> lines = File.ReadAllLines(filePath).ToList();
//MessageBox.Show(lines.Count.ToString(),"Count");
//add new column to the header row
string date = DateTime.Now.ToString("dd/MM/yyyy");
//string time = DateTime.Now.ToString("hh tt");
string time = DateTime.Now.ToString("hh:mm tt");
lines[0] += ","+date+" ("+time+")";
int index = 1;
//add new column value for each row.
lines.Skip(1).ToList().ForEach(line =>
{
// MessageBox.Show(lines[index++].ToString().Split(',')[0], "Names");
if (PresentStudents.Contains(lines[index].Split(',')[0]))
{
lines[index++] += "," + "P";
}
else
{
lines[index++] += "," + "A";
}
});
//write the new content
File.WriteAllLines(filePath, lines);
//************************************
this.Close();
MessageBox.Show(show, "Automatic Attendance System -> Select -> Attendance");
return;
}
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
a[0] = 1;//Manan
}
private void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
a[1] = 1;//Murtaza
}
private void CheckBox4_CheckedChanged(object sender, EventArgs e)
{
a[2] = 1;//imtiaz
}
private void CheckBox3_CheckedChanged(object sender, EventArgs e)
{
a[3] = 1;//yasir
}
private void Attendance_FormClosing_1(object sender, FormClosingEventArgs e)
{
return;
}
}
}