2022-07-06 16:42:53 +08:00
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD>˵<EFBFBD><EFBFBD>ӿ<EFBFBD>ʵ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2022-07-04 00:31:52 +08:00
|
|
|
|
#include"Menu.h"
|
|
|
|
|
|
|
|
|
|
void mainMenu(_ConnectionPtr connection) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
while (true) {
|
|
|
|
|
try {
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1.<2E><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>\n");
|
|
|
|
|
printf("2.<2E><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>\n");
|
|
|
|
|
printf("3.ɾ<><C9BE>ѧ<EFBFBD><D1A7>\n");
|
|
|
|
|
printf("4.<2E><EFBFBD>ѧ<EFBFBD><D1A7>\n");
|
|
|
|
|
printf("5.<2E><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("6.<2E><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
printf("7.ѧ<><D1A7><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("8.<2E>γ̹<CEB3><CCB9><EFBFBD>\n");
|
|
|
|
|
printf("9.<2E><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("0.<2E>˳<EFBFBD>\n");
|
2022-07-04 00:31:52 +08:00
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
int opt = -1;
|
|
|
|
|
checkOptInput(opt, 0, 9);
|
2022-07-04 00:31:52 +08:00
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
switch (opt) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 1://<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
showAllStudent(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 2://<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
insertStudent(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 3://ɾ<><C9BE>ѧ<EFBFBD><D1A7>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
deleteStudent(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 4://<2F><EFBFBD>ѧ<EFBFBD><D1A7>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
changeStudent(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 5://<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
|
2022-07-04 15:59:30 +08:00
|
|
|
|
importData(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 6://<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ļ<EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
exportData(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 7://ѧ<><D1A7><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
studentGradeMenu(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 8://<2F>γ̹<CEB3><CCB9><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
courseMenu(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 9://<2F><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
advancedFunction(connection);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
default://<2F>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
catch (_com_error& err) {
|
|
|
|
|
wprintf(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
wprintf(L"The application throws the error: %s\n", (wchar_t*)err.ErrorMessage());
|
|
|
|
|
wprintf(L"Description = %s\n", (wchar_t*)err.Description());
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void studentGradeMenu(_ConnectionPtr connection) {
|
|
|
|
|
while (true) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
try {
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1.<2E><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD>ɼ<EFBFBD>\n");
|
|
|
|
|
printf("2.<2E><>ȡѧ<C8A1><D1A7>ƽ<EFBFBD><C6BD><EFBFBD>ɼ<EFBFBD>\n");
|
|
|
|
|
printf("3.<2E><>ȡѧ<C8A1><D1A7><EFBFBD>ܳɼ<DCB3>\n");
|
|
|
|
|
printf("4.<2E><>ȡ<EFBFBD>༶ƽ<E0BCB6><C6BD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("5.<2E><>ȡ<EFBFBD>༶<EFBFBD><E0BCB6><EFBFBD>߷<EFBFBD>\n");
|
|
|
|
|
printf("6.<2E><>ȡ<EFBFBD>༶<EFBFBD><E0BCB6><EFBFBD>ͷ<EFBFBD>\n");
|
|
|
|
|
printf("7.<2E><>ȡ<EFBFBD>༶<EFBFBD>ɼ<EFBFBD>\n");
|
|
|
|
|
printf("8.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD>˵<EFBFBD>\n");
|
|
|
|
|
printf("0.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>\n");
|
|
|
|
|
|
|
|
|
|
int opt = -1;
|
|
|
|
|
checkOptInput(opt, 0, 8);
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
string stuId, courseId;
|
|
|
|
|
string stuClass, courseName;
|
|
|
|
|
double grade = -1;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
size_t size;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
Student* student;
|
|
|
|
|
Course* course;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
vector<Grade>* v;
|
|
|
|
|
switch (opt) {
|
2022-07-04 00:31:52 +08:00
|
|
|
|
case 1://<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD>ɼ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
2022-07-04 23:39:46 +08:00
|
|
|
|
cin >> courseName;
|
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0-100)<29><>");
|
2022-07-04 23:39:46 +08:00
|
|
|
|
while (!(cin >> grade) || (grade < 0) || (grade > 100)) {
|
2022-07-04 00:31:52 +08:00
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺";
|
|
|
|
|
cin.clear();
|
|
|
|
|
while (cin.get() != '\n');
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
|
|
|
|
addGrade(connection, *new Grade(stuId, course->getId(), doubleToString(grade)));
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 2://<2F><>ȡѧ<C8A1><D1A7>ƽ<EFBFBD><C6BD><EFBFBD>ɼ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>Ϊ<EFBFBD><EFBFBD>%.2lf\n", getOnesAvgGrade(connection, stuId));
|
|
|
|
|
break;
|
|
|
|
|
case 3://<2F><>ȡѧ<C8A1><D1A7><EFBFBD>ܳɼ<DCB3>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD>ܳɼ<EFBFBD>Ϊ<EFBFBD><EFBFBD>%.2lf\n", getOnesAllGrade(connection, stuId));
|
|
|
|
|
break;
|
|
|
|
|
case 4://<2F><>ȡ<EFBFBD>༶ƽ<E0BCB6><C6BD><EFBFBD><EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶<EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> stuClass;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
v = getGradeByStuClass(connection, stuClass);
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD>ð༶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << stuClass << " <20>༶ " << courseName << " <20>γ̵<CEB3>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>" << getClassAvgGrade(connection, stuClass, courseName) << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
break;
|
|
|
|
|
case 5://<2F><>ȡ<EFBFBD>༶<EFBFBD><E0BCB6><EFBFBD>߷<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶<EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> stuClass;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
v = getGradeByStuClass(connection, stuClass);
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD>ð༶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << stuClass << " <20>༶ " << courseName << " <20>γ̵<CEB3><CCB5><EFBFBD><EFBFBD>߷<EFBFBD>Ϊ<EFBFBD><CEAA>" << getClassMaxGrade(connection, stuClass, courseName) << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
break;
|
|
|
|
|
case 6://<2F><>ȡ<EFBFBD>༶<EFBFBD><E0BCB6><EFBFBD>ͷ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶<EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> stuClass;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
v = getGradeByStuClass(connection, stuClass);
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD>ð༶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << stuClass << " <20>༶ " << courseName << " <20>γ̵<CEB3><CCB5><EFBFBD><EFBFBD>ͷ<EFBFBD>Ϊ<EFBFBD><CEAA>" << getClassMinGrade(connection, stuClass, courseName) << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
break;
|
|
|
|
|
case 7://<2F><>ȡ<EFBFBD>༶<EFBFBD>ɼ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶<EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> stuClass;
|
|
|
|
|
v = getGradeByStuClass(connection, stuClass);
|
|
|
|
|
if (v == NULL) {
|
2022-07-04 23:39:46 +08:00
|
|
|
|
printf("<EFBFBD>ð༶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
2022-07-04 00:31:52 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
size = v->size();
|
|
|
|
|
cout << "ѧ<EFBFBD><EFBFBD>\t" << "<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>\t" << "<EFBFBD>ɼ<EFBFBD>\n";
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << (*v)[i].toString() << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 8://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
studentGradeExternMenu(connection);
|
|
|
|
|
break;
|
|
|
|
|
default://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
return;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
catch (_com_error& err) {
|
|
|
|
|
wprintf(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
wprintf(L"The application throws the error: %s\n", (wchar_t*)err.ErrorMessage());
|
|
|
|
|
wprintf(L"Description = %s\n", (wchar_t*)err.Description());
|
|
|
|
|
system("pause");
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void studentGradeExternMenu(_ConnectionPtr connection) {
|
|
|
|
|
while (true) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
try {
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1.ɾ<><C9BE>ijѧ<C4B3><D1A7>ij<EFBFBD>Ƴɼ<C6B3>\n");
|
|
|
|
|
printf("2.ɾ<><C9BE>ijѧ<C4B3><D1A7><EFBFBD>ɼ<EFBFBD>\n");
|
|
|
|
|
printf("3.ɾ<><C9BE>ij<EFBFBD>Ƴɼ<C6B3>\n");
|
|
|
|
|
printf("4.<2E><><EFBFBD><EFBFBD>ijѧ<C4B3><D1A7>ij<EFBFBD>Ƴɼ<C6B3>\n");
|
|
|
|
|
printf("5.<2E><>ѯijѧ<C4B3><D1A7>ij<EFBFBD>Ƴɼ<C6B3>\n");
|
|
|
|
|
printf("6.<2E><>ѯijѧ<C4B3><D1A7><EFBFBD>ɼ<EFBFBD>\n");
|
|
|
|
|
printf("7.<2E><>ѯij<D1AF>Ƴɼ<C6B3>\n");
|
|
|
|
|
printf("8.<2E><>ѯ<EFBFBD><D1AF><EFBFBD>гɼ<D0B3>\n");
|
|
|
|
|
printf("0.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>\n");
|
|
|
|
|
|
|
|
|
|
int opt = -1;
|
|
|
|
|
checkOptInput(opt, 0, 8);
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
string stuId, courseId;
|
|
|
|
|
string stuClass, courseName;
|
|
|
|
|
double grade = -1;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
size_t size;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
vector<Grade>* v;
|
|
|
|
|
Grade* gra;
|
|
|
|
|
Course* course;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
Student* student;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
switch (opt) {
|
2022-07-04 00:31:52 +08:00
|
|
|
|
case 1://ɾ<><C9BE>ijѧ<C4B3><D1A7>ij<EFBFBD>Ƴɼ<C6B3>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
|
|
|
|
gra = getOnesGrade(connection, stuId, course->getId());
|
|
|
|
|
if (gra == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸÿγ̵ijɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
deleteOnesGrade(connection, stuId, course->getId());
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 2://ɾ<><C9BE>ijѧ<C4B3><D1A7><EFBFBD>ɼ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v = getGradeByStuId(connection, stuId);
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
deleteGradeByStuId(connection, stuId);
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 3://ɾ<><C9BE>ij<EFBFBD>Ƴɼ<C6B3>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
|
|
|
|
v = getGradeByCourseId(connection, course->getId());
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
deleteGradeByCourseId(connection, course->getId());
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 4://<2F><><EFBFBD><EFBFBD>ijѧ<C4B3><D1A7>ij<EFBFBD>Ƴɼ<C6B3>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
|
|
|
|
gra = getOnesGrade(connection, stuId, course->getId());
|
|
|
|
|
if (gra == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸÿγ̵ijɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD>(0-100)<29><>");
|
|
|
|
|
while (!(cin >> grade) || (opt < 0) || (opt > 100)) {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺";
|
|
|
|
|
cin.clear();
|
|
|
|
|
while (cin.get() != '\n');
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
updateOnesGrade(connection, stuId, course->getId(), doubleToString(grade));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ijɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 5://<2F><>ѯijѧ<C4B3><D1A7>ij<EFBFBD>Ƴɼ<C6B3>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
gra = getOnesGrade(connection, stuId, course->getId());
|
|
|
|
|
if (gra == NULL) {
|
2022-07-04 23:39:46 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸÿγ̵ijɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
2022-07-04 00:31:52 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
cout << "ѧ<EFBFBD><EFBFBD>\t" << "<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>\t" << "<EFBFBD>ɼ<EFBFBD>\n";
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << (*gra).toString() << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
break;
|
|
|
|
|
case 6://<2F><>ѯijѧ<C4B3><D1A7><EFBFBD>ɼ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> stuId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
student = getStudentById(connection, stuId);
|
|
|
|
|
if (student == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
v = getGradeByStuId(connection, stuId);
|
|
|
|
|
if (v == NULL) {
|
2022-07-04 23:39:46 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
2022-07-04 00:31:52 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
size = v->size();
|
|
|
|
|
cout << "ѧ<EFBFBD><EFBFBD>\t" << "<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>\t" << "<EFBFBD>ɼ<EFBFBD>\n";
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << (*v)[i].toString() << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 7://<2F><>ѯij<D1AF>Ƴɼ<C6B3>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
|
|
|
|
course = getCourseByName(connection, courseName);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
v = getGradeByCourseId(connection, course->getId());
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>Ӧ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
size = v->size();
|
|
|
|
|
cout << "ѧ<EFBFBD><EFBFBD>\t" << "<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>\t" << "<EFBFBD>ɼ<EFBFBD>\n";
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << (*v)[i].toString() << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 8://<2F><>ѯ<EFBFBD><D1AF><EFBFBD>гɼ<D0B3>
|
|
|
|
|
v = getAllGrade(connection);
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
size = v->size();
|
|
|
|
|
cout << "ѧ<EFBFBD><EFBFBD>\t" << "<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>\t" << "<EFBFBD>ɼ<EFBFBD>\n";
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << (*v)[i].toString() << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
return;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
catch (_com_error& err) {
|
|
|
|
|
wprintf(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
wprintf(L"The application throws the error: %s\n", (wchar_t*)err.ErrorMessage());
|
|
|
|
|
wprintf(L"Description = %s\n", (wchar_t*)err.Description());
|
|
|
|
|
system("pause");
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void courseMenu(_ConnectionPtr connection) {
|
|
|
|
|
while (true) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
try {
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1.<2E><><EFBFBD>ӿγ<D3BF>\n");
|
|
|
|
|
printf("2.ɾ<><C9BE><EFBFBD>γ<EFBFBD>\n");
|
|
|
|
|
printf("3.<2E><><EFBFBD>Ŀγ<C4BF>\n");
|
|
|
|
|
printf("4.<2E><>ѯ<EFBFBD><D1AF><EFBFBD>пγ<D0BF>\n");
|
|
|
|
|
printf("0.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>\n");
|
|
|
|
|
int opt = -1;
|
|
|
|
|
checkOptInput(opt, 0, 4);
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
size_t size;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
string courseId, courseName;
|
|
|
|
|
vector<Course>* v;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
Course* course;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
switch (opt) {
|
2022-07-04 00:31:52 +08:00
|
|
|
|
case 1://<2F><><EFBFBD>ӿγ<D3BF>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ̺ţ<EFBFBD>");
|
|
|
|
|
cin >> courseId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
course = getCourseById(connection,courseId);
|
|
|
|
|
if (course != NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ<EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
addCourse(connection, *new Course(courseId, courseName));
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 2://ɾ<><C9BE><EFBFBD>γ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ̺ţ<EFBFBD>");
|
|
|
|
|
cin >> courseId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
course = getCourseById(connection, courseId);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
deleteCourse(connection, courseId);
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 3://<2F><><EFBFBD>Ŀγ<C4BF>
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ̺ţ<EFBFBD>");
|
|
|
|
|
cin >> courseId;
|
2022-07-04 23:39:46 +08:00
|
|
|
|
course = getCourseById(connection, courseId);
|
|
|
|
|
if (course == NULL) {
|
|
|
|
|
printf("<EFBFBD>ÿγ̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> courseName;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
updateCourseName(connection, courseId, courseName);
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>³ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
case 4://<2F><>ѯ<EFBFBD><D1AF><EFBFBD>пγ<D0BF>
|
|
|
|
|
v = getAllCourse(connection);
|
|
|
|
|
if (v == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿγ̼<EFBFBD>¼<EFBFBD><EFBFBD>\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
size = v->size();
|
|
|
|
|
cout << "<EFBFBD>γ̺<EFBFBD>\t" << "<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>\n";
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << (*v)[i].toString() << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
return;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
catch (_com_error& err) {
|
|
|
|
|
wprintf(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
wprintf(L"The application throws the error: %s\n", (wchar_t*)err.ErrorMessage());
|
|
|
|
|
wprintf(L"Description = %s\n", (wchar_t*)err.Description());
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void advancedFunction(_ConnectionPtr connection) {
|
|
|
|
|
system("cls");
|
|
|
|
|
_RecordsetPtr record(_uuidof(Recordset));
|
|
|
|
|
string sql;
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>cin<69><6E><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cin.clear();
|
|
|
|
|
while (cin.get() != '\n');
|
2022-07-04 22:17:38 +08:00
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
while (true) {
|
|
|
|
|
try {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
wprintf(L"sql>");
|
2022-07-04 22:17:38 +08:00
|
|
|
|
//<2F><>ȡSQL<51><4C><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
getline(cin, sql);
|
2022-07-04 22:17:38 +08:00
|
|
|
|
while (sql == "" || trim(sql)[trim(sql).size() - 1] != ';') {//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD>SQL<51><4C><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
wprintf(L" >");
|
|
|
|
|
string tmp;
|
|
|
|
|
getline(cin, tmp);
|
|
|
|
|
sql += " " + tmp;
|
|
|
|
|
}
|
2022-07-04 22:17:38 +08:00
|
|
|
|
//ȥ<><C8A5><EFBFBD><EFBFBD>β<EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>
|
|
|
|
|
sql = reduce(sql);
|
|
|
|
|
//<2F><>ȡSQL<51><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
string comType = "";
|
|
|
|
|
getSqlType(sql, comType);
|
2022-07-04 22:17:38 +08:00
|
|
|
|
//ִ<><D6B4>SQL<51><4C><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
if (comType == "select") {//<2F><>ѯ
|
|
|
|
|
record = connection->Execute(sql.c_str(), NULL, (long)0);
|
|
|
|
|
for (long i = 0; i < record->Fields->Count; i++)
|
|
|
|
|
wprintf(L"%s\t", (wchar_t*)record->Fields->GetItem(i)->Name);
|
|
|
|
|
printf("\n");
|
|
|
|
|
wprintf(L"%s", (wchar_t*)record->GetString(adClipString, long(-1), "\t", "\n", "Null"));
|
2022-07-04 22:17:38 +08:00
|
|
|
|
}else if (comType == "exit" || comType == "exit;") {//<2F>˳<EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
}else {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
connection->Execute(sql.c_str(), NULL, (long)0);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
catch (_com_error& err) {
|
|
|
|
|
wprintf(L"\nThe application throws the error: %s\n", (wchar_t*)err.ErrorMessage());
|
|
|
|
|
wprintf(L"Description = %s\n\n", (wchar_t*)err.Description());
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
void showAllStudent(_ConnectionPtr connection) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
vector<Student>* vs = getAllStudent(connection);
|
|
|
|
|
if (vs == NULL) {
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢΪ<EFBFBD>գ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
size_t size = vs->size();
|
2022-07-04 15:59:30 +08:00
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD>Ա<EFBFBD>\t<EFBFBD>༶\t״̬\n");
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
cout << (*vs)[i].toString() << "\n";
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void insertStudent(_ConnectionPtr connection) {
|
|
|
|
|
Student *stu = new Student();
|
|
|
|
|
|
|
|
|
|
string str;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> str;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
Student* checkExist = getStudentById(connection, str);
|
|
|
|
|
if (checkExist != NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
stu->setId(str);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> str;
|
|
|
|
|
stu->setName(str);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> str;
|
|
|
|
|
stu->setSex(str);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶<EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> str;
|
|
|
|
|
stu->setStuClass(str);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>״̬(<28>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>ѧ)<29><>");
|
|
|
|
|
cin >> str;
|
|
|
|
|
stu->setStatus(str);
|
|
|
|
|
|
|
|
|
|
addStudent(connection, *stu);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deleteStudent(_ConnectionPtr connection) {
|
|
|
|
|
string id;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> id;
|
|
|
|
|
Student *stu = getStudentById(connection,id);
|
|
|
|
|
if (stu == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-04 23:39:46 +08:00
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
deleteStudent(connection, id);
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void changeStudent(_ConnectionPtr connection) {
|
|
|
|
|
string id;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
|
|
|
|
|
cin >> id;
|
|
|
|
|
Student* stu = getStudentById(connection, id);
|
|
|
|
|
if (stu == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>༶(0) / ѧ<><D1A7>״̬(1)<29><>\n");
|
2022-07-04 00:31:52 +08:00
|
|
|
|
int opt = -1;
|
|
|
|
|
checkOptInput(opt, 0, 1);
|
|
|
|
|
|
|
|
|
|
string input;
|
|
|
|
|
switch (opt) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
case 0://<2F>İ༶
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°༶<EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> input;
|
|
|
|
|
updateStudentClass(connection,id,input);
|
|
|
|
|
break;
|
2022-07-04 22:17:38 +08:00
|
|
|
|
default://<2F><EFBFBD>״̬
|
2022-07-04 00:31:52 +08:00
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>");
|
|
|
|
|
cin >> input;
|
|
|
|
|
updateStudentStatus(connection,id, input);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void exportData(_ConnectionPtr connection) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
while (true) {
|
|
|
|
|
try {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
// <20>ļ<EFBFBD><C4BC>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2B4B4BD>ļ<EFBFBD><C4BC><EFBFBD>
|
|
|
|
|
if (_access("./data", 0) == -1) {
|
|
|
|
|
_mkdir("./data");
|
|
|
|
|
}
|
2022-07-04 15:59:30 +08:00
|
|
|
|
system("cls");
|
|
|
|
|
printf("1.<2E><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("2.<2E><><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><CEB3><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("3.<2E><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("4.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("0.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>\n");
|
|
|
|
|
int opt = -1;
|
|
|
|
|
checkOptInput(opt, 0, 4);
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
switch (opt) {
|
|
|
|
|
case 1://<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
exportStudentData(connection);
|
|
|
|
|
break;
|
|
|
|
|
case 2://<2F><><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><CEB3><EFBFBD>Ϣ
|
|
|
|
|
exportCourseData(connection);
|
|
|
|
|
break;
|
|
|
|
|
case 3://<2F><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>Ϣ
|
|
|
|
|
exportGradeData(connection);
|
|
|
|
|
break;
|
|
|
|
|
case 4://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
exportAllData(connection);
|
|
|
|
|
break;
|
|
|
|
|
default://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
catch (_com_error& err) {
|
|
|
|
|
wprintf(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
wprintf(L"The application throws the error: %s\n", (wchar_t*)err.ErrorMessage());
|
|
|
|
|
wprintf(L"Description = %s\n", (wchar_t*)err.Description());
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void exportStudentData(_ConnectionPtr connection) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
ofstream outFile("./data/student.txt", ios::out);
|
2022-07-04 15:59:30 +08:00
|
|
|
|
if (!outFile.is_open()) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>student.txt<78>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
size_t size;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
vector<Student>* vs;
|
|
|
|
|
vs = getAllStudent(connection);
|
|
|
|
|
if (vs == NULL) {
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢΪ<EFBFBD>գ<EFBFBD>\n");
|
|
|
|
|
outFile.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
outFile << "ѧ<EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD>Ա<EFBFBD>\t<EFBFBD>༶\t״̬\n";
|
|
|
|
|
size = vs->size();
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
|
|
|
|
outFile << (*vs)[i].toString();
|
|
|
|
|
if (i != (size - 1)) outFile << "\n";
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>student.txt<78>ļ<EFBFBD>!\n");
|
|
|
|
|
outFile.close();
|
|
|
|
|
}
|
2022-07-04 00:31:52 +08:00
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
void exportCourseData(_ConnectionPtr connection) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
ofstream outFile("./data/course.txt", ios::out);
|
2022-07-04 15:59:30 +08:00
|
|
|
|
if (!outFile.is_open()) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>course.txt<78>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
size_t size;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
vector<Course>* vc;
|
|
|
|
|
vc = getAllCourse(connection);
|
|
|
|
|
if (vc == NULL) {
|
|
|
|
|
printf("<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>ϢΪ<EFBFBD>գ<EFBFBD>\n");
|
|
|
|
|
outFile.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
outFile << "<EFBFBD>γ̺<EFBFBD>\t<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>\n";
|
|
|
|
|
size = vc->size();
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
|
|
|
|
outFile << (*vc)[i].toString();
|
|
|
|
|
if (i != (size - 1)) outFile << "\n";
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>course.txt<78>ļ<EFBFBD>!\n");
|
|
|
|
|
outFile.close();
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
void exportGradeData(_ConnectionPtr connection) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
ofstream outFile("./data/grade.txt", ios::out);
|
2022-07-04 15:59:30 +08:00
|
|
|
|
if (!outFile.is_open()) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>grade.txt<78>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
size_t size;
|
2022-07-04 15:59:30 +08:00
|
|
|
|
vector<Grade>* vg;
|
|
|
|
|
vg = getAllGrade(connection);
|
|
|
|
|
if (vg == NULL) {
|
|
|
|
|
printf("<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>ϢΪ<EFBFBD>գ<EFBFBD>\n");
|
|
|
|
|
outFile.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
outFile << "ѧ<EFBFBD><EFBFBD>\t<EFBFBD>γ̺<EFBFBD>\t<EFBFBD>ɼ<EFBFBD>\n";
|
|
|
|
|
size = vg->size();
|
2022-07-04 22:17:38 +08:00
|
|
|
|
for (size_t i = 0; i < size; i++) {
|
|
|
|
|
outFile << (*vg)[i].toString();
|
|
|
|
|
if (i != (size - 1)) outFile << "\n";
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>grade.txt<78>ļ<EFBFBD>!\n");
|
|
|
|
|
outFile.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void exportAllData(_ConnectionPtr connection) {
|
|
|
|
|
exportStudentData(connection);
|
|
|
|
|
exportCourseData(connection);
|
|
|
|
|
exportGradeData(connection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-04 00:31:52 +08:00
|
|
|
|
void importData(_ConnectionPtr connection) {
|
2022-07-04 15:59:30 +08:00
|
|
|
|
while (true) {
|
|
|
|
|
try {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
// <20>ļ<EFBFBD><C4BC>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2B4B4BD>ļ<EFBFBD><C4BC><EFBFBD>
|
|
|
|
|
if (_access("./data", 0) == -1) {
|
|
|
|
|
_mkdir("./data");
|
|
|
|
|
}
|
2022-07-04 15:59:30 +08:00
|
|
|
|
system("cls");
|
|
|
|
|
printf("1.<2E><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("2.<2E><><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><CEB3><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("3.<2E><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("4.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("0.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>\n");
|
|
|
|
|
int opt = -1;
|
|
|
|
|
checkOptInput(opt, 0, 4);
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
switch (opt) {
|
|
|
|
|
case 1://<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
importStudentData(connection);
|
|
|
|
|
break;
|
|
|
|
|
case 2://<2F><><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><CEB3><EFBFBD>Ϣ
|
|
|
|
|
importCourseData(connection);
|
|
|
|
|
break;
|
|
|
|
|
case 3://<2F><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>Ϣ
|
|
|
|
|
importGradeData(connection);
|
|
|
|
|
break;
|
|
|
|
|
case 4://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
importAllData(connection);
|
|
|
|
|
break;
|
|
|
|
|
default://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
catch (_com_error& err) {
|
|
|
|
|
wprintf(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
wprintf(L"The application throws the error: %s\n", (wchar_t*)err.ErrorMessage());
|
|
|
|
|
wprintf(L"Description = %s\n", (wchar_t*)err.Description());
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void importStudentData(_ConnectionPtr connection) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
ifstream inFile("./data/student.txt", ios::in);
|
2022-07-04 15:59:30 +08:00
|
|
|
|
if (!inFile.is_open()) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ȡstudent.txt<78>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
string title[5];//<2F><><EFBFBD>ڴ洢<DAB4><E6B4A2>ͷ<EFBFBD><CDB7>ÿ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
inFile >> title[0] >> title[1] >> title[2] >> title[3] >> title[4];
|
|
|
|
|
if (!(title[0] == "ѧ<EFBFBD><EFBFBD>" && title[1] == "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" && title[2] == "<EFBFBD>Ա<EFBFBD>" && title[3] == "<EFBFBD>༶" && title[4] == "״̬")) {
|
|
|
|
|
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>쳣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Student* student = new Student();
|
|
|
|
|
while (!inFile.eof()) {
|
|
|
|
|
inFile >> title[0] >> title[1] >> title[2] >> title[3] >> title[4];
|
2022-07-07 16:21:37 +08:00
|
|
|
|
if (getStudentById(connection, title[0]) == NULL) {
|
|
|
|
|
student->setId(title[0]);
|
|
|
|
|
student->setName(title[1]);
|
|
|
|
|
student->setSex(title[2]);
|
|
|
|
|
student->setStuClass(title[3]);
|
|
|
|
|
student->setStatus(title[4]);
|
|
|
|
|
addStudent(connection, *student);
|
|
|
|
|
}
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>student.txt<78>ļ<EFBFBD>!\n");
|
|
|
|
|
inFile.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void importCourseData(_ConnectionPtr connection) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
ifstream inFile("./data/course.txt", ios::in);
|
2022-07-04 15:59:30 +08:00
|
|
|
|
if (!inFile.is_open()) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ȡcourse.txt<78>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
string title[2];//<2F><><EFBFBD>ڴ洢<DAB4><E6B4A2>ͷ<EFBFBD><CDB7>ÿ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
inFile >> title[0] >> title[1];
|
|
|
|
|
if (!(title[0] == "<EFBFBD>γ̺<EFBFBD>" && title[1] == "<EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD>")) {
|
|
|
|
|
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>쳣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Course* course = new Course();
|
|
|
|
|
while (!inFile.eof()) {
|
|
|
|
|
inFile >> title[0] >> title[1];
|
2022-07-07 16:21:37 +08:00
|
|
|
|
if (getCourseById(connection, title[0]) == NULL) {
|
|
|
|
|
course->setId(title[0]);
|
|
|
|
|
course->setName(title[1]);
|
|
|
|
|
addCourse(connection, *course);
|
|
|
|
|
}
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>course.txt<78>ļ<EFBFBD>!\n");
|
|
|
|
|
inFile.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void importGradeData(_ConnectionPtr connection) {
|
2022-07-04 22:17:38 +08:00
|
|
|
|
ifstream inFile("./data/grade.txt", ios::in);
|
2022-07-04 15:59:30 +08:00
|
|
|
|
if (!inFile.is_open()) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ȡgrade.txt<78>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 22:17:38 +08:00
|
|
|
|
string title[3];//<2F><><EFBFBD>ڴ洢<DAB4><E6B4A2>ͷ<EFBFBD><CDB7>ÿ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
2022-07-04 15:59:30 +08:00
|
|
|
|
inFile >> title[0] >> title[1] >> title[2];
|
|
|
|
|
if (!(title[0] == "ѧ<EFBFBD><EFBFBD>" && title[1] == "<EFBFBD>γ̺<EFBFBD>" && title[2] == "<EFBFBD>ɼ<EFBFBD>")) {
|
|
|
|
|
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>쳣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Grade* grade = new Grade();
|
|
|
|
|
while (!inFile.eof()) {
|
|
|
|
|
inFile >> title[0] >> title[1] >> title[2];
|
2022-07-07 16:21:37 +08:00
|
|
|
|
if (getOnesGrade(connection, title[0], title[1]) == NULL) {
|
|
|
|
|
grade->setStuId(title[0]);
|
|
|
|
|
grade->setCourseId(title[1]);
|
|
|
|
|
grade->setGrade(title[2]);
|
|
|
|
|
addGrade(connection, *grade);
|
|
|
|
|
}
|
2022-07-04 15:59:30 +08:00
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>grade.txt<78>ļ<EFBFBD>!\n");
|
|
|
|
|
inFile.close();
|
|
|
|
|
}
|
2022-07-04 00:31:52 +08:00
|
|
|
|
|
2022-07-04 15:59:30 +08:00
|
|
|
|
void importAllData(_ConnectionPtr connection) {
|
|
|
|
|
importStudentData(connection);
|
|
|
|
|
importCourseData(connection);
|
|
|
|
|
importGradeData(connection);
|
2022-07-04 00:31:52 +08:00
|
|
|
|
}
|