销售管理系统 计算机课程设计(C语言)(3)

2019-08-30 17:50

{

productnode * first_product; //头指针

char pkindname[40]; //商品名称 int kind_number; //产品种类个数 }kindnode;

/*****************销售链表****************/ typedef struct {

kindnode* kindelem; int length; int listsize; }sqlist;

/*******************初始化L************/ int Init(sqlist &L) {int i;

L.kindelem=(kindnode*)malloc(SQMOUTLINK_INIT_SIZE*sizeof(kindnode)); if(!L.kindelem) exit(overflow); L.length=0;

L.listsize=SQMOUTLINK_INIT_SIZE; for(i=0;i

{(L.kindelem[i]).first_product=NULL; (L.kindelem[i]).kind_number=0; }

return ok; }

/********************创建商品和产品**************************/ int Create(sqlist &L) {plinklist p,q; int i,j,k,n;

printf(\请输入商品类数量:\\n\ do

{scanf(\ if(n<0)

{printf(\对不起,你输入有误!请重新选择(n>=0)\\n\ }while(n<0); for(i=0;i

{printf(\请输入第%d个商品类的名称:\\n\ scanf(\

printf(\请输入这类商品含有的产品种类数量:\\n\ do

{scanf(\ if(k<0) {printf(\对不起,你输入有误!请重新选择(k>=0)\\n\ }while(k<0);

L.kindelem[i].kind_number=k; if(k>=1)

{p=(plinklist)malloc(sizeof(productnode)); printf(\请输入第%d个产品名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\ scanf(\ printf(\请输入产品进货日期(年-月-日):\\n\

scanf(\_time).day)); printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入产品销售数量:\\n\ scanf(\

11

printf(\请输入产品销售时间(年-月-日):\\n\scanf(\ime).day)); p->product_income=(p->product_price)*(p->sales_quantity); p->product_stock=(p->product_quantity)-(p->sales_quantity); L.kindelem[i].first_product=p; p->next=NULL; }

for(j=1;j

{q=(plinklist)malloc(sizeof(productnode));

printf(\请输入第%d个产品名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\

scanf(\

printf(\请输入产品进货日期(年-月-日):\\n\scanf(\e).day));

printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入产品销售数量:\\n\ scanf(\

printf(\请输入产品销售时间(年-月-日):\\n\

scanf(\ime).day));

q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); q->next=p->next; p->next=q; p=q; }L.length++; }return ok; }

/***********************添加***********************************/ int Add(sqlist &L) {plinklist p,q; int k,j,n;

char pkindname[20];

printf(\请输入添加产品所属的商品类:\\n\ scanf(\

for(k=0;k

if(strcmp((L.kindelem[k]).pkindname,pkindname)==0) { printf(\请输入所要添加的产品类数量(个):\\n\ scanf(\ L.kindelem[k].kind_number=L.kindelem[k].kind_number+n; if(L.kindelem[k].first_product==NULL)//商品下没产品 {q=(plinklist)malloc(sizeof(productnode)); printf(\请输入需添加产品的名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\

scanf(\ printf(\请输入进货日期(年-月-日):\\n\

scanf(\e).day));

printf(\请输入产品单价:\\n\

12

scanf(\ printf(\请输入销售数量:\\n\ scanf(\

printf(\请输入销售时间(年-月-日):\\n\

scanf(\ime).day)); q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); q->next=NULL;

L.kindelem[k].first_product=q; p=L.kindelem[k].first_product; for(j=1;j

scanf(\ printf(\请输入进货日期(年-月-日):\\n\

scanf(\e).day));

printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入销售数量:\\n\ scanf(\

printf(\请输入销售时间(年-月-日):\\n\

scanf(\ime).day)); q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); /************************添加***********************************/

q->next=p->next;p->next=q;p=q; } } else//商品下有产品 {p=L.kindelem[k].first_product; for(j=0;j

scanf(\ printf(\请输入进货日期(年-月-日):\\n\

scanf(\e).day));

printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入销售数量:\\n\

13

scanf(\

printf(\请输入销售时间(年-月-日):\\n\

scanf(\ime).day)); q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); /************************添加***********************************/

for(p=L.kindelem[k].first_product;(p->next)!=NULL;p=p->next); q->next=p->next; p->next=q; p=q; }//for }//else break; }//if }//for

if(k>=L.length)//没有该商品类 { strcpy(L.kindelem[k].pkindname,pkindname); L.length++; printf(\请输入所要添加的产品类数量(个):\\n\ scanf(\ L.kindelem[k].kind_number=n; for(j=0;j

printf(\请输入此产品类所含产品的产品名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\ scanf(\ printf(\请输入产品的进货日期(年-月-日):\\n\

scanf(\e).day)); printf(\请输入产品的产品单价:\\n\ scanf(\ printf(\请输入产品的销售数量:\\n\ scanf(\ printf(\请输入产品的销售时间(年-月-日):\\n\

scanf(\ime).day)); p->product_income=(p->product_price)*(p->sales_quantity); p->product_stock=(p->product_quantity)-(p->sales_quantity); L.kindelem[k].first_product=p; p->next=NULL; }//for }//if

return ok; }

/*************************更改***************************/ void Alter(sqlist &L) {

int i,buy_number,order,sales_number,flag=0; double price;

14

char pkindname[10],product_name[10]; plinklist p;

printf(\请输入你所要修改的商品类:\\n\ scanf(\ for(i=0;inext)//产品匹配 { m++; if(strcmp(p->product_name,product_name)==0)//找到产品 { printf(\……………………………………………\\n\ printf(\修改选项:\\n\ printf(\进货日期\\n\ printf(\进货\\n\ printf(\销售\\n\ printf(\单价变动\\n\ printf(\返回\\n\

printf(\……………………………………………\\n\loop:

printf(\请进行选择:(0-7)\\n\ scanf(\ switch(order) { case 1: printf(\新的进货日期(年-月-日):\\n\

scanf(\e).day)); goto loop; case 2: printf(\进货(个):\\n\ scanf(\ p->product_quantity=p->product_quantity+buy_number; p->product_stock=(p->product_stock+buy_number); goto loop; case 3:

printf(\销售(个):\\t\ scanf(\ p->sales_quantity=p->sales_quantity+sales_number; p->product_stock=(p->product_stock)-sales_number; goto loop; case 4:

printf(\新单价(元):\\t\ scanf(\ p->product_price=price;

p->product_income=(p->sales_quantity)*(p->product_price); goto loop; case 0: system(\ flag=1; break;

15


销售管理系统 计算机课程设计(C语言)(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2018年部编新教材九年级语文上册11首古诗词

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: