基于C语言实现(控制台)校园外来人员进出监控与管理系统
♻️ 资源
大小:1.56MB
➡️资源下载:https://download.csdn.net/download/s1t16/87430299
校园外来人员进出监控与管理系统
开发背景
疫情防控期间,对于校外外来人员需要申请并记录校外人员信息。纸质化的登记不利于学校对校外人员的查询,并且有校外人员未登记就进入校园的风险,故需要一个校外人员登记系统,对校外人员进行登记。
系统功能设计
系统功能模块设计
该系统主要分解为访客和管理员两个部分。
对于访客部分,主要的操作有:提出申请,入校登记,离校登记;操作的类别有:个人访客和团体访客。
对于管理员部分,主要的操作有:审批申请,增加管理员,查询申请记录。
系统业务流程设计
用户首先选择管理员或者访客:
若为访客,那么就选择个人入校或代表团体入校,然后填写相关信息,如果已经申请,并且通过,那么就可以直接登记入校,在离校时,也应该登记离校时间。
若为管理员,可以选择审批申请,查询申请以及增加管理员。选择审批申请可以看到未通过的申请,可以选择相关的编号进行审批;选择查询申请,可以选择按照人员信息(姓名,性别,电话号码,身份证号,担保人姓名,是否为团队),申请入校日期和离校日期两种方式查询申请记录;选择增加管理员,需要输入管理员的账号和密码,必须保证账号没有相同的。
图 2 业务流程图
项目创建
系统开发环境要求
本项目的开发及运行环境要求:
操作系统:Window10
开发工具:Visual Studio 2019
开发语言:c 语言
项目创建过程
打开 Visual Studio 2019,然后新建项目
为项目命名和选择位置
项目创建后的样子(已经将头文件写了一部分):
预处理模块设计
文档完成人:湛辰铖
文件引用
# include<stdio.h> //标准输入输出 # include<Windows.h> //用于界面设计 # include<conio.h> //控制控制台的输入输出 # include<time.h> //获取访客进出时间 # include<string.h> //使用字符串函数宏定义
# define N 10 //代表最多的管理员数量 # define M 300 //容纳的最多的申请定义全局变量:
typedef struct { int is_team;//判断是否是团队入校:0---个人,1---团队 char name[20];//姓名 int sex;//性别:男---1,女---0 char telephone[20];//联系电话 char id_number[30];//身份证号 char work[50];//工作单位 int car_number[10];//车牌信息 char surety_name[20];//担保人姓名 char surety_phone[20];//担保人电话 int health_code;//健康码:绿码---1,黄码---2,紫码---3,红码---4 int health_cough;//是否身体有咳嗽发热: 有---1,无---0 int in_danger_area;//是否在14天内到过疫区: 有---1,无---0 char apply_in_time[15];//申请进入时间:格式为:2021/06/03/am或2021/06/03/pm char apply_out_time[15];//申请出校时间 char reason[30];//进校事由 int apply_result;//申请是否通过:通过---1,驳回---0,未审批---2 char real_in_time[15];//实际进入时间 char real_out_time[15];//实际出校时间 } typedef struct { char user_name[30];//账号 char password[30];//密码 } Guest guset;//当前申请人 Guest list_guest[M];//申请列表 Admin admin;//当前管理员 Admin list_admin[N];//管理员列表 int n=0;//代表现有管理员的数量 int m = 0;//代表现有的访客申请的数量函数声明
void gotoxy(int, int)输入参数:光标需要移动的坐标
实现功能:将光标移动到指定位置
void hide()实现功能: 隐藏光标
int menu()实现功能:显示菜单
void about()实现功能: 介绍该系统
void administrator()实现功能: 管理员登录
void guest()实现功能: 访客登录
void write()实现功能: 申请的数据存盘
void read()实现功能: 读取申请的数据
void request()实现功能: 提出申请
void record_in()实现功能: 记录进入时间
void record_out()实现功能: 记录出校时间
int check()实现功能: 管理员登录验证
void add()实现功能: 增加管理员
void seek()实现功能: 查询界面
void approve()实现功能: 审批
void data_seek()实现功能:按照日期查询
void info_seek()实现功能:按照人员信息查询
void name_seek()实现功能:按照申请人姓名查询
void id_seek()实现功能:申请人身份证号查询
void sex_seek()实现功能:申请人性别查询
void surety_seek()实现功能:担保人姓名查询
void telephone_seek()实现功能:申请人电话查询
void team_seek()- 实现功能:团队查询
- 系统界面设计
- 文档完成人:湛辰铖
- 界面需要在控制台的中间显示出该系统的基本信息,同时提供登录选项。
代码如下:
int menu() { gotoxy(40, 12); printf("欢迎来到校外人员登记系统"); gotoxy(43, 14); printf("1.访客登录"); gotoxy(43, 16); printf("2.管理员登陆"); gotoxy(43, 18); printf("3.关于"); gotoxy(43, 20); printf("其他任意键退出"); hide(); char ch; int result = 0; ch = _getch(); switch (ch) { case '1': result = 1; break; case '2': result = 2; break; case '3': result = 3; break; } system("cls"); return result; }该系统的基本信息
文档完成人:湛辰铖
这部分需要显示出该系统的制作人和基本相关信息
代码如下:
void about() { gotoxy(43, 12); printf("杭州电子科技大学--程序设计综合实践"); gotoxy(43, 14); printf("校园外来人员进出监控与管理系统"); gotoxy(43, 18); printf("制作人员:湛辰铖,林宁宇"); gotoxy(43, 20); printf("按任意键返回上级菜单"); hide(); char ch = _getch(); system("cls"); }管理员部分
文档完成人:湛辰铖
首先需要验证管理员身份
代码如下:
int check() { gotoxy(43, 12); printf("请输入管理员姓名:"); scanf_s("%s", admin.user_name,30); gotoxy(43, 14); printf("请输入密码:"); scanf_s("%s", admin.password,30); FILE *fp; errno_t err2,err1= fopen_s(&fp, "C:\\Users\\19278\\Desktop\\system_call\\admin.txt", "r"); if (err1 != 0) { system("cls"); gotoxy(43, 12); printf("管理员未注册"); return 0; } while (fp!=EOF) { fscanf_s(fp, "%s", list_admin[n].user_name,30); fscanf_s(fp, "%s", list_admin[n].password, 30); if (strcmp(list_admin[n].user_name, "")==0) break; n++; } err2 = fclose(fp); //判断输入的管理员是否正确 for (int i = 0; i < n; i++) { if (strcmp(admin.user_name, list_admin[i].user_name) == 0&&strcmp(admin.password,list_admin[i].password)==0) { system("cls"); return 1; } } gotoxy(43, 18); printf("管理员账号或密码错误"); gotoxy(43, 20); printf("按任意键返回上一级"); char ch = _getch(); return 0; }该部分分为三个模块:1. 审批申请,2. 查询申请,3. 增加管理员
审批申请:
需要读取申请名单,打印显示出需要审批的名单。
代码如下:
void approve() { system("cls"); read(); int ans = 0;//未通过的申请总数 gotoxy(43, 12); printf("审批未自动通过名单:"); gotoxy(12, 13); printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 进校事由"); for (int i = 0; i < m; i++) } if (list_guest[i].apply_result == 2) { ans++; gotoxy(12, 13 + ans); printf("%d. %-20s",i,list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-30s ", list_guest[i].reason); } } int end = 1; int der2=0;//要处理的编号 int temp = 1;//光标的位置 while (end) { gotoxy(43, 14 + ans + temp); temp++; printf("请输入要处理的审批编号或输入-1 返回上一级:"); scanf_s("%d",&der2); if (list_guest[der2].apply_result == 2&& der2 >= 0) { gotoxy(43, 14+ans+temp); temp++; printf("是否通过[y/n]"); char ch='\0'; scanf_s("\n%c",&ch); if (ch == 'y') { list_guest[der2].apply_result = 1; printf(" 审批成功!"); } else if (ch == 'n') { list_guest[der2].apply_result = 0; printf(" 驳回成功!"); } else printf(" 没有按提示输入!"); } else if (der2 == -1) { write(); end = 0; } } }查询申请:
可以分为两大类:按照日期查询和人员信息查询,在人员信息查询中,又分为了六类:申请人姓名,性别,电话,身份证号,担保人姓名,是否为团队
代码如下:
查询的界面:
void seek() { int end = 1; while (end) { system("cls"); gotoxy(43, 14); printf("请选择查询方式:"); gotoxy(43, 16); printf("1.申请人信息"); gotoxy(43, 18); printf("2.申请日期"); gotoxy(43, 20); printf("按任意键返回上级菜单"); hide(); char ch = _getch(); switch (ch) { case '1': info_seek(); break; case '2': data_seek(); break; default: end = 0; } } } //按照日期查询: void data_seek() { char data_begin[20] = { '\0' };//查询起始日期 char data_end[20] = { '\0' };//查询结束日期 system("cls"); gotoxy(43, 12); printf("请输入查询的开始时间(格式:yy/mm/dd):"); scanf_s("%s", data_begin,20); gotoxy(43, 14); printf("请输入查询的结束时间(格式:yy/mm/dd):"); scanf_s("%s", data_end, 20); read(); int sum = 0; printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 进校事由"); for (int i = 0; i < m; i++) { if (strcmp(list_guest[i].apply_in_time, data_begin) >= 0 && strcmp(list_guest[i].apply_out_time, data_end) < 0) { sum++; gotoxy(43, 14 + sum); printf("%d. %-20s", i, list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-30s ", list_guest[i].reason); } } gotoxy(43, 16 + sum); printf("该时间段内的申请总数为 %d\n", sum); gotoxy(43, 17 + sum); printf("按任意键返回上一级"); char ch = _getch(); } 按照申请人姓名查询: void name_seek() { int ans = 0; system("cls"); gotoxy(43, 12); printf("请输入查询申请人的姓名:"); char temp[20] = { '\0' }; scanf_s("%s", temp, 20); gotoxy(43, 14); printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 申请进校时间 申请离校时间 进校事由"); for (int i = 0; i < m; i++ { if (strcmp(list_guest[i].name, temp) == 0) { ans++; gotoxy(12, 13 + ans); printf("%d. %-20s", i, list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-15s ", list_guest[i].apply_in_time); printf("%-15s ", list_guest[i].apply_out_time); printf("%-30s ", list_guest[i].reason); } } gotoxy(43, 17 + ans); printf("查询到的总申请为 %d", ans); gotoxy(43, 19 + ans); printf("按任意键返回上一级"); char ch = _getch(); }按照申请人性别查询:
void sex_seek() { int ans = 0; system("cls"); gotoxy(43, 12); printf("请输入查询申请人的性别(输入 1 代表男,输入 0 代表女):"); int temp_sex = 0; scanf_s("%d", &temp_sex); gotoxy(43, 14); printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 申请进校时间 申请离校时间 进校事由"); for (int i = 0; i < m; i++) { if (list_guest[i].sex == temp_sex); { ans++; gotoxy(12, 13 + ans); printf("%d. %-20s", i, list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-15s ", list_guest[i].apply_in_time); printf("%-15s ", list_guest[i].apply_out_time); printf("%-30s ", list_guest[i].reason); } } gotoxy(43, 17 + ans); printf("查询到的总申请为 %d", ans); gotoxy(43, 19 + ans); printf("按任意键返回上一级"); char ch = _getch(); } 按照申请人电话和身份证号查询: void telephone_seek() { int ans = 0; system("cls"); gotoxy(43, 12); printf("请输入查询申请人的电话:"); char temp[20] = { '\0' }; scanf_s("%s", temp, 20); gotoxy(43, 14); printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 申请进校时间 申请离校时间 进校事由"); for (int i = 0; i < m; i++) { if (strcmp(list_guest[i].telephone, temp) == 0) { ans++; gotoxy(12, 13 + ans); printf("%d. %-20s", i, list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-15s ", list_guest[i].apply_in_time); printf("%-15s ", list_guest[i].apply_out_time); printf("%-30s ", list_guest[i].reason); } } gotoxy(43, 17 + ans); printf("查询到的总申请为 %d", ans); gotoxy(43, 19 + ans); printf("按任意键返回上一级"); char ch = _getch(); } void id_seek() { int ans = 0; system("cls"); gotoxy(43, 12); printf("请输入查询申请人的身份证号:"); char temp[30] = { '\0' }; scanf_s("%s", temp, 30); gotoxy(43, 14); printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 申请进校时间 申请离校时间 进校事由"); for (int i = 0; i < m; i++) { if (strcmp(list_guest[i].id_number, temp) == 0) { ans++; gotoxy(12, 13 + ans); printf("%d. %-20s", i, list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-15s ", list_guest[i].apply_in_time); printf("%-15s ", list_guest[i].apply_out_time); printf("%-30s ", list_guest[i].reason); } } gotoxy(43, 17 + ans); printf("查询到的总申请为 %d", ans); gotoxy(43, 19 + ans); printf("按任意键返回上一级"); char ch = _getch(); }担保人姓名查询:
void surety_seek() { int ans = 0; system("cls"); gotoxy(43, 12); printf("请输入查询担保人的姓名:"); char temp[20] = { '\0' }; scanf_s("%s", temp, 20); gotoxy(43, 14); printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 申请进校时间 申请离校时间 进校事由"); for (int i = 0; i < m; i++) { if (strcmp(list_guest[i].surety_name, temp) == 0) { ans++; gotoxy(12, 13 + ans); printf("%d. %-20s", i, list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-15s ", list_guest[i].apply_in_time); printf("%-15s ", list_guest[i].apply_out_time); printf("%-30s ", list_guest[i].reason); } } gotoxy(43, 17 + ans); printf("查询到的总申请为 %d", ans); gotoxy(43, 19 + ans); printf("按任意键返回上一级"); char ch = _getch(); } 是否为团队查询: void team_seek() { int ans = 0; system("cls"); gotoxy(43, 12); printf("请输入查询的类别(输入 0 代表个人,输入 1 代表团体):"); int temp_is_team = 0; scanf_s("%d", &temp_is_team); gotoxy(43, 14); printf("编号 申请人姓名 申请人性别 申请人电话 "); printf(" 担保人姓名 担保人电话 申请进校时间 申请离校时间 进校事由"); for (int i = 0; i < m; i++) { if (list_guest[i].is_team == temp_is_team) { ans++; gotoxy(12, 13 + ans); printf("%d. %-20s", i, list_guest[i].name); if (list_guest[i].sex == 1) printf("男 "); else printf("女 "); printf("%-20s ", list_guest[i].telephone); printf("%-20s ", list_guest[i].surety_name); printf("%-20s ", list_guest[i].surety_phone); printf("%-15s ", list_guest[i].apply_in_time); printf("%-15s ", list_guest[i].apply_out_time); printf("%-30s ", list_guest[i].reason); } } gotoxy(43, 17 + ans); printf("查询到的总申请为 %d", ans); gotoxy(43, 19 + ans); printf("按任意键返回上一级"); char ch = _getch(); } 增加管理员: 需要提供增加的管理员的账号和密码,同时保证管理员账号的唯一性 代码如下: void add() } system("cls"); char add_name[30] = { '\0' }, add_pass[30] = { '\0' }; gotoxy(43, 12); printf("请输入增加管理员的账号"); scanf_s("%s", add_name,30); gotoxy(43, 14); printf("请输入增加管理员的密码"); scanf_s("%s", add_pass,30); for (int i = 0; i < n; i++) { if (strcmp(add_name, list_admin[i].user_name) == 0) { system("cls"); gotoxy(43, 12); printf("该管理员已存在!"); gotoxy(43, 14); printf("按任意键返回上一级"); char ch = _getch(); return ; } } FILE* fp2; errno_t err2,err1 = fopen_s(&fp2,"C:\\Users\\19278\\Desktop\\system_call\\admin.txt","a"); fprintf_s(fp2, "%s\n",add_name); fprintf_s(fp2, "%s\n",add_pass); err2=fclose(fp2); system("cls"); gotoxy(43, 12); printf("增加成功!"); gotoxy(43, 14); printf("按任意键返回上一级"); char ch = _getch(); return; }项目运行效果
界面运行效果:
介绍部分:
管理员部分:
- 验证
- 管理员界面:
- 审批申请界面:
- 查询界面:
- 选择人员信息查询:
- 选择日期查询:
- 增加管理员:
访客部分:
文档完成人:林宁宇
界面:
提出申请模块:
登记进入时间模块:
登记离开时间模块:
项目创新点(此部分编号不一定是 11,根据自己的项目来调整)
文档完成人:林宁宇,湛辰铖
增加管理员:使得审批的效率更高;
增加了团队入校的功能:可以减少操作量,加快团队入校效率;
增加了自动审批的功能:减少学校管理方面的工作量;
收获和建议(此部分编号不一定是 12,根据自己的项目来调整)
组长 湛辰铖:
遇到的问题首先就是 scanf 和 fopen 的返回值被忽略这个问题,通过查阅资料知道,微软使用了 scanf_s 和 fopen_s 来代替 scanf 的不安全,c11 也已经增加了 scanf_s(其他编译器尚未增加),微软的这个编译器也可以使用 scanf,但是需要在头文件处增加一句宏定义;其次,接口的问题,因为小组合作写代码不一定能够一直讨论,同伴对代码做出的修改也不能第一时间知道,然后就要通过 GitHub 和 gitee 之类代码仓库进行管理。
这次项目得到的经验:每一个项目的一定需要制定规范; 其次,需要首先搭建好编译环境,防止将过多的精力放在了配置环境上; 然后,在已经搭建好的界面上进行代码的增删改会更易于测试。
自己在编写了一部分代码后,发现,当一个函数对外的关联性越弱,那么对这个函数的测试越容易。同时,也发现,过弱的关联性会导致代码的冗余。
自己主要编写界面框架和管理员的操作,在编写界面框架时,由于已经和同伴制定好了规则,所以比较轻松,但是在管理员的操作的部分,需要用到访客部分有一定的数据传输,这使得管理员这边的操作需要考虑到访客部分的数据读入。
最后的总结:在分工写代码前,制定规则很重要,使用相同的框架,相同的命名方式会让代码效率加倍!
成员 1:
附:源代码清单(每个部分写明是哪位同学完成)
