仪器仪表管理系统—语言课程设计_第1页
仪器仪表管理系统—语言课程设计_第2页
仪器仪表管理系统—语言课程设计_第3页
仪器仪表管理系统—语言课程设计_第4页
仪器仪表管理系统—语言课程设计_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、C语言课程设计报告仪器仪表管理1.题目要求I.【要求】系统功能的基本要求:(1)新的仪器仪表信息的录入;(2)在借出、归还、维修时对仪器仪表信息的修改;(3)对报废仪器仪表信息的删除;(4)按照一定的条件查询符合条件的仪器仪表信息;查询功能至少应该包括仪器仪表基本信息(如仪器仪表名字、仪器仪表编等)的查询、按时间点(借入时间、借出时间、归还时间)查询等(5)对查询结果的输出。【提示】数据结构采用结构体。仪器仪表信息包括仪器仪表名、仪器仪表编号、购买时间、借入时间、借出时间、归还时间、维修时间、状态信息(0代表可借出,1代表已借出,2代表正在维修)等。H.需求分析根据题目要求,需要把仪器仪表信息

2、的的数据存储在文件里,所以需要提供文件的输入输出等操作;在程序中要提供修改,删除,查找等操作;另外还应该提供键盘式选择菜单实现功能选择。2.功能实现设计2.1 总体设计系统功能模块图2.2 详细设计1 .主函数主函数一般设计得比较简洁,只提供输入输出和功能处理的函数调用其各功能模块用菜单方式选择。本题将main()函数体内的界面选择部分语句单独抽取出来作为一独立函数,目的在于系统执行完每部分功能模块后能够方便返回到系统界面。【程序】main()menu();菜单部分设计如下:【流程图】menu();voidmenu()intw,n;dosystem("cls");print

3、f("皿WELCOMETOTHEEQUIPMENTMANAGEMENTSYSTEMnnn");nn'n");printf("ttt1:Addmessageofnewequipmennn");printf("ttt2:Loadthemessageofallequipmentnn");printf("ttt3:Correctthemessageofequipmentnn");printf("ttt4:Ddletethemessageofbrokenequipmentnn");pri

4、ntf("ttt5:Searchthemessageofequipmentnn");printf("ttt6:Searchofalltheequipmentnn");printf("ttt7:Exit'n");printf("nntt=*=nnn");printf("Pleasechoiceyournumber:bb");scanf("%d",&n);if(n<1|n>7)w=1;elsew=0;while(w=1);/*选择功能*/switch(

5、n)case1:add_new_message();break;/*添力口模块*/case2:load_record();break;/*显示模块*/case3:modify();break;/*修改模块*/case4:delete();break;/*删除模块*/case5:search();break;/*查询模块*/case6:statistic();break;/*统计模块*/case7:exit(0);break;/*退出模块*/2 .各功能模块设计(1)添加模块【数据结构】【分析】单独看各数据信息,仪器仪表名是字符型,可采用字符型数组;仪器仪表编号、购买时间、借入时间、借出时间、归

6、还时间、维修时间应采用实型;状态信息是整数,采用整型。实际上操作时发现只有字符型的数据可以在文件中成功被保存,所以本题所有数据一律采用字符型。structequipcharnumber4;charname11;charb_time11;charbin_time11;charbout_time11;chargiveb_time11;charrepair_time11;/*time为下面程序中按时间查找和修改时记录输入的时间*/intstate;equM;【注意】equM中的M是仪表仪器个数,程序中采用宏定义的方式,可以随时在源程序宏定义中改,本程序宏定义#defineM50。流程图输入用户要输入

