用c语言制作商店商品管理系统
#include stdio.h
#include conio.h
#include bios.h
#include dos.h
#include malloc.h
#define NULL 0
#define LEN sizeof(struct mcd)
struct data /*声明一个日期的结构体类型*/
{
int year;
int month;
int day;
};
struct mcd /*声明有关商品信息的结构体类型*/
{
int code; /*编 号*/
char name[12]; /*品 名*/
long price; /*单 价*/
int num; /*数 量*/
char place[20]; /*产 地*/
struct data putdate; /*入库时间*/
struct data selldate; /*销售时间*/
struct mcd * next; /*运用指针处理链表*/
};
int n; /*记录链表有几条数据*/
struct mcd *head; /*声明链表头的指针*/
creat() /*输入商品信息的函数*/
{
struct mcd *p1,*p2;
n=0;
p1=p2=(struct mcd *)malloc(LEN); /*开辟一个新单元存放信息*/
head=p1;
loop: {
clrscr();
printf(“商品录入系统\n”);
printf(“录入号:%d\n”,n+1);
printf(“编 码:”);
scanf(“%d”,p1-code);
printf(“品 名:”);
scanf(“%s”,p1-name);
printf(“单 价:”);
scanf(“%ld”,p1-price);
printf(“数 量:”);
scanf(“%d”,p1-num);
printf(“产 地:”);
scanf(“%s”,p1-place);
printf(“入库时间:”);
scanf(“%d-%d-%d”,p1-putdate.year,p1-putdate.month,p1-putdate.day);
}
while(p1-num!=0)
{
n=n+1;
if(n==1)head=p1;
else p2-next=p1;
p2=p1;
p1=(struct mcd *)malloc(LEN);
goto loop;
}
p2-next=NULL;
main();
}
print() /*输出数据列表的函数*/
{
int m=0;
struct mcd *p;
clrscr();
printf(“编 号||品 名||单 价||数 量|| 产 地 ||入 库 时 间\n”);
p=head;
if(head!=NULL)
do
{
printf(“%-10d%-14s%-12ld%-10d%-22s%-4d-%-2d-%-2d\n”,p-code,p-name,p-price,p-num,p-place,p-putdate.year,p-putdate.month,p-putdate.day);
p=p-next;
m=m+1;
if(m%23==0){gotoxy(10,25);printf(“按任意键继续.”);getch();}
}while(p!=NULL);
getch();
main();
}
sell()
{
int code,m=3,ch;
long sum=0;
struct mcd *p1;
struct date today;
getdate(today);
clrscr();
printf(“商品销售系统\n”);
printf(“编 号||||品 名|||| 产 地 ||||单 价(元)||||出 售 时 间\n”);
loop:
do{
gotoxy(23,25);
printf(“按任意键继续,F2结帐,ESC键退出”);
ch=bioskey(0);
}while(0);
switch(ch)
{
case 15360:{
if(sum==0)
{
gotoxy(1,m);printf(“还没有购买商品!”);
getch();
sell();
break;
}
else {
gotoxy(1,m);
printf(“——————————————————————————“);
gotoxy(47,m+1);
printf(“总价: %-12ld元”,sum);
getch();
main();
break;
}
}
case 283:{main();break;}
default:
{
gotoxy(23,25);
printf(“请输入商品编码,会显示商品信息”);
gotoxy(1,m);
scanf(“%d”,code);
if(head==NULL)
{
printf(“你还没有进货.”);
getch();
main();
break;
}
p1=head;
while(code!=p1-codep1-next!=NULL)
{p1=p1-next;}
if(code==p1-code)
{
gotoxy(13,m);
printf(“%-16s%-24s%-16ld%4d-%2d-%2d”,p1-name,p1-place,p1-price,today.da_year,today.da_mon,today.da_day);
m=m+1;
p1-num=p1-num-1;
sum=sum+p1-price;
}
}
goto loop;
}
}
go()
{
int ch;
clrscr();
printf(“请问你要进行什么操作?\n1,插入;2,删除;3,什么也不做;\n”);
loop:
do{
ch=bioskey(0);
}while(0);
switch(ch)
{
case 561:insert();break;
case 818:del();break;
case 1075:main();break;
case 283:break;
default:{gotoxy(1,3);printf(“请按数字键选择!”);goto loop;}
}
getch();
main();
}
insert()
{
struct mcd *p0,*p1,*p2;
p0=p1=p2=(struct mcd*)malloc(LEN);
p1=head;
clrscr();
printf(“请输入要插入的商品的信息:\n”);
printf(“编 码:”);
scanf(“%d”,p0-code);
printf(“品 名:”);
scanf(“%s”,p0-name);
printf(“单 价:”);
scanf(“%ld”,p0-price);
printf(“数 量:”);
scanf(“%d”,p0-num);
printf(“产 地:”);
scanf(“%s”,p0-place);
printf(“入库时间:”);
scanf(“%d-%d-%d”,p0-putdate.year,p0-putdate.month,p0-putdate.day);
if(head==NULL)
{
head=p0;
p0-next=NULL;
}
else
{
while((p0-codep1-code)(p1-next!=NULL))
{
p2=p1;
p1=p1-next;
}
if(p0-code=p1-code)
{
if(head==p1)head=p0;
else p2-next=p0;
p0-next=p1;
}
else
{
p1-next=p0;p0-next=NULL;
}
}
n=n+1;
print();
}
del()
{
int code;
struct mcd *p1,*p2;
clrscr();
printf(“请输入要删除商品的编号:”);
scanf(“%d”,code);
if(head==NULL)
{
printf(“你还没有进货.”);
getch();
main();
}
p1=head;
while(code!=p1-codep1-next!=NULL)
{
p2=p1;
p1=p1-next;
}
if(code==p1-code)
{
if(code==head)head=p1-next;
else p2-next=p1-next;
n=n-1;
print();
}
else
{
printf(“找不到这条商品信息.”);
getch();
print();
}
}
main()
{
do{
clrscr();
printf(” . : : \n”);
printf(” ‘. :””””: : : :””:””:\n”);
printf(” ‘. : : :””” :””” : : :\n”);
printf(” ……………. : : :’, :’, ””’:””’: : :\n”);
printf(” ‘. .’ : : : ‘, : ‘, : :….:….:\n”);
printf(” ‘. .’ : : ,’ ,’ : : : :\n”);
printf(” ‘.’ : : ‘, : : : :\n”);
printf(“………:……….. :……..: : ‘, : :….:….:\n”);
printf(” …………… :”””””””’: ””:”” : \n”);
printf(” : , , : :”””: :”””: ,’ : : \n”);
printf(” : , , : : : : : :””””’: : ,’ : \n”);
printf(” : , , : : : : : : : : ,’ ….:…. \n”);
printf(” :, :”””’: : : : : : : : :,’ : \n”);
printf(” : : : : : : : : :””””” ,’ : \n”);
printf(” : : : : : : : : :………. ,’ : \n”);
printf(” : :…….: : : : : : : : ‘ : \n”);
printf(” : : : : : : : : ……:…..\n”);
printf(” : ..: :……: :……: :………: \n”);
gotoxy(60,19);
printf(“赵飞宇制造 V1.0”);
gotoxy(10,21);
printf(“1,销售系统;2,进货系统;3,查看列表;4,插入删除;5,销售盈亏;6,帮助文档”);
gotoxy(32,24);
printf(“按ESC键退出”);
key();
}while(0);
}
key()
{
int ch;
loop:
do{
ch=bioskey(0);
}while(0);
switch(ch)
{
case 561:sell();break;
case 818:creat();break;
case 1075:print();break;
case 1332:go();break;
case 283:break;
default:
{
gotoxy(30,22);
printf(“请按数字键选择!”);
goto loop;
}
}
}
用C语言编写“销售管理系统设计”程序
讲下设计思想吧
便条实际上包含了登陆信息了,所以省去了登陆环节,简单点做到如下几点就可以 了:
1、调用c的图形类创建一菜单,有便条录入、和信息查询两栏,信息查询下面再分各种查询
2、便条录入可以都不用图形界面了,直接按条目输入值,顺序输入即可
3、保存以文件形式,可以在第一次建立个txt文档,以制表符分割开来各个字段,但是每次写入的时候必须按行作为一条数据,可以适当增加需要的字段作为查询统计方便用(每个制表符分割的为一个字段)。
4、查询统计就直接检索这个txt文档,该加总的求平均的用循环去查即可。
5、结果输出即把查到的内容在屏幕上打印出来即可。
其他,如果用c++做就简单多了,没那么多代码写
c语言商品管理系统
假设某超市经营各种商品,每种商品包括以下信息:商品编号、商品名称、商品品牌、库存数量、售价、已售数量。系统的主要功能包括:1. 创建商品信息文件:根据提示输入若干商品的信息,并将信息保存至一个文件中。2. 商品进货管理:每次购入新商品,需按要求输入商品所含各项信息并存入商品信息文件中。如果已经存在该商品(以商品编号为准),则修改相应的库存数量信息,否则生成新的商品信息记录。3. 商品销售管理:每次有商品销售出去,则按要求输入商品编号和商品名称信息,并修改相应的商品信息文件。注意:商品销售时要检查库存数量的合法性(即销售出去的数量必须小于库存数量)。4. 按不同条件进行查询操作,输出满足条件的商品信息。(1) 输入商品名称,在商品信息文件中查找相应的商品信息并输出。(2) 输入商品品牌,在商品信息文件中查找该品牌的所有信息并输出。5. 按不同条件对商品信息进行统计工作。(1) 输入商品名称,在商品信息文件中统计该商品的销售总额。(2) 设置一个库存数量警戒值,输出库存数量小于该警戒值的所有库存商品的信息。(3) 输入商品品牌,在商品信息文件中统计其不同商品名称的库存量,并输出库存量最高的那个商品的信息。
满意请采纳。
c语言 商品管理系统
#include”stdio.h”
#include conio.h
#include stdlib.h
//#include”FILE.h”
typedef struct shangpin
{
char name[20];
int biaohao;
int shuliang;
double jiage;
}Node;
typedef struct list
{
Node data;
struct list *next;
}List ,*Slist;
void charu(Slist s,Node x);
int caidan()
{
int i;
while(1)
{
system(“cls”);
printf(“\n\t\t\t 商店销售管理系统\n\n”);
printf(“\t\t **********************************************\n\n”);
printf(“\t\t 1–添加商品 2–出售商品\n\n”);
printf(“\t\t 3–删除商品 4–显示商品\n\n”);
printf(“\t\t 5–查找商品 0–退出系统\n\n”);
printf(“\t\t **********************************************\n\n”);
printf(“请选择(0-5): “);
scanf(“%d”,i);
if(i6i=0)break;
}
return i;
}
void chushihua(Slist s)
{
Slist head=new List;
head-next=NULL;
s=head;
}
void tianjia(Slist s)
{
Node x;
Slist r,p,q;
int i=0;
r=new List;
r-next=NULL;
q=p=s-next;
while(q)
{
i++;
q=q-next;
}
printf(“请输入商品名称、数量以及价格: “);
scanf(“%s%d%lf”,x.name,x.shuliang,x.jiage);
x.biaohao=i+1;
r-data=x;
s-next=r;
r-next=p;
}
void duchu(Slist s)
{
FILE *cp;//定义文件指针
int i=0;
Node x;
if((cp=fopen(“shangpin.txt”,”a+”))==NULL)//打开文件
{printf(“文件打开失败!”);return ;}
fseek(cp,0L,SEEK_SET);//将文件指针移动到文件开头
while(!feof(cp))
{
fscanf(cp,”%s%d%lf”,x.name,x.shuliang,x.jiage);//读取文件的内容
x.biaohao=++i;
charu(s,x);//把读到的数据插入到链表上
}
fclose(cp);//关闭文件
}
void charu(Slist s,Node x)
{
Slist r,p=s-next;
r=new List;
r-next=NULL;
r-data=x;
s-next=r;
r-next=p;
}
void xieru(Slist s)
{
FILE *cp;//同上
Slist p=s-next;
if((cp=fopen(“shangpin.txt”,”w+”))==NULL)
{printf(“文件打开失败!”);return ;}//同上
while(p)
{
fprintf(cp,”%s %d %.2lf “,p-data.name,p-data.shuliang,p-data.jiage);//写入文件中,并且以空格隔开
p=p-next;
}
fclose(cp);//关闭文件
}
Slist chazhao(Slist s,int m)
{
Slist p=s-next;
if(p==0)return 0;
if(p-next==0)return p;
if(p-data.biaohao==m)return p;
while(p-next)
{
if(p-next-data.biaohao==m)return p;
p=p-next;
}
return 0;
}
void xianshi(Slist s)
{
Slist p;
p=s-next;
printf(“%10s%20s%10s%10s\n”,”商品编号”,”商品名称”,”商品数量”,”商品价格”);
while(p)
{
printf(“%10d%20s%10d%10.2f\n”,p-data.biaohao,p-data.name,p-data.shuliang,p-data.jiage);
p=p-next;
}
}
void shanchu(Slist s)
{
}
void chushou(Slist s)
{
}
void main()
{
int num;
Slist s;
chushihua(s);
duchu(s);
num=caidan();
while(1)
{
switch(num)
{
case 0:exit(0);break;
case 1:tianjia(s);break;
case 2:chushou(s);break;
case 3:shanchu(s);break;
case 4:xianshi(s);break;
case 5:chazhao(s,1);break;
}
printf(“按任意键继续!”);
getch();
num=caidan();
}
xieru(s);
}
//有些函数我在没写啊,你自己写写吧,文件的读取和写入,还有链表的创建我都给你写好了,也就是上面的1,4我都写好了,
//包括了文件,剩下的2,3,5,你自己试试,并且我也给你写了一个查找函数,你看看能用不!
C语言做个小型商品销售管理系统
我这里有一个!
具体的,稍微改一下就可以了!
#include “stdio.h” /*I/O函数*/
#include “stdlib.h” /*其它说明*/
#include “string.h” /*字符串函数*/
#include “conio.h” /*屏幕操作函数*/
#include “mem.h” /*内存操作函数*/
#include “ctype.h” /*字符操作函数*/
#include “alloc.h” /*动态地址分配函数*/
struct score
{
int mingci;
char xuehao[8];
char mingzi[20];
float score[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;
void shuru()
{
if((fp=fopen(“s_score.txt”,”ab+”))==NULL)
{
printf(“cannot open this file.\n”);
getch();exit(0);
}
for(i=0;i=1000;i++)
{
printf(“\nPlease shuru xuehao:”);
gets(data.xuehao);
printf(“Please shuru mingzi:”);
gets(data.mingzi);
printf(“Please shuru yuwen score:”);
gets(temp);data.score[0]=atof(temp);
printf(“Please shuru shuxue score:”);
gets(temp);data.score[1]=atof(temp);
printf(“Please input yingyu score:”);
gets(temp);data.score[2]=atof(temp);
printf(“Please shuru wuli score:”);
gets(temp);data.score[3]=atof(temp);
printf(“Please shur huaxue score:”);
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?y/n”);
ch=getch();
if(ch==’n’||ch==’N’)
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen(“s_score.txt”,”rb+”))==NULL)
{
printf(“Cannot reading this file.\n”);
exit(0);
}
for(i=0;i=1000;i++)
{
if((fread(info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf(“\nxuehao mingzi yuwen shuxue yingyu wuli huauxue zhongfen\n”);
for(j=0,k=1;ji;j++,k++)
{
info[j].mingci=k;
printf(“%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n”,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);
}
void xiugai()
{
if((fp=fopen(“s_score.txt”,”rb+”))==NULL||(fp1=fopen(“temp.txt”,”wb+”))==NULL)
{
printf(“Cannot open this file.\n”);
exit(0);
}
printf(“\nPLease shuru xiugai xuehao:”);
scanf(“%d”,i); getchar();
while((fread(data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf(“xuehao:%s\nmingzi:%s\n”,data.xuehao,data.mingzi);
printf(“Please shuru mingzi:”);
gets(data.mingzi);
printf(“Please shuru yuwen score:”);
gets(temp);data.score[0]=atof(temp);
printf(“Please shuru shuxue score:”);
gets(temp);data.score[1]=atof(temp);
printf(“Please input yingyu score:”);
gets(temp);data.score[2]=atof(temp);
printf(“Please input wuli score:”);
gets(temp);data.score[3]=atof(temp);
printf(“Please input huaxue score:”);
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);
}
void chazhao()
{
if((fp=fopen(“s_score.txt”,”rb”))==NULL)
{
printf(“\nCannot open this file.\n”);
exit(0);
}
printf(“\nPLease shuru xuehao chakan:”);
scanf(“%d”,i);
while(fread(data,sizeof(data),1,fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf(“xuehao:%s mingzi:%s\nyuwen:%f\n shuxue:%f\n yingyu:%f\n wuli:%f\n huaxue:%f\n “,data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen(“s_score.txt”,”rb+”))==NULL||(fp1=fopen(“temp.txt”,”wb+”))==NULL)
{
printf(“\nopen score.txt was failed!”);
getch();
exit(0);
}
printf(“\nPlease input ID which you want to del:”);
scanf(“%d”,i);getchar();
while((fread(data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf(“Anykey will delet it.\n”);
getch();
continue;
}
fwrite(data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove(“s_score.txt”);
rename(“temp.txt”,”s_score.txt”);
printf(“Data delet was succesful!\n”);
printf(“Anykey will return to main.”);
getch();
}
main()
{
while(1)
{
clrscr(); /*清屏幕*/
gotoxy(1,1); /*移动光标*/
textcolor(YELLOW); /*设置文本显示颜色为黄色*/
textbackground(BLUE); /*设置背景颜色为蓝色*/
window(1,1,99,99); /* 制作显示菜单的窗口,大小根据菜单条数设计*/
clrscr();
printf(“*************welcome to use student manage******************\n”);
printf(“*************************menu********************************\n”);
printf(“* ========================================================= * \n”);
printf(“* 1shuru 2xiugai * \n”);
printf(“* 3shanchu 4chazhao * \n”);
printf(“* 5xianshi 6exit * \n”);
printf(“* * \n”);
printf(“* ——————————————————— * \n”);
printf(” Please input which you want(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;
}
}
}