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
|
#include "func.h"
int main()
{
size_t index{}, tIndex{};
ifstream in;
in.open("E:/students.csv");
Student student[100];
string No, student_id, Last_name, First_name, Gender, DoB;
// Read the student.csv
if (!in.is_open())
{
cout << "Error!\n";
}
else
{
getline(in, No, ',');
getline(in, student_id, ',');
getline(in, Last_name, ',');
getline(in, First_name, ',');
getline(in, Gender, ',');
getline(in, DoB, '\n');
while (getline(in, student[index].no, ','))
{
getline(in, student[index].id, ',');
getline(in, student[index].last_name, ',');
getline(in, student[index].first_name, ',');
getline(in, student[index].gender, ',');
getline(in, student[index++].dob, '\n');
}
in.close();
}
// Write the password and username into acc.txt
ofstream out, outacc;
outacc.open("E:/acc.txt");
if (!outacc.is_open())
{
cout << "Error!\n";
}
else
{
outacc << "No User Pass\n";
for (int i = 0; i < index; i++)
{
outacc << student[i].no << " " << student[i].id << " " << student[i].id << endl;
}
outacc.close();
}
// Write the readed content from the .csv into a .txt
out.open("E:/student.txt");
if (!out.is_open())
{
cout << "Error!\n";
}
else
{
out << No << "," << student_id << "," << Last_name << "," << First_name << "," << Gender << "," << DoB << endl;
for (int i = 0; i < index; i++)
{
out << student[i].no << " ";
out << student[i].id << " ";
out << student[i].last_name << " ";
out << student[i].first_name << " ";
out << student[i].gender << " ";
out << student[i].dob << endl;
}
out.close();
}
//Read the timetable.csv
Timetable t[100];
string No_t, Course_ID, LectureAccount, Class, LecturesAccount, Start_Date, End_Date, Day_of_week, Start_hour, End_hour, Room;
in.open("E:/timetable.csv");
if (!in.is_open())
{
cout << "Error!\n";
}
else
{
getline(in, No_t, ',');
getline(in, Course_ID, ',');
getline(in, LectureAccount, ',');
getline(in, Start_Date, ',');
getline(in, End_Date, ',');
getline(in, Day_of_week, ',');
getline(in, Start_hour, ',');
getline(in, End_hour, ',');
getline(in, Room, '\n');
while (getline(in, t[tIndex].courses_no, ','))
{
getline(in, t[tIndex].courses_no, ',');
getline(in, t[tIndex].courses_id, ',');
getline(in, t[tIndex].lecture_account, ',');
getline(in, t[tIndex].start, ',');
getline(in, t[tIndex].end, ',');
getline(in, t[tIndex].day, ',');
getline(in, t[tIndex].start_hour, ',');
getline(in, t[tIndex].end_hour, ',');
getline(in, t[tIndex++].room, '\n');
}
in.close();
}
// Write the readed content from the .csv into a .txt
out.open("E:/timetable.txt");
if (!out.is_open())
{
cout << "Error!\n";
}
else
{
out << No_t << " " << Course_ID << " " << LectureAccount << " " << Start_Date << " " << End_Date << " " << Day_of_week << " " << Start_hour << " " << End_hour << " " << Room << endl;
for (int i = 0; i < tIndex; i++)
{
out << t[i].courses_no << " " << t[i].courses_id << " " << t[i].lecture_account << " " << t[i].start << " " << t[i].end << " " << t[i].day << " " << t[i].start_hour << " " << t[i].end_hour << " " << t[i].room << endl;
}
out.close();
}
//username, pass
ifstream inpass;
inpass.open("E:/acc.txt");
Pass p[100];
string No_p, User, Pass;
getline(inpass, No_p, ' ');
getline(inpass, User, ' ');
getline(inpass, Pass, ' ');
if (!inpass)
{
cout << "Error!\n";
}
else
{
for (int i = 0; i < index; i++)
{
getline(inpass, p[i].no, ' ');
getline(inpass, p[i].user, ' ');
getline(inpass, p[i].pass, '\n');
}
inpass.close();
}
cout << "1.Login\n";
cout << "2.Exit\n";
int a;
cin >> a;
system("cls");
if (a == 1)
{
string user, pass;
cout << "1.Username: ";
cin >> user;
cout << "2.Pass: ";
cin >> pass;
for (int i = 0; i < index; i++)
{
if (user == p[i].user && pass == p[i].pass)
{
int c;
system("cls");
cout << "1. Staff menu\n";
cout << "2. Lecturer menu\n";
cout << "3. Student menu\n";
cin >> c;
switch (c)
{
case 1:
system("cls");
cout << "1. Class\n" << "2. Courses\n" << "3. Scoreboard\n" << "4. Attendance list\n" << "5. Change pass\n";
cin >> c;
switch (c)
{
case 1:
system("cls");
cout << "1. Add student\n" << "2. Edit student's info\n" << "3. Remove student\n";
cout << "4. Change student\n" << "5. View classes's list\n" << "6. View list of a class's students\n";
int d;
cin >> d;
switch (d)
{
case 1:
system("cls");
AddStu(student, index);
break;
case 2:
system("cls");
EditStu(student, index);
break;
case 3:
system("cls");
// NOT DONE
break;
case 4:
system("cls");
// NOT DONE
break;
case 5:
system("cls");
// NOT DONE
break;
case 6:
cout << No << " " << student_id << " " << Last_name << " " << First_name << " " << Gender << " " << DoB << endl;
for (int i = 0; i < index; i++)
{
cout << right << setw(2) << student[i].no << " ";
cout << left << setw(10) << student[i].id << " ";
cout << setw(12) << student[i].last_name << " ";
cout << setw(11) << student[i].first_name << " ";
cout << setw(6) << student[i].gender << " ";
cout << student[i].dob << endl;
}
}
}
case 2:
system("cls");
// not done
break;
case 3:
system("cls");
// not done
break;
default:
system("cls");
break;
}
}
else
{
system("cls");
cout << "Wrong password! try again!\n";
return main();
}
}
}
else
{
return 0;
}
system("pause");
}
|