7、仪器的个数n输入模块流程图【程序】/*添加模块*/voidadd_new_message()intt,i,m;system("cls");t=load_equ();printf("Howmanygroupsdatasdoyouwanttoadd?n");printf("inputthenumber:bbb");scanf("%d",&m);for(i=0;i<m;i+)printf("nInput%dthequipmentrecord.n",i+1);input(t+i);/*调用

8、输入函数*/save(t+m,0);/*调用保存函数保存t+m组数据*/system("cls");menu();/*返回登陆界面*/*输入函数*/7voidinput(inti)b_in_timeb_out_timeg_back_timeprintf("Pleaseinput:nnumbernameb_timerepair_timestaten");scanf("%s%s%s%s%s%s%s%d",&equi.number,&,&equi.b_time,&equi.bin_time,

9、&equi.bout_time,&equi.giveb_time,&equi.repair_time,&equi.state);/*显示记录模块*/voidload_record()intt;t=load_equ();printf_n(t);printf("nnnPressanykeytogobacknn");getchar();menu();/*显示一个仪器记录的函数*/voidprintf_one(inti)printf("%-3s%-10s%-10s%-10s%-10s%-10s%-10s%d.nn",equi.nu

10、mber,,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);/*显示n个仪器记录的函数*/voidprintf_n(intn)intj;system("cls");/*清屏*/printf("numbernameb_timeb_in_timeb_out_timeg_back_timerepair_times'n");for(j=0;j<n;j+)if(j+1)%10=0)/*控制显示,每屏显示10彳T

11、*/printf("nnPassanykeytocontinue.");getchar();puts("nn");printf_one(j);/*调用显示一个仪器记录的函数*/(2)修改模块需求分析该模块的功能是显示所有仪器仪表信息,考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示用户修改该记录的哪部分信息,是仪器仪表的借出时间、归还时间、修理时间还是状态,根据用户选择修改相应信息。流程图让用户选择查询方式(numberorname)程序/*修改模块*/voidmodify()struct

12、equipmod;intt,i,m,w,addr=-1;charnumber4='',name11=''system("cls");/*清屏*/t=load_equ();doprintf("nInputtheequipment'numberorname(1:thenumber2:thename):nn");printf("Whatisyourchoice:bb");scanf("%d",&m);if(m=1|m=2)w=0;elsew=1;while(w=1);swi

13、tch(m)case 1:printf("nnPleaseinputtheequipment'snumber:bbbb");scanf("%s",number);break;case 2:printf("Pleaseinputtheequipment'sname:bbbbbbbbbbb");scanf("%s",name);break;for(i=0;i<t;i+)/*查找要修改的仪器*/if(strcmp(,name)=0|strcmp(equi.number,number

14、)=0)addr=i;printf("nnPleaseinputthenewinformation:nn");printf("numbernameb_timeb_in_timeb_out_timeg_back_timerepair_times'n");scanf("%s%s%s%s%s%s%s%d",mod.number,,mod.b_time,mod.bin_time,mod.bout_time,mod.giveb_time,mod.repair_time,&mod.state);strcpy(equ

15、i.number,mod.number);strcpy(,);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_time);strcpy(equi.repair_time,mod.repair_time);equi.state=mod.state;printf("%-3s%-10s%-10s%-10s%-10s%-10s%-10s%

16、d.nn",equi.number,,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);break;if(addr=-1)printf("Cannotfindtheequipmentwhichyouwanttomodify!nn");printf("Pressanykeytogobacknn");getchar();menu();save(t,0);/*修改后的信息保存*/printf("Pres

17、sanykeytogobacknn");getchar();menu();(3)查询模块查询模块流程图程序/*查询模块*/流程图voidsearch()intw,n;dosystem("cls");printf("ntt*nn");printf("ttbyb_timequantumtosearch?Input1n");printf("ttbygive_back_timequantumtosearch?Input2n");printf("ttbynumbertosearch?Input3n&quo

18、t;);printf("ttbynametosearch?Input4n");printf("tt*nn");printf("Choiceyournumber(1-4):bbb");scanf("%d",&n);if(n<1|n>4)w=1;elsew=0;while(w=1);/*选择功能*/switch(n)case1:sb_buy_tq();break;/*按购买时间段查询函数*/case2:sb_gb_tq();break;/*按归还时间段查询*/case3:sb_par_number(

19、);break;/*按指定编号查询*/case4:sb_name();break;/*按仪器名称查询*/voidsb_buy_tq()/*按购买时间段查询函数*/charyear111,year211;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputthestarttime:._._bbbbbbbbbbb");scanf("%s",year1);printf("n");printf("Pleaseinputthefinishtime:.

