服装管理系统文档.docx
《服装管理系统文档.docx》由会员分享,可在线阅读,更多相关《服装管理系统文档.docx(48页珍藏版)》请在冰豆网上搜索。
服装管理系统文档
C语言课程设计
服装管理系统
专业:
网络工程
题目:
班级:
193092班
姓名:
张博
学号:
20091002676
指导教师:
张冬梅
【整体E-R图】
一.服装管理系统
欢迎界面
欢迎界面及主函数代码
intmain()//主函数模块
{
voidMenu();//声明函数
Menu();//调用菜单函数
system("pause");//系统暂停函数
}
voidMenu()
voidAdmin();
intn,w;
do
/*用一个do-while循环控制输入
printf("_____________________________MENU_____________________________\n\n");
printf("\t\t\t请选择您以何种方式登录<1-4>:
\n");
printf("\t\t\t1).Admin\n");//管理员模块
printf("\t\t\t2).Shopkeeper\n");//店长模块
printf("\t\t\t3).Seller\n");//销售员模块
printf("\t\t\t4).Exit\n");//退出
printf("_______________________________________________________________\n\n");
printf("Choice[]\b\b");
scanf("%d",&n);
if(n<1||n>4)
w=1;
getchar();
else
w=0;
}while(w==1);
switch(n)
case1:
Admin();break;//管理员模块
case2:
Shopkeeper();break;//店主模块
case3:
Region();break;//售货员模块
case4:
exit(0);//退出
(管理员)登陆模块voidAdmin()函数
voidAdmin()
voidAdminWelcome();//管理员欢迎界面
voidChangePassWord();//密码修改函数
FILE*fplast;//文件尾指针
FILE*fp;//文件指针
intlast;
inti=0;
intPASS;//逻辑变量
charCPassWord[20];
charCID[20]="zhangbo";//账户
charID[20];
charPassWord[20];
fp=fopen("AdminPassWord.db","r");
fplast=fopen("AdminPassWord.db","r");
fseek(fplast,0,SEEK_END);//
last=ftell(fplast);
for(i=0;i{CPassWord[i]=fgetc(fp);}CPassWord[i]='\0';fclose(fp);printf("您好管理员,请输入您的账户及密码[ENTER]结束\n\n\n");do{printf("\t\t\t账户__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",ID);printf("\t\t\t密码__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",PassWord);if(strcmp(CPassWord,PassWord)==0&&strcmp(CID,ID)==0){printf("Welcome!\n\n");PASS=1;AdminWelcome();}else{printf("PasswordorIDerror\n");PASS=0;}}while(PASS!=1);}运行结果如下: 1).(管理员)用户添加模块/*****用户添加********/voidUserAdd(){inti;structUser{charname[20];//用户名charPassWord[20];//密码structUser*next;//指向下一个结构体的指针};structUser*head=NULL,*cur,*pre;FILE*fp;fp=fopen("UserInfo.txt","a");charinput[20];printf("请输入您第一位用户的ID:\n");/*创建动态线性链表*/while(scanf("%s",input)!=NULL&&input[0]!='#'){cur=(structUser*)malloc(sizeof(structUser));if(head==NULL)head=cur;elsepre->next=cur;cur->next=NULL;strcpy(cur->name,input);puts("请输入密码:");scanf("%s",&cur->PassWord);while(getchar()!='\n')continue;printf("请输入下一位的用户名:(#toquit)\n");fwrite(cur,sizeof(structUser),1,fp);pre=cur;}Cur=head;if(head==NULL)printf("您没有添加用户!");else{printf("您所添加的用户:\n");while(cur!=NULL){printf("ID:%s",cur->name);printf("\n");printf("密码:%s",cur->PassWord);printf("\n");cur=cur->next;}}cur=head;while(cur!=head)//释放内存{free(cur);cur=cur->next;}fclose(fp);} 2).(管理员)用户删除模块voidUserdelete(){structUser{charname[20];charPassWord[20];structUser*next;};structUserUsers[100];intn,i,m;FILE*fp;fp=fopen("UserInfo.txt","rb+");printf("请问您要删除哪位用户的记录");scanf("%d",&n);for(i=0;fread(&Users[i],sizeof(structUser),1,fp);i++){/*讲文件内容读入内存,并记录结构体的数目*/m=i;}strcpy(Users[n-1].name,"0");//将要删除的记录置为零strcpy(Users[n-1].PassWord,"0");fclose(fp);//关闭文件p=fopen("UserInfo.txt","w");//以写入的方式再打开文件for(i=0;i{//将内存存储的结构体值送到文件中,如果遇到零,就跳过*/if(strcmp(Users[i].name,"0")==0&&strcmp(Users[i].PassWord,"0")==0)continue;fwrite(&Users[i],sizeof(structUser),1,fp);}fclose(fp);}运行结果如下 删除前:删除第一位用户后: 3).(管理员)显示所有用户模块voidUserView(){inti;structUser{charname[20];charPassWord[20];structUser*next;};structUserUsers[20];FILE*fp;fp=fopen("UserInfo.txt","rb");for(i=0;fread(&Users[i],sizeof(structUser),1,fp)>0;i++){printf("编号:%dID:%10s密码:%10s\n\n",i+1,Users[i].name,Users[i].PassWord);}fclose(fp);system("pause");}二.店长模块(店长)登陆界面voidShopkeeper(){voidShopkeeperWelcome();FILE*fplast;FILE*fp;intlast,i=0,PASS;charch;charCPassWord[20];charCID[20]="zhangbo";charID[20];charPassWord[20];fp=fopen("ShopkeeperPassWord.db","r");fplast=fopen("ShopkeeperPassWord.db","r");fseek(fplast,0,SEEK_END);last=ftell(fplast);for(i=0;i{CPassWord[i]=fgetc(fp);}CPassWord[i]='\0';fclose(fp);printf("您好店长,请输入您的账户及密码[ENTER]结束\n\n\n");do{printf("\t\t\t账户__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",ID);printf("\t\t\t密码__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",PassWord);if(strcmp(CPassWord,PassWord)==0&&strcmp(CID,ID)==0){printf("Welcome!\n\n\n\n");PASS=1;ShopkeeperWelcome();}else{printf("PasswordorIDerror\n");PASS=0;}}while(PASS!=1);getchar();} (店长)自身信息修改voidChangesInfo(){structShopkeeper{charname[20];//姓名intage;//年龄charsex[5];//性别charschool[40];//毕业院校};structShopkeeperkeeper1[2];FILE*fp;inti,n;fp=fopen("Shopkeeper.txt","r");printf("1)查看自身信息2)修改自身信息\n");printf("choice[]\b\b");scanf("%d",&n);switch(n){case1:for(i=0;fread(&keeper1[i],sizeof(structShopkeeper),1,fp)>0;i++){printf("姓名:%10s年龄:%d性别:%s毕业院校:%s\n\n",keeper1[i].name,keeper1[i].age,keeper1[i].sex,keeper1[i].school);}break;case2:fclose(fp);fp=fopen("Shopkeeper.txt","w");printf("请输入您的姓名,年龄,性别,毕业院校:\n");scanf("%s%d%s%s",keeper1[0].name,&keeper1[0].age,keeper1[0].sex,keeper1[0].school);fwrite(&keeper1[0],sizeof(structShopkeeper),1,fp);break;default:printf("输入有误!\n");break;}fclose(fp);} (店长)商品信息浏览voidGoodsInfoView(){structGInfomation{charname[20];floatprice;};structGInfomationGoods[20];FILE*fp;intn,i;fp=fopen("GInfo.txt","r");printf("\n\n\n\n\n\n商品信息如下:\n");printf("编号名称价格\n");for(i=0;fread(&Goods[i],sizeof(structGInfomation),1,fp)>0;i++){printf("%3d%10s%.2f\n",i+1,Goods[i].name,Goods[i].price);}fclose(fp);} (店长)营业员业绩报表voidGoodsSellView(){structSellerInfo{charGoodsName[20];structSellerInfo*next;};structSellerInfoGoods[200];FILE*fp;inti,m=0;fp=fopen("SellerInfo.txt","r");for(i=0;fread(&Goods[i],sizeof(structSellerInfo),1,fp)>0;i++){printf("%d%s\n",i+1,Goods[i].GoodsName);m=i+1;}printf("共%d件\n\n\n",m);fclose(fp);} (店长)密码修改voidChangeSPassWord(){FILE*fp;charch;printf("新密码:");getchar();fp=fopen("ShopkeeperPassWord.db","wb");while((ch=getchar())!='\n'){putc(ch,fp);}fclose(fp);}(销售员)voidSeller(){intn;voidMenu();voidGoodsSell();voidGoodsSellView();printf("您可以做如下操作:<1-4>\n");printf("__________________________________________________\n\n");printf("\t\t\t1).商品浏览\n");printf("\t\t\t2).商品查找\n");printf("\t\t\t3).出售\n");printf("\t\t\t4).查看本月报表\n");printf("\t\t\t5).返回主菜单\n");printf("\n\n\n\n\n\n\n");printf("Choice[]\b\b");scanf("%d",&n);switch(n){case1:GoodsInfoView();Seller();break;case2:GoodsSearch();Seller();break;case3:GoodsSell();Seller();break;case4:GoodsSellView();Seller();break;case5:Menu();break;}}voidRegion(){voidSeller();structUser{charname[20];//用户名charPassWord[20];//密码structUser*next;//指向下一个结构体的指针};structUserUsers[20];charcID[30];charcPW[20];intw=0;FILE*fp;inti;fp=fopen("UserInfo.txt","rb");do{printf("\n\n\t\t\tID:_______________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",cID);printf("\n\n\t\t\tPW:_______________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",cPW);for(i=0;fread(&Users[i],sizeof(structUser),1,fp)>0;i++){if(strcmp(cID,Users[i].name)==0&&strcmp(cPW,Users[i].PassWord)==0){w=1;break;}elsew=0;}if(w==1)Seller();elseprintf("输入错误");}while(w!=1);fclose(fp);system("pause");}(销售员)(销售员)商品浏览voidGoodsInfoView()………………同店长一个函数 (销售员)商品查找voidGoodsSearch()//商品查找{structGInfomation{charname[20];floatprice;};FILE*fp;FILE*head,*last;intn;structGInfomationGoods[20];fp=fopen("GInfo.txt","r");printf("请输入查找的商品编号");scanf("%d",&n);fseek(fp,(n-1)*sizeof(structGInfomation),SEEK_SET);fread(&Goods[n-1],sizeof(structGInfomation),1,fp);printf("%s%.2f",Goods[n-1].name,Goods[n-1].price);fclose(fp);}(销售员)商品出售voidGoodsSell()//商品出售{structSellerInfo{charGoodsName[20];structSellerInfo*next;};FILE*fp;structSellerInfo*head=NULL,*pre,*cur;charinput[20];fp=fopen("SellerInfo.txt","ab");printf("请输入您要出售的商品的名称:\n");gets(input);while(gets(input)!=NULL&&input[0]!='\#'){cur=(structSellerInfo*)malloc(sizeof(structSellerInfo));if(head==NULL)head=cur;elsepre->next=cur;cur->next=NULL;strcpy(cur->GoodsName,input);fwrite(cur,sizeof(structSellerInfo),1,fp);printf("请输入您的下一商品的名称,如果没有,请按#:");pre=cur;}fclose(fp);}(销售员)查看报表voidGoodsSellView()….同店长营业员业绩报表参考文献1.谭浩强.《C程序设计》.清华大学出版社,1991年第一版.2.张冬梅.《C语言课程设计与学习指导》.中国铁道出版社2008年第一版源代码如下:#include#include#include/***********************管理员登陆模块****************************/voidAdmin(){voidAdminWelcome();//管理员欢迎界面voidChangePassWord();//密码修改函数FILE*fplast;//文件尾指针FILE*fp;//文件指针intlast;inti=0;int
CPassWord[i]=fgetc(fp);
CPassWord[i]='\0';
fclose(fp);
printf("您好管理员,请输入您的账户及密码[ENTER]结束\n\n\n");
printf("\t\t\t账户__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%s",ID);
printf("\t\t\t密码__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%s",PassWord);
if(strcmp(CPassWord,PassWord)==0&&strcmp(CID,ID)==0)
printf("Welcome!
\n\n");
PASS=1;
AdminWelcome();
{printf("PasswordorIDerror\n");PASS=0;}
}while(PASS!
=1);
运行结果如下:
1).(管理员)用户添加模块
/*****用户添加********/
voidUserAdd()
inti;
structUser
charname[20];//用户名
charPassWord[20];//密码
structUser*next;//指向下一个结构体的指针
};
structUser*head=NULL,*cur,*pre;
FILE*fp;
fp=fopen("UserInfo.txt","a");
charinput[20];
printf("请输入您第一位用户的ID:
/*创建动态线性链表*/
while(scanf("%s",input)!
=NULL&&input[0]!
='#')
cur=(structUser*)malloc(sizeof(structUser));
if(head==NULL)
head=cur;
pre->next=cur;
cur->next=NULL;
strcpy(cur->name,input);
puts("请输入密码:
");
scanf("%s",&cur->PassWord);
while(getchar()!
='\n')
continue;
printf("请输入下一位的用户名:
(#toquit)\n");
fwrite(cur,sizeof(structUser),1,fp);
pre=cur;
Cur=head;
printf("您没有添加用户!
printf("您所添加的用户:
while(cur!
=NULL)
printf("ID:
%s",cur->name);
printf("\n");
printf("密码:
%s",cur->PassWord);
cur=cur->next;
cur=head;
=head)//释放内存
free(cur);
2).(管理员)用户删除模块
voidUserdelete()
charname[20];
structUser*next;
structUserUsers[100];
intn,i,m;
fp=fopen("UserInfo.txt","rb+");
printf("请问您要删除哪位用户的记录");
for(i=0;fread(&Users[i],sizeof(structUser),1,fp);i++)
{/*讲文件内容读入内存,并记录结构体的数目*/
m=i;
strcpy(Users[n-1].name,"0");//将要删除的记录置为零
strcpy(Users[n-1].PassWord,"0");
fclose(fp);//关闭文件
p=fopen("UserInfo.txt","w");//以写入的方式再打开文件
for(i=0;i{//将内存存储的结构体值送到文件中,如果遇到零,就跳过*/if(strcmp(Users[i].name,"0")==0&&strcmp(Users[i].PassWord,"0")==0)continue;fwrite(&Users[i],sizeof(structUser),1,fp);}fclose(fp);}运行结果如下 删除前:删除第一位用户后: 3).(管理员)显示所有用户模块voidUserView(){inti;structUser{charname[20];charPassWord[20];structUser*next;};structUserUsers[20];FILE*fp;fp=fopen("UserInfo.txt","rb");for(i=0;fread(&Users[i],sizeof(structUser),1,fp)>0;i++){printf("编号:%dID:%10s密码:%10s\n\n",i+1,Users[i].name,Users[i].PassWord);}fclose(fp);system("pause");}二.店长模块(店长)登陆界面voidShopkeeper(){voidShopkeeperWelcome();FILE*fplast;FILE*fp;intlast,i=0,PASS;charch;charCPassWord[20];charCID[20]="zhangbo";charID[20];charPassWord[20];fp=fopen("ShopkeeperPassWord.db","r");fplast=fopen("ShopkeeperPassWord.db","r");fseek(fplast,0,SEEK_END);last=ftell(fplast);for(i=0;i{CPassWord[i]=fgetc(fp);}CPassWord[i]='\0';fclose(fp);printf("您好店长,请输入您的账户及密码[ENTER]结束\n\n\n");do{printf("\t\t\t账户__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",ID);printf("\t\t\t密码__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",PassWord);if(strcmp(CPassWord,PassWord)==0&&strcmp(CID,ID)==0){printf("Welcome!\n\n\n\n");PASS=1;ShopkeeperWelcome();}else{printf("PasswordorIDerror\n");PASS=0;}}while(PASS!=1);getchar();} (店长)自身信息修改voidChangesInfo(){structShopkeeper{charname[20];//姓名intage;//年龄charsex[5];//性别charschool[40];//毕业院校};structShopkeeperkeeper1[2];FILE*fp;inti,n;fp=fopen("Shopkeeper.txt","r");printf("1)查看自身信息2)修改自身信息\n");printf("choice[]\b\b");scanf("%d",&n);switch(n){case1:for(i=0;fread(&keeper1[i],sizeof(structShopkeeper),1,fp)>0;i++){printf("姓名:%10s年龄:%d性别:%s毕业院校:%s\n\n",keeper1[i].name,keeper1[i].age,keeper1[i].sex,keeper1[i].school);}break;case2:fclose(fp);fp=fopen("Shopkeeper.txt","w");printf("请输入您的姓名,年龄,性别,毕业院校:\n");scanf("%s%d%s%s",keeper1[0].name,&keeper1[0].age,keeper1[0].sex,keeper1[0].school);fwrite(&keeper1[0],sizeof(structShopkeeper),1,fp);break;default:printf("输入有误!\n");break;}fclose(fp);} (店长)商品信息浏览voidGoodsInfoView(){structGInfomation{charname[20];floatprice;};structGInfomationGoods[20];FILE*fp;intn,i;fp=fopen("GInfo.txt","r");printf("\n\n\n\n\n\n商品信息如下:\n");printf("编号名称价格\n");for(i=0;fread(&Goods[i],sizeof(structGInfomation),1,fp)>0;i++){printf("%3d%10s%.2f\n",i+1,Goods[i].name,Goods[i].price);}fclose(fp);} (店长)营业员业绩报表voidGoodsSellView(){structSellerInfo{charGoodsName[20];structSellerInfo*next;};structSellerInfoGoods[200];FILE*fp;inti,m=0;fp=fopen("SellerInfo.txt","r");for(i=0;fread(&Goods[i],sizeof(structSellerInfo),1,fp)>0;i++){printf("%d%s\n",i+1,Goods[i].GoodsName);m=i+1;}printf("共%d件\n\n\n",m);fclose(fp);} (店长)密码修改voidChangeSPassWord(){FILE*fp;charch;printf("新密码:");getchar();fp=fopen("ShopkeeperPassWord.db","wb");while((ch=getchar())!='\n'){putc(ch,fp);}fclose(fp);}(销售员)voidSeller(){intn;voidMenu();voidGoodsSell();voidGoodsSellView();printf("您可以做如下操作:<1-4>\n");printf("__________________________________________________\n\n");printf("\t\t\t1).商品浏览\n");printf("\t\t\t2).商品查找\n");printf("\t\t\t3).出售\n");printf("\t\t\t4).查看本月报表\n");printf("\t\t\t5).返回主菜单\n");printf("\n\n\n\n\n\n\n");printf("Choice[]\b\b");scanf("%d",&n);switch(n){case1:GoodsInfoView();Seller();break;case2:GoodsSearch();Seller();break;case3:GoodsSell();Seller();break;case4:GoodsSellView();Seller();break;case5:Menu();break;}}voidRegion(){voidSeller();structUser{charname[20];//用户名charPassWord[20];//密码structUser*next;//指向下一个结构体的指针};structUserUsers[20];charcID[30];charcPW[20];intw=0;FILE*fp;inti;fp=fopen("UserInfo.txt","rb");do{printf("\n\n\t\t\tID:_______________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",cID);printf("\n\n\t\t\tPW:_______________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",cPW);for(i=0;fread(&Users[i],sizeof(structUser),1,fp)>0;i++){if(strcmp(cID,Users[i].name)==0&&strcmp(cPW,Users[i].PassWord)==0){w=1;break;}elsew=0;}if(w==1)Seller();elseprintf("输入错误");}while(w!=1);fclose(fp);system("pause");}(销售员)(销售员)商品浏览voidGoodsInfoView()………………同店长一个函数 (销售员)商品查找voidGoodsSearch()//商品查找{structGInfomation{charname[20];floatprice;};FILE*fp;FILE*head,*last;intn;structGInfomationGoods[20];fp=fopen("GInfo.txt","r");printf("请输入查找的商品编号");scanf("%d",&n);fseek(fp,(n-1)*sizeof(structGInfomation),SEEK_SET);fread(&Goods[n-1],sizeof(structGInfomation),1,fp);printf("%s%.2f",Goods[n-1].name,Goods[n-1].price);fclose(fp);}(销售员)商品出售voidGoodsSell()//商品出售{structSellerInfo{charGoodsName[20];structSellerInfo*next;};FILE*fp;structSellerInfo*head=NULL,*pre,*cur;charinput[20];fp=fopen("SellerInfo.txt","ab");printf("请输入您要出售的商品的名称:\n");gets(input);while(gets(input)!=NULL&&input[0]!='\#'){cur=(structSellerInfo*)malloc(sizeof(structSellerInfo));if(head==NULL)head=cur;elsepre->next=cur;cur->next=NULL;strcpy(cur->GoodsName,input);fwrite(cur,sizeof(structSellerInfo),1,fp);printf("请输入您的下一商品的名称,如果没有,请按#:");pre=cur;}fclose(fp);}(销售员)查看报表voidGoodsSellView()….同店长营业员业绩报表参考文献1.谭浩强.《C程序设计》.清华大学出版社,1991年第一版.2.张冬梅.《C语言课程设计与学习指导》.中国铁道出版社2008年第一版源代码如下:#include#include#include/***********************管理员登陆模块****************************/voidAdmin(){voidAdminWelcome();//管理员欢迎界面voidChangePassWord();//密码修改函数FILE*fplast;//文件尾指针FILE*fp;//文件指针intlast;inti=0;int
{//将内存存储的结构体值送到文件中,如果遇到零,就跳过*/
if(strcmp(Users[i].name,"0")==0&&strcmp(Users[i].PassWord,"0")==0)continue;
fwrite(&Users[i],sizeof(structUser),1,fp);
运行结果如下
删除前:
删除第一位用户后:
3).(管理员)显示所有用户模块
voidUserView()
structUserUsers[20];
fp=fopen("UserInfo.txt","rb");
for(i=0;fread(&Users[i],sizeof(structUser),1,fp)>0;i++)
printf("编号:
%dID:
%10s密码:
%10s\n\n",i+1,Users[i].name,Users[i].PassWord);
system("pause");
二.店长模块
(店长)登陆界面
voidShopkeeper()
voidShopkeeperWelcome();
FILE*fplast;
intlast,i=0,PASS;
charch;
charCID[20]="zhangbo";
fp=fopen("ShopkeeperPassWord.db","r");
fplast=fopen("ShopkeeperPassWord.db","r");
fseek(fplast,0,SEEK_END);
for(i=0;i{CPassWord[i]=fgetc(fp);}CPassWord[i]='\0';fclose(fp);printf("您好店长,请输入您的账户及密码[ENTER]结束\n\n\n");do{printf("\t\t\t账户__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",ID);printf("\t\t\t密码__________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",PassWord);if(strcmp(CPassWord,PassWord)==0&&strcmp(CID,ID)==0){printf("Welcome!\n\n\n\n");PASS=1;ShopkeeperWelcome();}else{printf("PasswordorIDerror\n");PASS=0;}}while(PASS!=1);getchar();} (店长)自身信息修改voidChangesInfo(){structShopkeeper{charname[20];//姓名intage;//年龄charsex[5];//性别charschool[40];//毕业院校};structShopkeeperkeeper1[2];FILE*fp;inti,n;fp=fopen("Shopkeeper.txt","r");printf("1)查看自身信息2)修改自身信息\n");printf("choice[]\b\b");scanf("%d",&n);switch(n){case1:for(i=0;fread(&keeper1[i],sizeof(structShopkeeper),1,fp)>0;i++){printf("姓名:%10s年龄:%d性别:%s毕业院校:%s\n\n",keeper1[i].name,keeper1[i].age,keeper1[i].sex,keeper1[i].school);}break;case2:fclose(fp);fp=fopen("Shopkeeper.txt","w");printf("请输入您的姓名,年龄,性别,毕业院校:\n");scanf("%s%d%s%s",keeper1[0].name,&keeper1[0].age,keeper1[0].sex,keeper1[0].school);fwrite(&keeper1[0],sizeof(structShopkeeper),1,fp);break;default:printf("输入有误!\n");break;}fclose(fp);} (店长)商品信息浏览voidGoodsInfoView(){structGInfomation{charname[20];floatprice;};structGInfomationGoods[20];FILE*fp;intn,i;fp=fopen("GInfo.txt","r");printf("\n\n\n\n\n\n商品信息如下:\n");printf("编号名称价格\n");for(i=0;fread(&Goods[i],sizeof(structGInfomation),1,fp)>0;i++){printf("%3d%10s%.2f\n",i+1,Goods[i].name,Goods[i].price);}fclose(fp);} (店长)营业员业绩报表voidGoodsSellView(){structSellerInfo{charGoodsName[20];structSellerInfo*next;};structSellerInfoGoods[200];FILE*fp;inti,m=0;fp=fopen("SellerInfo.txt","r");for(i=0;fread(&Goods[i],sizeof(structSellerInfo),1,fp)>0;i++){printf("%d%s\n",i+1,Goods[i].GoodsName);m=i+1;}printf("共%d件\n\n\n",m);fclose(fp);} (店长)密码修改voidChangeSPassWord(){FILE*fp;charch;printf("新密码:");getchar();fp=fopen("ShopkeeperPassWord.db","wb");while((ch=getchar())!='\n'){putc(ch,fp);}fclose(fp);}(销售员)voidSeller(){intn;voidMenu();voidGoodsSell();voidGoodsSellView();printf("您可以做如下操作:<1-4>\n");printf("__________________________________________________\n\n");printf("\t\t\t1).商品浏览\n");printf("\t\t\t2).商品查找\n");printf("\t\t\t3).出售\n");printf("\t\t\t4).查看本月报表\n");printf("\t\t\t5).返回主菜单\n");printf("\n\n\n\n\n\n\n");printf("Choice[]\b\b");scanf("%d",&n);switch(n){case1:GoodsInfoView();Seller();break;case2:GoodsSearch();Seller();break;case3:GoodsSell();Seller();break;case4:GoodsSellView();Seller();break;case5:Menu();break;}}voidRegion(){voidSeller();structUser{charname[20];//用户名charPassWord[20];//密码structUser*next;//指向下一个结构体的指针};structUserUsers[20];charcID[30];charcPW[20];intw=0;FILE*fp;inti;fp=fopen("UserInfo.txt","rb");do{printf("\n\n\t\t\tID:_______________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",cID);printf("\n\n\t\t\tPW:_______________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",cPW);for(i=0;fread(&Users[i],sizeof(structUser),1,fp)>0;i++){if(strcmp(cID,Users[i].name)==0&&strcmp(cPW,Users[i].PassWord)==0){w=1;break;}elsew=0;}if(w==1)Seller();elseprintf("输入错误");}while(w!=1);fclose(fp);system("pause");}(销售员)(销售员)商品浏览voidGoodsInfoView()………………同店长一个函数 (销售员)商品查找voidGoodsSearch()//商品查找{structGInfomation{charname[20];floatprice;};FILE*fp;FILE*head,*last;intn;structGInfomationGoods[20];fp=fopen("GInfo.txt","r");printf("请输入查找的商品编号");scanf("%d",&n);fseek(fp,(n-1)*sizeof(structGInfomation),SEEK_SET);fread(&Goods[n-1],sizeof(structGInfomation),1,fp);printf("%s%.2f",Goods[n-1].name,Goods[n-1].price);fclose(fp);}(销售员)商品出售voidGoodsSell()//商品出售{structSellerInfo{charGoodsName[20];structSellerInfo*next;};FILE*fp;structSellerInfo*head=NULL,*pre,*cur;charinput[20];fp=fopen("SellerInfo.txt","ab");printf("请输入您要出售的商品的名称:\n");gets(input);while(gets(input)!=NULL&&input[0]!='\#'){cur=(structSellerInfo*)malloc(sizeof(structSellerInfo));if(head==NULL)head=cur;elsepre->next=cur;cur->next=NULL;strcpy(cur->GoodsName,input);fwrite(cur,sizeof(structSellerInfo),1,fp);printf("请输入您的下一商品的名称,如果没有,请按#:");pre=cur;}fclose(fp);}(销售员)查看报表voidGoodsSellView()….同店长营业员业绩报表参考文献1.谭浩强.《C程序设计》.清华大学出版社,1991年第一版.2.张冬梅.《C语言课程设计与学习指导》.中国铁道出版社2008年第一版源代码如下:#include#include#include/***********************管理员登陆模块****************************/voidAdmin(){voidAdminWelcome();//管理员欢迎界面voidChangePassWord();//密码修改函数FILE*fplast;//文件尾指针FILE*fp;//文件指针intlast;inti=0;int
printf("您好店长,请输入您的账户及密码[ENTER]结束\n\n\n");
{printf("Welcome!
\n\n\n\n");PASS=1;ShopkeeperWelcome();}
(店长)自身信息修改
voidChangesInfo()
structShopkeeper
charname[20];//姓名
intage;//年龄
charsex[5];//性别
charschool[40];//毕业院校
structShopkeeperkeeper1[2];
inti,n;
fp=fopen("Shopkeeper.txt","r");
printf("1)查看自身信息2)修改自身信息\n");
printf("choice[]\b\b");
for(i=0;fread(&keeper1[i],sizeof(structShopkeeper),1,fp)>0;i++)
{printf("姓名:
%10s年龄:
%d性别:
%s毕业院校:
%s\n\n",keeper1[i].name,keeper1[i].age,keeper1[i].sex,keeper1[i].school);}
break;
fclose(fp);fp=fopen("Shopkeeper.txt","w");
printf("请输入您的姓名,年龄,性别,毕业院校:
scanf("%s%d%s%s",keeper1[0].name,&keeper1[0].age,keeper1[0].sex,keeper1[0].school);
fwrite(&keeper1[0],sizeof(structShopkeeper),1,fp);break;
default:
printf("输入有误!
\n");break;
(店长)商品信息浏览
voidGoodsInfoView()
structGInfomation
floatprice;
structGInfomationGoods[20];
intn,i;
fp=fopen("GInfo.txt","r");
printf("\n\n\n\n\n\n商品信息如下:
printf("编号名称价格\n");
for(i=0;fread(&Goods[i],sizeof(structGInfomation),1,fp)>0;i++)
printf("%3d%10s%.2f\n",i+1,Goods[i].name,Goods[i].price);
(店长)营业员业绩报表
voidGoodsSellView()
structSellerInfo
charGoodsName[20];
structSellerInfo*next;
structSellerInfoGoods[200];
inti,m=0;
fp=fopen("SellerInfo.txt","r");
for(i=0;fread(&Goods[i],sizeof(structSellerInfo),1,fp)>0;i++)
printf("%d%s\n",i+1,Goods[i].GoodsName);m=i+1;
printf("共%d件\n\n\n",m);
(店长)密码修改
voidChangeSPassWord()
printf("新密码:
fp=fopen("ShopkeeperPassWord.db","wb");
while((ch=getchar())!
putc(ch,fp);
(销售员)
voidSeller()
intn;
voidMenu();
voidGoodsSell();
voidGoodsSellView();
printf("您可以做如下操作:
<1-4>\n");
printf("__________________________________________________\n\n");
printf("\t\t\t1).商品浏览\n");
printf("\t\t\t2).商品查找\n");
printf("\t\t\t3).出售\n");
printf("\t\t\t4).查看本月报表\n");
printf("\t\t\t5).返回主菜单\n");
printf("\n\n\n\n\n\n\n");
GoodsInfoView();Seller();break;
GoodsSearch();Seller();break;
GoodsSell();Seller();break;
GoodsSellView();Seller();break;
case5:
Menu();break;
voidRegion()
voidSeller();
charcID[30];
charcPW[20];
intw=0;
printf("\n\n\t\t\tID:
_______________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%s",cID);
printf("\n\n\t\t\tPW:
scanf("%s",cPW);
if(strcmp(cID,Users[i].name)==0&&strcmp(cPW,Users[i].PassWord)==0){w=1;break;}
if(w==1)
Seller();
printf("输入错误");
}while(w!
(销售员)商品浏览
voidGoodsInfoView()………………同店长一个函数
(销售员)商品查找
voidGoodsSearch()//商品查找
FILE*head,*last;
printf("请输入查找的商品编号");
fseek(fp,(n-1)*sizeof(structGInfomation),SEEK_SET);
fread(&Goods[n-1],sizeof(structGInfomation),1,fp);
printf("%s%.2f",Goods[n-1].name,Goods[n-1].price);
(销售员)商品出售
voidGoodsSell()//商品出售
structSellerInfo*head=NULL,*pre,*cur;
fp=fopen("SellerInfo.txt","ab");
printf("请输入您要出售的商品的名称:
gets(input);
while(gets(input)!
='\#')
cur=(structSellerInfo*)malloc(sizeof(structSellerInfo));
strcpy(cur->GoodsName,input);
fwrite(cur,sizeof(structSellerInfo),1,fp);
printf("请输入您的下一商品的名称,如果没有,请按#:
(销售员)查看报表
voidGoodsSellView()….同店长营业员业绩报表
参考文献
1.谭浩强.《C程序设计》.清华大学出版社,1991年第一版.
2.张冬梅.《C语言课程设计与学习指导》.中国铁道出版社2008年第一版
源代码如下:
#include
/***********************管理员登陆模块****************************/
int
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1