学生信息管理系统开发
学生信息管理系统
想起来好久没写博客了,最近的一段时间是我们学校的小学期,由于忙着设计这个项目(虽然很菜),所以没怎么刷题,博客也咕咕咕了好久
今天基本把所有的问题都处理了,所以我打算写一篇总结博客,总结一下写项目中遇到的坑。
先看看效果:
那么直接进入正题:
首先我是用的IDE是:VS2019(Visual Studio 2019)
开发用到了 easyx图形库(毕竟是一个UI程序嘛)
开发环境是Windows10 版本号是1909
然后采用了多文件编程(就是一个嘘头而已)
我先用多文件的思路,最后再把整个完整的代码放出来,只想看单文件编程的请跳过
首先写程序要先梳理思路,先要思考要实现什么功能,这点是很重要的,有什么想法可以先写下来,
就算后面实际写代码的时候不好实现,不写就行(能去查资料还是尽量查资料)
需求分析:
这是我的需求:
当然这些所谓的功能其实后面用一个函数就能实现一个功能,我喜欢在完成这些功能后打上√
然后开始分析我们需要写一个学生端,然后写一个教师端
登录和注册是两个端都共有的,所以我们发现可以写份分文件和一个主要的.cpp文件(当然如果是C语言的话,就是.c 后面同上)
由于代码比较长,我就不逐一解释。
先说.h文件里面存放的是结构体/类的还有该.h文件对应的.cpp文件里面的函数声明(注意只是声明!!!)
.h对应的.c文件里面放的是.h里面的声明的函数内容(可能有点绕,请理解)
注意1:所有的结构体或者什么声明只能定义一次,其他的文件想使用的话,直接#include"XXX.h"(包含需要使用的定义的头文件)
注意2: 如果你在引用头文件的时候遇到了头文件重定义问题,你可以使用#ifndef/#define/#endif 操作方法:传送门
我们先来看公共部分的分文件操作:
MAIN.h:
#pragma once #include<cstdio> #include"hstudent.h" #include"hteacher.h" #include"MAIN.h" extern class List1* L1;//第一个学生 extern class List2* L2;//第一个老师 extern SYSTEMTIME st; extern int X , Y ;//X:界面宽度 Y界面高度 extern int randnum; extern HWND HD; extern char qiandaoyuji[][50]; class List1* add_stu(class student* p, class List1* L);//学生信息添加 名字,学号,初始化学生信息 class List2* add_tea(class teacher* p, class List2* L);//初始化老师信息 int find_ID(class student* p1, class teacher* p2, class List1* L_1, class List2* L_2); bool save1(List1* p1);//学生文件存储函数 bool save2(List2* p2);//教师文件存储函数 void read(class List1* p1, class List2* p2);//文件读取函数 void Pregister();//注册 void Plog();//登录 void PMAIN();//主界面
存放的就是函数和结构体还有一些全局变量的引用
MAIN.cpp:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#pragma once #include<easyx.h> #include<graphics.h> #include<cstdio> #include<iostream> #include<windows.h> #include<cstring> #include<conio.h> #include<vector> #include<queue> #include<algorithm> #include <atlstr.h> #include<ctime> #include"hstudent.h" #include"hteacher.h" #include"MAIN.h" #pragma comment(lib,"Winmm.lib") using namespace std; List1* add_stu(student* p, List1* L)//学生信息添加 名字,学号,初始化学生信息 { student* temp = (student*)malloc(sizeof(student)); ::memset(temp, 0, sizeof(temp)); ::memset(temp->Data.cfxinxi.name, 0, sizeof(temp->Data.cfxinxi.name)); ::memset(temp->Data.hjxinxi.name, 0, sizeof(temp->Data.hjxinxi.name)); ::memset(&temp->Data.all_kemu, 0, sizeof(temp->Data.all_kemu)); ::memset(temp->Data.kebiao, 0, sizeof(temp->Data.kebiao)); temp->Data.cfxinxi.loc = 0; temp->Data.all_kemu.score = 0; temp->next = NULL; temp->Data.hjxinxi.loc = 0;//获奖 temp->Data.lastqiandao = p->Data.lastqiandao;//签到信息,每次登录都会重新置为0,别问为什么,问就是不会实时更新。°(°¯᷄◠¯᷅°)°。 GetLocalTime(&st); if (temp->Data.lastqiandao == (st.wYear * 365 + st.wMonth * 30 + st.wDay)) { temp->Data.qiandao = 1; } else { temp->Data.qiandao = 0; } if (*p->Data.ID != '\0') strcpy_s(temp->Data.ID, (p->Data.ID));//拷贝学生ID if (*p->Data.name != '\0') strcpy_s(temp->Data.name, (p->Data.name));//拷贝学生名字 if (*p->Data.mima != '\0') strcpy_s(temp->Data.mima, (p->Data.mima));//拷贝学生密码 if (p->Data.cfxinxi.loc)//拷贝处分信息 { add_chufen(&p->Data.cfxinxi, temp); } if (p->Data.hjxinxi.loc)//拷贝获奖信息 { add_huojiang(&p->Data.hjxinxi, temp); } //成绩录入 temp->Data.all_kemu.yuwen = p->Data.all_kemu.yuwen; temp->Data.all_kemu.shuxue = p->Data.all_kemu.shuxue; temp->Data.all_kemu.yingyu = p->Data.all_kemu.yingyu; temp->Data.all_kemu.wuli = p->Data.all_kemu.wuli; temp->Data.all_kemu.huaxue = p->Data.all_kemu.huaxue; temp->Data.all_kemu.Cyuyan = p->Data.all_kemu.Cyuyan; temp->Data.all_kemu.score = p->Data.all_kemu.score;//p->Data.all_kemu.yuwen + p->Data.all_kemu.shuxue + p->Data.all_kemu.yingyu + p->Data.all_kemu.wuli + p->Data.all_kemu.huaxue + p->Data.all_kemu.Cyuyan; //课表读取 for (int i = 0; i < 25; ++i) { strcpy_s(temp->Data.kebiao[i], p->Data.kebiao[i]); } student* pp = L->head; if (pp != NULL)//如果已有多个学生信息 { while (pp->next)//找到指针末尾 pp = pp->next; pp->next = temp; } else//如果为第一个学生 { L->head = temp; } return L; } List2* add_tea(teacher* p, List2* L)//初始化老师信息 { teacher* temp = (teacher*)malloc(sizeof(teacher)); temp->next = NULL; if (*p->Data.ID != '\0') strcpy_s(temp->Data.ID, p->Data.ID);//拷贝ID if (*p->Data.mima != '\0') strcpy_s(temp->Data.mima, p->Data.mima);//拷贝密码 if (*p->Data.name != '\0') strcpy_s(temp->Data.name, p->Data.name);//拷贝名字 teacher* pp = L->head; if (pp) { while (pp->next) pp = pp->next; pp->next = temp; } else L->head = temp; return L; } void add_huojiang(huojiang* hj, student* L)//学生获奖信息添加 用于初始化 { for (int i = 0; i < hj->loc && L->Data.hjxinxi.loc < 10 && i < 10; ++i) { strcpy_s(L->Data.hjxinxi.name[L->Data.hjxinxi.loc++], hj->name[i]); } return; } void add_chufen(chufen* cf, student* L)//添加学生处分信息 用于初始化时 { for (int i = 0; i < cf->loc && i < 10 && L->Data.cfxinxi.loc < 10; ++i) { strcpy_s(L->Data.cfxinxi.name[L->Data.cfxinxi.loc++], cf->name[i]); } return; } bool save1(List1* p1) { student* pp1; FILE* fp1 = NULL; fp1 = fopen("student.txt", "wb"); for (pp1 = p1->head; pp1 != NULL; pp1 = pp1->next) { fwrite(pp1, sizeof(student), 1, fp1); } fclose(fp1); return true; } bool save2(List2* p2) { teacher* pp2; FILE* fp2 = NULL; fp2 = fopen("teacher.txt", "wb"); if (fp2 == NULL) { printf("kk"); } for (pp2 = p2->head; pp2 != NULL; pp2 = pp2->next) { fwrite(pp2, sizeof(teacher), 1, fp2); } fclose(fp2); return true; } void read(List1* p1, List2* p2) { student* s1 = (student*)malloc(sizeof(student)); teacher* s2 = (teacher*)malloc(sizeof(student)); chufen* cf1 = (chufen*)malloc(sizeof(chufen)); ::memset(cf1->name, 0, sizeof(cf1->name)); cf1->loc = 0; ::memset(s1->Data.cfxinxi.name, 0, sizeof(s1->Data.cfxinxi.name)); s1->Data.cfxinxi.loc = 0; FILE* fp1 = NULL; FILE* fp2 = NULL; fp1 = fopen("student.txt", "rb"); if (fp1 == NULL) { fp1 = fopen("student.txt", "wb"); goto out1; } while (fread(s1, sizeof(student), 1, fp1)) { L1 = add_stu(s1, p1); } out1: fclose(fp1); fp2 = fopen("teacher.txt", "rb"); if (fp2 == NULL) { fopen("teacher.txt", "wb"); return; } while (fread(s2, sizeof(teacher), 1, fp2) != 0) { L2 = add_tea(s2, p2); } fclose(fp2); } void Plog()//登录界面 { cleardevice(); IMAGE pmain;//登录注册界面 IMAGE tp; loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 200, L"西柚信息管理登陆"); rectangle(520, 360, 850, 410); rectangle(520, 450, 850, 500); rectangle(520, 540, 850, 590); rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑"); outtextxy(420, 365, L"学号:"); outtextxy(420, 455, L"密码:"); outtextxy(640, 545, L"登录"); outtextxy(5, 5, L"返回"); MOUSEMSG mg; student* stu = (student*)malloc(sizeof(student)); teacher* tea = (teacher*)malloc(sizeof(teacher)); wchar_t xuehao[20]; ::memset(xuehao, 0, sizeof(xuehao)); wchar_t mima[20]; ::memset(mima, 0, sizeof(mima)); while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP)//返回主界面 { PMAIN(); } else if (mg.x > 520 && mg.x < 850 && mg.y>360 && mg.y < 410 && mg.uMsg == WM_LBUTTONUP)//学号输入 { setbkcolor(getpixel(521, 361)); clearrectangle(520, 360, 850, 410); rectangle(520, 360, 850, 410); InputBox(xuehao, 13, L"请输入学号"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, stu->Data.ID, wcslen(xuehao) * 2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, tea->Data.ID, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(525, 365, xuehao); } else if (mg.x > 520 && mg.x < 850 && mg.y>450 && mg.y < 500 && mg.uMsg == WM_LBUTTONUP)//密码输入 { setbkcolor(getpixel(521, 451)); clearrectangle(520, 450, 850, 500); rectangle(520, 450, 850, 500); InputBox(mima, 13, L"请输入密码"); WideCharToMultiByte(CP_ACP, 0, mima, -1, stu->Data.mima, wcslen(mima) * 2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, mima, -1, tea->Data.mima, wcslen(mima) * 2 + 1, NULL, NULL); outtextxy(525, 460, mima); } else if (mg.x > 520 && mg.x < 850 && mg.y>540 && mg.y < 590 && mg.uMsg == WM_LBUTTONUP)//登录 { int flag = find_ID(stu, tea, L1, L2); if (flag) { if (flag == 1)//学生账号 { student* k1 = NULL; k1 = find_student(stu, L1); outtextxy(520, 700, L"学生登录成功"); Sleep(1000); Pstudent(k1); } else if (flag == 2)//老师账号 { teacher* k2 = NULL; k2 = find_teacher(tea, L2); outtextxy(560, 700, L"老师登录成功"); Sleep(100); Pteacher(k2); } else if (flag == -1)//学生密码错误 { MessageBox(HD, L"密码错误,请重新输入", L"登录信息", MB_OK); } else if (flag == -2)//学生密码错误 { MessageBox(HD, L"密码错误,请重新输入", L"登录信息", MB_OK); } } else { MessageBox(HD, L"此账号并不存在", L"登录信息", MB_OK); } } } } void PMAIN()//主界面,初始界面 { cleardevice(); IMAGE pmain;//登录注册界面 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 200, L"西柚信息管理登陆"); rectangle(520, 360, 690, 410); rectangle(520, 450, 690, 500); rectangle(1100, 750, 1199, 799); settextstyle(40, 20, L"微软雅黑"); outtextxy(565, 365, L"登录"); outtextxy(565, 455, L"注册"); outtextxy(1110, 755, L"退出"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 520 && mg.x < 690) { if (mg.y > 360 && mg.y < 410 && mg.uMsg == WM_LBUTTONUP)//登录 { Plog(); } else if (mg.y > 450 && mg.y < 500 && mg.uMsg == WM_LBUTTONUP)//注册 { Pregister(); } } else if (mg.x > 1100 && mg.x < 1200 && mg.y>750 && mg.y < 800 && mg.uMsg == WM_LBUTTONUP) { exit(0); } } } void Pregister()//注册界面 { cleardevice(); IMAGE pmain;//登录注册界面 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(350, 50, L"西柚信息管理登陆"); rectangle(520, 120, 850, 180);//账号框 rectangle(520, 220, 850, 280);//密码框 rectangle(520, 320, 850, 380);//姓名框 rectangle(320, 420, 490, 480);//学生注册框 rectangle(720, 420, 890, 480);//教师注册框 rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回"); settextstyle(30, 18, L"微软雅黑"); outtextxy(420, 130, L"账号"); outtextxy(420, 230, L"密码"); outtextxy(420, 330, L"姓名"); outtextxy(330, 430, L"学生注册"); outtextxy(730, 430, L"教师注册"); student* stu = (student*)malloc(sizeof(student)); teacher* tea = (teacher*)malloc(sizeof(student)); stu->Data.cfxinxi.loc = 0; stu->Data.hjxinxi.loc = 0; ::memset(stu, 0, sizeof(student)); ::memset(tea, 0, sizeof(teacher)); MOUSEMSG mg; wchar_t zhanghao[20]; wchar_t mima[20]; wchar_t mingzi[20]; while (1) { mg = GetMouseMsg(); if (mg.x > 520 && mg.x < 850) { if (mg.y > 120 && mg.y < 180 && mg.uMsg == WM_LBUTTONUP)//账号 { setbkcolor(getpixel(521, 121)); clearrectangle(520, 120, 850, 180); rectangle(520, 120, 850, 180); InputBox(zhanghao, 13, L"请输入账号/学号"); outtextxy(530, 130, zhanghao); WideCharToMultiByte(CP_ACP, 0, zhanghao, -1, stu->Data.ID, wcslen(zhanghao) * 2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, zhanghao, -1, tea->Data.ID, wcslen(zhanghao) * 2 + 1, NULL, NULL); } else if (mg.y > 220 && mg.y < 280 && mg.uMsg == WM_LBUTTONUP)//密码 { setbkcolor(getpixel(521, 221)); clearrectangle(520, 220, 850, 280); rectangle(520, 220, 850, 280); InputBox(mima, 13, L"请输入密码"); outtextxy(530, 230, mima); WideCharToMultiByte(CP_ACP, 0, mima, -1, stu->Data.mima, wcslen(mima) * 2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, mima, -1, tea->Data.mima, wcslen(mima) * 2 + 1, NULL, NULL); } else if (mg.y > 320 && mg.y < 380 && mg.uMsg == WM_LBUTTONUP)//姓名 { setbkcolor(getpixel(521, 321)); clearrectangle(520, 320, 850, 380); rectangle(520, 320, 850, 380); InputBox(mingzi, 13, L"请输入姓名"); outtextxy(530, 330, mingzi); WideCharToMultiByte(CP_ACP, 0, mingzi, -1, stu->Data.name, wcslen(mingzi) * 2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, mingzi, -1, tea->Data.name, wcslen(mingzi) * 2 + 1, NULL, NULL); } } else if (mg.y > 420 && mg.y < 480)//注册 { if (mg.x > 320 && mg.x < 490 && mg.uMsg == WM_LBUTTONUP) { if (*stu->Data.ID == '\0') { MessageBox(HD, L"请先输入学号", L"注册信息", MB_OK); } else if (*stu->Data.mima == '\0') { MessageBox(HD, L"请先输入密码", L"注册信息", MB_OK); } else if (*stu->Data.name == '\0') { MessageBox(HD, L"请先输入姓名", L"注册信息", MB_OK); } else { int flag = find_ID(stu, tea, L1, L2); if (!flag) { chufen* chuf = (chufen*)malloc(sizeof(chufen)); ::memset(chuf, 0, sizeof(chuf)); ::memset(chuf->name, 0, sizeof(chuf->name)); chuf->loc = 1; strcpy_s(chuf->name[0], "暂无处分"); add_chufen(chuf, stu); huojiang huoj; ::memset(&huoj, 0, sizeof(huoj)); ::memset(huoj.name, 0, sizeof(huoj.name)); huoj.loc = 1; strcpy_s(huoj.name[0], "暂无获奖"); add_huojiang(&huoj, stu); ::memset(&stu->Data.all_kemu, 0, sizeof(stu->Data.all_kemu)); stu->Data.all_kemu.score = stu->Data.all_kemu.yuwen = stu->Data.all_kemu.shuxue = stu->Data.all_kemu.yingyu = stu->Data.all_kemu.wuli = stu->Data.all_kemu.huaxue = stu->Data.all_kemu.Cyuyan = 0; stu->Data.qiandao = 0; stu->Data.lastqiandao = 0; ::memset(stu->Data.kebiao, 0, sizeof(stu->Data.kebiao)); L1 = add_stu(stu, L1); save1(L1); MessageBox(HD, L"学生注册成功", L"注册信息", MB_OK); PMAIN(); } else { MessageBox(HD, L"该学号已经注册过", L"注册信息", MB_OK); } } } else if (mg.x > 720 && mg.x < 890 && mg.uMsg == WM_LBUTTONUP) { int flag = find_ID(stu, tea, L1, L2); if (!flag) { L2 = add_tea(tea, L2); save2(L2); MessageBox(HD, L"教师注册成功", L"注册信息", MB_OK); PMAIN(); } } } else if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { PMAIN(); } } } int find_ID(student* p1, teacher* p2, List1* L_1, List2* L_2) { class student* pp1 = L_1->head; class teacher* pp2 = L_2->head; while (pp1)//查找ID是否是学生 { if (!strcmp(pp1->Data.ID, p1->Data.ID)) { if (!strcmp(pp1->Data.mima, p1->Data.mima)) return 1;//是学生返回1 else return -1;//密码错误 } pp1 = pp1->next; } while (pp2)//查找是不是老师 { if (!strcmp(pp2->Data.ID, p2->Data.ID)) { if (!strcmp(pp2->Data.mima, p2->Data.mima)) return 2;//是老师返回2 else return -1;//老师密码错误 } pp2 = pp2->next; } return 0;//并不存在这个账号 }
cpp存放的就是这些函数的实现
先看学生端的分文件:
hstudennt.h:
#pragma once #include<cstdio> #include"hstudent.h" #include"hteacher.h" #include"MAIN.h" extern class List1* L1;//第一个学生 extern表示的是这个全局变量在其他文件定义过,所以直接定义就行,是起到一个修饰的作用 extern class List2* L2;//第一个老师 extern SYSTEMTIME st; extern int X , Y ;//X:界面宽度 Y界面高度 extern int randnum; extern HWND HD; extern char qiandaoyuji[][50]; class data2//老师的数据 { public: char ID[20];//账号 char mima[30];//密码 char name[30];//名字 }; class teacher { public: class data2 Data; class teacher* next;//指向下一个位置的指针 }; class List2//老师端,这样更方便记录信息 { public: class teacher* head; }; void Pteacher(teacher* tea); void Pteacher_GCJ(teacher* tea); void Pteacher_GHJ(teacher* tea); void Pteacher_KPM(teacher* tea); void Pteacher_GMA(teacher* tea); void Pteacher_CKQD(teacher* tea); void Pteacherr_GCF(teacher* tea); teacher* find_teacher(teacher* tea, List2* L);
这个.h文件存放的是老师端所有操作的声明(包括类的声明,那些操作函数的声明)
hstudent.cpp(注意和.h文件名称保持一致):
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#pragma once #include<easyx.h> #include<graphics.h> #include<cstdio> #include<iostream> #include<windows.h> #include<cstring> #include<conio.h> #include<vector> #include<queue> #include<algorithm> #include <atlstr.h> #include<ctime> #include"hstudent.h" #include"MAIN.h" #include"hteacher.h" #pragma comment(lib,"Winmm.lib") using namespace std; void Pstudent(student* stu) { cleardevice(); IMAGE pmain;//背景 IMAGE tx1, tx2; loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); //loadimage(&tx2, L"tx2.jpg", 200, 300); loadimage(&tx1, L"tx1.jpg", 200, 300); //putimage(1000, 0, &tx2, NOTSRCERASE); putimage(1000, 0, &tx1);// , SRCINVERT); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(370, 100, L"西柚信息管理学生端"); rectangle(1000, 0, 1200, 300);//头像 rectangle(1100, 300, 1200, 350);//签到按钮 rectangle(500, 200, 700, 250);//成绩查看 rectangle(500, 300, 700, 350);//排名查看 rectangle(500, 400, 700, 450);//获奖情况查看 rectangle(500, 500, 700, 550);//学习资料推荐 rectangle(500, 600, 700, 650);//课表查看 rectangle(500, 700, 700, 750);//处分信息查看 rectangle(1100, 750, 1199, 799);//退出程序 rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回");//返回 settextstyle(30, 15, L"微软雅黑");//签到字体 outtextxy(1120, 310, L"签到");//签到 outtextxy(1120, 760, L"退出");//退出程序 settextstyle(40, 20, L"微软雅黑");//选项信息字体格式 outtextxy(520, 205, L"我的成绩");//我的成绩 outtextxy(520, 305, L"我的排名");//我的排名 outtextxy(520, 405, L"获奖情况");//获奖情况 outtextxy(520, 505, L"学习资料");//学习资料 outtextxy(520, 605, L"我的课表");//我的课表 outtextxy(520, 705, L"我的处分");//我的处分 outtextxy(100, 100, CString(stu->Data.name));//学生名字 if (stu->Data.qiandao) { settextstyle(20, 10, L"微软雅黑"); outtextxy(720, 400, CString(qiandaoyuji[randnum % 20])); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 500 && mg.x < 700) { if (mg.y > 200 && mg.y < 250 && mg.uMsg == WM_LBUTTONUP)//我的成绩的范围 { Pstudent_chengji(stu); } else if (mg.y > 300 && mg.y < 350 && mg.uMsg == WM_LBUTTONUP)//我的排名的范围 { Pstudent_paiming(stu); } else if (mg.y > 400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//获奖情况的范围 { Pstudent_huojiang(stu); } else if (mg.y > 500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//学习资料的范围 { Pstudent_xuexi(stu); } else if (mg.y > 600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//我的课表的范围 { Pstudent_kebiao(stu); } else if (mg.y > 700 && mg.y < 750 && mg.uMsg == WM_LBUTTONUP)//我的处分的范围 { Pstudent_chufen(stu); } } else if (mg.x > 1100 && mg.x < 1200)//签到的范围 { if (mg.y > 300 && mg.y < 350 && mg.uMsg == WM_LBUTTONUP) { Pstudent_qiandao(stu); } else if (mg.y > 750 && mg.y < 800 && mg.uMsg == WM_LBUTTONUP) { save1(L1); save2(L2); exit(0); } } else if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { PMAIN(); } } } void Pstudent_qiandao(student* stu)//签到 { if (stu->Data.qiandao) { MessageBox(HD, L"已经签到过啦>_<", L"签到信息", MB_OK); } else { stu->Data.qiandao = 1; GetLocalTime(&st); stu->Data.lastqiandao = st.wYear * 365 + st.wMonth * 30 + st.wDay; MessageBox(HD, L"签到成功 ◍'ㅅ'◍ ♡", L"签到信息", MB_OK); settextstyle(20, 10, L"微软雅黑"); outtextxy(800, 400, CString(qiandaoyuji[randnum % 20])); } } void Pstudent_chengji(student* stu)//学生成绩 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); char ch[30]; settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的成绩 o(*≧▽≦)ツ"); settextstyle(40, 20, L"微软雅黑"); outtextxy(360, 150, L"我的语文成绩:"); outtextxy(360, 200, L"我的数学成绩:"); outtextxy(360, 250, L"我的英语成绩:"); outtextxy(360, 300, L"我的化学成绩:"); outtextxy(360, 350, L"我的物理成绩:"); outtextxy(360, 400, L"我的C语言成绩:"); if (stu->Data.all_kemu.yuwen < 60) settextcolor(RED); else if (stu->Data.all_kemu.yuwen < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.yuwen); outtextxy(700, 150, CString(ch)); if (stu->Data.all_kemu.shuxue < 60) settextcolor(RED); else if (stu->Data.all_kemu.shuxue < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.shuxue); outtextxy(700, 200, CString(ch)); if (stu->Data.all_kemu.yingyu < 60) settextcolor(RED); else if (stu->Data.all_kemu.yingyu < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.yingyu); outtextxy(700, 250, CString(ch)); if (stu->Data.all_kemu.huaxue < 60) settextcolor(RED); else if (stu->Data.all_kemu.huaxue < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.huaxue); outtextxy(700, 300, CString(ch)); if (stu->Data.all_kemu.wuli < 60) settextcolor(RED); else if (stu->Data.all_kemu.wuli < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.wuli); outtextxy(700, 350, CString(ch)); if (stu->Data.all_kemu.Cyuyan < 60) settextcolor(RED); else if (stu->Data.all_kemu.Cyuyan < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.Cyuyan); outtextxy(700, 400, CString(ch)); settextcolor(WHITE); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_paiming(student* stu)//排名功能 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); char ch[30]; settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的排名 ︿( ̄︶ ̄)︿"); settextstyle(40, 20, L"微软雅黑"); outtextxy(360, 150, L"我的语文排名:"); outtextxy(360, 200, L"我的数学排名:"); outtextxy(360, 250, L"我的英语排名:"); outtextxy(360, 300, L"我的化学排名:"); outtextxy(360, 350, L"我的物理排名:"); outtextxy(360, 400, L"我的C语言排名:"); outtextxy(360, 450, L"我的总分排名:"); student* p = L1->head; int rank[7] = { 1,1,1,1,1,1,1 }; for (; p != NULL; p = p->next) { if (strcmp(stu->Data.ID, p->Data.ID)) { if (stu->Data.all_kemu.yuwen < p->Data.all_kemu.yuwen) rank[0]++; if (stu->Data.all_kemu.shuxue < p->Data.all_kemu.shuxue) rank[1]++; if (stu->Data.all_kemu.yingyu < p->Data.all_kemu.huaxue) rank[2]++; if (stu->Data.all_kemu.wuli < p->Data.all_kemu.wuli) rank[3]++; if (stu->Data.all_kemu.huaxue < p->Data.all_kemu.huaxue) rank[4]++; if (stu->Data.all_kemu.Cyuyan < p->Data.all_kemu.Cyuyan) rank[5]++; if (stu->Data.all_kemu.score < p->Data.all_kemu.score) rank[6]++; } } for (int i = 150, j = 0; j < 7; i += 50, ++j) { ::sprintf(ch, "%d", rank[j]); outtextxy(700, i, CString(ch)); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_huojiang(student* stu)//获奖情况 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的获奖 <( ̄︶ ̄)>"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); for (int high = 100, i = 0; i < stu->Data.hjxinxi.loc; i++, high += 50) { if (*stu->Data.hjxinxi.name[i] != '\0') outtextxy(300, high, CString(stu->Data.hjxinxi.name[i])); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_xuexi(student* stu)//学习资料 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"西柚信息学习资料"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); outtextxy(100, 150, L"学习网址推荐"); outtextxy(700, 150, L"学习书籍推荐"); settextstyle(30, 15, L"微软雅黑");//网址和书籍字体 //网址推荐 outtextxy(100, 200, L"www.cnblogs.com/YHH520/");//我的博客 outtextxy(100, 250, L"www.nowcoder.com");//牛客 outtextxy(100, 300, L"www.icourse163.org");//Mooc outtextxy(100, 350, L"www.luogu.com.cn");//洛谷 outtextxy(100, 400, L"github.com");//github outtextxy(100, 450, L"leetcode-cn.com");//leetcode outtextxy(100, 500, L"47.94.129.140/ //西柚的练习网址");//SWPUACM outtextxy(100, 550, L"www.bilibili.com");//B站 //书籍推荐 outtextxy(700, 200, L"C Primer Plus"); outtextxy(700, 250, L"数据结构"); outtextxy(700, 300, L"计算机组成原理"); outtextxy(700, 350, L"挑战程序设计竞赛"); outtextxy(700, 400, L"算法竞赛入门经典"); outtextxy(700, 450, L"算法导论"); outtextxy(700, 500, L"编程之美"); outtextxy(700, 550, L"剑指Offer"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_kebiao(student* stu)//课表查看 { cleardevice(); IMAGE pmain;//主界面图片 wchar_t key1[20]; char key2[20]; loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(400, 50, L"我的课表"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); outtextxy(220, 250, L"星期一"); outtextxy(420, 250, L"星期二"); outtextxy(620, 250, L"星期三"); outtextxy(820, 250, L"星期四"); outtextxy(1020, 250, L"星期五"); outtextxy(30, 330, L"早自习"); outtextxy(30, 490, L"上午"); outtextxy(30, 690, L"下午"); for (int i = 300; i < 799; i += 100) { line(200, i, 1200, i); } for (int i = 200; i < 1199; i += 200) { line(i, 300, i, 800); } line(200, 799, 1200, 799); line(1199, 300, 1199, 799); for (int i = 0, n = 300; i < 5; ++i, n += 100) { for (int j = 0, m = 200; j < 5; ++j, m += 200) { outtextxy(m + 20, n + 20, CString(stu->Data.kebiao[i * 5 + j])); } } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } else if (mg.y > 300 && mg.y < 400)//第一行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 301)); clearrectangle(200, 300, 400, 400); rectangle(200, 300, 400, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[0], key2); outtextxy(220, 320, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 301)); clearrectangle(400, 300, 600, 400); rectangle(400, 300, 600, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[1], key2); outtextxy(420, 320, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 301)); clearrectangle(600, 300, 800, 400); rectangle(600, 300, 800, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[2], key2); outtextxy(620, 320, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 301)); clearrectangle(800, 300, 1000, 400); rectangle(800, 300, 1000, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[3], key2); outtextxy(820, 320, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 301)); clearrectangle(1000, 300, 1200, 400); rectangle(1000, 300, 1199, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[4], key2); outtextxy(1020, 320, CString(key2)); save1(L1); } } else if (mg.y > 400 && mg.y < 500)//第二行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 401)); clearrectangle(200, 400, 400, 500); rectangle(200, 400, 400, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[5], key2); outtextxy(220, 420, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 401)); clearrectangle(400, 400, 600, 500); rectangle(200, 400, 400, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[6], key2); outtextxy(420, 420, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 401)); clearrectangle(600, 400, 800, 500); rectangle(600, 400, 800, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[7], key2); outtextxy(620, 420, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 401)); clearrectangle(800, 400, 1000, 500); rectangle(800, 400, 1000, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[8], key2); outtextxy(820, 420, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 401)); clearrectangle(1000, 400, 1200, 500); rectangle(1000, 400, 1200, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[9], key2); outtextxy(1020, 420, CString(key2)); save1(L1); } } else if (mg.y > 500 && mg.y < 600)//第三行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 501)); clearrectangle(200, 500, 400, 600); rectangle(200, 500, 400, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[10], key2); outtextxy(220, 520, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 501)); clearrectangle(400, 500, 600, 600); rectangle(400, 500, 600, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[11], key2); outtextxy(420, 520, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 501)); clearrectangle(600, 500, 800, 600); rectangle(600, 500, 400, 800); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[12], key2); outtextxy(620, 520, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 501)); clearrectangle(800, 500, 1000, 600); rectangle(800, 500, 1000, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[13], key2); outtextxy(820, 520, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 501)); clearrectangle(1000, 500, 1200, 600); rectangle(1000, 500, 1200, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[14], key2); outtextxy(1020, 520, CString(key2)); save1(L1); } } else if (mg.y > 600 && mg.y < 700)//第四行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 601)); clearrectangle(200, 600, 400, 700); rectangle(200, 600, 400, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[15], key2); outtextxy(220, 620, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 601)); clearrectangle(400, 600, 600, 700); rectangle(400, 600, 600, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[16], key2); outtextxy(420, 620, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 601)); clearrectangle(600, 600, 800, 700); rectangle(600, 600, 800, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[17], key2); outtextxy(620, 620, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 601)); clearrectangle(800, 600, 1000, 700); rectangle(800, 600, 1000, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[18], key2); outtextxy(820, 620, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 601)); clearrectangle(1000, 600, 1200, 700); rectangle(1000, 600, 1200, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[19], key2); outtextxy(1020, 620, CString(key2)); save1(L1); } } else if (mg.y > 700 && mg.y < 800)//第五行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 701)); clearrectangle(200, 700, 400, 800); rectangle(200, 700, 400, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[20], key2); outtextxy(220, 720, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 701)); clearrectangle(400, 700, 600, 800); rectangle(400, 700, 600, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[21], key2); outtextxy(420, 720, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 701)); clearrectangle(600, 700, 800, 800); rectangle(600, 700, 800, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[22], key2); outtextxy(620, 720, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 701)); clearrectangle(800, 700, 1000, 800); rectangle(800, 700, 1000, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[23], key2); outtextxy(820, 720, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 701)); clearrectangle(1000, 700, 1199, 800); rectangle(1000, 700, 1199, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[24], key2); outtextxy(1020, 720, CString(key2)); save1(L1); } } } } void Pstudent_chufen(student* stu)//处分信息 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的处分信息"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); //chufen* p = stu->Data.cfxinxi.next; for (int high = 100, i = 0; i < stu->Data.cfxinxi.loc; i++, high += 50) { if (*stu->Data.cfxinxi.name[i] != '\0') outtextxy(300, high, CString(stu->Data.cfxinxi.name[i])); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } student* find_student(student* stu, List1* L)//建立在已经找到学生信息的情况下,把该学生的位置传出去 { student* p = L->head; while (p->next) { if (!strcmp(p->Data.ID, stu->Data.ID)) return p; p = p->next; } return p; } student* find_stuID(List1* L, char* num)//寻找num学号的学生 { student* p = L->head; while (p) { if (!strcmp(p->Data.ID, num)) return p; p = p->next; } return NULL; }
这个cpp文件里面存放的就是上面对应的.h文件的函数的定义(也就是函数的实现),(相当于自己写一个库?虽然比较小)
注意要把hstudent.h这个头文件引用进去.
然后同理老师端的分文件:
hteacher.h:
#pragma once #include<cstdio> #include"hstudent.h" #include"hteacher.h" #include"MAIN.h" extern class List1* L1;//第一个学生 extern class List2* L2;//第一个老师 extern SYSTEMTIME st; extern int X , Y ;//X:界面宽度 Y界面高度 extern int randnum; extern HWND HD; extern char qiandaoyuji[][50]; class data2//老师的数据 { public: char ID[20];//账号 char mima[30];//密码 char name[30];//名字 }; class teacher { public: class data2 Data; class teacher* next;//指向下一个位置的指针 }; class List2//老师端,这样更方便记录信息 { public: class teacher* head; }; void Pteacher(teacher* tea); void Pteacher_GCJ(teacher* tea); void Pteacher_GHJ(teacher* tea); void Pteacher_KPM(teacher* tea); void Pteacher_GMA(teacher* tea); void Pteacher_CKQD(teacher* tea); void Pteacherr_GCF(teacher* tea); teacher* find_teacher(teacher* tea, List2* L);
hteacher.cpp:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#pragma once #include<easyx.h> #include<graphics.h> #include<cstdio> #include<iostream> #include<windows.h> #include<cstring> #include<conio.h> #include<vector> #include<queue> #include<algorithm> #include <atlstr.h> #include<ctime> #include"hstudent.h" #include"hteacher.h" #include"MAIN.h" #pragma comment(lib,"Winmm.lib") using namespace std; void Pteacher(teacher* tea) { cleardevice(); IMAGE pmain;//登录注册界面 IMAGE tx1, tx2; loadimage(&tx1, L"tx1.jpg", 200, 300); loadimage(&tx2, L"tx2.jpg", 200, 300); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); putimage(1000, 0, &tx1); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(370, 100, L"西柚信息管理教师端"); rectangle(1000, 0, 1200, 300);//头像 rectangle(500, 200, 800, 250);//修改学生成绩 rectangle(500, 300, 800, 350);//修改学生获奖 rectangle(500, 400, 800, 450);//查看学生排名 rectangle(500, 500, 800, 550);//查看学生签到 rectangle(500, 600, 800, 650);//全校学生通知 rectangle(500, 700, 800, 750);//修改学生处分 rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑");//选项信息字体格式 outtextxy(5, 5, L"返回");//返回 outtextxy(520, 205, L"修改学生成绩");//修改学生成绩 outtextxy(520, 305, L"修改学生获奖");//修改学生获奖 outtextxy(520, 405, L"查看学生排名");//查看学生排名 outtextxy(520, 505, L"查看学生签到");//查看学生签到 outtextxy(520, 605, L"修改学生密码");//全校学生通知 outtextxy(520, 705, L"修改学生处分");//修改学生处分 outtextxy(100, 100, CString(tea->Data.name)); settextstyle(30, 15, L"微软雅黑");// rectangle(1100, 750, 1199, 799);//退出程序框 outtextxy(1120, 760, L"退出");//退出程序 MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 500 && mg.x < 800) { if (mg.y > 200 && mg.y < 250 && mg.uMsg == WM_LBUTTONUP)//修改学生成绩的范围 { Pteacher_GCJ(tea); } else if (mg.y > 300 && mg.y < 350 && mg.uMsg == WM_LBUTTONUP)//修改学生获奖的范围 { Pteacher_GHJ(tea); } else if (mg.y > 400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//查看学生排名的范围 { Pteacher_KPM(tea); } else if (mg.y > 500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//查看学生签到的范围 { Pteacher_CKQD(tea); } else if (mg.y > 600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//全校学生通知的范围 { Pteacher_GMA(tea); } else if (mg.y > 700 && mg.y < 750 && mg.uMsg == WM_LBUTTONUP)//修改学生处分的范围 { Pteacherr_GCF(tea); } } else if (mg.x > 1100 && mg.x < 1200 && mg.y > 750 && mg.y < 800 && mg.uMsg == WM_LBUTTONUP) { save1(L1); save2(L2); exit(0); } else if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { PMAIN(); } } } void Pteacher_GCJ(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// wchar_t key1[10]; char key2[10]; student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 200, 880, 250);//学生学号输入窗口 rectangle(920, 200, 1020, 250); for (int i = 400; i < 700; i += 100) { rectangle(450, i, 550, i + 50); } for (int i = 400; i < 700; i += 100) { rectangle(850, i, 950, i + 50); } settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"修改学生成绩"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 200, L"学生学号:"); outtextxy(350, 300, L"学生信息:"); outtextxy(300, 400, L"语文:"); outtextxy(300, 500, L"数学:"); outtextxy(300, 600, L"英语:"); outtextxy(700, 400, L"物理:"); outtextxy(700, 500, L"化学:"); outtextxy(700, 600, L"C语言:"); outtextxy(930, 205, L"确定"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.y > 200 && mg.y < 250) { if (mg.x > 550 && mg.x < 880 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 201)); clearrectangle(550, 200, 880, 250); rectangle(550, 200, 880, 250); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 210, xuehao); } else if (mg.x > 920 && mg.x < 1020 && mg.uMsg == WM_LBUTTONUP) { if (*xuehao2 != '\0') { temp = find_stuID(L1, xuehao2); if (temp) { char fenshu[15]; for (int i = 400; i < 700; i += 100) { setbkcolor(getpixel(451, i + 1)); clearrectangle(450, i, 550, i + 50); rectangle(450, i, 550, i + 50); } for (int i = 400; i < 700; i += 100) { setbkcolor(getpixel(851, i + 1)); clearrectangle(850, i, 950, i + 50); rectangle(850, i, 950, i + 50); } outtextxy(560, 305, CString(temp->Data.name)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.yuwen); outtextxy(460, 405, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.shuxue); outtextxy(460, 505, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.yingyu); outtextxy(460, 605, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.wuli); outtextxy(860, 405, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.huaxue); outtextxy(860, 505, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.Cyuyan); outtextxy(860, 605, CString(fenshu)); save1(L1); } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } } } else if (mg.x > 450 && mg.x < 550 && mg.y>400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//语文成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(451, 401)); clearrectangle(450, 400, 550, 450); rectangle(450, 400, 550, 450); InputBox(key1, 4, L"请输入学生语文成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(460, 405, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.yuwen; temp->Data.all_kemu.yuwen = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 450 && mg.x < 550 && mg.y>500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//数学成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(451, 551)); clearrectangle(450, 500, 550, 550); rectangle(450, 500, 550, 550); InputBox(key1, 4, L"请输入学生数学成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(460, 505, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.shuxue; temp->Data.all_kemu.shuxue = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 450 && mg.x < 550 && mg.y>600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//英语成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(451, 601)); clearrectangle(450, 600, 550, 650); rectangle(450, 600, 550, 650); InputBox(key1, 4, L"请输入学生英语成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(460, 605, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.yingyu; temp->Data.all_kemu.yingyu = atoi(key2); save1(L1); } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 850 && mg.x < 950 && mg.y>400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//物理成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(851, 401)); clearrectangle(850, 400, 950, 450); rectangle(850, 400, 950, 450); InputBox(key1, 4, L"请输入学生物理成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(860, 405, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.wuli; temp->Data.all_kemu.wuli = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 850 && mg.x < 950 && mg.y>500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//化学成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(851, 501)); clearrectangle(850, 500, 950, 550); rectangle(850, 500, 950, 550); InputBox(key1, 4, L"请输入学生成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(860, 505, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.huaxue; temp->Data.all_kemu.huaxue = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 850 && mg.x < 950 && mg.y>600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//C语言成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(851, 601)); clearrectangle(850, 600, 950, 650); rectangle(850, 600, 950, 650); InputBox(key1, 4, L"请输入学生C语言成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(860, 605, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.Cyuyan; temp->Data.all_kemu.Cyuyan = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } } } void Pteacher_GHJ(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// wchar_t key1[100]; char key2[100]; student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 120, 880, 170);//学生学号输入窗口 rectangle(920, 120, 1020, 170); rectangle(0, 0, 100, 50); rectangle(500, 300, 950, 350);//1 rectangle(500, 400, 950, 450);//2 rectangle(500, 500, 950, 550);//3 rectangle(500, 600, 950, 650);//4 rectangle(500, 700, 950, 750);//5 settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 40, L"修改学生获奖"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 120, L"学生学号:"); outtextxy(350, 200, L"学生信息:"); outtextxy(930, 125, L"确定"); for (int i = 300; i <= 700; i += 100) { outtextxy(300, i, L"获奖信息:"); } outtextxy(5, 5, L"返回"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 550 && mg.x < 880 && mg.y>120 && mg.y < 170 && mg.uMsg == WM_LBUTTONUP)//学号输入框 { setbkcolor(getpixel(601, 201)); clearrectangle(550, 120, 880, 170); rectangle(550, 120, 880, 170); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 130, xuehao); } else if (mg.y > 120 && mg.y < 170 && mg.x > 920 && mg.x < 1020 && mg.uMsg == WM_LBUTTONUP)//确认按钮 { if (*xuehao2 != '\0') { temp = find_stuID(L1, xuehao2); if (temp) { outtextxy(550, 200, CString(temp->Data.name)); for (int i = 0, j = 305; i < 5; ++i, j += 100) { outtextxy(510, j, CString(temp->Data.hjxinxi.name[i])); } } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 300 && mg.y < 350 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//1 { if (temp) { setbkcolor(getpixel(501, 301)); clearrectangle(500, 300, 950, 350); rectangle(500, 300, 950, 350); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 305, key1); strcpy(temp->Data.hjxinxi.name[0], key2); temp->Data.hjxinxi.loc = 1; save1(L1); } else { MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } } else if (mg.y > 400 && mg.y < 450 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//2 { if (temp) { setbkcolor(getpixel(501, 401)); clearrectangle(500, 400, 950, 450); rectangle(500, 400, 950, 450); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 405, key1); strcpy(temp->Data.hjxinxi.name[1], key2); temp->Data.hjxinxi.loc = 2; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 500 && mg.y < 550 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//3 { if (temp) { setbkcolor(getpixel(501, 501)); clearrectangle(500, 500, 950, 550); rectangle(500, 500, 950, 550); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 505, key1); strcpy(temp->Data.hjxinxi.name[2], key2); temp->Data.hjxinxi.loc = 3; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 600 && mg.y < 650 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//4 { if (temp) { setbkcolor(getpixel(501, 601)); clearrectangle(500, 600, 950, 650); rectangle(500, 600, 950, 650); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 605, key1); strcpy(temp->Data.hjxinxi.name[3], key2); temp->Data.hjxinxi.loc = 4; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 700 && mg.y < 750 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//5 { if (temp) { setbkcolor(getpixel(501, 701)); clearrectangle(500, 700, 950, 750); rectangle(500, 700, 950, 750); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 705, key1); strcpy(temp->Data.hjxinxi.name[4], key2); temp->Data.hjxinxi.loc = 5; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } } } void Pteacher_KPM(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 priority_queue<pair<int, const char*> >q; student* p = L1->head; for (; p; p = p->next) { q.push({ p->Data.all_kemu.score,p->Data.name }); } wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// char key2[100]; student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(800, 150, 1199, 200);//学生学号输入窗口 rectangle(1100, 200, 1199, 250);//确认按钮 rectangle(0, 0, 100, 50); settextstyle(50, 30, L"微软雅黑"); outtextxy(400, 40, L"查看学生排名"); settextcolor(GREEN); outtextxy(200, 100, L"前五名学生"); settextcolor(WHITE); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回"); outtextxy(800, 100, L"查找学生排名"); outtextxy(680, 150, L"学号:"); outtextxy(1110, 210, L"确定"); outtextxy(680, 300, L"学生信息:"); outtextxy(680, 400, L"语文排名 :"); outtextxy(680, 450, L"数学排名 :"); outtextxy(680, 500, L"英语排名 :"); outtextxy(680, 550, L"物理排名 :"); outtextxy(680, 600, L"化学排名 :"); outtextxy(680, 650, L"C语言排名:"); outtextxy(680, 700, L"总分排名 :"); for (int i = 0, j = 200; i < 5 && q.size(); ++i, j += 100, q.pop()) { sprintf(key2, "%d", q.top().first); outtextxy(200, j, CString(key2)); outtextxy(300, j, CString(q.top().second)); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 800 && mg.x < 1200 && mg.y>150 && mg.y < 200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 151)); clearrectangle(800, 150, 1200, 200); rectangle(800, 150, 1200, 200); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(810, 160, xuehao); } else if (mg.x > 1100 && mg.x < 1200 && mg.y>200 && mg.y < 250 && mg.uMsg == WM_LBUTTONUP) { if (*xuehao2) { temp = find_stuID(L1, xuehao2); if (temp) { setbkcolor(getpixel(801, 151)); clearrectangle(890, 290, 1100, 350); outtextxy(900, 300, CString(temp->Data.name)); char ch[10]; memset(ch, 0, sizeof(ch)); int rank[7] = { 1,1,1,1,1,1,1 }; for (p = L1->head; p != NULL; p = p->next) { if (strcmp(temp->Data.ID, p->Data.ID)) { if (temp->Data.all_kemu.yuwen < p->Data.all_kemu.yuwen) rank[0]++; if (temp->Data.all_kemu.shuxue < p->Data.all_kemu.shuxue) rank[1]++; if (temp->Data.all_kemu.yingyu < p->Data.all_kemu.huaxue) rank[2]++; if (temp->Data.all_kemu.wuli < p->Data.all_kemu.wuli) rank[3]++; if (temp->Data.all_kemu.huaxue < p->Data.all_kemu.huaxue) rank[4]++; if (temp->Data.all_kemu.Cyuyan < p->Data.all_kemu.Cyuyan) rank[5]++; if (temp->Data.all_kemu.score < p->Data.all_kemu.score) rank[6]++; } } for (int i = 410, j = 0; j < 7; i += 50, ++j) { ::sprintf(ch, "%d", rank[j]); setbkcolor(getpixel(901, i)); clearrectangle(900, i - 10, 1000, i + 50); outtextxy(910, i, CString(ch)); } } else { MessageBox(HD, L"未找到该学生信息=_=", L"学号输入信息", MB_OK); } } else { MessageBox(HD, L"请先输入学号=_=", L"学号输入信息", MB_OK); } } } } void Pteacher_GMA(teacher* tea) { cleardevice(); IMAGE pmain;//背景图 student* stu = NULL; wchar_t xuehao1[25]; char xuehao2[25]; wchar_t mima1[25]; char mima2[25]; memset(mima1, 0, sizeof(mima1)); memset(mima2, 0, sizeof(mima2)); memset(xuehao1, 0, sizeof(xuehao1)); memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(400, 200, L"学生密码修改"); rectangle(0, 0, 100, 50); rectangle(900, 350, 1000, 400);//确定 rectangle(500, 350, 900, 400); rectangle(500, 450, 900, 500); rectangle(500, 550, 900, 600); rectangle(500, 650, 900, 700); rectangle(650, 750, 850, 799); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回"); outtextxy(200, 350, L"学号:"); outtextxy(200, 450, L"学生信息:"); outtextxy(200, 550, L"原密码:"); outtextxy(200, 650, L"新密码:"); outtextxy(910, 355, L"确定"); outtextxy(660, 755, L"确定修改"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 500 && mg.x < 900 && mg.y>350 && mg.y < 400 && mg.uMsg == WM_LBUTTONUP)//学号输入 { setbkcolor(getpixel(501, 351)); clearrectangle(500, 350, 900, 400); rectangle(500, 350, 900, 400); InputBox(xuehao1, 13, L"请输入学号"); WideCharToMultiByte(CP_ACP, 0, xuehao1, -1, xuehao2, wcslen(xuehao1) * 2 + 1, NULL, NULL); outtextxy(510, 355, xuehao1); } else if (mg.x > 900 && mg.x < 1000 && mg.y>350 && mg.y < 400 && mg.uMsg == WM_LBUTTONUP)//确定按钮 { if (*xuehao2) { stu = find_stuID(L1, xuehao2); if (stu) { setbkcolor(getpixel(501, 451)); clearrectangle(500, 450, 900, 500); rectangle(500, 450, 900, 500); outtextxy(510, 455, CString(stu->Data.name)); setbkcolor(getpixel(501, 551)); clearrectangle(500, 550, 900, 600); rectangle(500, 550, 900, 600); outtextxy(510, 555, CString(stu->Data.mima)); } else { MessageBox(HD, L"没有该学生信息哦", L"学生信息", MB_OK); } } else { MessageBox(HD, L"请先输入学生学号", L"学生信息", MB_OK); } } else if (mg.x > 500 && mg.x < 900 && mg.y>650 && mg.y < 700 && mg.uMsg == WM_LBUTTONUP)//新密码输入框 { if (*xuehao2) { if (stu) { setbkcolor(getpixel(501, 651)); clearrectangle(500, 650, 900, 700); rectangle(500, 650, 900, 700); InputBox(mima1, 13, L"请输入新密码"); WideCharToMultiByte(CP_ACP, 0, mima1, -1, mima2, wcslen(mima1) * 2 + 1, NULL, NULL); outtextxy(510, 655, mima1); } else { MessageBox(HD, L"没有该学生信息哦", L"学生信息", MB_OK); } } else { MessageBox(HD, L"请先输入学生学号", L"学生信息", MB_OK); } } else if (mg.x > 650 && mg.x < 750 && mg.y>750 && mg.y < 799 && mg.uMsg == WM_LBUTTONUP)//确当修改框 { if (*xuehao2) { if (stu) { strcpy_s(stu->Data.mima, mima2); save1(L1); MessageBox(HD, L"学生密码修改成功", L"学生信息", MB_OK); } else { MessageBox(HD, L"没有该学生信息哦", L"学生信息", MB_OK); } } else { MessageBox(HD, L"请先输入学生学号", L"学生信息", MB_OK); } } } } void Pteacher_CKQD(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 120, 870, 170);//学生学号输入窗口 rectangle(870, 120, 970, 170); rectangle(0, 0, 100, 50); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 40, L"查看学生签到情况"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 120, L"学生学号:"); outtextxy(350, 200, L"学生信息:"); outtextxy(880, 125, L"确定"); outtextxy(5, 5, L"返回"); int tol_renshu = 0, tol_qiandaoshu = 0;//tol_renshu是总人数,tol_qiandaoshu是签到的人数 char tol_RS[10], tol_QDRS[10]; student* p = L1->head; for (; p; p = p->next) { if (p->Data.qiandao) ++tol_qiandaoshu; ++tol_renshu; } ::sprintf(tol_RS, "%d", tol_renshu); ::sprintf(tol_QDRS, "%d", tol_qiandaoshu); outtextxy(100, 300, L"学生总人数:"); outtextxy(100, 400, L"签到的学生数目:"); outtextxy(450, 300, CString(tol_RS)); outtextxy(450, 400, CString(tol_QDRS)); outtextxy(600, 300, L"未签到学生:"); outtextxy(850, 200, L"签到情况:"); p = L1->head; for (int j = 350, i = 600; p; p = p->next) { if (j > 800) { j = 350; i += 200; } if (!p->Data.qiandao) { settextcolor(RED); outtextxy(i, j, CString(p->Data.name));//输出未签到的名字 j += 50; settextcolor(WHITE); } } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 550 && mg.x < 870 && mg.y>120 && mg.y < 170 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(551, 121)); clearrectangle(550, 120, 870, 170); rectangle(550, 120, 870, 170); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 130, xuehao); } else if (mg.x > 850 && mg.x < 970 && mg.y>120 && mg.y < 170 && mg.uMsg == WM_LBUTTONUP) { if (*xuehao2) { temp = find_stuID(L1, xuehao2); if (temp) { if (temp->Data.qiandao) { setbkcolor(getpixel(601, 201)); clearrectangle(540, 200, 750, 240); outtextxy(550, 200, CString(temp->Data.name)); setbkcolor(getpixel(1051, 201)); clearrectangle(1040, 200, 1199, 240); settextcolor(GREEN); outtextxy(1050, 200, L"已签到"); settextcolor(WHITE); } else { setbkcolor(getpixel(601, 201)); clearrectangle(540, 200, 750, 240); outtextxy(550, 200, CString(temp->Data.name)); setbkcolor(getpixel(1051, 201)); clearrectangle(1040, 200, 1199, 240); settextcolor(RED); outtextxy(1050, 200, L"未签到"); settextcolor(WHITE); } } else { MessageBox(HD, L"未找到该学生信息=_=", L"学号输入信息", MB_OK); } } else { MessageBox(HD, L"请先输入学号=_=", L"学号输入信息", MB_OK); } } } } void Pteacherr_GCF(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// wchar_t key1[100]; char key2[100]; student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 120, 870, 170);//学生学号输入窗口 rectangle(920, 120, 1020, 170); rectangle(0, 0, 100, 50); rectangle(500, 300, 950, 350);//1 rectangle(500, 400, 950, 450);//2 rectangle(500, 500, 950, 550);//3 rectangle(500, 600, 950, 650);//4 rectangle(500, 700, 950, 750);//5 settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 40, L"修改学生处分"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 120, L"学生学号:"); outtextxy(350, 200, L"学生信息:"); outtextxy(930, 125, L"确定"); for (int i = 300; i <= 700; i += 100) { outtextxy(300, i, L"处分信息:"); } outtextxy(5, 5, L"返回"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 550 && mg.x < 870 && mg.y>120 && mg.y < 170 && mg.uMsg == WM_LBUTTONUP)//学号输入框 { setbkcolor(getpixel(601, 201)); clearrectangle(550, 120, 870, 170); rectangle(550, 120, 870, 170); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 130, xuehao); } else if (mg.y > 120 && mg.y < 170 && mg.x > 920 && mg.x < 1020 && mg.uMsg == WM_LBUTTONUP)//确认按钮 { if (*xuehao2 != '\0') { temp = find_stuID(L1, xuehao2); if (temp) { outtextxy(550, 200, CString(temp->Data.name)); for (int i = 0, j = 305; i < 5; ++i, j += 100) { outtextxy(510, j, CString(temp->Data.cfxinxi.name[i])); } } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 300 && mg.y < 350 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//1 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 301)); clearrectangle(500, 300, 950, 350); rectangle(500, 300, 950, 350); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 305, key1); strcpy(temp->Data.cfxinxi.name[0], key2); temp->Data.cfxinxi.loc = 1; save1(L1); } else MessageBox(HD, L"未找到该学号", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 400 && mg.y < 450 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//2 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 401)); clearrectangle(500, 400, 950, 450); rectangle(500, 400, 950, 450); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 405, key1); strcpy(temp->Data.cfxinxi.name[1], key2); temp->Data.cfxinxi.loc = 2; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 500 && mg.y < 550 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//3 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 501)); clearrectangle(500, 500, 950, 550); rectangle(500, 500, 950, 550); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 505, key1); strcpy(temp->Data.cfxinxi.name[2], key2); temp->Data.cfxinxi.loc = 3; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 600 && mg.y < 650 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//4 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 601)); clearrectangle(500, 600, 950, 650); rectangle(500, 600, 950, 650); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 605, key1); strcpy(temp->Data.cfxinxi.name[3], key2); temp->Data.cfxinxi.loc = 4; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 700 && mg.y < 750 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//5 { if (xuehao2) { if (temp) { setbkcolor(getpixel(501, 701)); clearrectangle(500, 700, 950, 750); rectangle(500, 700, 950, 750); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 705, key1); strcpy(temp->Data.cfxinxi.name[4], key2); temp->Data.cfxinxi.loc = 5; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } } } teacher* find_teacher(teacher* tea, List2* L)//建立在已经找到老师信息的情况下,把该老师的位置传出去 { teacher* p = L->head; while (p->next) { if (!strcmp(p->Data.ID, tea->Data.ID)) return p; p = p->next; } return p; }
最后是主文件里面:
#include<easyx.h> #include<graphics.h> #include<cstdio> #include<iostream> #include<windows.h> #include<cstring> #include<conio.h> #include<vector> #include<queue> #include<algorithm> #include <atlstr.h> #include<ctime> #include"hstudent.h" #include"hteacher.h" #include"MAIN.h" #pragma comment(lib,"Winmm.lib") SYSTEMTIME st;//windows的API时间获取 char qiandaoyuji[][50] = { "为成功找方法,不为失败找借口","理想的书籍是聪明的钥匙","书犹药也,善读之可以医愚。" ,"书籍乃世人积累智慧之长明灯。","好学而不勤问非真好学者。","聪明出于勤奋,天才在于积累","有志者事竞成","成功源于努力","世上无难事","宝剑锋自磨砺出","梅花香自苦寒来","天生我才必有用","一天过完,不会再来","行成于思,毁于随","If winter comes , can spring be far behind ?","There is no royal road to science.","Genius only means hard-working all one's life.","Nothing is impossible!","Doubt is the key to knowledge.","Clumsy birds have to start flying early."}; using namespace std; HWND HD; int X=1200, Y=800;//X:界面宽度 Y界面高度 int randnum; class List1* L1;//第一个学生 class List2* L2;//第一个老师 int main() { GetLocalTime(&st); srand((int)time(NULL)); randnum = rand(); L1 = (List1*)malloc(sizeof(List1)); L1->head = NULL; L2 = (List2*)malloc(sizeof(List2)); L2->head = NULL; read(L1, L2);//读取文件 initgraph(X, Y); HD=GetHWnd(); mciSendString(_T("open bkmusic.mp3 alias music"), NULL, 0, NULL); mciSendString(_T("play music repeat"), NULL, 0, NULL); PMAIN(); system("pause"); return 0; }
技巧总结
最后总结一下小技巧:
1.在我的学生端有个签到功能,这个功能要做到实时更新,就必须有一个记录时间的变量,我是直接卸载类里面的
我们可以通过定义一个SYSTEMTIME(windows的一个API)的变量,在程序启动的时候获取年月日,然后记录下来当签到的时候比较一下就好了。
2.在使用文件操作的时候尽量使用wb和rb的方式,以二进制的方式打开,这样文件存储就不会存在乱码的情况
3.输出的时候出现屯屯屯,这是由于类/结构体的变量没有初始化造成的,可以在每次声明后memset一下(具体操作看上面的.cpp文件)
4.easyx的更多操作请移步:传送门
5.MessageBox作为交互其实挺好用的, 学习传送门
单文件源码
最后附上由一个.cpp文件写成的源码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<easyx.h> #include<graphics.h> #include<cstdio> #include<iostream> #include<windows.h> #include<cstring> #include<conio.h> #include<vector> #include<queue> #include<algorithm> #include <atlstr.h> #include<ctime> #pragma comment(lib,"Winmm.lib") #define MOD 1000000005; SYSTEMTIME st;//windows的API时间获取 char qiandaoyuji[][50] = { "为成功找方法,不为失败找借口","理想的书籍是聪明的钥匙","书犹药也,善读之可以医愚。" ,"书籍乃世人积累智慧之长明灯。","好学而不勤问非真好学者。","聪明出于勤奋,天才在于积累","有志者事竞成","成功源于努力","世上无难事","宝剑锋自磨砺出","梅花香自苦寒来","天生我才必有用","一天过完,不会再来","行成于思,毁于随","If winter comes , can spring be far behind ?","There is no royal road to science.","Genius only means hard-working all one's life.","Nothing is impossible!","Doubt is the key to knowledge.","Clumsy birds have to start flying early."}; using namespace std; HWND HD; int X=1200, Y=800;//X:界面宽度 Y界面高度 int randnum; class subject { public: int yuwen; int shuxue; int yingyu; int wuli; int huaxue; int Cyuyan; int score;//总分 }; class huojiang { public: char name[10][100]; int loc=0; }; class chufen { public: char name[10][100]; int loc=0; }; class data1//学生的数据 { public: char ID[20];//账号 char mima[30];//密码 char name[30];//名字 char kebiao[25][10];//课表 int qiandao=0;//是否签到 int lastqiandao;//上次签到的时间 huojiang hjxinxi;//获奖信息 subject all_kemu;//科目信息 chufen cfxinxi;//处分信息 }; class data2//老师的数据 { public: char ID[20];//账号 char mima[30];//密码 char name[30];//名字 }; class student { public: class data1 Data; class student* next;///指向下一个位置的指针 }; class teacher { public: class data2 Data; class teacher* next;//指向下一个位置的指针 }; class List1//学生端 { public: class student* head; }; class List2//老师端,这样更方便记录信息 { public: class teacher* head; }; class List1 *L1;//第一个学生 class List2 *L2;//第一个老师 List1* add_stu(class student* p, class List1* L);//学生信息添加 名字,学号,初始化学生信息 List2* add_tea(class teacher* p, class List2* L);//初始化老师信息 int find_ID(class student* p1, class teacher* p2, class List1* L_1, class List2* L_2); bool save1(List1* p1); bool save2(List2* p2); void read(class List1* p1, class List2* p2); void Pregister(); void Plog(); void PMAIN(); student* find_stuID(List1* L, char* num); void Pstudent(student* stu);//学生端界面 void Pstudent_qiandao(student* stu);//签到 void Pstudent_chengji(student* stu);//学生成绩 void Pstudent_paiming(student* stu);//排名功能 void Pstudent_huojiang(student* stu);//获奖情况 void Pstudent_xuexi(student* stu);//学习资料 void Pstudent_kebiao(student* stu);//课表查看 void Pstudent_chufen(student* stu);//处分信息 void Pteacher(teacher* tea); void Pteacher_GCJ(teacher* tea); void Pteacher_GHJ(teacher* tea); void Pteacher_KPM(teacher* tea); void Pteacher_GMA(teacher* tea); void Pteacher_CKQD(teacher* tea); void Pteacherr_GCF(teacher* tea); student* find_student(student* stu, List1* L); teacher* find_teacher(teacher* tea, List2* L); void add_huojiang(huojiang* hj, student* L); int main() { GetLocalTime(&st); srand((int)time(NULL)); randnum = rand(); L1 = (List1*)malloc(sizeof(List1)); L1->head = NULL; L2 = (List2*)malloc(sizeof(List2)); L2->head = NULL; read(L1, L2);//读取文件 initgraph(X, Y); HD=GetHWnd(); mciSendString(_T("open bkmusic.mp3 alias music"), NULL, 0, NULL); mciSendString(_T("play music repeat"), NULL, 0, NULL); PMAIN(); system("pause"); return 0; } void add_huojiang(huojiang* hj,student* L)//学生获奖信息添加 用于初始化 { for (int i = 0; i < hj->loc && L->Data.hjxinxi.loc < 10 && i < 10; ++i) { strcpy_s(L->Data.hjxinxi.name[L->Data.hjxinxi.loc++], hj->name[i]); } return ; } void add_chufen(chufen* cf, student* L)//添加学生处分信息 用于初始化时 { for (int i = 0; i < cf->loc&&i<10&&L->Data.cfxinxi.loc<10; ++i) { strcpy_s(L->Data.cfxinxi.name[L->Data.cfxinxi.loc++], cf->name[i]); } return ; } List1* add_stu(student* p, List1* L)//学生信息添加 名字,学号,初始化学生信息 { student* temp = (student*)malloc(sizeof(student)); ::memset(temp, 0, sizeof(temp)); ::memset(temp->Data.cfxinxi.name, 0, sizeof(temp->Data.cfxinxi.name)); ::memset(temp->Data.hjxinxi.name, 0, sizeof(temp->Data.hjxinxi.name)); ::memset(&temp->Data.all_kemu, 0, sizeof(temp->Data.all_kemu)); ::memset(temp->Data.kebiao, 0, sizeof(temp->Data.kebiao)); temp->Data.cfxinxi.loc = 0; temp->Data.all_kemu.score = 0; temp->next = NULL; temp->Data.hjxinxi.loc = 0;//获奖 temp->Data.lastqiandao = p->Data.lastqiandao;//签到信息,每次登录都会重新置为0,别问为什么,问就是不会实时更新。°(°¯᷄◠¯᷅°)°。 GetLocalTime(&st); if (temp->Data.lastqiandao == (st.wYear * 365 + st.wMonth * 30 + st.wDay)) { temp->Data.qiandao = 1; } else { temp->Data.qiandao = 0; } if (*p->Data.ID != '\0') strcpy_s(temp->Data.ID, (p->Data.ID));//拷贝学生ID if (*p->Data.name != '\0') strcpy_s(temp->Data.name, (p->Data.name));//拷贝学生名字 if (*p->Data.mima != '\0') strcpy_s(temp->Data.mima, (p->Data.mima));//拷贝学生密码 if (p->Data.cfxinxi.loc)//拷贝处分信息 { add_chufen(&p->Data.cfxinxi, temp); } if (p->Data.hjxinxi.loc)//拷贝获奖信息 { add_huojiang(&p->Data.hjxinxi, temp); } //成绩录入 temp->Data.all_kemu.yuwen = p->Data.all_kemu.yuwen; temp->Data.all_kemu.shuxue = p->Data.all_kemu.shuxue; temp->Data.all_kemu.yingyu = p->Data.all_kemu.yingyu; temp->Data.all_kemu.wuli = p->Data.all_kemu.wuli; temp->Data.all_kemu.huaxue = p->Data.all_kemu.huaxue; temp->Data.all_kemu.Cyuyan = p->Data.all_kemu.Cyuyan; temp->Data.all_kemu.score = p->Data.all_kemu.score;//p->Data.all_kemu.yuwen + p->Data.all_kemu.shuxue + p->Data.all_kemu.yingyu + p->Data.all_kemu.wuli + p->Data.all_kemu.huaxue + p->Data.all_kemu.Cyuyan; //课表读取 for (int i = 0; i < 25; ++i) { strcpy_s(temp->Data.kebiao[i], p->Data.kebiao[i]); } student* pp = L->head; if (pp!=NULL)//如果已有多个学生信息 { while (pp->next)//找到指针末尾 pp = pp->next; pp->next = temp; } else//如果为第一个学生 { L->head = temp; } return L; } List2* add_tea( teacher* p,List2* L)//初始化老师信息 { teacher* temp =(teacher*)malloc(sizeof(teacher)); temp->next = NULL; if(*p->Data.ID!='\0') strcpy_s(temp->Data.ID, p->Data.ID);//拷贝ID if (*p->Data.mima != '\0') strcpy_s(temp->Data.mima, p->Data.mima);//拷贝密码 if (*p->Data.name != '\0') strcpy_s(temp->Data.name, p->Data.name);//拷贝名字 teacher* pp = L->head; if (pp) { while (pp->next) pp = pp->next; pp->next = temp; } else L->head = temp; return L; } bool save1( List1* p1 ) { student* pp1; FILE* fp1 = NULL; fp1 = fopen("student.txt", "wb"); for (pp1 = p1->head; pp1 != NULL; pp1 = pp1->next) { fwrite(pp1, sizeof(student), 1, fp1); } fclose(fp1); return true; } bool save2(List2* p2) { teacher* pp2; FILE* fp2 = NULL; fp2= fopen("teacher.txt", "wb"); if (fp2 == NULL) { printf("kk"); } for (pp2 = p2->head; pp2 != NULL; pp2 = pp2->next) { fwrite(pp2, sizeof(teacher),1, fp2); } fclose(fp2); return true; } void read( List1* p1, List2* p2) { student *s1=(student*)malloc(sizeof(student)); teacher *s2=(teacher*)malloc(sizeof(student)); chufen* cf1 = (chufen*)malloc(sizeof(chufen)); ::memset(cf1->name, 0, sizeof(cf1->name)); cf1->loc = 0; ::memset(s1->Data.cfxinxi.name, 0, sizeof(s1->Data.cfxinxi.name)); s1->Data.cfxinxi.loc = 0; FILE* fp1 = NULL; FILE* fp2 = NULL; fp1=fopen("student.txt", "rb"); if (fp1 == NULL) { fp1=fopen("student.txt", "wb"); goto out1; } while(fread(s1, sizeof(student), 1, fp1)) { L1 = add_stu(s1, p1); } out1: fclose(fp1); fp2=fopen("teacher.txt", "rb"); if (fp2 == NULL) { fopen( "teacher.txt", "wb"); return; } while(fread(s2, sizeof(teacher), 1, fp2)!=0) { L2=add_tea(s2, p2); } fclose(fp2); } void Pteacher(teacher *tea) { cleardevice(); IMAGE pmain;//登录注册界面 IMAGE tx1, tx2; loadimage(&tx1, L"tx1.jpg", 200, 300); loadimage(&tx2, L"tx2.jpg", 200, 300); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); putimage(1000, 0, &tx1); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(370, 100, L"西柚信息管理教师端"); rectangle(1000, 0, 1200, 300);//头像 rectangle(500, 200, 800, 250);//修改学生成绩 rectangle(500, 300, 800, 350);//修改学生获奖 rectangle(500, 400, 800, 450);//查看学生排名 rectangle(500, 500, 800, 550);//查看学生签到 rectangle(500, 600, 800, 650);//全校学生通知 rectangle(500, 700, 800, 750);//修改学生处分 rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑");//选项信息字体格式 outtextxy(5, 5, L"返回");//返回 outtextxy(520, 205, L"修改学生成绩");//修改学生成绩 outtextxy(520, 305, L"修改学生获奖");//修改学生获奖 outtextxy(520, 405, L"查看学生排名");//查看学生排名 outtextxy(520, 505, L"查看学生签到");//查看学生签到 outtextxy(520, 605, L"修改学生密码");//全校学生通知 outtextxy(520, 705, L"修改学生处分");//修改学生处分 outtextxy(100, 100, CString(tea->Data.name)); settextstyle(30, 15, L"微软雅黑");// rectangle(1100, 750, 1199, 799);//退出程序框 outtextxy(1120, 760, L"退出");//退出程序 MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 500 && mg.x < 800) { if (mg.y > 200 && mg.y < 250 && mg.uMsg == WM_LBUTTONUP)//修改学生成绩的范围 { Pteacher_GCJ(tea); } else if (mg.y > 300 && mg.y < 350 && mg.uMsg == WM_LBUTTONUP)//修改学生获奖的范围 { Pteacher_GHJ(tea); } else if (mg.y > 400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//查看学生排名的范围 { Pteacher_KPM(tea); } else if (mg.y > 500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//查看学生签到的范围 { Pteacher_CKQD(tea); } else if (mg.y > 600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//全校学生通知的范围 { Pteacher_GMA(tea); } else if (mg.y > 700 && mg.y < 750 && mg.uMsg == WM_LBUTTONUP)//修改学生处分的范围 { Pteacherr_GCF(tea); } } else if (mg.x > 1100 && mg.x < 1200 && mg.y > 750 && mg.y < 800 && mg.uMsg == WM_LBUTTONUP) { save1(L1); save2(L2); exit(0); } else if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { PMAIN(); } } } void Pstudent(student* stu) { cleardevice(); IMAGE pmain;//背景 IMAGE tx1,tx2; loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); //loadimage(&tx2, L"tx2.jpg", 200, 300); loadimage(&tx1, L"tx1.jpg", 200, 300); //putimage(1000, 0, &tx2, NOTSRCERASE); putimage(1000, 0, &tx1);// , SRCINVERT); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(370, 100, L"西柚信息管理学生端"); rectangle(1000, 0, 1200, 300);//头像 rectangle(1100, 300, 1200, 350);//签到按钮 rectangle(500, 200, 700, 250);//成绩查看 rectangle(500, 300, 700, 350);//排名查看 rectangle(500, 400, 700, 450);//获奖情况查看 rectangle(500, 500, 700, 550);//学习资料推荐 rectangle(500, 600, 700, 650);//课表查看 rectangle(500, 700, 700, 750);//处分信息查看 rectangle(1100, 750, 1199, 799);//退出程序 rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回");//返回 settextstyle(30, 15, L"微软雅黑");//签到字体 outtextxy(1120, 310, L"签到");//签到 outtextxy(1120, 760, L"退出");//退出程序 settextstyle(40, 20, L"微软雅黑");//选项信息字体格式 outtextxy(520, 205, L"我的成绩");//我的成绩 outtextxy(520, 305, L"我的排名");//我的排名 outtextxy(520, 405, L"获奖情况");//获奖情况 outtextxy(520, 505, L"学习资料");//学习资料 outtextxy(520, 605, L"我的课表");//我的课表 outtextxy(520, 705, L"我的处分");//我的处分 outtextxy(100, 100, CString(stu->Data.name));//学生名字 if (stu->Data.qiandao) { settextstyle(20, 10, L"微软雅黑"); outtextxy(720, 400, CString(qiandaoyuji[randnum%20])); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 500 && mg.x < 700) { if (mg.y > 200 && mg.y < 250 && mg.uMsg == WM_LBUTTONUP)//我的成绩的范围 { Pstudent_chengji(stu); } else if (mg.y > 300 && mg.y < 350 && mg.uMsg == WM_LBUTTONUP)//我的排名的范围 { Pstudent_paiming(stu); } else if (mg.y > 400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//获奖情况的范围 { Pstudent_huojiang(stu); } else if (mg.y > 500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//学习资料的范围 { Pstudent_xuexi(stu); } else if (mg.y > 600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//我的课表的范围 { Pstudent_kebiao(stu); } else if (mg.y > 700 && mg.y < 750 && mg.uMsg == WM_LBUTTONUP)//我的处分的范围 { Pstudent_chufen(stu); } } else if (mg.x > 1100 && mg.x < 1200)//签到的范围 { if (mg.y > 300 && mg.y < 350 && mg.uMsg == WM_LBUTTONUP) { Pstudent_qiandao(stu); } else if (mg.y > 750 && mg.y < 800 && mg.uMsg == WM_LBUTTONUP) { save1(L1); save2(L2); exit(0); } } else if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50&&mg.uMsg==WM_LBUTTONUP) { PMAIN(); } } } void Pstudent_qiandao(student* stu)//签到 { if (stu->Data.qiandao) { MessageBox(HD, L"已经签到过啦>_<", L"签到信息", MB_OK); } else { stu->Data.qiandao = 1; GetLocalTime(&st); stu->Data.lastqiandao = st.wYear * 365 + st.wMonth * 30 + st.wDay; MessageBox(HD, L"签到成功 ◍'ㅅ'◍ ♡", L"签到信息", MB_OK); settextstyle(20, 10, L"微软雅黑"); outtextxy(800, 400, CString(qiandaoyuji[randnum % 20])); } } void Pstudent_chengji(student* stu)//学生成绩 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); char ch[30]; settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的成绩 o(*≧▽≦)ツ"); settextstyle(40, 20, L"微软雅黑"); outtextxy(360, 150, L"我的语文成绩:"); outtextxy(360, 200, L"我的数学成绩:"); outtextxy(360, 250, L"我的英语成绩:"); outtextxy(360, 300, L"我的化学成绩:"); outtextxy(360, 350, L"我的物理成绩:"); outtextxy(360, 400, L"我的C语言成绩:"); if (stu->Data.all_kemu.yuwen < 60) settextcolor(RED); else if (stu->Data.all_kemu.yuwen < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.yuwen); outtextxy(700, 150, CString(ch)); if (stu->Data.all_kemu.shuxue < 60) settextcolor(RED); else if (stu->Data.all_kemu.shuxue < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.shuxue); outtextxy(700, 200, CString(ch)); if (stu->Data.all_kemu.yingyu < 60) settextcolor(RED); else if (stu->Data.all_kemu.yingyu < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.yingyu); outtextxy(700, 250, CString(ch)); if (stu->Data.all_kemu.huaxue < 60) settextcolor(RED); else if (stu->Data.all_kemu.huaxue < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.huaxue); outtextxy(700, 300, CString(ch)); if (stu->Data.all_kemu.wuli < 60) settextcolor(RED); else if (stu->Data.all_kemu.wuli < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.wuli); outtextxy(700, 350, CString(ch)); if (stu->Data.all_kemu.Cyuyan < 60) settextcolor(RED); else if (stu->Data.all_kemu.Cyuyan < 80) settextcolor(YELLOW); else settextcolor(GREEN); ::sprintf(ch, "%d", stu->Data.all_kemu.Cyuyan); outtextxy(700, 400, CString(ch)); settextcolor(WHITE); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_paiming(student* stu)//排名功能 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); char ch[30]; settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的排名 ︿( ̄︶ ̄)︿"); settextstyle(40, 20, L"微软雅黑"); outtextxy(360, 150, L"我的语文排名:"); outtextxy(360, 200, L"我的数学排名:"); outtextxy(360, 250, L"我的英语排名:"); outtextxy(360, 300, L"我的化学排名:"); outtextxy(360, 350, L"我的物理排名:"); outtextxy(360, 400, L"我的C语言排名:"); outtextxy(360, 450, L"我的总分排名:"); student* p = L1->head; int rank[7] = {1,1,1,1,1,1,1}; for (; p != NULL; p = p->next) { if (strcmp(stu->Data.ID, p->Data.ID)) { if (stu->Data.all_kemu.yuwen < p->Data.all_kemu.yuwen) rank[0]++; if (stu->Data.all_kemu.shuxue < p->Data.all_kemu.shuxue) rank[1]++; if (stu->Data.all_kemu.yingyu < p->Data.all_kemu.huaxue) rank[2]++; if (stu->Data.all_kemu.wuli < p->Data.all_kemu.wuli) rank[3]++; if (stu->Data.all_kemu.huaxue < p->Data.all_kemu.huaxue) rank[4]++; if (stu->Data.all_kemu.Cyuyan < p->Data.all_kemu.Cyuyan) rank[5]++; if (stu->Data.all_kemu.score < p->Data.all_kemu.score) rank[6]++; } } for (int i = 150, j = 0; j < 7;i+=50, ++j) { ::sprintf(ch, "%d", rank[j]); outtextxy(700, i, CString(ch)); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50&&mg.uMsg== WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_huojiang(student* stu)//获奖情况 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的获奖 <( ̄︶ ̄)>"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); for (int high = 100, i = 0; i < stu->Data.hjxinxi.loc; i++, high += 50) { if (*stu->Data.hjxinxi.name[i] != '\0') outtextxy(300, high, CString(stu->Data.hjxinxi.name[i])); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_xuexi(student* stu)//学习资料 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"西柚信息学习资料"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); outtextxy(100, 150, L"学习网址推荐"); outtextxy(700, 150, L"学习书籍推荐"); settextstyle(30, 15, L"微软雅黑");//网址和书籍字体 //网址推荐 outtextxy(100, 200, L"www.cnblogs.com/YHH520/");//我的博客 outtextxy(100, 250, L"www.nowcoder.com");//牛客 outtextxy(100, 300, L"www.icourse163.org");//Mooc outtextxy(100, 350, L"www.luogu.com.cn");//洛谷 outtextxy(100, 400, L"github.com");//github outtextxy(100, 450, L"leetcode-cn.com");//leetcode outtextxy(100, 500, L"47.94.129.140/ //西柚的练习网址");//SWPUACM outtextxy(100, 550, L"www.bilibili.com");//B站 //书籍推荐 outtextxy(700, 200, L"C Primer Plus"); outtextxy(700, 250, L"数据结构"); outtextxy(700, 300, L"计算机组成原理"); outtextxy(700, 350, L"挑战程序设计竞赛"); outtextxy(700, 400, L"算法竞赛入门经典"); outtextxy(700, 450, L"算法导论"); outtextxy(700, 500, L"编程之美"); outtextxy(700, 550, L"剑指Offer"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pstudent_kebiao(student* stu)//课表查看 { cleardevice(); IMAGE pmain;//主界面图片 wchar_t key1[20]; char key2[20]; loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(400, 50, L"我的课表"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); outtextxy(220, 250, L"星期一"); outtextxy(420, 250, L"星期二"); outtextxy(620, 250, L"星期三"); outtextxy(820, 250, L"星期四"); outtextxy(1020, 250, L"星期五"); outtextxy(30, 330, L"早自习"); outtextxy(30, 490, L"上午"); outtextxy(30, 690, L"下午"); for (int i = 300; i < 799; i += 100) { line(200, i, 1200, i); } for (int i = 200; i < 1199; i += 200) { line(i, 300, i, 800); } line(200, 799, 1200, 799); line(1199, 300, 1199, 799); for (int i = 0,n=300; i < 5; ++i,n+=100) { for (int j = 0,m=200; j < 5; ++j,m+=200) { outtextxy(m+20, n+20, CString(stu->Data.kebiao[i * 5 + j])); } } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } else if (mg.y>300 && mg.y < 400 )//第一行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 301)); clearrectangle(200, 300, 400, 400); rectangle(200, 300, 400, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[0], key2); outtextxy(220, 320, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 301)); clearrectangle(400, 300, 600, 400); rectangle(400, 300, 600, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[1], key2); outtextxy(420, 320, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 301)); clearrectangle(600, 300, 800, 400); rectangle(600, 300, 800, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[2], key2); outtextxy(620, 320, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 301)); clearrectangle(800, 300, 1000, 400); rectangle(800, 300, 1000, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[3], key2); outtextxy(820, 320, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 301)); clearrectangle(1000, 300, 1200, 400); rectangle(1000, 300, 1199, 400); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[4], key2); outtextxy(1020, 320, CString(key2)); save1(L1); } } else if (mg.y > 400 && mg.y < 500)//第二行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 401)); clearrectangle(200, 400, 400, 500); rectangle(200, 400, 400, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[5], key2); outtextxy(220, 420, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 401)); clearrectangle(400, 400, 600, 500); rectangle(200, 400, 400, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[6], key2); outtextxy(420, 420, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 401)); clearrectangle(600, 400, 800, 500); rectangle(600, 400, 800, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[7], key2); outtextxy(620, 420, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 401)); clearrectangle(800, 400, 1000, 500); rectangle(800, 400, 1000, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[8], key2); outtextxy(820, 420, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 401)); clearrectangle(1000, 400, 1200, 500); rectangle(1000, 400, 1200, 500); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[9], key2); outtextxy(1020, 420, CString(key2)); save1(L1); } } else if (mg.y > 500 && mg.y < 600 )//第三行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 501)); clearrectangle(200, 500, 400, 600); rectangle(200, 500, 400, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[10], key2); outtextxy(220, 520, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 501)); clearrectangle(400, 500, 600, 600); rectangle(400, 500, 600, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[11], key2); outtextxy(420, 520, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 501)); clearrectangle(600, 500, 800, 600); rectangle(600, 500, 400, 800); InputBox(key1,5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[12], key2); outtextxy(620, 520, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 501)); clearrectangle(800, 500, 1000, 600); rectangle(800, 500, 1000, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[13], key2); outtextxy(820, 520, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 501)); clearrectangle(1000, 500, 1200, 600); rectangle(1000, 500, 1200, 600); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[14], key2); outtextxy(1020, 520, CString(key2)); save1(L1); } } else if (mg.y > 600 && mg.y < 700)//第四行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 601)); clearrectangle(200, 600, 400, 700); rectangle(200, 600, 400, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[15], key2); outtextxy(220, 620, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 601)); clearrectangle(400, 600, 600, 700); rectangle(400, 600, 600, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[16], key2); outtextxy(420, 620, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 601)); clearrectangle(600, 600, 800, 700); rectangle(600, 600, 800, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[17], key2); outtextxy(620, 620, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 601)); clearrectangle(800, 600, 1000, 700); rectangle(800, 600, 1000, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[18], key2); outtextxy(820, 620, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 601)); clearrectangle(1000, 600, 1200, 700); rectangle(1000, 600, 1200, 700); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[19], key2); outtextxy(1020, 620, CString(key2)); save1(L1); } } else if (mg.y > 700 && mg.y < 800 )//第五行 { if (mg.x > 200 && mg.x < 400 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(201, 701)); clearrectangle(200, 700, 400, 800); rectangle(200, 700, 400, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[20], key2); outtextxy(220, 720, CString(key2)); save1(L1); } else if (mg.x > 400 && mg.x < 600 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(401, 701)); clearrectangle(400, 700, 600, 800); rectangle(400, 700, 600, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[21], key2); outtextxy(420, 720, CString(key2)); save1(L1); } else if (mg.x > 600 && mg.x < 800 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 701)); clearrectangle(600, 700, 800, 800); rectangle(600, 700, 800, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[22], key2); outtextxy(620, 720, CString(key2)); save1(L1); } else if (mg.x > 800 && mg.x < 1000 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 701)); clearrectangle(800, 700, 1000, 800); rectangle(800, 700, 1000, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[23], key2); outtextxy(820, 720, CString(key2)); save1(L1); } else if (mg.x > 1000 && mg.x < 1200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(1001, 701)); clearrectangle(1000, 700, 1199, 800); rectangle(1000, 700, 1199, 799); InputBox(key1, 5, L"请输入学科"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); strcpy_s(stu->Data.kebiao[24], key2); outtextxy(1020, 720, CString(key2)); save1(L1); } } } } void Pstudent_chufen(student* stu)//处分信息 { cleardevice(); IMAGE pmain;//主界面图片 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"我的处分信息"); settextstyle(40, 20, L"微软雅黑"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); //chufen* p = stu->Data.cfxinxi.next; for (int high=100,i=0; i< stu->Data.cfxinxi.loc; i++,high+=50) { if(*stu->Data.cfxinxi.name[i]!='\0') outtextxy(300, high, CString(stu->Data.cfxinxi.name[i])); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pstudent(stu); } } } void Pteacher_GCJ(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// wchar_t key1[10]; char key2[10]; student* temp=NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 200, 880, 250);//学生学号输入窗口 rectangle(920, 200, 1020, 250); for (int i = 400; i < 700; i += 100) { rectangle(450, i, 550, i+50); } for (int i = 400; i < 700; i += 100) { rectangle(850, i, 950, i + 50); } settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 50, L"修改学生成绩"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 200, L"学生学号:"); outtextxy(350, 300, L"学生信息:"); outtextxy(300, 400, L"语文:"); outtextxy(300, 500, L"数学:"); outtextxy(300, 600, L"英语:"); outtextxy(700, 400, L"物理:"); outtextxy(700, 500, L"化学:"); outtextxy(700, 600, L"C语言:"); outtextxy(930, 205, L"确定"); rectangle(0, 0, 100, 50); outtextxy(5, 5, L"返回"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.y > 200 && mg.y < 250) { if (mg.x > 550 && mg.x < 880 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(601, 201)); clearrectangle(550, 200, 880, 250); rectangle(550, 200, 880, 250); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 210, xuehao); } else if (mg.x > 920 && mg.x < 1020 && mg.uMsg == WM_LBUTTONUP) { if (*xuehao2 != '\0') { temp = find_stuID(L1, xuehao2); if (temp) { char fenshu[15]; for (int i = 400; i < 700; i += 100) { setbkcolor(getpixel(451, i + 1)); clearrectangle(450, i, 550, i + 50); rectangle(450, i, 550, i + 50); } for (int i = 400; i < 700; i += 100) { setbkcolor(getpixel(851, i + 1)); clearrectangle(850, i, 950, i + 50); rectangle(850, i, 950, i + 50); } outtextxy(560, 305, CString(temp->Data.name)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.yuwen); outtextxy(460, 405, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.shuxue); outtextxy(460, 505, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.yingyu); outtextxy(460, 605, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.wuli); outtextxy(860, 405, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.huaxue); outtextxy(860, 505, CString(fenshu)); ::sprintf(fenshu, "%d", temp->Data.all_kemu.Cyuyan); outtextxy(860, 605, CString(fenshu)); save1(L1); } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息",MB_OK); } } } else if (mg.x > 450 && mg.x < 550 && mg.y>400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//语文成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(451, 401)); clearrectangle(450, 400, 550, 450); rectangle(450, 400, 550, 450); InputBox(key1, 4, L"请输入学生语文成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(460, 405, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.yuwen; temp->Data.all_kemu.yuwen = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 450 && mg.x < 550 && mg.y>500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//数学成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(451, 551)); clearrectangle(450, 500, 550, 550); rectangle(450, 500, 550, 550); InputBox(key1, 4, L"请输入学生数学成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(460, 505, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.shuxue; temp->Data.all_kemu.shuxue = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 450 && mg.x < 550 && mg.y>600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//英语成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(451, 601)); clearrectangle(450, 600, 550, 650); rectangle(450, 600, 550, 650); InputBox(key1, 4, L"请输入学生英语成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(460, 605, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.yingyu; temp->Data.all_kemu.yingyu = atoi(key2); save1(L1); } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 850 && mg.x < 950 && mg.y>400 && mg.y < 450 && mg.uMsg == WM_LBUTTONUP)//物理成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(851, 401)); clearrectangle(850, 400, 950, 450); rectangle(850, 400, 950, 450); InputBox(key1, 4, L"请输入学生物理成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(860, 405, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.wuli; temp->Data.all_kemu.wuli = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 850 && mg.x < 950 && mg.y>500 && mg.y < 550 && mg.uMsg == WM_LBUTTONUP)//化学成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(851, 501)); clearrectangle(850, 500, 950, 550); rectangle(850, 500, 950, 550); InputBox(key1, 4, L"请输入学生成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(860, 505, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.huaxue; temp->Data.all_kemu.huaxue = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.x > 850 && mg.x < 950 && mg.y>600 && mg.y < 650 && mg.uMsg == WM_LBUTTONUP)//C语言成绩 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(851, 601)); clearrectangle(850, 600, 950, 650); rectangle(850, 600, 950, 650); InputBox(key1, 4, L"请输入学生C语言成绩 ヾ(´∀`o)+"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(860, 605, key1); temp->Data.all_kemu.score += atoi(key2) - temp->Data.all_kemu.Cyuyan; temp->Data.all_kemu.Cyuyan = atoi(key2); save1(L1); } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } } } void Pteacher_GHJ(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// wchar_t key1[100]; char key2[100]; student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 120, 880, 170);//学生学号输入窗口 rectangle(920, 120, 1020, 170); rectangle(0, 0, 100, 50); rectangle(500, 300, 950, 350);//1 rectangle(500, 400, 950, 450);//2 rectangle(500, 500, 950, 550);//3 rectangle(500, 600, 950, 650);//4 rectangle(500, 700, 950, 750);//5 settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 40, L"修改学生获奖"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 120, L"学生学号:"); outtextxy(350, 200, L"学生信息:"); outtextxy(930, 125, L"确定"); for (int i = 300; i <= 700; i += 100) { outtextxy(300, i, L"获奖信息:"); } outtextxy(5, 5, L"返回"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 550 && mg.x < 880 && mg.y>120 && mg.y < 170&&mg.uMsg==WM_LBUTTONUP)//学号输入框 { setbkcolor(getpixel(601, 201)); clearrectangle(550, 120, 880, 170); rectangle(550, 120, 880, 170); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 130, xuehao); } else if (mg.y > 120 && mg.y < 170 && mg.x > 920 && mg.x < 1020 && mg.uMsg == WM_LBUTTONUP)//确认按钮 { if (*xuehao2 != '\0') { temp = find_stuID(L1, xuehao2); if (temp) { outtextxy(550, 200, CString(temp->Data.name)); for (int i = 0,j=305; i < 5; ++i,j+=100) { outtextxy(510, j, CString(temp->Data.hjxinxi.name[i])); } } else { MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } } else MessageBox(HD, L"没有该学生的信息\n请检查学号是否正确(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 300 && mg.y < 350 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//1 { if (temp) { setbkcolor(getpixel(501, 301)); clearrectangle(500, 300, 950, 350); rectangle(500, 300, 950, 350); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 305, key1); strcpy(temp->Data.hjxinxi.name[0], key2); temp->Data.hjxinxi.loc = 1; save1(L1); } else { MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } } else if (mg.y > 400 && mg.y < 450 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//2 { if (temp) { setbkcolor(getpixel(501, 401)); clearrectangle(500, 400, 950, 450); rectangle(500, 400, 950, 450); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 405, key1); strcpy(temp->Data.hjxinxi.name[1], key2); temp->Data.hjxinxi.loc = 2; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 500 && mg.y < 550 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//3 { if (temp) { setbkcolor(getpixel(501, 501)); clearrectangle(500, 500, 950, 550); rectangle(500, 500, 950, 550); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 505, key1); strcpy(temp->Data.hjxinxi.name[2], key2); temp->Data.hjxinxi.loc = 3; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 600 && mg.y < 650 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//4 { if (temp) { setbkcolor(getpixel(501, 601)); clearrectangle(500, 600, 950, 650); rectangle(500, 600, 950, 650); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 605, key1); strcpy(temp->Data.hjxinxi.name[3], key2); temp->Data.hjxinxi.loc = 4; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 700 && mg.y < 750 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//5 { if (temp) { setbkcolor(getpixel(501, 701)); clearrectangle(500, 700, 950, 750); rectangle(500, 700, 950, 750); InputBox(key1, 20, L"请输入学生获奖情况"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 705, key1); strcpy(temp->Data.hjxinxi.name[4], key2); temp->Data.hjxinxi.loc = 5; save1(L1); } else MessageBox(HD, L"请先输入正确学生学号(>﹏<)", L"查找学生信息", MB_OK); } } } void Pteacher_KPM(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 priority_queue<pair<int, const char*> >q; student* p=L1->head; for (; p; p = p->next) { q.push({ p->Data.all_kemu.score,p->Data.name }); } wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// char key2[100]; student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(800, 150, 1199, 200);//学生学号输入窗口 rectangle(1100, 200, 1199, 250);//确认按钮 rectangle(0, 0, 100, 50); settextstyle(50, 30, L"微软雅黑"); outtextxy(400, 40, L"查看学生排名"); settextcolor(GREEN); outtextxy(200, 100, L"前五名学生"); settextcolor(WHITE); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回"); outtextxy(800, 100, L"查找学生排名"); outtextxy(680, 150, L"学号:"); outtextxy(1110, 210, L"确定"); outtextxy(680, 300, L"学生信息:"); outtextxy(680, 400, L"语文排名 :"); outtextxy(680, 450, L"数学排名 :"); outtextxy(680, 500, L"英语排名 :"); outtextxy(680, 550, L"物理排名 :"); outtextxy(680, 600, L"化学排名 :"); outtextxy(680, 650, L"C语言排名:"); outtextxy(680, 700, L"总分排名 :"); for (int i = 0,j=200; i < 5 && q.size(); ++i,j+=100, q.pop()) { sprintf(key2, "%d", q.top().first); outtextxy(200, j,CString(key2) ); outtextxy(300, j, CString(q.top().second)); } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 800 && mg.x < 1200 && mg.y>150 && mg.y < 200 && mg.uMsg == WM_LBUTTONUP) { setbkcolor(getpixel(801, 151)); clearrectangle(800, 150, 1200, 200); rectangle(800, 150, 1200, 200); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(810, 160, xuehao); } else if (mg.x > 1100 && mg.x < 1200 && mg.y>200 && mg.y < 250 && mg.uMsg == WM_LBUTTONUP) { if (*xuehao2) { temp = find_stuID(L1, xuehao2); if (temp) { setbkcolor(getpixel(801, 151)); clearrectangle(890,290,1100,350 ); outtextxy(900, 300, CString(temp->Data.name)); char ch[10]; memset(ch, 0, sizeof(ch)); int rank[7] = { 1,1,1,1,1,1,1 }; for (p = L1->head; p != NULL; p = p->next) { if (strcmp(temp->Data.ID, p->Data.ID)) { if (temp->Data.all_kemu.yuwen < p->Data.all_kemu.yuwen) rank[0]++; if (temp->Data.all_kemu.shuxue < p->Data.all_kemu.shuxue) rank[1]++; if (temp->Data.all_kemu.yingyu < p->Data.all_kemu.huaxue) rank[2]++; if (temp->Data.all_kemu.wuli < p->Data.all_kemu.wuli) rank[3]++; if (temp->Data.all_kemu.huaxue < p->Data.all_kemu.huaxue) rank[4]++; if (temp->Data.all_kemu.Cyuyan < p->Data.all_kemu.Cyuyan) rank[5]++; if (temp->Data.all_kemu.score < p->Data.all_kemu.score) rank[6]++; } } for (int i = 410, j = 0; j < 7; i += 50, ++j) { ::sprintf(ch, "%d", rank[j]); setbkcolor(getpixel(901, i)); clearrectangle(900, i - 10, 1000, i + 50); outtextxy(910, i, CString(ch)); } } else { MessageBox(HD, L"未找到该学生信息=_=", L"学号输入信息", MB_OK); } } else { MessageBox(HD, L"请先输入学号=_=", L"学号输入信息", MB_OK); } } } } void Pteacher_GMA(teacher* tea) { cleardevice(); IMAGE pmain;//背景图 student* stu=NULL; wchar_t xuehao1[25]; char xuehao2[25]; wchar_t mima1[25]; char mima2[25]; memset(mima1, 0, sizeof(mima1)); memset(mima2, 0, sizeof(mima2)); memset(xuehao1, 0, sizeof(xuehao1)); memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(400, 200, L"学生密码修改"); rectangle(0, 0, 100, 50); rectangle(900, 350, 1000, 400);//确定 rectangle(500, 350, 900, 400); rectangle(500, 450, 900, 500); rectangle(500, 550, 900, 600); rectangle(500, 650, 900, 700); rectangle(650, 750, 850, 799); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回"); outtextxy(200, 350, L"学号:"); outtextxy(200, 450, L"学生信息:"); outtextxy(200, 550, L"原密码:"); outtextxy(200, 650, L"新密码:"); outtextxy(910, 355, L"确定"); outtextxy(660, 755, L"确定修改"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 500 && mg.x < 900 && mg.y>350 && mg.y < 400 && mg.uMsg == WM_LBUTTONUP)//学号输入 { setbkcolor(getpixel(501, 351)); clearrectangle(500, 350, 900, 400); rectangle(500, 350, 900, 400); InputBox(xuehao1, 13, L"请输入学号"); WideCharToMultiByte(CP_ACP, 0, xuehao1, -1, xuehao2, wcslen(xuehao1) * 2 + 1, NULL, NULL); outtextxy(510, 355, xuehao1); } else if (mg.x > 900 && mg.x < 1000 && mg.y>350 && mg.y < 400 && mg.uMsg == WM_LBUTTONUP)//确定按钮 { if (*xuehao2) { stu = find_stuID(L1, xuehao2); if (stu) { setbkcolor(getpixel(501, 451)); clearrectangle(500, 450, 900, 500); rectangle(500, 450, 900, 500); outtextxy(510, 455, CString(stu->Data.name)); setbkcolor(getpixel(501, 551)); clearrectangle(500, 550, 900, 600); rectangle(500, 550, 900, 600); outtextxy(510, 555, CString(stu->Data.mima)); } else { MessageBox(HD, L"没有该学生信息哦", L"学生信息", MB_OK); } } else { MessageBox(HD, L"请先输入学生学号", L"学生信息", MB_OK); } } else if (mg.x > 500 && mg.x < 900 && mg.y>650 && mg.y < 700 && mg.uMsg == WM_LBUTTONUP)//新密码输入框 { if (*xuehao2) { if (stu) { setbkcolor(getpixel(501, 651)); clearrectangle(500, 650, 900, 700); rectangle(500, 650, 900, 700); InputBox(mima1, 13, L"请输入新密码"); WideCharToMultiByte(CP_ACP, 0, mima1, -1, mima2, wcslen(mima1) * 2 + 1, NULL, NULL); outtextxy(510, 655, mima1); } else { MessageBox(HD, L"没有该学生信息哦", L"学生信息", MB_OK); } } else { MessageBox(HD, L"请先输入学生学号", L"学生信息", MB_OK); } } else if (mg.x > 650 && mg.x < 750 && mg.y>750 && mg.y < 799 && mg.uMsg == WM_LBUTTONUP)//确当修改框 { if (*xuehao2) { if (stu) { strcpy_s(stu->Data.mima, mima2); save1(L1); MessageBox(HD, L"学生密码修改成功", L"学生信息", MB_OK); } else { MessageBox(HD, L"没有该学生信息哦", L"学生信息", MB_OK); } } else { MessageBox(HD, L"请先输入学生学号", L"学生信息", MB_OK); } } } } void Pteacher_CKQD(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 120, 870, 170);//学生学号输入窗口 rectangle(870, 120, 970, 170); rectangle(0, 0, 100, 50); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 40, L"查看学生签到情况"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 120, L"学生学号:"); outtextxy(350, 200, L"学生信息:"); outtextxy(880, 125, L"确定"); outtextxy(5, 5, L"返回"); int tol_renshu=0,tol_qiandaoshu=0;//tol_renshu是总人数,tol_qiandaoshu是签到的人数 char tol_RS[10], tol_QDRS[10]; student* p = L1->head; for (; p; p = p->next) { if (p->Data.qiandao) ++tol_qiandaoshu; ++tol_renshu; } ::sprintf(tol_RS, "%d",tol_renshu); ::sprintf(tol_QDRS, "%d", tol_qiandaoshu); outtextxy(100, 300, L"学生总人数:"); outtextxy(100, 400, L"签到的学生数目:"); outtextxy(450, 300, CString(tol_RS)); outtextxy(450, 400, CString(tol_QDRS)); outtextxy(600, 300, L"未签到学生:"); outtextxy(850, 200, L"签到情况:"); p = L1->head; for (int j=350,i=600; p; p = p->next) { if (j > 800) { j = 350; i += 200; } if (!p->Data.qiandao) { settextcolor(RED); outtextxy(i, j, CString(p->Data.name));//输出未签到的名字 j += 50; settextcolor(WHITE); } } MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 550 && mg.x < 870 && mg.y>120 && mg.y < 170&&mg.uMsg==WM_LBUTTONUP) { setbkcolor(getpixel(551, 121)); clearrectangle(550, 120, 870, 170); rectangle(550, 120, 870, 170); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 130, xuehao); } else if (mg.x > 850 && mg.x < 970 && mg.y>120 && mg.y < 170 && mg.uMsg == WM_LBUTTONUP) { if (*xuehao2) { temp = find_stuID(L1, xuehao2); if (temp) { if (temp->Data.qiandao) { setbkcolor(getpixel(601, 201)); clearrectangle(540, 200, 750, 240); outtextxy(550, 200, CString(temp->Data.name)); setbkcolor(getpixel(1051, 201)); clearrectangle(1040, 200, 1199, 240); settextcolor(GREEN); outtextxy(1050, 200, L"已签到"); settextcolor(WHITE); } else { setbkcolor(getpixel(601, 201)); clearrectangle(540, 200, 750, 240); outtextxy(550, 200, CString(temp->Data.name)); setbkcolor(getpixel(1051, 201)); clearrectangle(1040, 200, 1199, 240); settextcolor(RED); outtextxy(1050, 200, L"未签到"); settextcolor(WHITE); } } else { MessageBox(HD, L"未找到该学生信息=_=", L"学号输入信息", MB_OK); } } else { MessageBox(HD, L"请先输入学号=_=", L"学号输入信息", MB_OK); } } } } void Pteacherr_GCF(teacher* tea) { cleardevice(); IMAGE pmain;//主界面图片 wchar_t xuehao[25];//读取输入信息 char xuehao2[25];// wchar_t key1[100]; char key2[100]; student* temp = NULL; ::memset(xuehao, 0, sizeof(xuehao)); ::memset(xuehao2, 0, sizeof(xuehao2)); loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); rectangle(550, 120, 870, 170);//学生学号输入窗口 rectangle(920, 120, 1020, 170); rectangle(0, 0, 100, 50); rectangle(500, 300, 950, 350);//1 rectangle(500, 400, 950, 450);//2 rectangle(500, 500, 950, 550);//3 rectangle(500, 600, 950, 650);//4 rectangle(500, 700, 950, 750);//5 settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 40, L"修改学生处分"); settextstyle(40, 20, L"微软雅黑"); outtextxy(350, 120, L"学生学号:"); outtextxy(350, 200, L"学生信息:"); outtextxy(930, 125, L"确定"); for (int i = 300; i <= 700; i += 100) { outtextxy(300, i, L"处分信息:"); } outtextxy(5, 5, L"返回"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg == WM_LBUTTONUP) { Pteacher(tea); } else if (mg.x > 550 && mg.x < 870 && mg.y>120 && mg.y < 170 && mg.uMsg == WM_LBUTTONUP)//学号输入框 { setbkcolor(getpixel(601, 201)); clearrectangle(550, 120, 870, 170); rectangle(550, 120, 870, 170); InputBox(xuehao, 13, L"请输入正确的学生学号哦(* ̄3 ̄)╭"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, xuehao2, wcslen(xuehao) * 2 + 1, NULL, NULL); outtextxy(560, 130, xuehao); } else if (mg.y > 120 && mg.y < 170 && mg.x > 920 && mg.x < 1020 && mg.uMsg == WM_LBUTTONUP)//确认按钮 { if (*xuehao2 != '\0') { temp = find_stuID(L1, xuehao2); if (temp) { outtextxy(550, 200, CString(temp->Data.name)); for (int i = 0, j = 305; i < 5; ++i, j += 100) { outtextxy(510, j, CString(temp->Data.cfxinxi.name[i])); } } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 300 && mg.y < 350 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//1 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 301)); clearrectangle(500, 300, 950, 350); rectangle(500, 300, 950, 350); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 305, key1); strcpy(temp->Data.cfxinxi.name[0], key2); temp->Data.cfxinxi.loc = 1; save1(L1); } else MessageBox(HD, L"未找到该学号", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 400 && mg.y < 450 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//2 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 401)); clearrectangle(500, 400, 950, 450); rectangle(500, 400, 950, 450); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 405, key1); strcpy(temp->Data.cfxinxi.name[1], key2); temp->Data.cfxinxi.loc = 2; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 500 && mg.y < 550 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//3 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 501)); clearrectangle(500, 500, 950, 550); rectangle(500, 500, 950, 550); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 505, key1); strcpy(temp->Data.cfxinxi.name[2], key2); temp->Data.cfxinxi.loc = 3; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 600 && mg.y < 650 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//4 { if (*xuehao2) { if (temp) { setbkcolor(getpixel(501, 601)); clearrectangle(500, 600, 950, 650); rectangle(500, 600, 950, 650); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 605, key1); strcpy(temp->Data.cfxinxi.name[3], key2); temp->Data.cfxinxi.loc = 4; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } else if (mg.y > 700 && mg.y < 750 && mg.x > 500 && mg.x < 950 && mg.uMsg == WM_LBUTTONUP)//5 { if (xuehao2) { if (temp) { setbkcolor(getpixel(501, 701)); clearrectangle(500, 700, 950, 750); rectangle(500, 700, 950, 750); InputBox(key1, 20, L"请输入学生处分信息"); WideCharToMultiByte(CP_ACP, 0, key1, -1, key2, wcslen(key1) * 2 + 1, NULL, NULL); outtextxy(505, 705, key1); strcpy(temp->Data.cfxinxi.name[4], key2); temp->Data.cfxinxi.loc = 5; save1(L1); } else MessageBox(HD, L"未找到该学号=_=", L"查找学生信息", MB_OK); } else MessageBox(HD, L"请先输入学号(>﹏<)", L"查找学生信息", MB_OK); } } } void Plog()//登录界面 { cleardevice(); IMAGE pmain;//登录注册界面 IMAGE tp; loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 200, L"西柚信息管理登陆"); rectangle(520, 360, 850, 410); rectangle(520, 450, 850, 500); rectangle(520, 540, 850, 590); rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑"); outtextxy(420, 365, L"学号:"); outtextxy(420, 455, L"密码:"); outtextxy(640, 545, L"登录"); outtextxy(5, 5, L"返回"); MOUSEMSG mg; student* stu = (student*)malloc(sizeof(student)); teacher* tea = (teacher*)malloc(sizeof(teacher)); wchar_t xuehao[20]; ::memset(xuehao, 0, sizeof(xuehao)); wchar_t mima[20]; ::memset(mima, 0, sizeof(mima)); while (1) { mg = GetMouseMsg(); if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50 && mg.uMsg== WM_LBUTTONUP)//返回主界面 { PMAIN(); } else if (mg.x > 520 && mg.x < 850 && mg.y>360 && mg.y < 410&&mg.uMsg== WM_LBUTTONUP)//学号输入 { setbkcolor(getpixel(521,361)); clearrectangle(520, 360, 850, 410); rectangle(520, 360, 850, 410); InputBox(xuehao, 13, L"请输入学号"); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, stu->Data.ID, wcslen(xuehao)*2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, xuehao, -1, tea->Data.ID, wcslen(xuehao)*2 + 1, NULL, NULL); outtextxy(525, 365, xuehao); } else if (mg.x > 520 && mg.x < 850 && mg.y>450 && mg.y < 500&&mg.uMsg== WM_LBUTTONUP)//密码输入 { setbkcolor(getpixel(521, 451)); clearrectangle(520, 450, 850, 500); rectangle(520, 450, 850, 500); InputBox(mima, 13, L"请输入密码"); WideCharToMultiByte(CP_ACP, 0, mima, -1, stu->Data.mima, wcslen(mima)*2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, mima, -1, tea->Data.mima, wcslen(mima)*2 + 1, NULL, NULL); outtextxy(525, 460, mima); } else if (mg.x > 520 && mg.x < 850 && mg.y>540 && mg.y < 590 && mg.uMsg== WM_LBUTTONUP)//登录 { int flag = find_ID(stu, tea, L1, L2); if (flag) { if (flag == 1)//学生账号 { student* k1 = NULL; k1 = find_student(stu, L1); outtextxy(520, 700, L"学生登录成功"); Sleep(1000); Pstudent(k1); } else if(flag==2)//老师账号 { teacher* k2 = NULL; k2 = find_teacher(tea,L2); outtextxy(560, 700, L"老师登录成功"); Sleep(100); Pteacher(k2); } else if (flag == -1)//学生密码错误 { MessageBox(HD, L"密码错误,请重新输入", L"登录信息",MB_OK); } else if (flag == -2)//学生密码错误 { MessageBox(HD, L"密码错误,请重新输入", L"登录信息", MB_OK); } } else { MessageBox(HD, L"此账号并不存在", L"登录信息",MB_OK); } } } } void PMAIN()//主界面,初始界面 { cleardevice(); IMAGE pmain;//登录注册界面 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(360, 200, L"西柚信息管理登陆"); rectangle(520, 360, 690, 410); rectangle(520, 450, 690, 500); rectangle(1100, 750, 1199, 799); settextstyle(40, 20, L"微软雅黑"); outtextxy(565, 365, L"登录"); outtextxy(565, 455, L"注册"); outtextxy(1110, 755, L"退出"); MOUSEMSG mg; while (1) { mg = GetMouseMsg(); if (mg.x > 520 && mg.x < 690) { if (mg.y > 360 && mg.y < 410 && mg.uMsg== WM_LBUTTONUP)//登录 { Plog(); } else if (mg.y > 450 && mg.y < 500 && mg.uMsg== WM_LBUTTONUP)//注册 { Pregister(); } } else if (mg.x > 1100 && mg.x < 1200 && mg.y>750 && mg.y < 800 && mg.uMsg == WM_LBUTTONUP) { exit(0); } } } void Pregister()//注册界面 { cleardevice(); IMAGE pmain;//登录注册界面 loadimage(&pmain, L"PMAIN.jpg", X, Y); putimage(0, 0, &pmain); setbkmode(TRANSPARENT); settextstyle(50, 30, L"微软雅黑"); outtextxy(350, 50, L"西柚信息管理登陆"); rectangle(520, 120, 850, 180);//账号框 rectangle(520, 220, 850, 280);//密码框 rectangle(520, 320, 850, 380);//姓名框 rectangle(320, 420, 490, 480);//学生注册框 rectangle(720, 420, 890, 480);//教师注册框 rectangle(0, 0, 100, 50); settextstyle(40, 20, L"微软雅黑"); outtextxy(5, 5, L"返回"); settextstyle(30, 18, L"微软雅黑"); outtextxy(420, 130, L"账号"); outtextxy(420, 230, L"密码"); outtextxy(420, 330, L"姓名"); outtextxy(330, 430, L"学生注册"); outtextxy(730, 430, L"教师注册"); student* stu = (student*)malloc(sizeof(student)); teacher* tea = (teacher*)malloc(sizeof(student)); stu->Data.cfxinxi.loc = 0; stu->Data.hjxinxi.loc = 0; ::memset(stu, 0, sizeof(student)); ::memset(tea, 0, sizeof(teacher)); MOUSEMSG mg; wchar_t zhanghao[20]; wchar_t mima[20]; wchar_t mingzi[20]; while (1) { mg=GetMouseMsg(); if (mg.x > 520 && mg.x < 850) { if (mg.y > 120 && mg.y < 180 && mg.uMsg == WM_LBUTTONUP)//账号 { setbkcolor(getpixel(521,121)); clearrectangle(520, 120, 850, 180); rectangle(520, 120, 850, 180); InputBox(zhanghao, 13, L"请输入账号/学号"); outtextxy(530, 130, zhanghao); WideCharToMultiByte(CP_ACP, 0, zhanghao, -1, stu->Data.ID, wcslen(zhanghao)*2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, zhanghao, -1, tea->Data.ID, wcslen(zhanghao)*2 + 1, NULL, NULL); } else if (mg.y > 220 && mg.y < 280 && mg.uMsg == WM_LBUTTONUP)//密码 { setbkcolor(getpixel(521, 221)); clearrectangle(520, 220, 850, 280); rectangle(520, 220, 850, 280); InputBox(mima, 13, L"请输入密码"); outtextxy(530, 230, mima); WideCharToMultiByte(CP_ACP, 0, mima, -1, stu->Data.mima, wcslen(mima)*2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, mima, -1, tea->Data.mima, wcslen(mima)*2 + 1, NULL, NULL); } else if (mg.y > 320 && mg.y < 380 && mg.uMsg == WM_LBUTTONUP)//姓名 { setbkcolor(getpixel(521, 321)); clearrectangle(520, 320, 850, 380); rectangle(520, 320, 850, 380); InputBox(mingzi, 13, L"请输入姓名"); outtextxy(530, 330, mingzi); WideCharToMultiByte(CP_ACP, 0, mingzi, -1, stu->Data.name, wcslen(mingzi)*2 + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, mingzi, -1, tea->Data.name, wcslen(mingzi)*2 + 1, NULL, NULL); } } else if (mg.y > 420 && mg.y < 480)//注册 { if (mg.x > 320 && mg.x < 490 && mg.uMsg == WM_LBUTTONUP) { if (*stu->Data.ID=='\0') { MessageBox(HD, L"请先输入学号", L"注册信息", MB_OK); } else if (*stu->Data.mima=='\0') { MessageBox(HD, L"请先输入密码", L"注册信息", MB_OK); } else if (*stu->Data.name == '\0') { MessageBox(HD, L"请先输入姓名", L"注册信息", MB_OK); } else { int flag = find_ID(stu, tea, L1, L2); if (!flag) { chufen* chuf = (chufen*)malloc(sizeof(chufen)); ::memset(chuf, 0, sizeof(chuf)); ::memset(chuf->name, 0, sizeof(chuf->name)); chuf->loc = 1; strcpy_s(chuf->name[0], "暂无处分"); add_chufen(chuf, stu); huojiang huoj; ::memset(&huoj, 0, sizeof(huoj)); ::memset(huoj.name, 0, sizeof(huoj.name)); huoj.loc = 1; strcpy_s(huoj.name[0], "暂无获奖"); add_huojiang(&huoj, stu); ::memset(&stu->Data.all_kemu, 0, sizeof(stu->Data.all_kemu)); stu->Data.all_kemu.score = stu->Data.all_kemu.yuwen = stu->Data.all_kemu.shuxue = stu->Data.all_kemu.yingyu = stu->Data.all_kemu.wuli = stu->Data.all_kemu.huaxue = stu->Data.all_kemu.Cyuyan = 0; stu->Data.qiandao = 0; stu->Data.lastqiandao = 0; ::memset(stu->Data.kebiao, 0, sizeof(stu->Data.kebiao)); L1 = add_stu(stu, L1); save1(L1); MessageBox(HD, L"学生注册成功", L"注册信息", MB_OK); PMAIN(); } else { MessageBox(HD, L"该学号已经注册过", L"注册信息", MB_OK); } } } else if (mg.x > 720 && mg.x < 890 && mg.uMsg == WM_LBUTTONUP) { int flag = find_ID(stu, tea, L1, L2); if (!flag) { L2 = add_tea(tea, L2); save2(L2); MessageBox(HD, L"教师注册成功", L"注册信息", MB_OK); PMAIN(); } } } else if (mg.x > 0 && mg.x < 100 && mg.y>0 && mg.y < 50&&mg.uMsg== WM_LBUTTONUP) { PMAIN(); } } } int find_ID(student* p1, teacher* p2,List1* L_1, List2* L_2) { class student* pp1 = L_1->head; class teacher* pp2 = L_2->head; while (pp1)//查找ID是否是学生 { if (!strcmp(pp1->Data.ID, p1->Data.ID)) { if (!strcmp(pp1->Data.mima, p1->Data.mima)) return 1;//是学生返回1 else return -1;//密码错误 } pp1 = pp1->next; } while (pp2)//查找是不是老师 { if (!strcmp(pp2->Data.ID, p2->Data.ID)) { if (!strcmp(pp2->Data.mima, p2->Data.mima)) return 2;//是老师返回2 else return -1;//老师密码错误 } pp2 = pp2->next; } return 0;//并不存在这个账号 } student* find_student(student* stu, List1* L)//建立在已经找到学生信息的情况下,把该学生的位置传出去 { student* p = L->head; while (p->next) { if (!strcmp(p->Data.ID, stu->Data.ID)) return p; p = p->next; } return p; } teacher* find_teacher(teacher* tea, List2* L)//建立在已经找到老师信息的情况下,把该老师的位置传出去 { teacher* p = L->head; while (p->next) { if (!strcmp(p->Data.ID, tea->Data.ID)) return p; p = p->next; } return p; } student* find_stuID(List1* L, char* num)//寻找num学号的学生 { student* p = L->head; while (p) { if (!strcmp(p->Data.ID, num)) return p; p = p->next; } return NULL; }
软件体验
想体验的话,可以到我的github文件里面下载那个rar,下载后安装就行。(文件所需要的素材也都在那里面)
https://github.com/MangataTS/-just-play-play
如果有不明白的请私信我,或者添加我的QQ:1196991321