20、_._bbbbbbbbbbb");scanf("%s",year2);printf("n");system("cls");for(i=0;i<t;i+)if(strcmp(equi.b_time,year1)>=0)&&(strcmp(equi.b_time,year2)<=0)C语言课程设计报告printf_one(i);/*把符合条件的记录显示出来*/sum+;save_search_record(i);/*把符合条件的记录保存在查询记事本里*/getch();if(sum=0)syst

21、em("cls");printf("Sorry!Cannotfindtheequipmentwhichyouwantto.nn");getch();printf("Pressanykeytogobacktheformerstepn");getchar();menu();voidsb_gb_tq()/*按购买时间段查询函数*/charyear111,year211;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputthestarttime:

22、._._bbbbbbbbbbb");scanf("%s",year1);printf("n");printf("Pleaseinputthefinishtime:._._bbbbbbbbbbb");scanf("%s",year2);printf("n");system("cls");for(i=0;i<t;i+)if(strcmp(equi.giveb_time,year1)>=0)&&(strcmp(equi.b_time,year2

23、)<=0)printf_one(i);/*把符合条件的记录显示出来*/sum+;save_search_record(i);/*把符合条件的记录保存在查询记事本里*/getch();if(sum=0)9C语言课程设计报告system("cls");printf("*nn");printf("Sorry!Cannotfindtheequipmentwhichyouwantto.nn");printf("*nn");getch();printf("Pressanykeytogobacktheformer

24、stepn");getchar();menu();voidsb_par_number()/*按指定编号查询*/charnumber4;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputtheequipmentnumber(000999):bbbb");scanf("%s",number);printf("n");system("cls");for(i=0;i<t;i+)if(strcmp(equi.number,

25、number)=0)printf_one(i);/*把符合条件的记录显示出来*/sum+;*/save_search_record(i);/*把符合条件的记录保存在查询记事本里getch();if(sum=0)system("cls");printf("Sorry!Cannotfindtheequipmentwhichyouwantto.nn");getch();printf("Pressanykeytogobacktheformerstepn");getchar();menu();voidsb_name()/*按仪器名称查询*/ch

26、arname11;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputtheequipmentname:bbbbbbbbbbb");scanf("%s",name);printf("n");system("cls");for(i=0;i<t;i+)if(strcmp(,name)=0)printf_one(i);/*把符合条件的记录显示出来*/sum+;save_search_record(i);/*把符合

27、条件的记录保存在查询记事本里*/getch();if(sum=0)system("cls");printf("Sorry!Cannotfindtheequipmentwhichyouwantto.nn");getch();printf("Pressanykeytogobacktheformerstepn");getchar();menu();(4)删除模块需求分析流程图该模块的功能与修改模块一样先显示所有仪器仪表信息,同样考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示

