参考资料:
https://blog.csdn.net/u012534008/article/details/54601045
http://www.cnblogs.com/smyhvae/p/4148458.html

https://blog.csdn.net/qq_41226029/article/details/79438131

程序框架:

编译环境:VS 2017

EEMS.h

#ifndef EEMS#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>
#include<conio.h>#define N sizeof(struct EQUIPMENT)/**结构体定义*/
struct EQUIPMENT
{char number[11];           //登录号 char name[11];                //设备名  char type[11];               //设备类型   char price[11];                //设备价格char in_time[11];         //购入时间char status[11];          //设备状态,1:正常  ; 0:报废char out_time[11];           //报废时间int x;struct EQUIPMENT *next;   //指向结构体的指针
};
typedef struct EQUIPMENT Equipment;
typedef Equipment *equipment;/**设置信息*/
void menu();    //主菜单
void color(short x);    //颜色设置
void HideCursor();      //隐藏光标
void toxy(short x, short y);        //光标移动
void find_equipment();      //设备查询菜单栏
void over();            //退出EEMS/**设备操作*/
void input_library();               //设备入库
void amend_equipment();             //修改设备信息
void del_equipment();               //删除设备信息
void print_equipment();             //显示全部设备
void find_name_equipment();         //按设备名查询
void find_type_equipment();         //按设备类型查询
void find_number_equipment();       //按设备编号查询 /**文件操作*/
void save_equipment(equipment p);       //存储设备信息
equipment read_file();
void empty_file();#endif // !EEMS

setting.cpp

