商品销售管理系统设计doc 41页.docx

上传人:b****7 文档编号:16107849 上传时间:2023-07-10 格式:DOCX 页数:39 大小:23.90KB
下载 相关 举报
商品销售管理系统设计doc 41页.docx_第1页
第1页 / 共39页
商品销售管理系统设计doc 41页.docx_第2页
第2页 / 共39页
商品销售管理系统设计doc 41页.docx_第3页
第3页 / 共39页
商品销售管理系统设计doc 41页.docx_第4页
第4页 / 共39页
商品销售管理系统设计doc 41页.docx_第5页
第5页 / 共39页
商品销售管理系统设计doc 41页.docx_第6页
第6页 / 共39页
商品销售管理系统设计doc 41页.docx_第7页
第7页 / 共39页
商品销售管理系统设计doc 41页.docx_第8页
第8页 / 共39页
商品销售管理系统设计doc 41页.docx_第9页
第9页 / 共39页
商品销售管理系统设计doc 41页.docx_第10页
第10页 / 共39页
商品销售管理系统设计doc 41页.docx_第11页
第11页 / 共39页
商品销售管理系统设计doc 41页.docx_第12页
第12页 / 共39页
商品销售管理系统设计doc 41页.docx_第13页
第13页 / 共39页
商品销售管理系统设计doc 41页.docx_第14页
第14页 / 共39页
商品销售管理系统设计doc 41页.docx_第15页
第15页 / 共39页
商品销售管理系统设计doc 41页.docx_第16页
第16页 / 共39页
商品销售管理系统设计doc 41页.docx_第17页
第17页 / 共39页
商品销售管理系统设计doc 41页.docx_第18页
第18页 / 共39页
商品销售管理系统设计doc 41页.docx_第19页
第19页 / 共39页
商品销售管理系统设计doc 41页.docx_第20页
第20页 / 共39页
亲,该文档总共39页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

商品销售管理系统设计doc 41页.docx

《商品销售管理系统设计doc 41页.docx》由会员分享,可在线阅读,更多相关《商品销售管理系统设计doc 41页.docx(39页珍藏版)》请在冰点文库上搜索。

商品销售管理系统设计doc 41页.docx

商品销售管理系统设计doc41页

 

、商品销售管理

问题描述:

已知一公司有10种产品(产品编号,产品名称,产品价格,产品产地,库存数量(最开始为1000个)),设计一程序,完成以下功能:

1)1)销售:

从键盘输入顾客姓名,销售数量、销售日期,实现销售功能。

需要判断产品是否存在,销售数量是否小于库存数量,销售日期格式是否合法(格式为:

YYYY-MM-DD,如2009-01-02))

2)2)能根据产品编号查询产品的销售历史

3)3)计算时间段内各个产品的销售总额

4)4)能根据顾客姓名,查询购买历史

5)5)能显示所有顾客的姓名

提示:

●●定义一个日期结构体保存日期,具体信息为:

年、月、日

●●判断存款日期和取款日期的格式是否合法时,需要判断长度是否为10,第5位和第8位是否为’-’,字符,将1-4位表示的年份,6-7位表示的月份,9-10位表示的日期分别转换成整数。

判断是否满足构成日期的条件闰年月份只能是1-12之间的数,如果是闰年,二月可以是29天否则不能大于28,1,3,5,7,8,10,12月可以是31天,其余只能小于等于30(建议写成函数)。

●●定义一个结构体数组保存10种产品信息,具体信息为:

产品编号,产品名称,产品价格,产品产地,库存数量(最开始为1000个)

●●定义一个链表,保存销售信息,具体为:

顾客代码,销售数量、销售日期。

●●定义一个链表保存顾客信息,具体为:

顾客代码,顾客姓名

●●当输入销售信息时查询顾客链表,如果在链表中存在该姓名的顾客记录,则将其代码在该销售链表中插入一条记录,如果不存在,则在顾客链表中插入一条记录,(顾客代码需要自动生成)。

 #include"stdio.h" /*I/O函数*/

#include"stdlib.h"/*标准库函数*/

#include"string.h"/*字符串函数*/

#include"ctype.h"/*字符操作函数*/

#include"time.h"/*时钟函数*/

#include"cstdlib"

#include"conio.h"

intx,k;/*定义全局变量用于保存当前商品种类*/

structproduct/*定义商品数据结构*/