28、用户是否确定要删除。删除模块流程图程序/*删除模块*/3. voiddelete1()4. 5. FILE*fp1;6. /structequipmod;7. intt,i,m,w,addr=-1;8. charnumber4='',name11=''9. /chara12,a22;10. system("cls");/*清屏*/11. t=load_equ();12. if(fp1=fopen("record.txt","w")=NULL)/*以只写方式打开*/13. 14. printf("

29、;nCannotopenfilen");15. exit(0);16. 17. system("cls");18. do19. 20. system("cls");21. printf("nPleaseInputtheequipment'numberornametofindit(1:thenumber2:thename):nn");22. printf("Whatisyourchoice:bb");23. scanf("%d",&m);24. if(m=1|m=2)25

30、. w=0;26. else27. w=1;28. while(w=1);29.30. switch(m)31.32.case1:C语言课程设计报告33. printf("nnPleaseinputtheequipment'snumber:()bbbb");34. scanf("%s",number);break;35. case2:36. printf("Pleaseinputtheequipment'sname:()bbbbbbbbbbb");37. scanf("%s",name);break

31、;38. 39.40. for(i=0;i<t;i+)/*查找要删除的仪器*/41. 42. if(strcmp(,name)=0|strcmp(equi.number,number)=0)43. 44. addr=i;45. system("cls");46.printf("%-3s%-10s%-10s%-10s%-10s%-10s%-10s%d.nn",equi.number,,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repa

32、ir_time,equi.state);getch();system("cls");printf("Congratunations!Youhavebeensuccessfultodeleteit'sinformation.A_An");getch();continue;fwrite(&equi,sizeof(structequip),1,fp1);/*把不想删除的保存在记事本里,想删除的不保存即为删除*/fclose(fpl);/*关闭文件*/if(addr=-1)system("cls");printf("

33、Cannotfindtheequipmentwhichyouwanttodelete!nn");getch();printf("nnnPressanykeytogoback.nn");getchar();menu();(6)统计模块按要求可按时间段统计按基本信息统计并保存至统计记录文档流程图类似查询模块/*统计模块*/voidstatistic()intw,n;dosystem("cls");printf("ntt*nn");printf("ttbyb_timequantumtostatistic?Input1n&

34、quot;);printf("ttbygive_back_timequantumtostatistic?Input2n");printf("ttbynumbertostatistic?Input3n");printf("ttbynametostatistic?Input4n");printf("tt*nn");27printf("Choiceyournumber(1-4):bbb");scanf("%d",&n);if(n<1|n>4)w=1;elsew=

35、0;while(w=1);选择功能*/*switch(n)case3:tb_par_number();break;case4:tb_name();break;case1:tb_buy_tq();break;case2:tb_gb_tq();break;voidtb_par_number()charnumber4;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputtheequipmentnumber(000999):bbbb");scanf("%s",number);p

36、rintf("n");for(i=0;i<t;i+)if(strcmp(equi.number,number)=0)*/sum+;save_statistic_record(i);/*把符合条件的记录保存在查询记事本里if(sum=0)system("cls");printf("Sorry!Cannotfindtheequipmentwhichyouwantto!nn");getch();elsesystem("cls");printf("Thereare%-2dequipment(s)whichy

37、ouwanttostatisticintherecord!nn",sum);getch();printf("Pressanykeytogobacktheformerstepn");getchar();menu();voidtb_name()charname11;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputtheequipmentname:bbbbbbbbbbb");scanf("%s",name);printf("n&qu

38、ot;);for(i=0;i<t;i+)if(strcmp(,name)=0)sum+;save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/if(sum=0)system("cls");printf("Sorry!Cannotfindtheequipmentwhichyouwantto!nn");getch();elsesystem("cls");printf("Thereare%-2dequipment(s)whichyouwanttostatisticint

39、herecord!nn",sum);getch();printf("Pressanykeytogobacktheformerstepn");getchar();menu();voidtb_buy_tq()charyear111,year211;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputthestarttime:._._bbbbbbbbbbb");scanf("%s",year1);printf("n");pri

40、ntf("Pleaseinputthefinishtime:._._bbbbbbbbbbb");scanf("%s",year2);printf("n");for(i=0;i<t;i+)if(strcmp(equi.b_time,year1)>=0)&&(strcmp(equi.b_time,year2)<=0)sum+;save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/if(sum=0)system("cls");printf("

41、;*nn");printf("Sorry!Cannotfindtheequipmentwhichyouwantto!nn");printf("*nn");getch();elsesystem("cls");printf("*nn");printf(Thereare%-2dequipment(s)whichyouwanttostatisticintherecord!nn",sum);printf("*nnnn");getch();printf("Pressanykey

42、togobacktheformerstepn");getchar();menu();voidtb_gb_tq()charyear111,year211;intt,i,sum=0;t=load_equ();system("cls");printf("Pleaseinputthestarttime:._._bbbbbbbbbbb");scanf("%s",year1);printf("n");printf("Pleaseinputthefinishtime:._._bbbbbbbbbbb"

43、);scanf("%s",year2);printf("n");for(i=0;i<t;i+)if(strcmp(equi.giveb_time,year1)>=0)&&(strcmp(equi.giveb_time,year2)<=0)sum+;save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/if(sum=0)system("cls");printf(”*nn");printf("Sorry!Cannotfindtheequipment

44、whichyouwantto!nn");printf(”*nn");getch();elsesystem("cls");printf(”*n'n");theprintf("Thereare%-2dequipment(s)whichyouwanttostatisticinrecord!nn",sum);printf("*nnnn");getch();printf("Pressanykeytogobacktheformerstepn");getchar();menu();(7)显示

45、记录模块voidload_record()/*显示记录模块*/intt;t=load_equ();printf_n(t);system("cls");printf("nnnPressanykeytogobacknn");getch();getchar();menu();公共函数下面是在每个功能模块中都有可能用到的一些公共函数。11)保存函数save(intn)(2) voidsave(intn,intm)/*n表示保存n组数据,m表示保存在哪个文件夹里*/(3) (4) FILE*fp;(5) inti;(6) 6)if(m=0)(7) fp=fopen