#include"EEMS.h"void menu()    //菜单
{do{system("cls");  //清屏system("mode con cols=150 lines=40"); //设置屏幕大小HideCursor();  //隐藏光标 color(15);    //设置一个好看的颜色 char t;toxy(50, 5);//将光标移动到(50,5)坐标处printf("\t\t   实验设备管理系统");toxy(48, 8);printf("\t\t|     1.设备入库      |");toxy(48, 10);printf("\t\t|     2.修改信息      |");toxy(48, 12);printf("\t\t|     3.删除信息      |");toxy(48, 14);printf("\t\t|     4.设备查询      |");toxy(48, 16);printf("\t\t|     5.设备总览      |");toxy(48, 18);printf("\t\t|     6.退出软件      |");t = _getch();    //不回显函数 switch (t){case '1':input_library(); break;case '2':amend_equipment(); break;case '3':del_equipment(); break;case '4':find_equipment(); break;case '5':print_equipment(); break;case '6':over(); break;default:break;}} while (1);
}void HideCursor()     //隐藏光标
{CONSOLE_CURSOR_INFO cursor_info = { 1, 0 };SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}void toxy(short x, short y)      //将光标移动到X,Y坐标处
{COORD pos = { x , y };HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(Out, pos);
}void color(short x)
{if (x >= 0 && x <= 15){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);}else{SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);}
}/**图书查询菜单栏*/
void find_equipment()  //查询图书
{do{system("cls");  //清屏 color(8);char t;toxy(50, 5);printf("\t设备查询");toxy(48, 8);printf("|     1.设备名查询      |");toxy(48, 10);printf("|     2.登录号查询      |");toxy(50, 12);printf("请键入[1--2]选择查询方式,键入数字[0]返回主菜单");t = _getch();switch (t){case '0':menu(); break;case '1':find_name_equipment(); break;case '2':find_number_equipment(); break;default:break;}} while (1);
}/**退出BMS*/
void over()       //退出软件
{char t;toxy(48, 11);printf("-----------------------");toxy(48, 12);printf("|   您确定要退出吗?  |");toxy(48, 14);printf("| 1.确定     2.取消   |");toxy(48, 15);printf("-----------------------");while (1){t = _getch();         //输入tswitch (t){case '1':system("cls");color(6);toxy(48, 10);printf("正在安全退出....");Sleep(1000);     //暂停1秒 system("cls");color(8);toxy(48, 10);printf("已安全退出软件");toxy(48, 12);printf("谢谢使用!");toxy(48, 14);printf("by-by^_^");exit(0);  break; //终止程序 case '2':menu(); break;   //调用函数,进入菜单 default:break;}}
}

equipment_operation.cpp

#include"EEMS.h"/**设备入库*/
void input_library()
{do{system("cls");color(10);char t;equipment p;p = (equipment)malloc(N);     //申请空间 //输入设备信息toxy(48, 8);printf("请输入设备登录号(小于10位数):");scanf_s("%s", p->number, 10); getchar();toxy(48, 10);printf("请输入设备名(小于10位数):");scanf_s("%s", p->name, 10); getchar();toxy(48, 12);printf("请输入设备类型(小于10位数):");scanf_s("%s", p->type, 10); getchar();toxy(48, 14);printf("请输入设备价格(小于10位数):");scanf_s("%s", p->price,10); getchar();toxy(48, 16);printf("请输入设备购入时间(小于10位数)[年月日] :");scanf_s("%s", p->in_time, 10); getchar();toxy(48, 18);printf("请输入设备状态[1:正常  0:报废] :");scanf_s("%s", p->status, 10); getchar();toxy(48, 20);printf("请输入设备报废时间(若设备正常则填'#')[年月日] :");scanf_s("%s", &p->out_time,10); getchar();toxy(48, 22);save_equipment(p);toxy(48, 24);printf("正在保存....");Sleep(1000);   //暂停1秒 system("cls");toxy(46, 8);printf("-------------------------");toxy(46, 9);printf("|                       |");toxy(46, 10);printf("| 保存成功!是否继续?  |");toxy(46, 12);printf("| 1.是             2.否 |");toxy(46, 13);printf("|                       |");toxy(46, 14);printf("-------------------------");while (1)    //利用死循环可有效防止其他按键干扰 {t = _getch();if (t == '1'){break;}else if (t == '2'){menu();}}} while (1);
}/**    修改设备信息*/
void amend_equipment()
{do{system("cls");color(10);equipment head, p;int i = 11, j = 0, x;char ch, t;FILE *fp;    //文件指针 char _name[11];char number[11];       //登录号 char name[11];            //设备名  char type[11];           //设备类型   char price[11];            //设备价格char in_time[11];     //购入时间char status[11];          //设备状态,1:正常  ; 0:报废char out_time[11];           //报废时间head = read_file();p = head;toxy(48, 10);printf("请输入你要修改设备的设备名:");gets_s(_name, 10);while (p != NULL)    //初始化p->x为0 {p->x = 0;p = p->next;}p = head;    //让p重新指向表头 toxy(20, 5);printf("***********************************************设备信息******************************************************");toxy(20, 8);printf("-------------------------------------------------------------------------------------------------------------");toxy(20, 9);printf("登录号        设备名        设备种类         设备价格         购入时间         设备状态          报废时间");toxy(20, 10);printf("-------------------------------------------------------------------------------------------------------------");while (p != NULL){if (p != NULL && strcmp(p->name, _name) == 0){toxy(20, i);j++;printf("%s               %s  %14s  %14s  %14s                  %s  %14s\n", p->number, p->name, p->type, p->price, p->in_time, p->status, p->out_time);p->x = j;    //给符合查询标准的结点标号 i++;}p = p->next;}if (j == 0)                   //如果j=0,即没有进入前面的搜索循环,也就是没有找到相应的信息 {toxy(50, i);printf("没有找到相应的信息!(按0返回,按1重新搜索)");while (1)               //死循环是为了防止除0和1的其他按键干扰 {ch = _getch();if (ch == '0'){menu(); break;}else if (ch == '1'){break;}}if (ch == '1')     //如果输入的ch等于1,则结束本次循环 continue;}while (1){toxy(45, i);printf("请输入您要修改的设备的编号:");scanf_s("%d", &x); getchar();if (x > j || x == 0){toxy(45, ++i);printf("输入错误,请重新输入!");Sleep(500);}else{break;}}p = head;     //让p重新指向表头 while (p != NULL && p->x != x)   //遍历链表查询符合条件的结点 {p = p->next;}if (p)    //如果p不为空 {system("cls");//输入要修改的信息 toxy(48, 8);printf("请输入设备登录号(小于10位数):");scanf_s("%s", &number, 10); getchar(); strcpy_s(p->number, 10, number);toxy(48, 10);printf("请输入设备名(小于10位数):");scanf_s("%s", &name, 10); getchar(); strcpy_s(p->name, 10, name);toxy(48, 12);printf("请输入设备类型(小于10位数):");scanf_s("%s", &type, 10); getchar(); strcpy_s(p->type, 10, type);toxy(48, 14);printf("请输入设备价格(小于10位数):");scanf_s("%s", &price, 10); getchar(); strcpy_s(p->price, 10, price);toxy(48, 16);printf("请输入设备购入时间(小于10位数)[年/月/日]:    ");scanf_s("%s", &in_time, 10); getchar(); strcpy_s(p->in_time, 10, in_time);toxy(48, 18);printf("请输入设备状态[1:正常  0:报废]:    ");scanf_s("%s", &status, 10); getchar(); strcpy_s(p->status, 10, status);toxy(48, 20);printf("请输入设备报废时间(若设备正常则填'#')[年/月/日]:    ");scanf_s("%s", &out_time,10); getchar(); strcpy_s(p->out_time, 10, out_time);}color(7);toxy(46, 8);printf("-------------------------");toxy(46, 9);printf("|                       |");toxy(46, 10);printf("|     是否确认修改?    |");toxy(46, 12);printf("| 1.是             2.否 |");toxy(46, 13);printf("|                       |");toxy(46, 14);printf("-------------------------");while (1)   //利用死循环防止其他按键干扰 {t = _getch();if (t == '1'){break;}else if (t == '2'){menu();}}system("cls");toxy(46, 10);printf("正在修改,请稍后....");fopen_s(&fp, "myequipment", "wb");   //以只写的方式打开名为myequipment的二进制文件,打开的同时清空文件中的内容 if (fp == NULL){printf("cannot open file");}if (fwrite(head, N, 1, fp) != 1)   //将head写入fp所指向的文件中 {printf("write error!");}fclose(fp);   //关闭文件 if (head != NULL)   //如果head不为空 {p = head->next;     //让p指向第二个结点 fopen_s(&fp, "myequipment", "ab");   //以追加的方式打开文件 if (fp == NULL){printf("cannot open file");}while (p != NULL){if (fwrite(p, N, 1, fp) != 1)//将p写入fp所指向的文件中{printf("write error!");}p = p->next;}fclose(fp);  //关闭文件 }Sleep(500);   //暂停0.5秒 system("cls");toxy(46, 10);printf("修改成功!即将自动返回主菜单....");Sleep(500);break;} while (1);menu();
}/**删除设备信息*/
void del_equipment()   //删除信息
{do{system("cls");color(9);FILE *fp;equipment head = NULL;equipment p = NULL;equipment pre = NULL;int j = 0, x, i = 11;char name[11];char t, c, ch;head = read_file();    //调用函数,返回表头地址 toxy(48, 10);printf("请输入你要删除设备的设备名:");scanf_s("%s", name, 10);p = head;while (p != NULL){p->x = 0;p = p->next;}p = head;toxy(20, 5);printf("***********************************************设备信息******************************************************");toxy(20, 8);printf("-------------------------------------------------------------------------------------------------------------");toxy(20, 9);printf("登录号        设备名        设备种类         设备价格         购入时间         设备状态          报废时间");toxy(20, 10);printf("-------------------------------------------------------------------------------------------------------------");while (p != NULL){if (p != NULL && strcmp(p->name, name) == 0){toxy(20, i);j++;printf("%s\t\t  %s  %14s  %14s  %14s\t\t\t%s  %14s\n", p->number, p->name, p->type, p->price, p->in_time, p->status, p->out_time);p->x = j;i++;}p = p->next;}if (j == 0)                   //如果j=0,即没有进入前面的搜索循环,也就是没有找到相应的信息 {toxy(50, i);printf("没有找到相应的信息!(按0返回,按1重新搜索)");while (1)               //死循环是为了防止除0和1的其他按键干扰 {ch = _getch();if (ch == '0'){menu(); break;}else if (ch == '1'){break;}}if (ch == '1')     //如果输入的ch等于1,则结束本次循环 continue;}while (1){toxy(45, i);printf("请输入您要删除的设备的编号:");scanf_s("%d", &x); getchar();if (x > j || x == 0){toxy(45, ++i);printf("输入错误,请重新输入!");Sleep(500);}else{break;}}color(7);toxy(46, 8);printf("-------------------------");toxy(46, 9);printf("|                       |");toxy(46, 10);printf("|     是否确认删除?    |");toxy(46, 12);printf("| 1.是             2.否 |");toxy(46, 13);printf("|                       |");toxy(46, 14);printf("-------------------------");while (1){t = _getch();if (t == '1'){break;}else if (t == '2'){menu();}}p = head;while (p != NULL && p->x != x){pre = p;p = p->next;}if (p != NULL){if (pre == NULL){head = head->next;}else{pre->next = p->next;}}free(p);fopen_s(&fp, "myequipment", "wb");if (fp == NULL){printf("cannot open file");}if (fwrite(head, N, 1, fp) != 1){printf("write error!");}fclose(fp);if (head != NULL){p = head->next;fopen_s(&fp, "myequipment", "ab");if (fp == NULL){printf("cannot open file");}while (p != NULL){if (fwrite(p, N, 1, fp) != 1){printf("write error!");}p = p->next;}fclose(fp);}system("cls");toxy(46, 10);printf("正在删除,请稍后....");Sleep(500);system("cls");toxy(46, 8);printf("-------------------------");toxy(46, 9);printf("|                       |");toxy(46, 10);printf("|  删除成功,是否继续? |");toxy(46, 12);printf("| 1.是             2.否 |");toxy(46, 13);printf("|                       |");toxy(46, 14);printf("-------------------------");while (1){c = _getch();if (c == '1'){break;}else if (c == '2'){menu();}}} while (1);}/**显示全部设备信息*/
void print_equipment()
{system("cls");color(6);equipment head, p;int i = 11;int sum = 0;head = read_file();toxy(20, 5);printf("***********************************************设备信息******************************************************");toxy(20, 8);printf("-------------------------------------------------------------------------------------------------------------");toxy(20, 9);printf("登录号        设备名        设备种类         设备价格         购入时间         设备状态          报废时间");toxy(20, 10);printf("-------------------------------------------------------------------------------------------------------------");if (head == NULL){toxy(45, 11);printf("库中没有设备!(按任意键返回)");getchar();_getch();menu();}p = head;while (p != NULL){toxy(20, i);printf("%s\t\t  %s  %14s  %14s  %14s\t\t\t%s  %14s\n", p->number, p->name, p->type, p->price, p->in_time, p->status, p->out_time);i++;//sum += p->num;//计算设备总量 p = p->next;}toxy(48, 7);//printf("图书总量为:%d", sum);toxy(45, i);printf("按任意键返回");getchar();_getch();//不回显函数 menu();
}void find_name_equipment()  //按名字查询
{system("cls");color(8);equipment head, p;int i = 11;head = read_file();char name[11];toxy(48, 8);printf("请输入您要查询设备的设备名:");gets_s(name, 10);toxy(48, 10);printf("正在查询....");Sleep(500);p = head;toxy(20, 5);printf("***********************************************设备信息******************************************************");toxy(20, 8);printf("-------------------------------------------------------------------------------------------------------------");toxy(20, 9);printf("登录号        设备名        设备种类         设备价格         购入时间         设备状态          报废时间");toxy(20, 10);printf("-------------------------------------------------------------------------------------------------------------");while (p != NULL){if (p != NULL && strcmp(p->name, name) == 0){toxy(20, i);printf("%s               %s  %14s  %14s  %14s                  %s  %14s\n", p->number, p->name, p->type, p->price, p->in_time, p->status, p->out_time);i++;}p = p->next;}toxy(45, i);printf("按任意键返回!");getchar();find_equipment();
}void find_number_equipment()   //按设备编号查询
{system("cls");color(8);equipment head, p;int i = 11;head = read_file();char number[11];toxy(48, 8);printf("请输入您要查询设备的登录号:");gets_s(number, 10);toxy(48, 10);printf("正在查询....");Sleep(500);p = head;toxy(20, 5);printf("***********************************************设备信息******************************************************");toxy(20, 8);printf("-------------------------------------------------------------------------------------------------------------");toxy(20, 9);printf("登录号        设备名        设备种类         设备价格         购入时间         设备状态          报废时间");toxy(20, 10);printf("-------------------------------------------------------------------------------------------------------------");while (p != NULL){if (p != NULL && strcmp(p->number, number) == 0){toxy(20, i);printf("%s               %s  %14s  %14s  %14s                  %s  %14s\n", p->number, p->name, p->type, p->price, p->in_time, p->status, p->out_time);i++;}p = p->next;}toxy(45, i);printf("按任意键返回!");getchar();_getch();find_equipment();
}

file_operation.cpp

#include"EEMS.h"void save_equipment(equipment p)   //将p中内容写入文件
{FILE *fp;    //文件指针 fopen_s(&fp, "myequipment", "ab");   //以追加的方式打开名字为myequipment的二进制文件 if (fp == NULL){printf("cannot open file");}if (fwrite(p, N, 1, fp) != 1)   //将p所指向的一段大小为N的内容存入fp所指向的文件中 {printf("write error");}fclose(fp);    //关闭文件
}equipment read_file()      //将文件中的内容读出到链表中,返回值为表头地址
{FILE *fp;       //文件指针 int n = 0;equipment head = NULL;equipment p2 = NULL;equipment p = NULL;equipment pr = NULL;fopen_s(&fp, "myequipment", "ab+");     //以只读的方式打开文件 if (fp == NULL){printf("cannot open file\n");}while (!feof(fp))        //判断文件位置标志是否移动到文件末尾 {n++;p = (equipment)malloc(N); //向内存申请一段空间 fread(p, N, 1, fp);     //将fp所指向的文件中的内容赋给p if (n == 1){head = p;p2 = p;}else             //创建链表 {pr = p2;p2->next = p;p2 = p;}}if (pr != NULL)pr->next = NULL;elsehead = NULL;fclose(fp);    //关闭文件 return head;   //返回头指针
}/*make empty file*/
void empty_file()
{FILE *fp;       //文件指针 fopen_s(&fp, "myequipment", "w");  fclose(fp);    //关闭文件
}

运行测试
running_test.cpp

#include"EEMS.h"int main()
{//empty_file();    //初始化二进制文件menu();getchar();return 0;
}

C/C++ 实验设备管理系统相关推荐

  1. c语言设备管理系统实训答辩,C语言设计(力学实验设备管理系统)1答辩.doc

    <程序设计基础>课程设计 课题名称 力学实验设备管理系统设计 专 业 班 级 姓 名 学 号 指导教师 陈世基 2012年 06 月 12 日 目录 设计目的 ---------.1 总体 ...

  2. c语言课程设计实验设备,C语言课程设计课程设计_力学实验设备管理系统

    --------------------------------------------------正文内容开始-------------------------------------------- ...

  3. c语言实验设备管理系统设计作业,c语言程序设计实验设备管理系统

    c语言程序设计实验设备管理系统 1 苏州市职业大学继续教育学院 课 程 设 计 说 明 书 名称 C 语言程序设计课程设计 2012 年 10 月 31 日至 2012 年 11 月 14 日共 2 ...

  4. 实验室管理系统/实验设备管理系统

    主要内容--开发一个实验室/实验设备管理系统,基本设备信息包括: 设备编号 id 设备名称 name 类型 type 价格 price 设备数量 number 生产公司 company 备注信息 co ...

  5. (C语言)实验设备管理系统——源代码和解析(博主复习用)

    C语言源代码: #include<stdio.h> #include<string.h> #include<stdlib.h> #include<Window ...

  6. 实验室预约管理系统 实验设备 笔记本

    实验室预约管理系统 实验设备 笔记本 489.88626414948373CrazyWorker

  7. C语言实验设备预约管理系统

    C语言实验设备预约管理系统 一.实验设备预约管理系统1.设计目标 基于c语言技术设计并开发实验设备预约管理系统. 2.系统要求 1)系统以菜单方式工作,包括系统主菜单,子菜单. 2)系统包括实验设备管 ...

  8. java计算机毕业设计机械生产企业办公设备管理系统MyBatis+系统+LW文档+源码+调试部署

    java计算机毕业设计机械生产企业办公设备管理系统MyBatis+系统+LW文档+源码+调试部署 java计算机毕业设计机械生产企业办公设备管理系统MyBatis+系统+LW文档+源码+调试部署 本源 ...

  9. 盛元广通高校开放式实验教学管理系统

    随着科技的不断发展,高校教育也在迎来了新的变革.开放式实验教学管理系统模块作为其中的一项重要创新,正在为高校教育带来许多便利和可能性.传统的实验教学常常受到时间和场地的限制,学生很难有足够的机会去亲自 ...

最新文章

  1. 设计模式---(设计原则)面向对象设计原则
  2. 你想建设一个能承受500万PV/每天的网站吗?如果计算呢?
  3. 第二十六天 iptables的nat功能
  4. 【数学和算法】协方差矩阵、方差
  5. CRM和ERP的Sales Organization的映射关系
  6. CENTOS7 Python3.7 PyAudio 安装
  7. 类型“unknown”上不存在属性“foreach”_JavaScript红宝书第四版精简解析系列--映射Map数据类型...
  8. CPU 用户时间 系统时间
  9. 外企重修课:商人高通、任性微软、老姜IBM
  10. 发布Flask项目到服务器
  11. sass基础语法-Mixin混合器,%placeholder占位符继承之间的区别
  12. UDF函数:对字符串实现sha256加密,返回64位十六进制字符串
  13. dedecms 织梦配置 手机 wap 站点,并绑定二级域名
  14. 解决潘多拉路由器固件使用AIDISK共享优盘,出现U盘每次爆满问题
  15. SpringBoot---Eureka
  16. PTA 7-2 复数计算
  17. 基于HTML5的数据可视化方法有哪些
  18. lifi与wifi的论文_WIFI研究论文()
  19. [vue][面试]谈一谈对vue组件化的理解?
  20. java查找当天数据,mysql 查询当天、本周,本月,上一个月的数据

热门文章

  1. gbt7714在overleaf中如何把英文作者大写变小写
  2. stm32中的CAN通讯列表模式配置解析与源码
  3. PCI-PCIE中断机制之一
  4. Bitvise——服务器与本地交互软件(适合大文件传输)
  5. 在C#中设置打印机纸张大小
  6. CMOS与TTL电路的区别
  7. NVIDIA CUDA 高度并行处理器编程(一):CUDA简介
  8. 【隧道应用-1】netsh端口映射内网
  9. 计算机网络笔试面试常考
  10. 【跳坑日记】Ubuntu 16.04安装 Ruby2.7.0遇到的坑:cannot load such file -- openssl (LoadError)