资源描述:
《C语言设计实现销售管理系统源代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include"stdio.h"#include"string.h"#include"stdlib.h"structgoods{charname[20];intprice;charpro[20];intkc;intxs;}s[30];voidadd();voidselect();voidupdate();voidcenter(){intk;printf("----------------------欢迎登陆销售管理系统--------------------");printf("");printf("");printf("");printf("
2、请输入您要操作的功能:");printf("1,添加商品信息2,查找商品信息3,修改商品信息4,退出系统");scanf("%d",&k);switch(k){case1:system("CLS");add();break;case2:system("CLS");select();break;case3:system("CLS");update();break;case4:exit(0);break;}}voidadd(){FILE*fp;fp=fopen("goods.txt","a");printf("请输入商品名称单价生产厂家库存量销售量");
3、scanf("%s%d%s%d%d",&s[0].name,&s[0].price,&s[0].pro,&s[0].kc,&s[0].xs);fwrite(&s[0],sizeof(structgoods),1,fp);printf("添加成功");fclose(fp);center();}voidselect(){inti;charname[20];intmoney,k;FILE*fp;fp=fopen("goods.txt","rb");printf("您是要查找1;按商品名称2;生产厂家:");scanf("%d",&k);switch(k){ca
4、se1:printf("请输入商品名称:");scanf("%s",&name);for(i=0;i<30;i++){fread(&s[i],sizeof(structgoods),1,fp);if(strcmp(s[i].name,name)==0){printf("销售量金额库存量为:");money=s[i].price*s[i].xs;printf("%dt%dt%d",s[i].xs,money,s[i].kc);}}break;case2:printf("请输入生产厂家:");scanf("%s",&name);for(i=0;i
5、<30;i++){fread(&s[i],sizeof(structgoods),1,fp);if(strcmp(s[i].pro,name)==0){printf("销售量金额库存量为:");money=s[i].price*s[i].xs;printf("%dt%dt%d",s[i].xs,money,s[i].kc);}}break;}fclose(fp);center();}voidupdate(){inti;charname[20];intup,k;FILE*fp;fp=fopen("goods.txt","rb");for(i=0;i<3
6、0;i++){fread(&s[i],sizeof(structgoods),1,fp);}fclose(fp);if((fp=fopen("goods.txt","wb"))!=NULL)printf("请输入您要修改的商品名称:");scanf("%s",name);printf("您要修改:1,库存量2,销售量");scanf("%d",&k);switch(k){case1:for(i=0;i<30;i++){if(strcmp(s[i].name,name)==0){printf("请输入您要修改的值:");scanf("%d",&up);
7、s[i].kc=up;printf("修改成功");}fwrite(&s[i],sizeof(structgoods),1,fp);}break;case2:for(i=0;i<30;i++){if(strcmp(s[i].name,name)==0){printf("请输入您要修改的值:");scanf("%d",&up);s[i].xs=up;printf("修改成功");}fwrite(&s[i],sizeof(structgoods),1,fp);}break;}fclose(fp);center();}intmain(){center();
8、}