voidchushou(intcount);
voidAppend();
voidSelldelete();
voidAmend();
voidFindin();
voidBrowse();
voidcolorsetting();
voidEndprogram();
voidzonghe();
structproduce_node*lianbiao();
structproduce_node*Create_produce_Doc();
structproduce_node*InsertDoc(structproduce_node*();
voidchushou(intcount);
voidAppend();
voidSelldelete();
voidAmend();
voidFindin();
voidBrowse();
voidcolorsetting();
voidEndprogram();
voidzonghe();
structproduce_node*lianbiao();
structproduce_node*Create_produce_Doc();
structproduce_node*InsertDoc(structproduce_node*∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞【小型超市管理系统】∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞\n");
printf("系统菜单显示如下");
printf("\n\t1=====================【新购商品入库】\n");
printf("\n\t2=====================【商品信息删除】\n");
printf("\n\t3=====================【商品信息修改】\n");
printf("\n\t4=====================【商品信息查询】\n");
printf("\n\t5=====================【商品信息浏览】\n");
printf("\n\t6=====================【系统颜色设置】\n");
printf("\n\t7=====================【应用程序退出】\n");
printf("\n\t8=====================【商品价值总和浏览】\n");
printf("\n\t9=====================【商品的出售管理】\n");
printf("\n\t10====================【商品的预计的利润】\n");
printf("\n\t请输入您要选择的菜单......");
scanf("%d",&choice);
switch(choice)
{
case1:
Append();
break;
case2:
Selldelete();
break;
case3:
Amend();
break;
case4:
Findin();
break;
case5:
Browse();
break;
case6:
colorsetting();
break;
case7:
Endprogram();
break;
case8:
zonghe();
break;
case9:
{inti;
printf("请输入您要卖出的数量:
");
scanf("%d",&i);
chushou(i);}
break;
case10:
liren();
break;
default:
printf("\n\t\t\t\t\t输入无效,请您重新输入......");
getch();
system("cls");
menu();
}
}
voidcolorsetting()
{inta;
charchoice;
system("cls");
printf("\n\n\t\t选择以下方案\n");
printf("\n\n\t\t1**************红底黑字\n");
printf("\n\n\t\t2**************白底黑字\n");
printf("\n\n\t\t3**************黑底红字\n");
printf("\n\n\t\t4**************绿底蓝字\n");
printf("\n\n\t\t5**************黄底紫字\n");
printf("\n\n\t\t6**************系统默认\n");
printf("\n\n\t\t\t\t\t请挑选您喜爱的颜色<1-5>......");
scanf("%d",&a);
switch(a)
{
case1:
system("color40");
break;
case2:
system("color70");
break;
case3:
system("color04");
break;
case4:
system("color21");
break;
case5:
system("color65");
break;
case6:
system("color1a");
break;
default:
printf("\n\n\t\t\t\t\t输入无效,重新输入......");
getch();
colorsetting();
}
printf("\n选择的颜色您还满意吗?
(y返回主菜单n继续选择)");
scanf("%c",&choice);
if(choice=='Y'||choice=='y')
{
system("cls");
menu();
}
else
{
colorsetting();
}
}
intvalidateID(intid)
{
FILE*fp;
structimai;
fp=fopen("ima.date","r");
if(fp==NULL)
{
printf("\t\t\t系统错误,请您重试........");
exit(0);
}
fread(&i,sizeof(structima),1,fp);
while(!
feof(fp))
{
if(i.id==id)
{
fclose(fp);
return1;
break;
}
fread(&i,sizeof(structima),1,fp);
}
fclose(fp);
return0;
}
voidAppend()
{
structproduce_node*i;
structproduce_nodej;
charchoice;
FILE*fp;
fp=fopen("ima.date","ab");
i=&j;
if(fp==NULL)
{
printf("\t\t\t系统错误,请您重试........");
exit(0);
}
labID:
printf("\n\t请您输入要入库商品的信息...\n");
printf("\t\t\t\t商品的编号:
");
scanf("%d",&j.id);
if(validateID(j.id)==1)
{
printf("\t\t\t\t此编号已被使用,请您重新输入......\n");
gotolabID;
}
else
printf("****************************此编号没有被使用您可以使用**********************************\n");
i=lianbiao();
while(i!
=NULL)
{
fwrite(i,sizeof(structproduce_node),1,fp);
i=i->next;
}
fclose(fp);
printf("\t\t\t\t\t\t商品信息已入库成功!
!
!
\n");
free(i);
printf("\n您想继续吗?
(yn)");
scanf("%c",&choice);
if(choice=='Y'||choice=='y')
{
Append();
}
else
{
system("cls");
menu();
}
}
voidSelldelete()
{structimai[1000];
structimatemp;
intdelID;
charchoice;
intindex=0;
intj=0;
FILE*fp;
fp=fopen("ima.date","r");
if(fp==NULL)
{
printf("\t\t\t系统错误,请您重试........");
exit(0);
}
fread(&temp,sizeof(structima),1,fp);
while(!
feof(fp))
{
i[index]=temp;
index++;
fread(&temp,sizeof(structima),1,fp);
}
fclose(fp);
printf("\n\t请输入要删除的商品的编号:
");
scanf("%d",&delID);
fopen("ima.date","w");*打开文件*
if(fp==NULL)
{
printf("\t\t\t系统错误,请您重试........");
exit(0);
}
for(j=0;j{
if(i[j].id!
=delID)
{
fwrite(&i[j],sizeof(structima),1,fp);
}
}
fclose(fp);
printf("\t\t\t\t\t商品信息已清除!
!
!
\n");
printf("\n您想继续吗?
(yn)");
scanf("%c",&choice);
if(choice=='Y'||choice=='y')
{
Selldelete();
}
else
{
system("cls");
menu();
}
}
voidAmend()
{intindex=0;
intID,j;
charchoice;
structimai[1000];
structimatemp;
FILE*fp;
fp=fopen("ima.date","r");
if(fp==NULL)
{
printf("\t\t\t系统错误,请您重试........");
exit(0);
}
fread(&temp,sizeof(structima),1,fp);
while(!
feof(fp))
{
i[index]=temp;
index++;
fread(&temp,sizeof(structima),1,fp);
}
fclose(fp);
fp=fopen("ima.date","w");
if(fp==NULL)
{
printf("\\t\t\t系统错误,请您重试........");
exit(0);
}
printf("\n\t请输入要修改的信息的商品的编号:
");
scanf("%d",&ID);
for(j=0;j<=index-1;j++)
{
if(i[j].id!
=ID)
{
fwrite(&i[j],sizeof(structima),1,fp);
}
else
{
printf("\t\t商品名称修改为:
");
scanf("%s",i[j].name);
printf("\t\t商品生产地修改为:
");
scanf("%s",i[j].produce);
printf("\t\t商品数量修改为:
");
scanf("%d",&i[j].number);
printf("\t\t商品进货单价修改为:
");
scanf("%lf",&i[j].price);
printf("\t\t商品出售单价修改为:
");
scanf("%lf",&i[j].price1);
fwrite(&i[j],sizeof(structima),1,fp);
}
}
fclose(fp);
printf("\t\t\t\t商品信息已修改......");
printf("\n您想继续吗?
(yn)");
scanf("%c",&choice);
if(choice=='Y'||choice=='y')
{
Amend();
}
else
{
system("cls");
menu();
}
}
voidFindin()
{
inta=0;
FILE*fp;
intfindID;charchoice;structimai;
fp=fopen("ima.date","r");
if(fp==NULL)
{
printf("\t\t\t系统错误,请你重试........");
exit(0);
}
printf("\n\t请输入要查询的商品的编号..");
scanf("%d",&findID);
fread(&i,sizeof(structima),1,fp);
while(!
feof(fp))
{
if(i.id==findID)
{
a=1;
printf("\n\n\t***************商品信息******************");
printf("\n\t商品编号...%30d\n",i.id);
printf("\n\t-----");
printf("\n\t商品名称...%30s\n",i.name);
printf("\n\t-----");
printf("\n\t生产厂家...%30s\n",i.produce);
printf("\n\t-----");
printf("\n\t进口数量...%30d\n",i.number);
printf("\n\t-----");
printf("\n\t进货价格...%30.3f\n",i.price);
printf("\n\t-----")