46、("record.txt","w");/*以只写方式打开*/(8) elseif(m=1)(9) 9)fp=fopen("search_record.txt","w");(10) else(11) fp=fopen("statistic_record.txt","w");(12) if(fp=NULL)(13) (14) printf("nCannotopenfilen");(15) exit(0);(16) (17)for(i=0;i<n;i+)(

47、18) (19)fwrite(&equi,sizeof(structequip),1,fp);(20)(21)fclose(fp);(22)Search保存函数(23)voidsave_search_record(inti)(24)(25)FILE*fp;(26)fp=fopen("search_record.txt","a");(27)fwrite(&equi,sizeof(structequip),1,fp);228)fclose(fp);(29)(30)Statistic保存函数(31) voidsave_statistic_rec

48、ord(inti)(32)(33)FILE*fp;(34)fp=fopen("statistic_record.txt","a");(35)fwrite(&equi,sizeof(structequip),1,fp);336)fclose(fp);(37)338)输入整一个记录函数input(inti)说明形参i表示第i个仪器仪表的记录。程序voidinput(inti)printf("Pleaseinput:nnumbernameb_timeb_in_timeb_out_timeg_back_timerepair_timestaten

49、");scanf("%s%s%s%s%s%s%s%d",&equi.number,&,&equi.b_time,&equi.bin_time,&equi.bout_time,&equi.giveb_time,&equi.repair_time,&equi.state);(39)加载函数load()说明该函数可以用来加载所有记录,并且可以返回所有记录的个数。程序(40)intload_equ()/*加载仪器信息并计算记录仪器个数的函数*/(41)(42)FILE*fp;(43)inti

50、;(44)if(fp=fopen("record.txt","rb")=NULL)/*以只读方式打开*/(45) (46) printf("nCannotopenfile'n");(47) exit(0);(48) (49) for(i=0;!feof(fp);i+)/*从文件中读入数据并保存在结构体数组中*/550)fread(&equi,sizeof(structequip),1,fp);(51) fclose(fp);(52) return(i-1);(53) (54)显示n个记录的函数(55) voidprintf_n(intn)(56) (57) intj;(58) system("cls");/*清屏*/(59) printf("numbernameb_timeb_in_timeb_out_timeg_back_timerepair_timesn");(60) for(j=0;j<n;j+)(61) (62) if(j+1)%10=0)/*控制显示,每屏显示10行*/(63) (64) printf("nnPassanykeytocontinue.");(65) getchar();(66) puts("n

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论