仓库管理系统(c语言)_第1页
仓库管理系统(c语言)_第2页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

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

文档简介

作品名称一、系统背景:

开发者:本软件能减轻对货物数目管理及价格盈亏等信息处理的工作量以便能快捷及时准方面符合当今社会的商业形式而且本软件体积小操作简单是管理仓库的不二选择二、系统简介:设计亮点:◆三级菜单使操作更简便明了◆密码操作能有效保证客户信息的安全性dos命令调用使信息存储的实体属性为隐藏且无扩展名大大增大了安全系数◆数据结构为链表摆脱了数据数量的限制◆提供三种查看模式并会标出排名◆退出店主模式时会提示是否保存若选择yes着进行保存操作根本功能:·在员工模式下可输入卖出货物的名称和数目程序自动在后台进行一系列的操作·新建数据并同时对其处理·修改数据·插入数据·删除数据·查找数据·查看数据·数据存档·修改密码三、系统结构图#defineLENsizeof(structshop)#include<stdio。h>#include〈conio。h>#include<string.h>#include〈stdlib。h〉structshop{charname[30];floatprice_in;floatprice_out;intnum_in;intnum_now;intnum_sold;floatwin;floatpercent;structshop*next;;intn=0;voidmain(void){dauto(tp*;intmenu1(structshop**h_p);voidprint1(void);voidassistant(structshop*head);intpassword(void);intmenu2(structshop**h_p);voidprint2(void);d(tp*;voidrewrite(structshop**h_p);voidinsert(structshop**h_p);voiddeleat(structshop**h_p);d(tp;voidprintall(structshop**h_p);voidsave(structshop*head);voidpassword_set(void);intpassword_exi(structshop**h_p);ttp;voidload(structshop**h_p);voidsave(structshop*head);structshop*addbuild(structshop**h_p);voidsort0(structshop**h_p);intsearch1(structshop**h_p,chara[30]);voidsort1(structshop**h_p);d(tp*;voidsort3(structshop**h_p);voidprint3(void);voidpassword_create(void);structshop*addbuild(structshop**h_p);inta;structshop*head,**h_p;head=NULL;h_p=&head;auto1(h_p);do{a=menu1(h_p);}e(a!=;system(”cls");printf("感谢使用^_^”);getch();}intmenu1(structshop**h_p){inta,b;structshop*head;head=*h_p;(;scanf(”%d",&a);putchar('\n');getchar();do{switch(a){case1:assistant(head);break;case2:()do{;}while(b!=9);break;default:break;}if(a!=3){(;print1();scanf(”%d”,&a);}}while(a!=3);return(a);}intmenu2(structshop**h_p){intb;chara;structshop*head;head=*h_p;;(%,;putchar('\n');getchar();do{switch(b){case1:creat(h_p);break;case2:rewrite(h_p);break;case3:insert(h_p);break;case4:deleat(h_p);break;case5:search(h_p);break;case6:printall(h_p);break;case7:head=*h_p;save(head);break;e:(;default:break;}if(b!=9){system("cls");print2();scanf(”%d",&b);;}}while(b!=9);(n保存吗?;putchar(’\n');scanf(”%c",&a);if(a=='y'){head=*h_p;save(head);}return(b);}voidauto1(structshop**h_p){if(password_exi(h_p)&&data_exi(h_p))(;}voidprint1(void){system("cls”);printf("********************************************************************************\n”);printf(” \n");printf(”********************************************************************************\n");printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n");printf(" #******************* 菜单*****************# \n");printf(” #| 1.员工模式 |#;printf(” #| 2。店主模式 |#;printf(" #| 3。退出 |#\n");printf(" #*********************************************# \n”);printf(” ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n");(n请选择1”}voidassistant(structshop*head){chara[50],c='y’;intb;structshop*i;i=head;while(c==’y'){(;n;(;putchar('\n’);printf(”\n请输入卖出的商品数量:\n");scanf("%d",&b);(;while(strcmp(i->name,a)!=0&&i—>next!=NULL)i=i->next;if(i—>next!=NULL){i—〉num_now—=b;〉—*—;}elseprintf("\n此商品不存在或通知店主更新数据库\n”);”n:;putchar(’\n’);c=getchar();;}save(head);}intpassword(void){FILE*fp;chara[50],b[50];inti;(;fp=fopen(”c:\\y_secrea”,”rb”);”%,;fclose(fp);printf("请输入密码:\n");putchar(’\n');i=0;do{b[i]=getch();printf("*");i++;}while(b[i—1]!=13&&i〈19);b[i—1]='\0’;if(strcmp(a,b)==0)return(1);elsereturn(0);}voidprint2(void){system("cls");printf("********************************************************************************\n");printf(” \n");printf("********************************************************************************\n");printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n");printf(" #******************* 菜单************# ;printf(”\n”);printf(”\n”);printf(”#|#|#|1。新建3.插入5。查找2。修改4.删除6.查看|#|#|#\n");printf("\n");printf(";#|#|7.保存9。上一层8.改密|#|#printf(”#*********************************************# \n");printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n");printf(”请选择(1—9):”);}voidcreat(structshop**h_p){structshop*head,*i,*j;intf=1;head=NULL;n=0;printf("\n请输入数据若完成请在名称处输“0”.\n\n");(&;if(strcmp(i-〉name,”0”)==0)f=0;while(f){n++;if(n==1)head=j;f=1;printf(”\n请输入下一种货物的数据.\n\n");i=addbuild(&head);if(strcmp(i->name,”0")==0){(;f=0;break;}〉next=i;j=i;}j->next=NULL;*h_p=head;}voidrewrite(structshop**h_p){chara[30];structshop*i,*j,*head;head=*h_p;i=head;do{(n;putchar('\n');gets(a);if(n>=1&&!search1(h_p,a){n;;if(head==NULL)gotoend;}}while(n〉=1&&!search1(h_p,a));while(strcmp(a,i—>name)!=0&&i—〉next!=NULL){i=i—>next;}if(strcmp(a,i-〉name)==0){n真的要修改吗??n;putchar('\n');if(getchar()==’y’){getchar();j=addbuild(h_p);;i-〉price_in=j-〉price_in;i-〉price_out=j—>price_out;i—>num_in=j—>num_in;i-〉num_now=j->num_now;i—〉num_sold=j->num_sold;i-〉win=j—>win;i-〉percent=j-〉percent;free(j);”n;}d;}voidinsert(structshop**h_p){structshop*i,*j,*x,*head;head=*h_p;x=addbuild(h_p);i=j=head;e((—〉〈){j=i;i=i—>next;}(—〉—〉{if(i==head)head=x;elsej->next=x;x—〉next=i;}else{i-〉next=x;x—>next=NULL;}printf("\n插入完成^_^\n\n.”);*h_p=head;}voiddeleat(structshop**h_p){structshop*i,*j,*head;chara[30],b;head=*h_p;do{system(”cls”);printf(”\n请输入你要删除的货物的名称:\n");putchar(’\n’);;if(n>=1&&!search1(h_p,a)){printf(”\n不存在的货物名称!\n");if(head==NULL)gotoend;}}while(n〉=1&&!search1(h_p,a));”n:;putchar('\n');b=getchar();;if(b==’y’){i=head;while(strcmp(i—〉name,a)!=0&&i-〉next!=NULL){j=i;i=i—〉next;}if(strcmp(i—>name,a)==0){if(i==head){head=i-〉next;free(i);}elsej—>next=i—〉next;n——;”n;*h_p=head;}};}voidsearch(structshop**h_p){intbegin,end,mid,t;chara[30];structshop*i,*head;head=*h_p;i=head;printf(”\n请输入要查询货物的名称:");putchar(’\n’);gets(a);(〉,)&—〉{i=i-〉next;}if(strcmp(i—〉name,a)==0)){f n名t进t售价t进货数目 存货数目 销量t赢t利率;printf(”\n===============================================================================\n");printf(”%s%10。2f%10。2f%10d%10d%10d%9.2f%10.2f",i—〉name,i-〉price_in,i—〉price_out,i—>num_in,〉,〉;}elsen;getch();}voidprintall(structshop**h_p){inta,c;charb=’y';structshop*i;while(b=='y’){do{system(”cls");print3();scanf("%d",&a);};switch(a){e(;;case2:sort2(h_p);break;case3:sort3(h_p);break;default:break;}for(c=1,i=*h_p;i—〉next!=NULL;i=i-〉next,c++){n名称t进价t售t进货数目 存货数目 销量t赢t利t排名\n");printf("\n===============================================================================\n");f%%%f———〉price_out,i-〉num_in,——;if(c%8==0){getch();getchar();printf(”按任意键继续.。\n”);}}n名称t进价t售t进货数目 存货数目 销量t赢t利t排名;printf(”\n===============================================================================\n”);f%%9%——〉price_out,i-〉num_in,,〉—,;getch();getchar();system("cls");(;(,;putchar(’\n’);}}voidsave(structshop*head){FILE*fp;structshop*i;b:a”;system("delc:\\y_data");fp=fopen(”c:\\y_data”,"wb+");i=head;for(i=head;i—〉next!=NULL;i=i-〉next){price_out,i->num_in,i-〉num_now,i->num_sold,i—〉win,i-〉percent);}fprintf(fp,"%s%7.2f,%.2f,%d,%d,%d,%。2f,%。2f,",i-〉name,i-〉price_in,i->price_out,i—〉num_in,i->num_now,i-〉num_sold,i—〉win,i-〉percent);fclose(fp);system("attribc:\\y_data+h”);printf("\n^_^已保存\n");}voidpassword_set(){FILE*fp;inti,f=0,t=0;rdo{if(password()){do{system("cls”);(9位n;putchar('\n');i=0;do{a[i]=getch();printf(”*");i++;}while(a[i—1]!=13&&i〈19);a[i—1]=’\0’;”n;putchar(’\n');i=0;do{b[i]=getch();printf(”*”);i++;}b[1!&;b[i-1]=’\0';if(strcmp(a,b)==0&&i>2){t=1;(b:a;l;fp=fopen("c:\\y_secrea”,”wb+");fprintf(fp,"%s”,a);fclose(fp);printf(”\n密码修改完成^_^\n”);};}while(t==0);}elsef++;if(f==3)break;}while(t==0);}intpassword_exi(structshop**h_p){FILE*fp;if(fp=fopen("c:\\y_secrea",”rb")!=NULL){fclose(fp);return1;}else{password_create();(;*;return0;}}intdata_exi(structshop**h_p){FILE*fp;(!{fclose(fp);return1;}else{creat(h_p);save(*h_p);return0;}}voidload(structshop**h_p){FILE*fp;structshop*head,*i,*j;head=NULL;j=i=(structshop*)malloc(LEN);if(fp=fopen("c:\\y_data","rb”)!=NULL){while(!feof(fp){fscanf(fp,”%s%f,%f,%d,%d,%d,%f,%f”,i-〉name,&i->price_in,&i—>price_out,&〉〉,&——;n++;if(n==1)head=j;if(!feof(fp)i=(structshop*)malloc(LEN);j-〉next=i;j=i;}j->next=NULL;*h_p=head;fclose(fp);}}structshop*addbuild(structshop**h_p){structshop*i;intb,f;floatc;ra;i=(structshop*)malloc(LEN);do{f=0;printf(”\n请输入名称:\n\n");scanf("%s”,a);if(n>=1&&search1(h_p,a)){(n;f=1;}}f;(〉;if(strcmp(i—>name,”0")==0)return(i);printf("请输入进价:\n\n");scanf(”%f",&c);i-〉price_in=c;printf("请输入售价:\n\n”);”;i—〉price_out=c;;scanf("%d”,&b);i—>num_in=b;printf("请输入现存数目:\n\n");(%b;i->num_now=b;i-〉num_sold=i->num_in-i->num_now;i—>win=(i->num_in—i—〉num_now)*(i—〉price_out-i—>price_in);i—〉percent=(i—>price_out—i->price_in)/(i->price_in);return(i);}voidsort0(structshop**h_p){structshop*i,*j,*z,*sei,*jt,*seit;intni,nj,np,t;charsm[30];if(n〉=2)for(i=*h_p,ni=1;i-〉next!=NULL;i=i-〉next,ni++){strcpy(sm,i->name);np=ni;for(j=i->next,nj=ni+1;j—〉next!=NULL;j=j—〉next,nj++)if(strcmp(sm,j—>name)>0){np=nj;strcpy(sm,j—>name);}if(j—〉next==NULL)if(strcmp(sm,j—>name)〉0)np=nj;if(np!=ni){for(t=1,j=*h_p;t〈np—1;j=j—>next,t++);jt=j->next;i=jt;if(ni==1){seit=*h_p;z=*h_p;*h_p=j—>next;j—〉next=z;}else{for(t=1,sei=*h_p;t〈ni-1;sei=sei—>next,t++);seit=sei—>next;z=sei->next;sei—>next=j—〉next;j->next=z;}z=jt-〉next;jt—>next=seit-〉next;seit—〉next=z;}}}intsearch1(structshop**h_p,chara[30]){structshop*i;intj;for(i=*h_p,j=1;j<n;j++,i=i—>next){if(strcmp(a,i—>name)==0)return1;;if(strcmp(a,i—>name)==0)return1;elsereturn0;}voidsort1(structshop**h_p){structshop*i,*j,*z,*sei,*jt,*seit;intni,nj,np,t;intsm;if(n>=2)for(i=*h_p,ni=1;i—>next!=NULL;i=i—>next,ni++){sm=i—>num_sold;np=ni;for(j=i-〉next,nj=ni+1;j—>next!=NULL;j=j->next,nj++)if(sm<j—〉num_sold){np=nj;sm=j—〉num_sold;}if(j—>next==NULL)if(sm<j—>num_sold)np=nj;if(np!=ni){for(t=1,j=*h_p;t〈np—1;j=j->next,t++);jt=j-〉next;i=jt;if(ni==1){seit=*h_p;z=*h_p;*h_p=j—〉next;j—>next=z;}else{for(t=1,sei=*h_p;t〈ni-1;sei=sei—>next,t++);seit=sei—〉next;z=sei->next;sei->next=j->next;j—〉next=z;}z=jt->next;jt->next=seit->next;seit—〉next=z;}}}voidsort2(structshop**h_p){structshop*i,*j,*z,*sei,*jt,*seit;intni,nj,np,t;floatsm;if(n>=2)for(i=*h_p,ni=1;i—〉next!=NULL;i=i-〉next,ni++){sm=i—>win;np=ni;for(j=i-〉next,nj=ni+1;j-〉next!=NULL;j=j-〉next,nj++)if(sm〈j—>win){np=nj;sm=j—〉win;}if(j—〉next==NULL)if(sm<j—〉win)np=nj;if(np!=ni){for(t=1,j=*h_p;t<np—1;j=j—>next,t++);jt=j—〉next;i=jt;if(ni==1){seit=*h_p;z=*h_p;*h_p=j—>next;j—〉next=z;}else{for(t=1,sei=*h_p;t〈ni-1;sei=sei-〉next,t++);seit=sei-〉next;z=sei—〉next;sei—>next=j-〉next;j->next=z;}z=jt-〉next;jt—>next=seit-〉next;seit—〉next=z;}}}voidsort3(structshop**h_p){structshop*i,*j,*z,*sei,*jt,*seit;intni,nj,np,t;floatsm;if(n〉=2)for(i=*h_p,ni=1;i—>next!=NULL;i=i-〉next,ni++){sm=i->percent;np=ni;for(j=i-〉next,nj=ni+1;j-〉next!=NULL;j=j->next,nj++)if(sm<j—>percent){np=nj;sm=j—〉percent;}if(j->next==NULL)if(sm<j—〉percent)np=nj;if(np!=ni){for(t=1,j=*h_p;t<np-1;j=j-〉next,t++);jt=j-〉next;i=jt;if(ni==1){seit=*h_p;z=*h_p;*h_p=j—〉next;j—>next=z;}else{for(t=1,sei=*h_p;t<ni-1

温馨提示

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

评论

0/150

提交评论