| C语言做个小型商品销售管理系统 | ||||||||||||||||
|
名易软件设计了一个商品信息管理系统,模拟超市商品管理。 对商品信息进行分类:日用品,食品,电器 各类商品包括的信息有:编号,商品名称,商品类别,产地,供货商,单价,库存数量,采购日期。 系统实现下述功能: (1)能录入商品信息 (2)能对商品信息进行查询 可以按编号,按商品名称,按商品类别,按供货商,按产地进行查询 (3)可以对商品信息进行修改,删除 (4)可以对新商品进行入库登记 要求:界面友好,易于操作,采用二进制文件存储数据。 设计一个商品销售系统,模拟超市商品销售流程。 销售单包含的信息如下:流水号,商品编号,销售数量,销售单价,销售日期,销售人员 系统实现下述功能: (1)商品销售: 要求:输入销售单,根据商品编号,读取并显示磁盘文件中的商品信息,根据销售数量,修改库存, (2)商品销售信息查询: a)根据商品编号查询 b)根据销售日期查询 c)根据销售人员查询 (3)统计 a)日销售额b)月销售额c)季销售额d)月度销售排名e)。。。 (4)库存信息提醒 我们来看下 #includestdio.h*IO函数* #includestdlib.h*其它说明* #includestring.h*字符串函数* #includeconio.h*屏幕操作函数* #includemem.h*内存操作函数* #includectype.h*字符操作函数* #includealloc.h*动态地址分配函数* structscore { intmingci; charxuehao[8]; charmingzi[20]; floatscore[6]; }data,info[1000]; inti,j,k=0; chartemp[20],ch; FILE*fp,*fp1; voidshuru() { if((fp=fopen(s_score.txt,ab+))==NULL) { printf(cannotopenthisfile.n); getch();exit(0); } for(i=0;i=1000;i++) { printf(nPleaseshuruxuehao:); gets(data.xuehao); printf(Pleaseshurumingzi:); gets(data.mingzi); printf(Pleaseshuruyuwenscore:); gets(temp);data.score[0]=atof(temp); printf(Pleaseshurushuxuescore:); gets(temp);data.score[1]=atof(temp); printf(Pleaseinputyingyuscore:); gets(temp);data.score[2]=atof(temp); printf(Pleaseshuruwuliscore:); gets(temp);data.score[3]=atof(temp); printf(Pleaseshurhuaxuescore:); gets(temp);data.score[4]=atof(temp); data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4]; fwrite(data,sizeof(data),1,fp); printf(another?yn); ch=getch(); if(ch=='n'||ch=='N') break; }fclose(fp); } voidxianshi() { floats;intn; if((fp=fopen(s_score.txt,rb+))==NULL) { printf(Cannotreadingthisfile.n); exit(0); } for(i=0;i=1000;i++) { if((fread(info[i],sizeof(info[i]),1,fp))!=1) break; } printf(nxuehaomingziyuwenshuxueyingyuwulihuauxuezhongfenn); for(j=0,k=1;j { info[j].mingci=k; printf(%6s%8s%3.1f%3.1f%3.1f%3.1f%3.1f%3.1fn,info[j].xuehao,info[j].mingzi,info[j].score[0],info[j].score[1],info[j].score[2],info[j].score[3],info[j].score[4], info[j].score[5]); } getch(); fclose(fp); } voidxiugai() { if((fp=fopen(s_score.txt,rb+))==NULL||(fp1=fopen(temp.txt,wb+))==NULL) { printf(Cannotopenthisfile.n); exit(0); } printf(nPLeaseshuruxiugaixuehao:); scanf(%d,i);getchar(); while((fread(data,sizeof(data),1,fp))==1) { j=atoi(data.xuehao); if(j==i) { printf(xuehao:%snmingzi:%sn,data.xuehao,data.mingzi); printf(Pleaseshurumingzi:); gets(data.mingzi); printf(Pleaseshuruyuwenscore:); gets(temp);data.score[0]=atof(temp); printf(Pleaseshurushuxuescore:); gets(temp);data.score[1]=atof(temp); printf(Pleaseinputyingyuscore:); gets(temp);data.score[2]=atof(temp); printf(Pleaseinputwuliscore:); gets(temp);data.score[3]=atof(temp); printf(Pleaseinputhuaxuescore:); gets(temp);data.score[4]=atof(temp); data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4]; }fwrite(data,sizeof(data),1,fp1); } fseek(fp,0L,0); fseek(fp1,0L,0); while((fread(data,sizeof(data),1,fp1))==1) { fwrite(data,sizeof(data),1,fp); } fclose(fp); fclose(fp1); } voidchazhao() { if((fp=fopen(s_score.txt,rb))==NULL) { printf(nCannotopenthisfile.n); exit(0); } printf(nPLeaseshuruxuehaochakan:); scanf(%d,i); while(fread(data,sizeof(data),1,fp)==1) { j=atoi(data.xuehao); if(i==j) { printf(xuehao:%smingzi:%snyuwen:%fnshuxue:%fnyingyu:%fnwuli:%fnhuaxue:%fn,data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]); }getch(); } } voidshanchu() { if((fp=fopen(s_score.txt,rb+))==NULL||(fp1=fopen(temp.txt,wb+))==NULL) { printf(nopenscore.txtwasfailed!); getch(); exit(0); } printf(nPleaseinputIDwhichyouwanttodel:); scanf(%d,i);getchar(); while((fread(data,sizeof(data),1,fp))==1) { j=atoi(data.xuehao); if(j==i) { printf(Anykeywilldeletit.n); getch(); continue; } fwrite(data,sizeof(data),1,fp1); } fclose(fp); fclose(fp1); remove(s_score.txt); rename(temp.txt,s_score.txt); printf(Datadeletwassuccesful!n); printf(Anykeywillreturntomain.); getch(); } main() { while(1) { clrscr();*清屏幕* gotoxy(1,1);*移动光标* textcolor(YELLOW);*设置文本显示颜色为黄色* textbackground(BLUE);*设置背景颜色为蓝色* window(1,1,99,99);*制作显示菜单的窗口,大小根据菜单条数设计* clrscr(); printf(*************welcometousestudentmanage******************n); printf(*************************menu********************************n); printf(*=========================================================*n); printf(*1shuru2xiugai*n); printf(*3shanchu4chazhao*n); printf(*5xianshi6exit*n); printf(**n); printf(*---------------------------------------------------------*n); printf(Pleaseinputwhichyouwant(1-6):); ch=getch(); switch(ch) { case'1':shuru();break; case'2':xiugai();break; case'3':shanchu();break; case'4':chazhao();break; case'5':xianshi();break; case'6':exit(0); default:continue; } } }
|