{

  intnum;/*商品编号*/

  charname[20];/*商品名称*/

  floatprice; /*商品售价*/

  charplace[10];/*商品名称*/

  intstorage; /*商品库存*/

 }_product[10],product1[10];//定义主结构体数组和备用结构体数组

 structdata//定义日期结构体

 {intyear,month,day;

 };

 structsell/*定义销售数据结构*/

{

  intcus;/*顾客代码*/

  intnum;/*商品编号*/

  floatsells;/*销售数量*/

 chardata1[12];/*日期*/

  structsell*next;

 }*head_s,*pp,*tail_s;//定义头指针操、作指针以及尾指针

 

 structcustomer/*定义销售数据结构*/

{

  intcus;/*顾客代码*/

  charname[10];/*顾客姓名*/

  structcustomer*next;

}*head_c,*qq,*tail_c;//定义头指针操、作指针以及尾指针

voidload();//读取文件函数

voidadd();//添加销售信息函数

intsearch_num();//根据商品编号查询商品的销售历史

voidcal();//计算时间段内各个商品的销售总额

intsearch_name();//根据顾客姓名,查询购买历史

voidlist_name();//显示所有顾客的姓名

voidmain();//主函数

intjudge();//主体判断函数

intjudge_data(char*data1);//细节判断函数,用于判断日期是否合法

voiddownload_s();//写入销售信息(顾客代码,销售数量、销售日期)文件

voiddownload_c();//导出顾客购买记录

voiddisplay();//显示现在的商品信息

//主函数

 voidmain()

