《仪器仪表管理系统—C语言课程设计(共27页).doc》由会员分享,可在线阅读,更多相关《仪器仪表管理系统—C语言课程设计(共27页).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
3、根据n的值调用各功能模块函数 主函数的菜单流程图【程序】main()system(cls);/*清屏*/menu();void menu()int w,n;dosystem(cls);printf(tt WELCOME 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 equip
4、mentnn);printf(ttt4:Ddlete 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
5、_new_message();break;/*添加模块*/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。输
7、入用户要输入仪器的个数n 【流程图】i从0到n1调用输入函数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);/*调用输
8、入函数*/save(t+m,0);/*调用保存函数 保存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,&e
9、qui.repair_time,&equi.state);/*显示记录模块*/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,eq
10、ui.giveb_time,equi.repair_time,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);/*调用显
11、示一个仪器记录的函数*/ (2)修改模块需求分析 该模块的功能是显示所有仪器仪表信息,考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示用户修改该记录的哪部分信息,是仪器仪表的借出时间、归还时间、修理时间还是状态,根据用户选择修改相应信息。让用户选择查询方式(number or name)流程图输入number or name是否找到此记录 Y N显示找到的记录,调用修改函数提示没有找到 返回主菜单询问用户是否继续修改修改模块流程图程序/*修改模块*/void modify()struct equip mod;int t,i,m,
12、w,addr=-1;char number4= , name11= ;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(%
13、s,number);break; case 2: printf(Please 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
14、repair_time sn); scanf(%s%s%s%s%s%s%s%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_tim
15、e); strcpy(equi.giveb_time,mod.giveb_time);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( Canno
16、t find the equipment which you want to 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
17、);printf(ttby b_time quantum to search? Input1n);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
18、:sb_buy_tq();break;/*按购买时间段查询函数*/case 2:sb_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
19、,year1); printf(n); printf(Please input the 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 th
20、e equipment which you want to.nn); getch(); 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 inpu
21、t the 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(*nn); printf(Sorry! Cannot find the equipment which you want t
22、o.nn); printf(*nn); getch(); printf(Press 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(str
23、cmp(equi.number,number)=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(); printf(Press any key to go back the former step.n); getchar(); menu();void sb_name()/*按仪
24、器名称查询*/char name11;int t,i,sum=0;t=load_equ();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(
25、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();(4)删除模块需求分析 该模块的功能与修改模块一样先显示所有仪器仪表信息,同样考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示用户是否确定要删除。让用户选择如何搜寻记录(by number or by name)流程图输入要删除的仪器编号
26、或名称是否找到此记录 Y N显示找到的记录提示没有找到删除 并保存未删除的记录删除 保存为删除的记 返回主菜单删除模块流程图程序 /*删除模块*/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(nCan
27、not open filen);15. exit(0);16. 17. system(cls);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.
28、case 1:33. printf(nnPlease input the equipments 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. add
29、r=i;45. system(cls);46. 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); getch(); system(cls);printf(Congratunations ! You have been successful to delete its information. _n); getch();co
30、ntinue;fwrite(&equi,sizeof(struct equip),1,fp1);/*把不想删除的保存在记事本里,想删除的不保存即为删除*/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) 统计模块 按要求可按时间段统计 按基本信息统计 并保存至统计记录文档 流程图类似查询模块/*
31、统计模块*/ void statistic()int w,n;dosystem(cls);printf(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
32、);scanf(%d,&n);if(n4) w=1;else w=0;while (w=1);/*选择功能*/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(%
33、s,number);printf(n); for(i=0;it;i+) if(strcmp(equi.number,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
34、the record!nn,sum);getch(); printf(Press any key to 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) 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 go back the