1、作品名称开发者:一、 系统背景:本软件能减轻对货物数目管理及价格盈亏等信息处理工作量方便能快捷立即正确调整货物仓储量达成最合理化。能够使店主不失效率节省大量精力用于其它方面 符合当今社会商业形式而且本软件体积小操作简单是管理仓库不二选择二、 系统介绍:设计亮点:三级菜单使操作更简便明了密码操作能有效确保用户信息安全性独特dos命令调用使信息存放实体属性为隐藏且无扩展名大大增大了安全系数数据结构为链表摆脱了数据数量限制提供三种查看模式并会标出排名退出店主模式时会提醒是否保留若选择yes着进行保留操作基础功效:在职员模式下可输入卖出货物名称和数目程序自动在后台进行一系列操作新建数据并同时对其处理修
2、改数据插入数据删除数据查找数据查看数据数据存档修改密码三、 系统结构图 #define LEN sizeof(struct shop)#include#include#include#includestruct shopchar name30;float price_in;float price_out;int num_in;int num_now;int num_sold;float win;float percent;struct shop *next;int n=0;void main(void)void auto1(struct shop *h_p);int menu1(struct
3、shop *h_p);void print1(void);void assistant(struct shop *head);int password(void);int menu2(struct shop *h_p);void print2(void);void creat(struct shop *h_p);void rewrite(struct shop *h_p);void insert(struct shop *h_p);void deleat(struct shop *h_p);void search(struct shop *h_p);void printall(struct s
4、hop *h_p);void save(struct shop *head);void password_set(void);int password_exi(struct shop *h_p);int data_exi(struct shop *h_p);void load(struct shop *h_p);void save(struct shop *head);struct shop *addbuild(struct shop *h_p);void sort0(struct shop *h_p);int search1(struct shop *h_p,char a30);void s
5、ort1(struct shop *h_p);void sort2(struct shop *h_p);void sort3(struct shop *h_p);void print3(void);void password_create(void);struct shop *addbuild(struct shop *h_p);int a;struct shop *head,*h_p;head=NULL;h_p=&head;auto1(h_p);doa=menu1(h_p);while(a!=3);system(cls);printf(谢谢使用_);getch();int menu1(str
6、uct shop *h_p)int a,b;struct shop *head;head=*h_p;print1();scanf(%d,&a);putchar(n);getchar();doswitch(a)case 1:assistant(head);break;case 2:if(password()dob=menu2(h_p);while(b!=9);break;default:break;if(a!=3)system(cls);print1();scanf(%d,&a);while(a!=3);return(a);int menu2(struct shop *h_p)int b;cha
7、r a;struct shop *head;head=*h_p;print2();scanf(%d,&b);putchar(n);getchar();doswitch(b) case 1:creat(h_p);break;case 2:rewrite(h_p);break;case 3:insert(h_p);break;case 4:deleat(h_p);break;case 5:search(h_p);break;case 6:printall(h_p);break;case 7:head=*h_p;save(head);break;case 8:password_set();break
8、;default:break;if(b!=9)system(cls);print2();scanf(%d,&b);getchar();while(b!=9);printf(n保留吗?(y/n):);putchar(n);scanf(%c,&a);if(a=y)head=*h_p;save(head);return(b);void auto1(struct shop *h_p)if(password_exi(h_p) & data_exi(h_p)load(h_p);void print1(void)system(cls);printf(*n);printf( 仓库管理系统 n);printf(
9、*n);printf( n);printf( #* 菜单 *# n);printf( #| 1.职员模式 |# n);printf( #| 2.店主模式 |# n);printf( #| 3.退出 |# n);printf( #*# n);printf( n);printf(n请选择(1-3):);void assistant(struct shop *head)char a50,c=y;int b;struct shop *i;i=head;while(c=y)system(cls);printf(n请输入卖出商品名称:n);gets(a);putchar(n);printf(n请输入卖出商
10、品数量:n);scanf(%d,&b);putchar(n);while(strcmp(i-name,a)!=0&i-next!=NULL)i=i-next;if(i-next!=NULL)i-num_now-=b;i-win=(i-num_in-i-num_now)*(i-price_out-i-price_in);elseprintf(n此商品不存在或通知店主更新数据库n);printf(n继续吗?(y/n):);putchar(n);c=getchar();getchar();save(head);int password(void)FILE*fp;char a50,b50;int i;
11、system(cls);fp=fopen(c:y_secrea,rb);fscanf(fp,%s,&a);fclose(fp);printf(请输入密码:n);putchar(n);i=0;dobi=getch();printf(*);i+;while(bi-1!=13&iname,0)=0)f=0;while(f)n+;if(n=1)head=j;f=1;printf(n请输入下一个货物数据.nn);i=addbuild(&head);if(strcmp(i-name,0)=0)free(i);f=0;break;j-next=i;j=i;j-next=NULL;*h_p=head;void
12、 rewrite(struct shop *h_p)char a30;struct shop *i,*j,*head;head=*h_p;i=head;doprintf(n请输入要修改货物名称:);putchar(n);gets(a);if(n=1&!search1(h_p,a)printf(n不存在货物名称!n);getch();if(head=NULL) goto end;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) printf(n真要修改
13、吗??(y/n):); putchar(n); if(getchar()=y) getchar(); j=addbuild(h_p); strcpy(i-name,j-name);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); printf(n修改完成_nn); end:;void insert(struct shop *h_p)struct sho
14、p *i,*j,*x,*head;head=*h_p;x=addbuild(h_p);i=j=head;while(strcmp(i-name,x-name)next!=NULL) j=i; i=i-next; if(strcmp(i-name,x-name)=0) if(i=head) head=x; else j-next=x; x-next=i; else i-next=x; x-next=NULL; printf(n插入完成_nn.);*h_p=head;void deleat(struct shop *h_p)struct shop*i,*j,*head;char a30,b;hea
15、d=*h_p;dosystem(cls);printf(n请输入你要删除货物名称:n);putchar(n);gets(a);if(n=1&!search1(h_p,a)printf(n不存在货物名称!n);if(head=NULL) goto end;while(n=1&!search1(h_p,a);printf(n真要删除吗?(y/n):);putchar(n);b=getchar();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)
16、if(i=head) head=i-next; free(i); else j-next=i-next; n-; printf(n删除完成_.nn); *h_p=head;end:;void search(struct shop *h_p)int begin,end,mid,t;char a30;struct shop *i,*head;head=*h_p;i=head;printf(n请输入要查询货物名称:);putchar(n);gets(a);while(strcmp(i-name,a)!=0)&i-next!=NULL)i=i-next;if(strcmp(i-name,a)=0)pr
17、intf(n名称t进价t售价t进货数目 存货数目 销量 t赢利t利率n);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,i-num_now,i-num_sold,i-win,i-percent); elseprintf(n此货物不存在!n);getch();void printall(struct shop *h_p)int a,c; char b=y;struct shop *i;while(b=y)dosystem(cls);print3();s
18、canf(%d,&a);while(a!=1&a!=2&a!=3);switch(a)case 1:sort1(h_p);break;case 2:sort2(h_p);break;case 3:sort3(h_p);break;default:break;for(c=1,i=*h_p;i-next!=NULL;i=i-next,c+)printf(n名称t进价t售价t进货数目 存货数目 销量 t赢利t利率t排名n);printf(n=n);printf(%s%10.2f%10.2f%10d%10d%10d%9.2f%10.2f%8d,i-name,i-price_in,i-price_out
19、,i-num_in,i-num_now,i-num_sold,i-win,i-percent,c); if(c%8=0)getch();getchar();printf(按任意键继续。n);printf(n名称t进价t售价t进货数目 存货数目 销量 t赢利t利率t排名n);printf(n=n);printf(%s%10.2f%10.2f%10d%10d%10d%9.2f%10.2f%8d,i-name,i-price_in,i-price_out,i-num_in,i-num_now,i-num_sold,i-win,i-percent,c); getch();getchar();syste
20、m(cls);printf(查看其它排列方法?(y/n):);scanf(%c,&b);putchar(n);void save(struct shop *head)FILE *fp;struct shop *i;system(attrib c:y_data -h);system(del c:y_data);fp=fopen(c:y_data,wb+);i=head;for(i=head;i-next!=NULL;i=i-next)fprintf(fp,%s%7.2f,%.2f,%d,%d,%d,%.2f,%.2f,i-name,i-price_in,i-price_out,i-num_in,
21、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(attrib c:y_data +h);printf(n_已保留n);void password_set()FILE *fp;int i,f=0,t=0;char a20,b20;doif(password()dosystem(cls);pri
22、ntf(请输入新密码(319位):n);putchar(n);i=0;doai=getch();printf(*);i+;while(ai-1!=13&i19);ai-1=0;printf(n请确定新密码:n);putchar(n);i=0;dobi=getch();printf(*);i+;while(bi-1!=13&i2)t=1;system(attrib c:y_secrea -h);system(del c:y_secrea);fp=fopen(c:y_secrea,wb+);fprintf(fp,%s,a);fclose(fp);printf(n密码修改完成_n);while(t=
23、0);elsef+;if(f=3)break;while(t=0);int password_exi(struct shop *h_p)FILE *fp;if(fp=fopen(c:y_secrea,rb)!=NULL)fclose(fp);return 1;else password_create();creat(h_p);save(*h_p);return 0;int data_exi(struct shop *h_p)FILE *fp;if(fp=fopen(c:y_data,rb)!=NULL)fclose(fp);return 1;elsecreat(h_p);save(*h_p);
24、return 0;void load(struct shop *h_p)FILE *fp;struct shop *head,*i,*j;head=NULL;j=i=(struct shop *)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,&i-num_in,&i-num_now,&i-num_sold,&i-win,&i-percent);n+;if(n=1)head=j;if(!feof(f
25、p)i=(struct shop*)malloc(LEN);j-next=i;j=i;j-next=NULL;*h_p=head;fclose(fp);struct shop *addbuild(struct shop *h_p)struct shop *i;int b,f;float c;char a30;i=(struct shop *)malloc(LEN);dof=0;printf(n请输入名称:nn);scanf(%s,a);if(n=1&search1(h_p,a)printf(n名称反复!n);f=1;while(f);strcpy(i-name,a);if(strcmp(i-n
26、ame,0)=0)return(i);printf(请输入进价:nn);scanf(%f,&c);i-price_in=c;printf(请输入售价:nn);scanf(%f,&c);i-price_out=c;printf(请输入进货数目:nn);scanf(%d,&b);i-num_in=b;printf(请输入现存数目:nn);scanf(%d,&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-
27、price_in)/(i-price_in);return(i);void sort0(struct shop *h_p)struct shop *i,*j,*z,*sei,*jt,*seit;int ni,nj,np,t;char sm30;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-n
28、ext=NULL)if(strcmp(sm,j-name)0) np=nj; if(np!=ni) for(t=1,j=*h_p;tnext,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;tnext,t+); seit=sei-next; z=sei-next; sei-next=j-next; j-next=z; z=jt-next;jt-next=seit-next;seit-next=z;int search1(struct shop *h_p,
29、char a30)struct shop *i;int j;for(i=*h_p,j=1;jnext)if(strcmp(a,i-name)=0)return 1;if(strcmp(a,i-name)=0)return 1;elsereturn 0;void sort1(struct shop *h_p)struct shop *i,*j,*z,*sei,*jt,*seit;int ni,nj,np,t;int sm;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=n
30、i+1;j-next!=NULL;j=j-next,nj+) if(smnum_sold) np=nj; sm=j-num_sold; if(j-next=NULL)if(smnum_sold) np=nj; if(np!=ni) for(t=1,j=*h_p;tnext,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;tnext,t+); seit=sei-next; z=sei-next; sei-next=j-next; j-next=z; z=j
31、t-next;jt-next=seit-next;seit-next=z;void sort2(struct shop *h_p)struct shop *i,*j,*z,*sei,*jt,*seit;int ni,nj,np,t;float sm;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(smwin) np=nj; sm=j-win; if(j-next=NULL)if(smwin) np=nj; if(np!=ni) for(t=1,j=*h_p;tnext,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;tnext,t+); seit=sei-next; z=sei-next; sei-next=j-next; j-next=z; z=jt-next;jt-next=seit-next;seit-next=z;