当前位置:文档之家› 超市仓库管理系统_程序

超市仓库管理系统_程序

超市仓库管理系统程序如下:#include <stdio.h>#include<stdlib.h>#include <string.h>#include<malloc.h>#include"仓库管理系统.h"#define N 500#define LEN sizeof(struct product)#define ILEN sizeof(struct in_product)#define OLEN sizeof(struct out_product)#define QLEN sizeof(struct quit_product)void init(){head=NULL;qhead=NULL;ihead=NULL;ohead=NULL;printf("\t\t★★★★★★★★★★★★★★★★★★★★★★★★★★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★ ******************** ★\n"); printf("\t\t★ * * ★\n");printf("\t\t★ * ♀欢迎进入♀ * ★\n");printf("\t\t★ * * ★\n"); printf("\t\t★ * 超市仓库管理系统 * ★\n");printf("\t\t★ * * ★\n");printf("\t\t★ ******************** ★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n"); printf("\t\t\t\t 1: 入库管理\n");printf("\t\t\t\t 2: 出库管理\n");printf("\t\t\t\t 3: 退货管理\n");printf("\t\t\t\t 4: 商品统计\n");printf("\t\t\t\t 0: 退出系统\n");}void menu(){printf("\t\t\t\t 1: 添加数据\n");printf("\t\t\t\t 2: 删除数据\n");printf("\t\t\t\t 3: 修改数据\n");printf("\t\t\t\t 4: 查看数据\n");printf("\t\t\t\t其它: 退回上一级菜单\n");}void menu2(){printf("\t\t★★★★★★★★★★★★★★★★★★★★★★★★★★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★ ******************** ★\n");printf("\t\t★ * * ★\n");printf("\t\t★ * ♀欢迎进入♀ * ★\n");printf("\t\t★ * * ★\n");printf("\t\t★ * 超市仓库管理系统 * ★\n");printf("\t\t★ * * ★\n");printf("\t\t★ ******************** ★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★★\n");printf("\t\t★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n");printf("\t\t\t\t 1: 入库管理\n");printf("\t\t\t\t 2: 出库管理\n");printf("\t\t\t\t 3: 退货管理\n");printf("\t\t\t\t 4: 商品统计\n");printf("\t\t\t\t 0: 退出系统\n");printf("\n\t\t\t\t输入错误,请重新输入!\n");}int Rkjl() //入库信息录入文件{ struct in_product p[N],s;int i=0,j,n;FILE *pf,*pf1;pf=fopen("入库信息记录.dat","rb+");pf1=fopen("入库信息记录.xls","r+");//printf("入库编号商品编号入库商品名入库数量入库价格总价\n");for(i=0;fread(&p[i],ILEN,1,pf)!=NULL;i++);//printf("%ld\t%s\t%s\t%d\t%d\t%d\n",p[i].num,p[i].p_num,p[i].name,p[i].amount,p[ i].price,p[i].t_price);for(j=0;j<i;j++)for(n=0;n<i-1;n++)if(p[n].num>p[n+1].num)//入库编号小的先录入{s=p[n];p[n]=p[n+1];p[n+1]=s;}rewind(pf);fseek(pf1,56L,0);for(j=0;j<i;j++){fwrite(&p[j],ILEN,1,pf);fprintf(pf1,"%ld\t%s\t%s\t%d\t%d\t%d\n",p[j].num,p[j].p_num,p[j].name,p[j].amou nt,p[j].price,p[j].t_price);}fclose(pf);fclose(pf1);return 0;}int Ckjl() //出库信息录入文件{ struct out_product p[N],s;int i,j,n;FILE *pf,*pf1;pf=fopen("出库信息记录.dat","rb+");pf1=fopen("出库信息记录.xls","r+");//printf("出库编号商品编号出库商品名出库数量出库价格总价\n");for(i=0;fread(&p[i],OLEN,1,pf)!=NULL;i++);//printf("%ld\t%s\t%s\t%d\t%d\t%d\n",p[i].num,p[i].p_num,p[i].name,p[i].amount,p[ i].price,p[i].t_price);for(j=0;j<i;j++)for(n=0;n<i-1;n++)if(p[n].num>p[n+1].num)//出库编号小的先录入{s=p[n];p[n]=p[n+1];p[n+1]=s;}rewind(pf);fseek(pf1,56L,0);for(j=0;j<i;j++){fwrite(&p[j],OLEN,1,pf);fprintf(pf1,"%ld\t%s\t%s\t%d\t%d\t%d\n",p[j].num,p[j].p_num,p[j].name,p[j].amou nt,p[j].price,p[j].t_price);}fclose(pf);fclose(pf1);return 0;}int Thjl() //退货信息录入文件{ struct quit_product p[N],s;int i,j,n;FILE *pf,*pf1;pf=fopen("退货信息记录.dat","rb+");pf1=fopen("退货信息记录.xls","r+");for(i=0;fread(&p[i],QLEN,1,pf)!=NULL;i++);for(j=0;j<i;j++)for(n=0;n<i-1;n++)if(p[n].num>p[n+1].num)//退货编号小的先录入{s=p[n];p[n]=p[n+1];p[n+1]=s;}rewind(pf);fseek(pf1,56L,0);for(j=0;j<i;j++){fwrite(&p[j],QLEN,1,pf);fprintf(pf1,"%ld\t%s\t%s\t%d\t%d\t%d\n",p[j].num,p[j].p_num,p[j].name,p[j].amou nt,p[j].price,p[j].t_price);}fclose(pf);fclose(pf1);return 0;}int insert_product() //添加商品数据并录入文件{struct product *p1,*p;FILE *pf;if((pf=fopen("商品信息记录.xls","r"))==NULL){pf=fopen("商品信息记录.xls","w");fprintf(pf,"%s\t%s\t%s\t%s\t%s\t%s\n","商品编号","商品名","型号/规格","商品数量","进货价","销售价");fclose(pf);}pf=fopen("商品信息记录.xls","a+");p1=(struct product *)malloc(LEN);p=head;if (p==NULL){ printf("\n下列数据将录入\"商品信息记录\"文件中!\n");printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n商品名:");scanf("%s",&p1->name);printf("\n型号/规格:");scanf("%s",&p1->spec);printf("\n商品数量:");scanf("%d",&p1->amount);printf("\n进货价:");scanf("%d",&p1->price);printf("\n销售价:");scanf("%d",&p1->s_price);fprintf(pf,"%s\t%s\t%s\t%d\t%d\t%d\n",p1->p_num,p1->name,p1->spec,p1->amoun t,p1->price,p1->s_price);fclose(pf);head=p1;head->next=NULL;return 0;}while(p->next!=NULL)//把指针移到链表末端,在链表末端插入数据p=p->next;p->next=p1;printf("\n下列数据将录入\"商品信息记录\"文件中!\n");printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n商品名:");scanf("%s",&p1->name);printf("\n型号/规格:");scanf("%s",&p1->spec);printf("\n商品数量:");scanf("%d",&p1->amount);printf("\n进货价:");scanf("%d",&p1->price);printf("\n销售价:");scanf("%d",&p1->s_price);fprintf(pf,"%s\t%s\t%s\t%d\t%d\t%d\n",p1->p_num,p1->name,p1->spec,p1->amount,p1->price,p1->s_price);fclose(pf);p1->next=NULL;return 0;}int in_insert() //添加入库数据{struct in_product *p1,*p2;int n=0;char c[5];FILE *pf;system("cls");pf=fopen("入库信息记录.dat","ab+");p1=p2=(struct in_product *)malloc(ILEN);printf("\t\t\t**输入入库商品信息**\n");printf("\n下列数据将录入\"入库信息记录\"文件中!\n");printf("\n入库编号:");scanf("%ld",&p1->num);printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n入库商品名:");scanf("%s",&p1->name);printf("\n入库数量:");scanf("%d",&p1->amount);printf("\n入库价格:");scanf("%d",&p1->price);p1->t_price=p1->amount*p1->price;printf("\n总价:");printf("%d\n",p1->t_price);fwrite(p1,ILEN,1,pf);insert_product();ihead=NULL;while(1){n=n+1;if(n==1)ihead=p1;else p2->next=p1;p2=p1;p1=(struct in_product *)malloc(ILEN);while(1){printf("\n退出输入请按Y/y键,任意键继续:");scanf("%s",c);if(strcmp(c,"y")==0||strcmp(c,"Y")==0){ fclose(pf);p2->next=NULL;return 0;}else break;}printf("\n下列数据将录入\"入库信息记录\"文件中!\n");printf("\n入库编号:");scanf("%ld",&p1->num);printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n入库商品名:");scanf("%s",&p1->name);printf("\n入库数量:");scanf("%d",&p1->amount);printf("\n入库价格:");scanf("%d",&p1->price);p1->t_price=p1->amount*p1->price;printf("\n总价:");printf("%d\n",p1->t_price);fwrite(p1,ILEN,1,pf);insert_product();}fclose(pf);p2->next=NULL;return 0;}int in_modify() //修改入库数据{system("cls");long m_num;FILE *fp,*fp1;int i,j,n;int t=3;struct in_product xg[N];fp=fopen("入库信息记录.dat","rb+");fp1=fopen("入库信息记录.xls","r+");printf("入库编号商品编号入库商品名入库数量入库价格总价\n");printf("-----------------------------------------------------------------------\n");for(i=0;fread(&xg[i],ILEN,1,fp)!=NULL;i++){ printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",xg[i].num,xg[i].p_num,xg[i].name,xg[i].amount,xg[i].price,xg[i].t_price);printf("-----------------------------------------------------------------------\n");}printf("输入要修改的商品的入库编号:");IXG: scanf("%ld",&m_num);j=0;while(j<i){if(xg[j].num==m_num){printf("\t\t\t输入新的入库商品信息!\n");printf("\n商品编号:");scanf("%s",&xg[j].p_num);printf("\n入库商品名:");scanf("%s",&xg[j].name);printf("\n入库数量:");scanf("%d",&xg[j].amount);printf("\n入库价格:");scanf("%d",&xg[j].price);xg[j].t_price=xg[j].amount*xg[j].price;printf("\n总价:");printf("%d\n",xg[j].t_price);printf("\t\t\t商品信息修改成功!\n");printf("入库编号商品编号入库商品名入库数量入库价格总价\n");printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",xg[j].num,xg[j].p_num,xg[j].name,xg[j].amount,xg[j].price,xg[j].t_price);rewind(fp);fseek(fp1,56L,0);for(n=0;n<i;n++){fwrite(&xg[n],ILEN,1,fp);fprintf(fp1,"%ld\t%s\t%s\t%d\t%d\t%d\n",xg[n].num,xg[n].p_num,xg[n].name,xg [n].amount,xg[n].price,xg[n].t_price);}fclose(fp);fclose(fp1);printf("按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该入库编号,请重新输入,还有[%d]次机会:",t);goto IXG;}int in_select() //查询入库数据{system("cls");FILE *fp;int i,j;int t=3;long s_num;struct in_product cx[N];if((fp=fopen("入库信息记录.dat","rb"))==NULL){printf("can not open file\n");exit(0);}printf("\t\t\t--------------------\n");printf("\t\t\t★入库货物统计如下★\n");printf("\t\t\t--------------------\n\n");printf("入库编号商品编号入库商品名入库数量入库价格总价\n");printf("-----------------------------------------------------------------------\n");for(i=0;fread(&cx[i],ILEN,1,fp)!=NULL;i++){ printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",cx[i].num,cx[i].p_num,cx[i].name,cx[i].amount,cx[i].price,cx[i].t_price);printf("-----------------------------------------------------------------------\n");}fclose(fp);printf("输入要查询的入库编号:");ICX:scanf("%ld",&s_num);j=0;while(j<i){if(cx[j].num==s_num){printf("\n查询结果如下:\n\n");printf("入库编号商品编号入库商品名入库数量入库价格总价\n");printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",cx[j].num,cx[j].p_num,cx[j].name,cx[j].amount,cx[j].price,cx[j].t_price);printf("按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该入库编号,还有[%d]次机会,请重新输入:",t);goto ICX;}int in_delete() //删除入库数据,若所要取出的商品数量小于商品总数量,则是商品总数减少//若取出所有商品数量,则删除那一行数据{system("cls");int i,n,j;int t=3;int s;long d_num;struct in_product sc[N];FILE *fp,*fp1;fp=fopen("入库信息记录.dat","rb+");for(i=0;fread(&sc[i],ILEN,1,fp)!=NULL;i++);printf("输入要取出的商品的入库编号:");ISC:scanf("%ld",&d_num);printf("\n 输入要取出的商品的数量:");scanf("%d",&s);j=0;while(j<i){if(sc[j].num==d_num){fp=fopen("入库信息记录.dat","wb+");fp1=fopen("入库信息记录.xls","w");fprintf(fp1,"%s\t%s\t%s\t%s\t%s\t%s\n","入库编号","商品编号","入库商品名","入库数量","入库价格","总价");if((sc[j].amount-s)==0){for(n=j;n<i-1;n++)sc[n]=sc[n+1];fseek(fp1,56L,0);for(n=0;n<i-1;n++){ fwrite(&sc[n],ILEN,1,fp);fprintf(fp1,"%ld\t%s\t%s\t%d\t%d\t%d\n",sc[n].num,sc[n].p_num,sc[n].name,sc [n].amount,sc[n].price,sc[n].t_price);}}else if((sc[j].amount-s)>0){sc[j].amount-=s;fseek(fp1,56L,0);for(n=0;n<i;n++){ fwrite(&sc[n],ILEN,1,fp);fprintf(fp1,"%ld\t%s\t%s\t%d\t%d\t%d\n", sc[n].num,sc[n].p_num,sc[n].name,sc[n].amount,sc[n].price,sc[n].t_price);}}else{printf("\n 没有这么多的库存量!\n");printf("\n按回车键退回上一级菜单....");getchar();getchar();return 0;}fclose(fp);fclose(fp1);printf("\n ☆商品已成功取出!\n\n");printf("按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该入库编号,还有[%d]次机会,请重新输入:",t);goto ISC;return 0;}int out_insert() //增加出库数据//删除了入库数据,则把该数据信息增加到“输入出库商品信息”文件中{system("cls");struct out_product *p1,*p2;int n=0;char c[5];FILE *pf;pf=fopen("出库信息记录.dat","ab+");p1=p2=(struct out_product *)malloc(OLEN);printf("\t\t\t**输入出库商品信息**\n\n");printf("下列数据将录入\"出库信息记录\"文件中!\n");printf("\n出库编号:");scanf("%ld",&p1->num);printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n出库商品名:");scanf("%s",&p1->name);printf("\n出库数量:");scanf("%d",&p1->amount);printf("\n出库价格:");scanf("%d",&p1->price);p1->t_price=p1->amount*p1->price;printf("\n总价:");printf("%d\n",p1->t_price);fwrite(p1,OLEN,1,pf);ohead=NULL;while(1){n=n+1;if(n==1)ohead=p1;else p2->next=p1;p2=p1;p1=(struct out_product *)malloc(OLEN);while(1){printf("退出输入请按Y/y键,任意键继续:");scanf("%s",c);if(strcmp(c,"y")==0||strcmp(c,"Y")==0){ fclose(pf);p2->next=NULL;return 0;}else break;}printf("\n出库编号:");scanf("%ld",&p1->num);printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n出库商品名:");scanf("%s",&p1->name);printf("\n出库数量:");scanf("%d",&p1->amount);printf("\n出库价格:");scanf("%d",&p1->price);p1->t_price=p1->amount*p1->price;printf("\n总价:");printf("%d\n",p1->t_price);fwrite(p1,OLEN,1,pf);}fclose(pf);p2->next=NULL;return 0;}int out_modify() //修改出库数据//相当于更新“出库信息记录”中的内容{system("cls");long m_num;FILE *fp,*fp1;int i,j,n;int t=3;struct out_product xg[N];fp=fopen("出库信息记录.dat","rb+");fp1=fopen("出库信息记录.xls","r+");printf("出库编号商品编号出库商品名出库数量出库价格总价\n");printf("-----------------------------------------------------------------------\n");for(i=0;fread(&xg[i],OLEN,1,fp)!=NULL;i++){printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",xg[i].num,xg[i].p_num,xg[i].name,xg[i].amount,xg[i].price,xg[i].t_price);printf("-----------------------------------------------------------------------\n");}printf("输入要修改的商品的出库编号:");OXG: scanf("%ld",&m_num);while(j<i){if(xg[j].num==m_num){ printf("\n\t\t\t输入新的出库商品信息!\n");printf("\n商品编号:");scanf("%s",&xg[j].p_num);printf("\n出库商品名:");scanf("%s",&xg[j].name);printf("\n出库数量:");scanf("%d",&xg[j].amount);printf("\n出库价格:");scanf("%d",&xg[j].price);xg[j].t_price=xg[j].price*xg[j].amount;printf("\n总价:");printf("%d\n",xg[j].t_price);printf("\t\t\t商品信息修改成功!\n");printf("出库编号商品编号出库商品名出库数量出库价格总价\n");printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",xg[j].num,xg[j].p_num,xg[j].name,xg[j].amount,xg[j].price,xg[j].t_price);rewind(fp);fseek(fp1,56L,0);for(n=0;n<i;n++){ fwrite(&xg[n],OLEN,1,fp);fprintf(fp1,"%ld\t%s\t%s\t%d\t%d\t%d\n",xg[n].num,xg[n].p_num,xg[n].name,xg [n].amount,xg[n].price,xg[n].t_price);}fclose(fp);fclose(fp1);printf("按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该出库编号,还有[%d]次机会,请重新输入:",t);goto OXG;}int out_select() //查询出库数据{system("cls");FILE *fp;int i,j;int t=3;long s_num;struct out_product cx[N];if((fp=fopen("出库信息记录.dat","rb"))==NULL){printf("can not open file\n");exit(0);}printf("\t\t\t--------------------\n");printf("\t\t\t★出库货物统计如下★\n");printf("\t\t\t--------------------\n\n");printf("出库编号商品编号出库商品名出库数量出库价格总价\n");printf("-----------------------------------------------------------------------\n");for(i=0;fread(&cx[i],OLEN,1,fp)!=NULL;i++){ printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",cx[i].num,cx[i].p_num,cx[i].name,cx[i].amount,cx[i].price,cx[i].t_price);printf("-----------------------------------------------------------------------\n");}fclose(fp);printf("输入要查询的出库编号:");OCX:scanf("%ld",&s_num);j=0;while(j<i){if(cx[j].num==s_num){printf("\n查询结果如下:\n\n");printf("出库编号商品编号出库商品名出库数量出库价格总价\n");printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",cx[j].num,cx[j].p_num,cx[j].name,cx[j].amount,cx[j].price,cx[j].t_price);printf("按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该出库编号,还有[%d]次机会,请重新输入:",t);goto OCX;}int out_delete() //删除出库数据{system("cls");int i,n,j;int t=3;long d_num;struct out_product sc[N];FILE *fp,*fp1;fp=fopen("出库信息记录.dat","rb+");for(i=0;fread(&sc[i],OLEN,1,fp)!=NULL;i++);printf("输入要删除的商品的出库编号:");OSC:scanf("%ld",&d_num);j=0;while(j<i){if(sc[j].num==d_num){ for(n=j;n<i-1;n++)sc[n]=sc[n+1];fp=fopen("出库信息记录.dat","wb+");fp1=fopen("出库信息记录.xls","w");fprintf(fp1,"%s\t%s\t%s\t%s\t%s\t%s\n","出库编号","商品编号","出库商品名","出库数量","出库价格","总价");fseek(fp1,56L,0);for(n=0;n<i-1;n++){ fwrite(&sc[n],ILEN,1,fp);fprintf(fp1,"%ld\t%s\t%s\t%d\t%d\t%d\n",sc[n].num,sc[n].p_num,sc[n].name,sc[n]. amount,sc[n].price,sc[n].t_price);}fclose(fp);fclose(fp1);printf("删除成功!\n");printf("按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该出库编号,还有[%d]次机会,请重新输入:",t);goto OSC;}int quit_insert() //添加退货数据{system("cls");struct quit_product *p1,*p2;int n=0;char c[5];FILE *pf;pf=fopen("退货信息记录.dat","ab+");p1=p2=(struct quit_product *)malloc(QLEN);printf("\t\t\t**输入退还货物信息**\n");printf("\n下列数据将录入\"退货信息记录\"文件之中!\n");printf("\n退货编号:");scanf("%ld",&p1->num);printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n退还货物名:");scanf("%s",&p1->name);printf("\n退货数量:");scanf("%d",&p1->amount);printf("\n退货价格:");scanf("%d",&p1->price);p1->t_price=p1->price*p1->amount;printf("\n总价:");printf("%d\n",p1->t_price);fwrite(p1,QLEN,1,pf);qhead=NULL;while(1){n=n+1;if(n==1)qhead=p1;else p2->next=p1;p2=p1;p1=(struct quit_product *)malloc(QLEN);while(1){printf("退出输入请按Y/y键,任意键继续:");scanf("%s",c);if(strcmp(c,"y")==0||strcmp(c,"Y")==0){ fclose(pf);p2->next=NULL;return 0;}else break;}printf("\n退货编号:");scanf("%ld",&p1->num);printf("\n商品编号:");scanf("%s",&p1->p_num);printf("\n退还货物名:");scanf("%s",&p1->name);printf("\n退货数量:");scanf("%d",&p1->amount);printf("\n退货价格:");scanf("%d",&p1->price);p1->t_price=p1->price*p1->amount;printf("\n总价:");printf("%d\n",p1->t_price);fwrite(p1,QLEN,1,pf);}fclose(pf);p2->next=NULL;return 0;}int quit_modify() //修改退货数据,相当于更新数据库{system("cls");long m_num;FILE *fp,*fp1;int i,j,n;int t=3;struct quit_product xg[N];fp=fopen("退货信息记录.dat","rb+");fp1=fopen("退货信息记录.xls","r+");printf("退货编号商品编号退还货物名退货数量退货价格总价\n");printf("-----------------------------------------------------------------------\n");for(i=0;fread(&xg[i],QLEN,1,fp)!=NULL;i++){printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",xg[i].num,xg[i].p_num,xg[i].name,xg[i].amount,xg[i].price,xg[i].t_price);printf("-----------------------------------------------------------------------\n");}printf("\n输入要修改的商品的退货编号:");QXG: scanf("%ld",&m_num);j=0;while(j<i){if(xg[j].num==m_num){printf("\n\t\t\t输入新的退还货物信息!\n");printf("\n商品编号:");scanf("%s",&xg[j].p_num);printf("\n退还货物名:");scanf("%s",&xg[j].name);printf("\n退货数量:");scanf("%d",&xg[j].amount);printf("\n退货价格:");scanf("%d",&xg[j].price);xg[j].t_price=xg[j].amount*xg[j].price;printf("\n总价:");printf("%d\n",xg[j].t_price);printf("\t\t\t商品信息修改成功!\n");printf("退货编号商品编号退还货物名退货数量退货价格总价\n");printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n", xg[j].num,xg[j].p_num,xg[j].name,xg[j].amount,xg[j].price,xg[j].t_price);rewind(fp);fseek(fp1,56L,0);for(n=0;n<i;n++){ fwrite(&xg[n],QLEN,1,fp);fprintf(fp1,"%ld\t%s\t%s\t%d\t%d\t%d\n",xg[n].num,xg[n].p_num,xg[n].name,xg [n].amount,xg[n].price,xg[n].t_price);}fclose(fp);fclose(fp1);printf("\n按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该退货编号,还有[%d]次机会,请重新输入:",t);goto QXG;}int quit_select() //查询退货数据{system("cls");FILE *fp;int i,j;int t=3;long s_num;struct quit_product cx[N];if((fp=fopen("退货信息记录.dat","rb"))==NULL){printf("找不到文件\n");exit(0);}printf("\t\t\t--------------------\n");printf("\t\t\t★退还货物统计如下★\n");printf("\t\t\t--------------------\n\n");printf("退货编号商品编号退还货物名退货数量退货价格总价\n");printf("-----------------------------------------------------------------------\n");for(i=0;fread(&cx[i],QLEN,1,fp)!=NULL;i++){ printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",cx[i].num,cx[i].p_num,cx[i].name,cx[i].amount,cx[i].price,cx[i].t_price);printf("-----------------------------------------------------------------------\n");}fclose(fp);printf("\n输入要查询的退货编号:");QCX:scanf("%ld",&s_num);j=0;while(j<i){if(cx[j].num==s_num){printf("\n查询结果如下:\n\n");printf("退货编号商品编号退还货物名退货数量退货价格总价\n");printf(" %-8ld %-8s %-10s %-8d %-8d %-8d\n",cx[j].num,cx[j].p_num,cx[j].name,cx[j].amount,cx[j].price,cx[j].t_price);printf("\n按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该退货编号,还有[%d]次机会,请重新输入:",t);goto QCX;}int quit_delete() //删除不需要记录了的退货数据{system("cls");int i,n,j;int t=3;long d_num;struct quit_product sc[N];FILE *fp,*fp1;fp=fopen("退货信息记录.dat","rb+");for(i=0;fread(&sc[i],QLEN,1,fp)!=NULL;i++);printf("\n\n输入要删除的商品的退货编号:");QSC:scanf("%ld",&d_num);j=0;while(j<i){if(sc[j].num==d_num){ for(n=j;n<i-1;n++)sc[n]=sc[n+1];fp=fopen("退货信息记录.dat","wb+");fp1=fopen("退货信息记录.xls","w");fprintf(fp1,"%s\t%s\t%s\t%s\t%s\t%s\n","退货编号","商品编号","退还货物名","退货数量","退货价格","总价");fseek(fp1,56L,0);for(n=0;n<i-1;n++){ fwrite(&sc[n],QLEN,1,fp);fprintf(fp1,"%ld\t%s\t%s\t%d\t%d\t%d\n",sc[n].num,sc[n].p_num,sc[n].name,sc[n]. amount,sc[n].price,sc[n].t_price);}fclose(fp);fclose(fp1);printf("\n★删除成功!\n");printf("\n按回车键退回上一级菜单....");getchar();getchar();return 0;}j++;}t--;if(t==0)return 0;printf("\n没有找到该退货编号,还有[%d]次机会,请重新输入:",t);goto QSC;}int total() //商品总的记录查询,不删除任何数据{system("cls");printf("\t\t\t********************\n");printf("\t\t\t* *\n");printf("\t\t\t* 商品统计信息 *\n");printf("\t\t\t* *\n");printf("\t\t\t********************\n\n\n");struct product tj,s;int i=0;//char c;long s_sum=0,p_sum=0;FILE *fp;if((fp=fopen("商品信息记录.xls","r"))==NULL){ printf("\n\n\t\t\t 还没统计数据!\n");//printf("\n\n按回车键退回上一级菜单....");//c=getchar();//c=getchar();system("pause");return 0;}printf("商品编号商品名型号/规格商品数量进货价销售价\n");printf("---------------------------------------------------------------------\n ");fseek(fp,56L,0);while(!feof(fp)){fscanf(fp,"%s\t%s\t%s\t%d\t%d\t%d\n",&tj.p_num,&,&tj.spec,&tj.amount,&tj.price,&tj.s_price);p_sum+=tj.price*tj.amount;s_sum+=tj.amount;printf("%-8s %-8s %-10s %-8d %-8d %-8d\n",tj.p_num,,tj.spec,tj.amount,tj.price,tj.s_price);printf("---------------------------------------------------------------------\n ");i++;}printf("\n商品种类有:%d(种)\n",i);printf("\n商品总数为:%ld(件)\n",s_sum);printf("\n商品总进货价为:%ld(元)\n",p_sum);/*while(1){printf("\n按任意键退回上一级菜单....");scanf("%s",c);if(strcmp(c,"Y")==0||strcmp(c,"y")==0)return 0;}*///printf("\n按回车键退回上一级菜单....");// c=getchar();// c=getchar();system("pause");return 0;}int in_case(){char choice;choice=getchar();system("cls");printf("\t\t\t\t********************\n");printf("\t\t\t\t* *\n");printf("\t\t\t\t* 入库信息管理 *\n");printf("\t\t\t\t* *\n");printf("\t\t\t\t********************\n\n\n");menu();while(1){printf("\n\t\t\t\t 输入你的选择:");scanf("%c",&choice);switch(choice){case '1': in_insert();Rkjl();getchar();break;case '2': in_delete();break;case '3': in_modify();break;。

相关主题