《仪器仪表管理系统—C语言课程设计报告.doc》由会员分享,可在线阅读,更多相关《仪器仪表管理系统—C语言课程设计报告.doc(27页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、- .仪器仪表管理1.题目要求.【要求】 系统功能的根本要求:(1) 新的仪器仪表信息的录入;(2) 在借出、归还、维修时对仪器仪表信息的修改;(3) 对报废仪器仪表信息的删除;(4) 按照一定的条件查询符合条件的仪器仪表信息;查询功能至少应该包括仪器仪表根本信息如仪器仪表名字、仪器仪表编等的查询、按时间点借入时间、借出时间、归还时间查询等(5) 对查询结果的输出。 【提示】 数据构造采用构造体。仪器仪表信息包括仪器仪表名、仪器仪表编号、购置时间、借入时间、借出时间、归还时间、维修时间、状态信息0代表可借出,1代表已借出,2代表正在维修等。.需求分析根据题目要求,需要把仪器仪表信息的的数据存储
2、在文件里,所以需要提供文件的输入输出等操作;在程序中要提供修改,删除,查找等操作;另外还应该提供键盘式选择菜单实现功能选择。2.功能实现设计2.1总体设计仪器仪表管理系统添加查询修改删除退出系统功能模块图2.2详细设计1. 主函数主函数一般设计得比拟简洁,只提供输入输出和功能处理的函数调用。其各功能模块用菜单方式选择。此题将main函数体的界面选择局部语句单独抽取出来作为一独立函数,目的在于系统执行完每局部功能模块后能够方便返回到系统界面。【程序】main()menu();菜单局部设计如下:【流程图】显示一系列功能选项输入n,判断n是否是17 N Y根据n的值调用各功能模块函数 主函数的菜单流
3、程图【程序】main()system(cls);/*清屏*/menu();void menu()int w,n;dosystem(cls);printf(tt WELE TO THE EQUIPMENT MANAGEMENT SYSTEMnnn);printf(nntt=*=nnn);printf(ttt1:Add message of new equipmennn);printf(ttt2:Load the message of all equipmentnn);printf(ttt3:Correct the message of equipmentnn);printf(ttt4:Ddlet
4、e the message of broken equipmentnn);printf(ttt5:Search the message of equipmentnn);printf(ttt6:Search of all the equipmentnn);printf(ttt7:Exitn);printf(nntt=*=nnn);printf(Please choice your number: bb);scanf(%d,&n);if(n7) w=1;else w=0;while (w=1);/*选择功能*/switch(n)case 1:add_new_message();break;/*添加
5、模块*/case 2:load_record();break;/*显示模块*/case 3:modify();break;/*修改模块*/case 4:delete();break;/*删除模块*/case 5:search();break;/*查询模块*/case 6:statistic();break;/*统计模块*/case 7:exit(0);break;/*退出模块*/2. 各功能模块设计1添加模块 【数据构造】 【分析】 单独看各数据信息,仪器仪表名是字符型,可采用字符型数组;仪器仪表编号、购置时间、借入时间、借出时间、归还时间、维修时间应采用实型;状态信息是整数,采用整型。实际上
6、操作时发现只有字符型的数据可以在文件中成功被保存,所以此题所有数据一律采用字符型。struct equipchar number4;char name11;char b_time11;char bin_time11;char bout_time11;char giveb_time11;char repair_time11; /*time为下面程序中按时间查找和修改时记录输入的时间*/int state;equM;【注意】equM中的M是仪表仪器个数,程序中采用宏定义的方式,可以随时在源程序宏定义中改,本程序宏定义#define M 50。输入用户要输入仪器的个数n 【流程图】i从0到n1调用输
7、入函数input(i)i!0 Y调用保存函数save(n)输入模块流程图【程序】/*添加模块*/void add_new_message()int t,i,m;system(cls);t=load_equ();printf(How many groups datas do you want to add?n);printf(input the number: bbb);scanf(%d,&m);for(i=0;im;i+)printf(nInput %dth equipment record.n,i+1);input(t+i);/*调用输入函数*/save(t+m,0);/*调用保存函数 保存
8、t+m组数据*/system(cls);menu();/*返回登陆界面*/*输入函数*/ void input(int i)printf(Please input:nnumber name b_time b_in_time b_out_time g_back_time repair_time staten);scanf(%s %s %s %s %s %s %s %d,&equi.number,&equi.name,&equi.b_time,&equi.bin_time,&equi.bout_time,&equi.giveb_time,&equi.repair_time,&equi.state)
9、;/*显示记录模块*/void load_record()int t;t=load_equ();printf_n(t);printf(nnnPress any key to go back.nn);getchar();menu();/*显示一个仪器记录的函数*/void printf_one(int i)printf(%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.nn,equi.number,equi.name,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_ti
10、me,equi.state);/*显示n个仪器记录的函数*/void printf_n(int n)int j;system(cls);/*清屏*/printf(number name b_time b_in_time b_out_time g_back_time repair_time sn);for(j=0;jn;j+) if(j+1)%10=0)/*控制显示,每屏显示10行*/ printf(nnPass any key to continue .);getchar();puts(nn); printf_one(j);/*调用显示一个仪器记录的函数*/ 2修改模块需求分析 该模块的功能是
11、显示所有仪器仪表信息,考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示用户修改该记录的哪局部信息,是仪器仪表的借出时间、归还时间、修理时间还是状态,根据用户选择修改相应信息。让用户选择查询方式number or name流程图输入number or name是否找到此记录 Y N显示找到的记录,调用修改函数提示没有找到返回主菜单询问用户是否继续修改修改模块流程图程序/*修改模块*/void modify()struct equip mod;int t,i,m,w,addr=-1;char number4= , name11= ;
12、system(cls);/*清屏*/t=load_equ();doprintf(nInput the equipmentnumber or name ( 1:the number 2:the name ):nn);printf(What is your choice: bb);scanf(%d,&m);if(m=1|m=2) w=0;else w=1;while(w=1);switch(m) case 1: printf(nnPlease input the equipments number:_bbbb); scanf(%s,number);break; case 2: printf(Ple
13、ase input the equipments name:_bbbbbbbbbbb); scanf(%s,name);break;for(i=0;it;i+)/*查找要修改的仪器*/ if(strcmp(equi.name,name)=0|strcmp(equi.number,number)=0) addr=i; printf(nnPlease input the new information:nn);printf(number name b_time b_in_time b_out_time g_back_time repair_time sn);scanf(%s%s%s%s%s%s%s
14、%d,mod.number,mod.name,mod.b_time,mod.bin_time,mod.bout_time,mod.giveb_time,mod.repair_time,&mod.state);strcpy(equi.number,mod.number);strcpy(equi.name,mod.name);strcpy(equi.b_time,mod.b_time);strcpy(equi.bin_time,mod.bin_time);strcpy(equi.bout_time,mod.bout_time); strcpy(equi.giveb_time,mod.giveb_t
15、ime);strcpy(equi.repair_time,mod.repair_time); equi.state=mod.state;printf(%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.nn,equi.number,equi.name,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);break; if(addr=-1) printf( Cannot find the equipment which you want to
16、 modify!nn);printf( Press any key to go back.nn); getchar(); menu(); save(t,0);/*修改后的信息保存*/printf( Press any key to go back.nn);getchar();menu();3查询模块显示一系列功能选项流程图输入n,判断n是否是1-4 N Y根据n的值调用各子功能模块函数查询模块流程图程序/*查询模块*/void search()int w,n;dosystem(cls);printf(ntt*nn);printf(ttby b_time quantum to search? I
17、nput1n);printf(ttby give_back_time quantum to search? Input2n);printf(ttby number to search? Input3n);printf(ttby name to search? Input4n);printf(tt*nn);printf( Choice your number(1-4): bbb);scanf(%d,&n);if(n4) w=1;else w=0;while (w=1);/*选择功能*/switch(n)case 1:sb_buy_tq();break;/*按购置时间段查询函数*/case 2:s
18、b_gb_tq();break;/*按归还时间段查询*/case 3:sb_par_number();break;/*按指定编号查询*/case 4:sb_name();break;/*按仪器名称查询*/void sb_buy_tq()/*按购置时间段查询函数*/ char year111,year211; int t,i,sum=0; t=load_equ(); system(cls); printf(Please input the start time:_._._bbbbbbbbbbb); scanf(%s,year1); printf(n); printf(Please input t
19、he finish time:_._._bbbbbbbbbbb); scanf(%s,year2); printf(n); system(cls); for(i=0;i=0)&(strcmp(equi.b_time,year2)=0) printf_one(i);/*把符合条件的记录显示出来*/ sum+; save_search_record(i);/*把符合条件的记录保存在查询记事本里*/ getch(); if(sum=0) system(cls); printf(Sorry! Cannot find the equipment which you want to.nn); getch(
20、); printf(Press any key to go back the former step.n); getchar(); menu();void sb_gb_tq()/*按购置时间段查询函数*/char year111,year211;int t,i,sum=0;t=load_equ();system(cls);printf(Please input the start time:_._._bbbbbbbbbbb);scanf(%s,year1);printf(n);printf(Please input the finish time:_._._bbbbbbbbbbb);scanf
21、(%s,year2);printf(n);system(cls); for(i=0;i=0)&(strcmp(equi.b_time,year2)=0) printf_one(i);/*把符合条件的记录显示出来*/ sum+; save_search_record(i);/*把符合条件的记录保存在查询记事本里*/ getch(); if(sum=0) system(cls); printf(*nn); printf(Sorry! Cannot find the equipment which you want to.nn); printf(*nn); getch(); printf(Press
22、 any key to go back the former step.n); getchar(); menu();void sb_par_number()/*按指定编号查询*/char number4;int t,i,sum=0;t=load_equ();system(cls);printf(Please input the equipment number(000999):_bbbb);scanf(%s,number);printf(n); system(cls); for(i=0;it;i+) if(strcmp(equi.number,number)=0) printf_one(i);
23、/*把符合条件的记录显示出来*/ sum+; save_search_record(i);/*把符合条件的记录保存在查询记事本里*/ getch(); if(sum=0) system(cls); printf(Sorry! Cannot find the equipment which you want to.nn); getch(); printf(Press any key to go back the former step.n); getchar(); menu();void sb_name()/*按仪器名称查询*/char name11;int t,i,sum=0;t=load_e
24、qu();system(cls);printf(Please input the equipment name:_bbbbbbbbbbb);scanf(%s,name);printf(n);system(cls); for(i=0;it;i+) if(strcmp(equi.name,name)=0) printf_one(i);/*把符合条件的记录显示出来*/ sum+; save_search_record(i);/*把符合条件的记录保存在查询记事本里*/ getch(); if(sum=0) system(cls); printf(Sorry! Cannot find the equip
25、ment which you want to.nn); getch(); printf(Press any key to go back the former step.n); getchar(); menu();4删除模块需求分析 该模块的功能与修改模块一样先显示所有仪器仪表信息,同样考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示用户是否确定要删除。让用户选择如何搜寻记录by number or by name流程图输入要删除的仪器编号或名称是否找到此记录 Y N显示找到的记录提示没有找到删除 并保存未删除的记录删除 保存为
26、删除的记返回主菜单删除模块流程图程序 /*删除模块*/3. void delete1()4. 5. FILE *fp1;6. /struct equip mod;7. int t,i,m,w,addr=-1;8. char number4= , name11= ;9. /char a12,a22;10. system(cls);/*清屏*/11. t=load_equ();12. if(fp1=fopen(record.txt,w)=NULL)/*以只写方式翻开*/13. 14. printf(nCannot open filen);15. exit(0);16. 17. system(cls
27、);18. do19. 20. system(cls);21. printf(nPlease Input the equipmentnumber or name to find it( 1:the number 2:the name ):nn);22. printf(What is your choice: bb);23. scanf(%d,&m);24. if(m=1|m=2)25. w=0;26. else27. w=1;28. while(w=1);29.30. switch(m)31. 32. case 1:33. printf(nnPlease input the equipment
28、s number:(_)bbbb);34. scanf(%s,number);break;35. case 2:36. printf(Please input the equipments name:(_)bbbbbbbbbbb);37. scanf(%s,name);break;38. 39.40. for(i=0;it;i+)/*查找要删除的仪器*/41. 42. if(strcmp(equi.name,name)=0|strcmp(equi.number,number)=0)43. 44. addr=i;45. system(cls);46. printf(%-3s %-10s %-10
29、s %-10s %-10s %-10s %-10s %d.nn,equi.number,equi.name,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);getch();system(cls);printf(Congratunations ! You have been successful to delete its information. _n);getch();continue;fwrite(&equi,sizeof(struct equip),1,fp1);/
30、*把不想删除的保存在记事本里,想删除的不保存即为删除*/fclose(fp1);/*关闭文件*/if(addr=-1)system(cls);printf( Cannot find the equipment which you want to delete!nn);getch();printf( nnnPress any key to go back.nn);getchar();menu();(6) 统计模块 按要求可按时间段统计 按根本信息统计 并保存至统计记录文档 流程图类似查询模块/*统计模块*/void statistic()int w,n;dosystem(cls);printf(
31、ntt*nn);printf(ttby b_time quantum to statistic? Input1n);printf(ttby give_back_time quantum to statistic? Input2n);printf(ttby number to statistic? Input3n);printf(ttby name to statistic? Input4n);printf(tt*nn);printf( Choice your number(1-4): bbb);scanf(%d,&n);if(n4) w=1;else w=0;while (w=1);/*选择功
32、能*/switch(n)case 3:tb_par_number();break;case 4:tb_name();break;case 1:tb_buy_tq();break;case 2:tb_gb_tq();break;void tb_par_number()char number4;int t,i,sum=0;t=load_equ();system(cls);printf(Please input the equipment number(000999):_bbbb);scanf(%s,number);printf(n); for(i=0;it;i+) if(strcmp(equi.n
33、umber,number)=0) sum+; save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/ if(sum=0) system(cls); printf( Sorry! Cannot find the equipment which you want to!nn); getch(); else system(cls);printf( There are%-2dequipment(s) which you want to statistic in the record!nn,sum);getch(); printf(Press any key to
34、go back the former step.n); getchar(); menu();void tb_name()char name11;int t,i,sum=0;t=load_equ();system(cls);printf(Please input the equipment name:_bbbbbbbbbbb);scanf(%s,name);printf(n); for(i=0;it;i+) if(strcmp(equi.name,name)=0) sum+; save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/ if(sum=0) sys
35、tem(cls);printf( Sorry! Cannot find the equipment which you want to!nn);getch(); else system(cls);printf( There are%-2dequipment(s) which you want to statistic in the record!nn,sum);getch(); printf(Press any key to go back the former step.n); getchar(); menu();void tb_buy_tq()char year111,year211;int t,i,sum=0;t=load_equ();