{

     intchoice;

     structcustomer*head;//定义结构指针

     head=malloc(sizeof(structcustomer));//申请动态存储空间

     head->next=NULL;

 do

    {

        printf("***********************欢迎使用商品销售管理系统!

!

!

*******************\n\n");

        printf("             1.导入商品信息\n");

        printf("             2.显示商品信息\n");

        printf("             3.输入销售记录记录\n");

        printf("             4.按编号查寻商品销售历史\n");

        printf("             5.计算时间段内各个销售总额\n");

        printf("             6.按顾客姓名查找购买历史\n");

        printf("             7.显示顾客姓名\n");

        printf("             8.导出销售信息(顾客代码,销售数量、销售日期)文件\n");

        printf("             9.导出顾客信息文件\n");

        printf("             0.退出\n");

        printf("***********************************************************************\n");

        printf("请选择不同功能输入0----9的数字\n若输入其它值会提前退出\n");

        scanf("%d",&choice);

        system("cls"); 

        switch(choice)

        {

        case1:

            load();

            system("cls");

            break;

        case2:

            display();

            break;

        case3:

            add();

            break;

        case4:

            search_num();

            break;

        case5:

            cal();

            break;

        case6:

            search_name();

            break;

        case7:

            list_name(head);

            break;

      case8:

            download_s();

            break;

        case9:

            download_c();

            break;

        case0:

            printf("\n\n\n\n");

            printf("*************谢谢使用************\n\n\n\n");

            break;

        }

    }while(choice>0&&choice<=9);

}

voiddisplay()

{

  intcode,i=0;

  pp=(structsell*)malloc(sizeof(structsell));//申请动态存储空间并将指针转变为结构类型

  qq=(structcustomer*)malloc(sizeof(structcustomer));//申请动态存储空间并将指针转变为结构类型

 

  pp->next=NULL;

  qq->next=NULL;

  system("cls");  /*清屏*/

  printf("**************************商品信息**************************\n\n\n");

  printf(" 商品编号  商品名称  商品价格  商品产地  库存数量\n");

  while(i<10) 

    { //输出商品记录

        printf("%8d%12s %12.2f%10s%14d\n",_product[i].num,_product[i].name,_product[i].price,

            _product[i].place,_product[i].storage);

        i++;

    }

  printf("\n\n查询完毕,请按任意键继续......");

        getch();

        system("cls");

}

voidload(){//读取文件函数

     inti=0,n=0,a,b,j;

     FILE*fp;//指向文件的指针

     do{

     printf("请选择导入商品信息的方法\n1:

通过键盘输入\n2:

通过文件导入\n");

     scanf("%d",&a);

     if(a==2){

     

  

  if((fp=fopen("商品信息.txt","rb"))==NULL)//打开文件

  {

   printf("不能打开文件,请检查文件路径\n"); //不能打开

   exit(0); //退出*/

  }printf("*****************88商品信息88*******************\n");

    printf("编号  名称   价格   产地   库存数量\n");

    while(!

feof(fp))    

    { //读入文件

        fscanf(fp,"%d%s%f%s%d",&_product[i].num,_product[i].name,&_product[i].price,_product[i].place,&_product[i].storage);

        printf("%-10d%-10s%-10.2f%-12s%-12d\n",_product[i].num,_product[i].name,_product[i].price,_product[i].place,_product[i].storage);

        i++;

    }

        for(i=0;i<10;i++)

            product1[i]=_product[i]; //对备用结构体数组赋值

        fclose(fp);//关闭文件

        printf("\t\t数据读入成功!

按任意键继续......\n");

        }

     if(a==1)

     {if((fp=fopen("商品信息1.txt","w"))==NULL)//打开文件

  {

   printf("不能打开文件,请检查文件路径\n"); //不能打开

   exit(0); //退出*/

  }

     printf("请输入商品种数");

     scanf("%d",&b);

     printf("*************商品信息***************\n");

     printf("编号 名称 价格 产地 库存数量\n");

     for(j=1;j<=b;j++){

    

     scanf("%d%s%f%s%d",&_product[i].num,_product[i].name,&_product[i].price,_product[i].place,&_product[i].storage);

     fprintf(fp,"%-6d%-6s%-6.2f%-6s%-6d\n",_product[i].num,_product[i].name,_product[i].price,_product[i].place,_product[i].storage);

     }

     fclose(fp);//关闭文件

        printf("\t\t数据读入成功!

按任意键继续......\n");

        }

     

}while(a!

=1&&a!

=2);}

//细节判断函数,用于判断日期是否合法

 intjudge_data(char*data1)

{

    intn=1,m,year=(data1[0]-48)*1000+(data1[1]-48)*100+(data1[2]-48)*10+(data1[3]-48),

        month=(data1[5]-48)*10+(data1[6]-48),day=(data1[8]-48)*10+(data1[9]-48);

    m=strlen(data1);

    if(m!

=10)

        n=0;

    if(data1[4]!

='-'||data1[7]!

='-')

        n=0;

    if(year>10000||year<1000||month>12||month<1||day>31||day<1)n=0;

    if(((year%4==0&&year%100!

=0)||(year%400==0))&&month==2)

        if(day>30)n=0;

    if(month==2&&day>=29)n=0;

    if(month==4||month==6||month==9||month==11)

        if(day>30)n=0;

        returnn;

 }

 

 //判断函数

 intjudge()//判断商品编号数量日期是否正确

{

    inti,j=0,k,temp;

    for(i=0;i<10;i++)

        if(pp->num==_product[i].num)

        {

            j++;

            x=k=i;

            temp=_product[k].storage;

            if((_product[k].storage-(int)pp->sells)>=0)

                _product[k].storage-=(int)pp->sells;//判断计算剩余量

            break;

        }

        if(j==0)return3;//判断是否存在输入编号的商品

        elseif(temp-(int)pp->sells<0)return2;//判断输入量是否大于剩余库存量

             elseif(pp->sells-(int)pp->sells>=1e-6)return4;//商品量

                 elseif(judge_data(pp->data1)==0)return0;//判断日期

                      elsereturn1;//完全正确

}

//添加销售信息函数

 voidadd()

{

  intcode,i=0,n,m;

  pp=(structsell*)malloc(sizeof(structsell));//申请动态存储空间并将指针转变为结构类型

  qq=(structcustomer*)malloc(sizeof(structcustomer));//申请动态存储空间并将指针转变为结构类型

  srand(time(0));

  code=rand();        

  pp->next=NULL;

  qq->next=NULL;

  system("cls");  /*清屏*/

  printf("请输入销售记录\n\n\n");/*提示输入记录*/

  printf("顾客姓名    商品编号    销售数量     销售日期\n");

  printf("-----------------------------------------------------------\n");

  scanf("%s%d%f%s",qq->name,&pp->num,&pp->sells,pp->data1); /*输入记录*/

  n=(int)pp->sells;

  if(n<=0)

  {

      printf("商品数量有误!

!

!

请从新输入");

      scanf("%f",&pp->sells);

  }

  

  while

(1)

  {

      m=judge();//判断商品编号数量日期是否正确

      if(m==1){ 

         //pp=(structsell*)malloc(sizeof(structsell));//申请动态存储空间并将指针转变为结构类型

     //qq=(structcustomer*)malloc(sizeof(structcustomer));

            pp->cus=qq->cus=code;//随机数

        if(head_s==NULL)

            head_s=pp;

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2