| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2265 人关注过本帖
标题:求助!!!!!商店存货管理系统
只看楼主 加入收藏
l2007
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-1-2
收藏
 问题点数:0 回复次数:4 
求助!!!!!商店存货管理系统
一、    设计内容与设计要求:
建立一商店存货管理系统,要求每次出货时取进货时间最早且最接近保质期中止时间的货物。
分步实施:
1.    初步完成总体设计,搭好框架,确定人机对话的界面,确定函数个数;
2.    完成最低要求:建立一个文件,包括5个种类的货物情况,能对商品信息进行扩充(追加),修改和删除以及简单的排序;
3.    进一步要求:扩充商品数量,以及完成系统查询功能。有兴趣的同学可以自己扩充系统功能。
要求:1)界面友好,函数功能要划分好
2)总体设计应画一流程图
3)程序要加必要的注释
4)要提供程序测试方案
搜索更多相关主题的帖子: 商店 系统 管理 
2008-01-02 22:53
maapple007
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-8-31
收藏
得分:0 
看看
2008-08-31 20:42
ldy1204
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-9-1
收藏
得分:0 
有点用
原来写的一个,有点不同,但可能有帮助吧


#include <dos.h>
#include <bios.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#define LEFT 0x4b00  /*左*/
#define RIGHT 0x4d00 /*右*/
#define DOWN 0x5000 /*下*/
#define UP 0x4800 /*上*/
#define SPACE 0x3920 /*空格*/
#define ESC 0x011b /* ESC键*/
#define ENTER 0x1c0d /*回车键*/
#define Backspace 0xe08 /*擦除键*/
#define ALT_I 5888
#define ALT_W 4352
#define ALT_C 11776
#define ALT_M 12800
int key;/*按键变量*/
int textx,texty;/*光标坐标,x行,y列*/
struct menu/*菜单用的结构体*/
{
   char name[10];/*主菜单名*/
   char str[10][20];/*选项*/
   int n;/*选项数*/
}ml[4];/*使用了4个,可根据需要增删*/
struct COMPANY    /*公司*/
{
   int n;
   unsigned items;
   unsigned workers;
   char name[20];  /*公司名称*/
   struct ITEM *first;
   struct WORKER *next;
}com;
struct ITEM /*商品目录基本信息*/
{
    char num[15];
    char name[21];
    int stocknum;/*库存数量*/
    float price;
    struct ITEM *next;
};
struct WORKER   /*收银员信息*/
{
   char num[9];
   char name[11];
   char sex[2];
   char ID[19];
   char password[11];
   float price;  /*计销售总金额*/
   struct WORKER *next;
   struct SALE1 *first;
}worker;
struct SALE1   /*销售单信息*/
{
   char salenum[9];
   char data[10];
   char workernum[9];
   float price;  /*销售总金额*/
   int quantity; /*总件数*/
   struct SALE1 *next;
   struct SALE2 *first;
};
struct SALE2   /*销售单明细信息*/
{
   char salenum[9];
   char itemnum[15];
   char name[21];
   int piece;
   float price;
   float total; /*小计*/
   struct SALE2 *next;
};
struct INVENTARY   /*盘存表*/
{
    char num[15];
    char name[21];
    char data[11];
    int invennum;  /*结存数量*/
    int factnum;   /*实际盘存数量*/
    char head[11];   /*负责人*/
    struct INVENTARY *next;
};
struct COMPANY *pcom;
int b; /*计盘存数量*/
char save[4096];/*保存文本区域空间*/
char c[4096];/*清屏专用空间*/
int i,j;/*常用变量*/
void Menu();/*初始化界面*/
void Selectitem();/*定义菜单*/
void DrawSelectitem();/*显示主菜单*/
void BlackText(int x,int y,char *z);/*选中菜单*/
void RedText(int x,int y,char *z);/*正常菜单*/
void Run();/*具体操作过程*/
void DrawMl(int n);/*显示下拉菜单*/
void MoveMl(int n,int x);/*菜单选项的控制*/
void Enter(int m,int n);/*菜单选项的具体功能*/
void read_file1(struct COMPANY *,FILE*);
void read_file2(struct COMPANY *,FILE*);
int create1(struct COMPANY *);
void create2(struct COMPANY *);
void sort1(struct COMPANY *);
void sort2(struct COMPANY *);
void ItemAdd();
void ItemChange();/*物品修改*/
void ItemDel();/*删除物品资料*/
void WorkerAdd(); /*增加收银员*/
void WorkerChange();
void WorkerDel();
void Workerfeat();/*收银员销售业绩统计*/
void Iteminfor(); /*商品销售情况统计*/
void Sale(); /*商品销售*/
void create_sale(struct SALE1*,struct COMPANY *);
void output_sale(struct SALE1*);
void write_file();
void find();
void stock_search();
void Sale_search();
void item_search();
void Ventary();/*盘存*/
void ClrScr();/*自定义清屏函数*/
void DrawFrame(int left,int up,int right,int down,int textcolor,int backgroundcolor);/*画边框*/
/***主函数****/
void main(void)
{
   FILE *fp1,*fp2;
   if((fp1=fopen("item.dat","rb"))==NULL){
    printf("input the name of the company:");
    scanf("%s",&com.name);
    com.items=0;
    com.first=NULL;
    create1(&com);
    sort1(&com);         /*按顺序排列*/
   }
   else{
       fread(&com,sizeof(struct COMPANY),1,fp1);
       com.first=NULL;
       read_file1(&com,fp1);
       fclose(fp1);
   }
   if((fp2=fopen("worker.dat","rb"))==NULL){
    com.next=NULL;
    com.workers=0;
    create2(&com);
    sort2(&com);
   }
   else{
       fread(&worker,sizeof(struct COMPANY),1,fp2);
       com.next=NULL;
       read_file2(&com,fp2);
       fclose(fp2);
   }
   Menu();/*初始化界面*/
   Run();/*具体操作过程*/
}
void ClrScr()
{
   int i,j;
   puttext(2,3,78,23,c);/*刚开始已经用gettext把蓝色的一块地方保存下来,现在再还原*/
   gotoxy(2,3);
}
/*初始化界面*/
void Menu()
{
   textbackground(BLUE);/*将背景设置为蓝色*/
   window(1,1,25,80);
   clrscr();
   textx=3;/*光标初始化位置*/
   texty=2;
   gotoxy(1,2);
   printf("%c",218);/*画左上角*/
   for(i=0;i<78;i++)
   printf("%c",196); /*画水平直线*/
   printf("%c",191);/*画右上角*/
   for(i=3;i<=23;i++)
   {
      gotoxy(1,i);
      printf("%c",179); /*画垂直线*/
      gotoxy(80,i);
      printf("%c",179);
   }
   printf("%c",192); /*画左下角*/
   for(i=0;i<78;i++)
      printf("%c",196);
   printf("%c",217); /*画右下角*/
   gotoxy(1,1);
   textcolor(7); /*设置灰色*/
   for(i=0;i<80;i++)
      cprintf("%c",219);/*用符号实现画主菜单的灰色背景区???????*/
   Selectitem();  /*调用选项函数*/
   DrawSelectitem(); /*画选项*/
   gettext(2,3,78,23,c); /*保存当前文本区域*/
}
/*定义菜单*/
void Selectitem()
{
   strcpy(ml[0].name,"Item");/*下面的具体选项补空格是为了各菜单黑色背景相同*/
   strcpy(ml[0].str[0],"Add          ");/*添加物品*/
   strcpy(ml[0].str[1],"Change       ");
   strcpy(ml[0].str[2],"Del          ");/*删除物品资料*/
   strcpy(ml[0].str[3],"Exit         ");/*退出系统*/
   ml[0].n=4; /*保存菜单的项数*/
   strcpy(ml[1].name,"Worker");
   strcpy(ml[1].str[0],"Add          ");/*添加新会员*/
   strcpy(ml[1].str[1],"Change       ");/*查询会员资料*/
   strcpy(ml[1].str[2],"Del          ");/*删除会员资料*/
   ml[1].n=3;
   strcpy(ml[2].name,"Count");  /*统计*/
   strcpy(ml[2].str[0],"Worker feat  ");/*销售业绩*/
   strcpy(ml[2].str[1],"Item infor   ");/*商品销售情况*/
   ml[2].n=3;
   strcpy(ml[3].name,"Manage"); /*管理*/
   strcpy(ml[3].str[0],"Sale"); /*商品销售*/
   strcpy(ml[3].str[1],"Ventary"); /*盘存*/   
   ml[3].n=2;
}
/*显示主单名*/
void DrawSelectitem()
{
   for(i=0;i<4;i++)
   RedText(i,1,ml[i].name); /*显示主菜单名,且首字母为红色*/
}
/*正常显示菜单*/
void RedText(int x,int y,char *z)
{
   textbackground(7); /*设置背景颜色为浅灰色*/
   gotoxy(3+x*12,y);
   for(j=0;z[j];j++)
   {
      if(j==0)
  textcolor(RED);/*第一个字母显示红色*/
      else
  textcolor(BLACK); /*设置黑色*/
      cprintf("%c",z[j]); /*输出菜单名*/
   }
}
/*显示选中菜单*/
void BlackText(int x,int y,char *z)
{
   textbackground(0); /*设置背景颜色为黑色*/
   textcolor(15); /*设置文本颜色为白色*/
   gotoxy(3+12*x,y);/*定位坐标*/
   cputs(z); /*输出菜单名字符串*/
}
/*按键操作过程*/
void Run()
{
   while(1)
   {
      gotoxy(texty,textx);
      key=bioskey(0);/*接收按键*/
      switch(key)
      {
  case ALT_I: DrawMl(0);break; /*显示下拉菜单1物品*/
  case ALT_W: DrawMl(1);break;/*显示下拉菜单2收银员*/
  case ALT_C: DrawMl(2);break;/*显示下拉菜单3统计*/
  case ALT_M: DrawMl(3);break;/*商品管理*/
  case UP:  /*上光标键的操作控制*/
     {
        if(textx==3)
    textx=23;
        textx--;
        gotoxy(texty,textx);
     }break;
  case DOWN:  /*下光标键的操作控制*/
     {
        if(textx==23)
    textx=3;
        textx++;
        gotoxy(texty,textx);
     }break;
  case LEFT: /*左光标键的操作控制*/
     {
        if(texty==2)
    texty=79;
        texty--;
        gotoxy(texty,textx);
     }break;
  case Backspace: /*擦除键的设置*/
     {
        if(texty==2&&textx==3)
    continue;
        else
        {
    if(texty!=2)
       texty--; /*擦除键的细节问题,先擦去东西,然后光标还要往后退一格*/
    else
       if(texty==2)
       {
   texty=78;
   textx--;
       }
       gotoxy(texty,textx);
       printf(" ");
       gotoxy(texty,textx);
    }
        }break;/*end case 0xe08*/
  case RIGHT: /*右光标键的操作控制*/
     {
        if(texty==79)
    texty=2;
        texty++;
        gotoxy(texty,textx);
     }break;
  case SPACE:                /*空格键的操???????*/
     {
        if(texty==79)
    continue;
        else
        {
    gotoxy(texty,textx); /*空格的细节操作*/
    printf(" ");
    texty++;
    gotoxy(texty,textx);
        }
     }break;
  case ENTER: /*回车的控制操作?????????*/
     {
        if(textx==23)
    continue;
        textx++;
        texty=2;
        gotoxy(texty,textx);
     }break;
  default : /*非控制键的结果*/
     {
        if(texty==79&&textx==23)/*到达最后就不再输出*/
    continue;
        else
    if(texty==79&&textx!=23) /*到行的最后*/
    {
       textx++;
       texty=2;
    }
        gotoxy(texty,textx);/*输出结果*/
        printf("%c",key);
        if(texty==79) /*如果texty==79就不执行*/
    continue;
        else /*如果没到行尾就继续执行,使光标向前移动一位*/
    texty++;
  }
      }
   }/*大循环的大括号*/
}
/*画边框函数*/
void DrawFrame(int l,int u,int r,int d,int tcolor,int bcolor)
{
   textbackground(bcolor); /*背景颜色*/
   textcolor(bcolor); /*文本颜色*/
   for(i=l;i<=r;i++) /*输出背景区域*/
   {
      for(j=u;j<=d;j++)
      {
  gotoxy(i,j);
  printf("%c",219); /*输出背景字符*/
      }
   }
   textcolor(tcolor);/*边框颜色*/
   for(i=u+1;i<d;i++) /*在背景区域内输出边框线*/
   {
      gotoxy(l,i);
      cprintf("%c",179); /*垂直线*/
      gotoxy(r,i);
      cprintf("%c",179);
   }
   for(i=l+1;i<r;i++)
   {
      gotoxy(i,u);
      cprintf("%c",196); /*水平线*/
      gotoxy(i,d);
      cprintf("%c",196);
   }
   gotoxy(l,u);
   cprintf("%c",218);/*左上角*/
   gotoxy(r,u);
   cprintf("%c",191);/*右上角*/
   gotoxy(l,d);
   cprintf("%c",192);/*左下角*/
   gotoxy(r,d);
   cprintf("%c",217); /*右下角*/
/* gettext(l+1,u+1,r-1,d-1,save1);*//*保存边框内区域*/
}
/*显示具体下拉选择项目*/
void DrawMl(int n)
{
   gettext(1,1,80,25,save);/*保存被掩盖的地方*/
   BlackText(n,1,ml[n].name);/*反选显示主菜单*/
   DrawFrame(3+12*n-1,2,3+12*n+19,3+ml[n].n,0,7);/*下拉菜单的边框*/
   for(i=3;i<3+ml[n].n;i++)/*输出所选菜单各选项*/
   {
      if(i==3)
  BlackText(n,i,ml[n].str[i-3]);/*默认选中第一项*/
      else
  RedText(n,i,ml[n].str[i-3]);/*其余各项首字符红色显示*/
   }
   MoveMl(n,3);/*菜单选项的控制*/
}
/*菜单选项的控制,n决定水平项,x决定下拉的选项*/
void MoveMl(int n,int x)
{
   int flag=1;
   while(flag)
   {
      key=bioskey(0);/*接收按键*/
      gotoxy(79,1);
      switch(key)
      {
  case ESC:/*退出循环*/
    puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
    flag=0;
    break;
  case LEFT:/*移到左边的选项*/
    puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
    if(n==0)/*往左移动越界的话移到最后一个选项*/
       DrawMl(3);
    else
       DrawMl(n-1);
    flag=0;
    break;
  case RIGHT:/*移动右边的选项*/
    puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
    if(n==3)/*往右移动越界的话移到第一个选项*/
       DrawMl(0);
    else
       DrawMl(n+1);
    flag=0;
    break;
  case UP:/*具体选项往上移动*/
    RedText(n,x,ml[n].str[x-3]);/*输出红色字体*/
    if(x==3)/*移到最上面再按上键,就移到最下面*/
       x=3+ml[n].n-1;
    else
       x--;/*移动到新的要显示的内容*/
    BlackText(n,x,ml[n].str[x-3]);/*输出黑色字体*/
    flag=1;
    break;
  case DOWN:/*具体选项往下移动*/
    RedText(n,x,ml[n].str[x-3]);
    if(x==(3+ml[n].n-1))/*移动到最底下再按下键就移到最上面*/
       x=3;
    else
       x++;/*移动到新的要显示的内容*/
    BlackText(n,x,ml[n].str[x-3]);
    flag=1;
    break;
  case ENTER:
    puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
    Enter(n,x-3);/*菜单选项的具体功能*/
    flag=0;
    break;
  }
   gotoxy(79,1);

   }
}
 /*菜单选项的具体功能*/
void Enter(int m,int n)
{
   switch(m)
   {
      case 0:switch(n) /*选择了物品菜单选项*/
      {
  case 0:ItemAdd();break;/*添加物品*/
  case 1:ItemChange();break;/*查询*/
  case 2:ItemDel();break;/*删除资料*/
  case 3:exit(0);break;

      } break;/*退出系统*/
      case 1: switch(n) /*选择了职员菜单选项*/
       {
  case 0: WorkerAdd();break;
  case 1: WorkerChange();break;
  case 2: WorkerDel();break;
       }break;
      case 2:switch(n) /*选择了帮助菜单选项*/
      {
  case 0: Workerfeat();break;
  case 1: Iteminfor();break;
      }break;
      case 3:switch(n)
        {
  case 0: Sale();break;
  case 1: Ventary();break;
        }break;
   }/*结束外switch*/
}
/*录入商品信息,建立先进后出链表同时建立盘存表*/
int  create1(struct COMPANY*pcom)
{
    struct ITEM *p;
    char ch;
    do{
        p=(struct ITEM *)malloc(sizeof(struct ITEM));
        printf("\ninput the item number,name,stock and price:");
        scanf("%14s%19s%d%f",p->num,p->name,&p->stocknum,&p->price);
        pcom->n=+p->stocknum;    /*记总盘存数*/
        p->next=pcom->first;
        pcom->first=p;
        printf("continue?(y/n)");
        while(isspace(ch=getchar()));
    }while(toupper(ch)=='Y');
}
/*将链表所有结点写入数据文件*/
void write_file(struct COMPANY *pcom,FILE*myfile)
{
struct ITEM *p;
for (p=pcom->first;p!=NULL;p=p->next)
fwrite(p,sizeof(struct ITEM),1,myfile) ;
}
void sort1(struct COMPANY *pcom)  
{
    struct ITEM *p,*next,*last;
    unsigned m,n;
    for(m=0;m<pcom->items;m++)
        for(last=p=pcom->first,n=0;n<pcom->items-1-m;n++,last=p,p=p->next)
            if(strcmp(p->name,p->next->name)>0) /*交换两结点在链表中的位置*/
            {
                next=p->next;
                if(p!=pcom->first)
                    last->next=next;
                else pcom->first=next;
                p->next=next->next;
                next->next=p;
                p=next;
            }
}
/*从文件中读数据重建链表,先进先出*/
void read_file1(struct COMPANY *pcom,FILE*myfile)
{
    struct ITEM buf,*p,*tail;
    unsigned n;
    for(tail=pcom->first,n=0;n<pcom->items;tail=p,++n){
       if(fread(&buf,sizeof(struct ITEM),1,myfile)!=1)
       {
           pcom->items=n;
           break;
       }
        p=(struct ITEM*)malloc(sizeof(struct ITEM));
        *p=buf;
        if(pcom->first==NULL)
            pcom->first=p;
        else
            tail->next=p;
        p->next=NULL;
    }
}
void ItemAdd(struct COMPANY *pcom)     /*添加物品*/
{
    struct ITEM *p,*current,*last;
    char ch;
    do{
        p=(struct ITEM *)malloc(sizeof(struct ITEM));
        printf("\ninput the item number,name,stock,price:\n");
        scanf("14%s%19s%d%f",p->num,p->name,&p->stocknum,&p->price);
        for(last=current=pcom->first;current->next!=NULL&&((strcmp(p->name,current->name))>0);){
            last=current;
            current=current->next;
        }
        if(current->next==NULL&&strcmp(p->name,current->name)>0){
            current->next=p;
            p->next=NULL;
        }
        else{
            p->next=current;
            if (current==pcom->first)
                pcom->first=p;
            else
                last->next=p;
        }
        pcom->items++;
        printf("continue?(y/n)");
        while(isspace(ch=getchar()));
    }while(ch=='Y'||ch=='y');  
}
void ItemChange(struct COMPANY *pcom)
{
    struct ITEM *p=pcom->first;
    char a[15],ch;
    do{
        printf("\ninput the number of the item you want to change:");
        scanf("%s",a);
        while(strcmp(a,p->num)!=0&&p!=NULL)
            p=p->next;
        if(p!=NULL){
            printf("\ninput the item number,name,stock,price");
            scanf("14%s%19s%d%f",p->num,p->name,&p->stocknum,&p->price);
            sort1(pcom);
        }
        else printf("error:the item number does not exit!");
        printf("do you want to continue?(y\n)");
        while(isspace(ch=getchar()));
    }while(ch=='y'||ch=='Y');  
}
void ItemDel(struct COMPANY*pcom)
{
    char a[9],ch;
    struct ITEM *current ,*last;
    do{
        printf("\ninput the item number you want to delete:\n");
        scanf("%d",a);
        for(last=current=pcom->first;current!=NULL;last=current,current=current->next);
        ;
        if(current!=NULL){
            if(current!=pcom->first)
                last->next=current->next;
            else pcom->first=current->next;
            free(current);
        }
        else fprintf(stderr,"error: number of the item!\n");
        printf("continue?(y/n)");
        while(isspace(ch=getchar()));
    }while(ch=='y'||ch=='Y');
}
void create2(struct COMPANY *pcom)
{
    int n=0;
    struct WORKER *p;
    char ch;
    do{
        p=(struct WORKER *)malloc(sizeof(struct WORKER));
        printf("\ninput the worker's number,name,sex,ID and password:\n");
        scanf("%9s%12s%2s&19s%11s",p->num,p->name,p->sex,p->ID,p->password);
        p->price=0;
        p->next=pcom->next;
        pcom->next=p;
        n++;
        printf("continue?(y/n)");
        while(isspace(ch=getchar()));
    }while(toupper(ch)=='Y');
    pcom->workers=n;  /*收银员人数*/
}
void sort2(struct COMPANY *pcom)
{
    struct WORKER *p,*next,*last;
    unsigned m,n;
    for(m=0;m<pcom->workers;m++)
        for(last=p=pcom->next,n=0;n<pcom->workers-1-m;n++,last=p,p=p->next)
            if(strcmp(p->name,p->next->name)>0) /*交换两结点在链表中的位置*/
            {
                next=p->next;
                if(p!=pcom->next)
                    last->next=next;
                else pcom->next=next;
                p->next=next->next;
                next->next=p;
                p=next;
            }   
}
void read_file2(struct COMPANY *pcom,FILE*myfile)
{
    struct WORKER buf,*p,*tail;
    unsigned n;
    for(tail=pcom->next,n=0;n<pcom->workers;tail=p,++n){
       if(fread(&buf,sizeof(struct WORKER),1,myfile)!=1)
       {
           pcom->workers=n;
           break;
       }
        p=(struct WORKER*)malloc(sizeof(struct WORKER));
        *p=buf;
        if(pcom->next==NULL)
            pcom->next=p;
        else
            tail->next=p;
        p->next=NULL;
    }
}
void WorkerAdd(struct COMPANY *pcom)     /*添加收银员*/
{
    struct WORKER *p,*current,*last;
    char ch;
    do{
        p=(struct WORKER *)malloc(sizeof(struct WORKER));
        printf("\ninput the worker's number,name,sex,ID and password:\n");
        scanf("%9s%12s%2s&19s%11s",p->num,p->name,p->sex,p->ID,p->password);
        for(last=current=pcom->next;current->next!=NULL&&((strcmp(p->name,current->name))>0);){
            last=current;
            current=current->next;
        }
        if(current->next==NULL&&strcmp(p->name,current->name)>0){
            current->next=p;
            p->next=NULL;
        }
        else{
            p->next=current;
            if (current==pcom->next)
                pcom->next=p;
            else
                last->next=p;
        }
        pcom->workers++;
        printf("continue?(y/n)");
        while(isspace(ch=getchar()));
    }while(ch=='Y'||ch=='y');  
}
void WorkerChange(struct COMPANY *pcom)
{
    struct WORKER *p=pcom->next;
    char a[9],ch;
    do{
        printf("\ninput the number of the worker you want to change:");
        scanf("%s",a);
        while(strcmp(a,p->num)!=0&&p!=NULL)
            p=p->next;
        if(p!=NULL){
            printf("\ninput the worker's number,name,sex,ID and password:\n");
            scanf("%9s%12s%2s&19s%11s",p->num,p->name,p->sex,p->ID,p->password);
            sort2(pcom);
        }
        else printf("error:the worker's number does not exit!");
        printf("do you want to continue?(y\n)");
        while(isspace(ch=getchar()));
    }while(ch=='y'||ch=='Y');  
}
void WorkerDel(struct COMPANY*pcom)
{
    char a[9],ch;
    struct WORKER *current ,*last;
    do{
        printf("\ninput the worker's number you want to delete:\n");
        scanf("%d",a);
        for(last=current=pcom->next;current!=NULL;last=current,current=current->next);
        ;
        if(current!=NULL){
            if(current!=pcom->next)
                last->next=current->next;
            else pcom->next=current->next;
            free(current);
        }
        else fprintf(stderr,"error: number of the worker!\n");
        printf("continue?(y/n)");
        while(isspace(ch=getchar()));
    }while(ch=='y'||ch=='Y');
}
void Sale()  /*商品销售:输入收银员的工号,建立销售单及明细记录链*/
{
    struct WORKER *p;
    struct SALE1 *other;
    char a[9],ch;
    p=pcom->next;
inx:
    printf("\ninput your work number:\n");
    scanf("%s",a);
    while(strcmp(a,p->num)!=0){ /*遍历指针*/
        if(p!=NULL) p=p->next;
        else break;
}
    if(p==NULL) {printf("input error:the work number does not exit!");
    goto inx;
    }
    else{         /*插入销售单*/
        do{
            other=(struct SALE1*)malloc(sizeof(struct SALE1));
            printf("\ninput your sale number and data:");
            scanf("%s%s",other->salenum,other->data);
            strcpy(other->workernum,a);
            other->first=NULL;
            other->price=0;
            create_sale(other,pcom);
            p->price=+other->price;
            output_sale(other);
            printf("continue?(y/n)");
            while(isspace(ch=getchar()));
        }while(ch=='y'||ch=='Y');
        ClrScr();
    }
}
/*创建销售单明细链*/
void create_sale(struct SALE1*other,struct COMPANY *pcom)
{
    struct SALE2 *s;
    struct ITEM *t;
    char a[15],ch;
    t=pcom->first;

        s=(struct SALE2*)malloc(sizeof(struct SALE2));
iny:
        printf("\ninput the item number and piece:");
        scanf("%s%d",a,&s->piece);
        while(strcmp(a,t->num)!=0){
            if(t!=NULL) t=t->next;
            else break;
        }
        if(t==NULL){
            printf("input error:the item number does not exit!");
            goto iny;
        }
        else {
            strcpy(s->name,t->name);
            s->price=t->price;
            s->total=s->piece*s->price;
            b=t->stocknum-s->piece;     /*盘存计数*/
            strcpy(s->salenum,other->salenum);
            other->price=+s->total;
            other->quantity=+s->piece;
        }
        s->next=other->first;
        other->first=s;
        printf("continue?(y/n)");
        scanf("s",&ch);
if (ch=='y'||ch=='Y')
goto iny;
else return;
    }

void output_sale(struct SALE1*other)
{
    struct SALE2 *s;
    for(s=other->first;s!=NULL;s=s->next){
        window(10,10,70,15);
        gotoxy(1,1);
        printf("sale number:%s\n",s->salenum);
            printf("item number:%s\n",s->itemnum);
            printf("item name:%s\n",s->name);
            printf("item piece:%d\n",s->piece);
            printf("item price:%f\n",s->price);
            printf("total price:%f\n",s->total);
    }
    printf("worker number:%s\n",other->workernum);
        printf("total quantity:%d",other->quantity);
    printf("total price:%f",other->price);
    exit (-1) ;
}
void Iteminfor()
{
}
void Find()/*查询*/
{
    struct WORKER *p;
    struct SALE1 *t;
    int flag=1,k;
    char a[9],*menufind[]={
        "\n1:search products out of stock" /*查询库存数为零的商品*/
            "\n2:search item sale information" /*商品某段时间?????某商品的销售情况*/
            "\n3:search the item information" /*商品相关信息查询*/
            "\n0:exit"
            "\nselect[0-3]:"
    };
    ClrScr();
    while(flag){
        for(k=0;k<=4;k++)
            printf("%s",menufind[k]);    
        scanf("%d",&k);
        switch(k){
        case 1:
            stock_search();
            break;
        case 2:
            Sale_search();  /*某商品的销售情况*/
            break;    
        case 3:        
            item_search();
            break;
        case 0:
            flag=0;
            break;
        default:
            printf("select error!\n");
        }
    }
}
void stock_search()
{
    struct ITEM *p=pcom->first;
    long n=0;
    printf("this function is to find items out of stock\n");
    for(;p!=NULL;p=p->next)
            if(p->stocknum==0)
            {
                n++;
                printf("items out of stock:\n");
                printf("itemnumber:%s itemname:%s\n",p->num,p->name);
            }
      if(!n)            
        printf("not found items out of stock\n");    
}
void Sale_search()          /*某段?时间?的销售情况*/
{    
    int n=0;
    char ch,a[10],b[10],c[15];
    struct SALE1 *s;
    struct SALE2 *t;
    struct WORKER *p;
    do{
        printf("this function is to search a certain item's stock situation during sometime\n");
        printf("please input the number of item  you want to search\n");
        scanf("%s",c);
        printf("please input start time of search,for example:20070604\n");
        scanf("%s",a);
        printf("please input end time of search\n");
        scanf("%s",b);
        for(p=pcom->next;p!=NULL;p=p->next)
        {
            for(s=p->first;s!=NULL;s=s->next)
            {
                if(strcmp(s->data,a)>0&&strcmp(b,s->data)>0)
                    for(t=s->first;t!=NULL;t=t->next)
                        if(strcmp(t->itemnum,c)==0)
                            n=+t->piece;
            }
        }
        printf("item number:%s\n",c);
        printf("from %s to %s",a,b);
        printf("total saled %d pieces\n",n);
        printf("continue?(y/n)");
        while(isspace(ch=getchar()));
    }while(toupper(ch)=='Y');
}
void item_search()
{
    char a[15];
    struct ITEM *p=pcom->first;
    printf("this function is to show an item's information\n");
    printf("please input the number of item  you want to search\n");
    scanf("%s",a);
    if(strcmp(p->num,a)!=0)
        p=p->next;
    printf("item name:%s\n",p->name);
    printf("item stocknum:%s\n",p->stocknum);
    printf("item price:%s\n",p->price);    
}
void Workerfeat()/*收银员销售业绩统计*/
{
    struct WORKER *p,*next,*last;
    struct COMPANY *t;
    unsigned m,n,r;
    for(m=0;m<pcom->workers;m++)
        for(last=p=pcom->next,n=0;n<pcom->workers-1-m;n++,last=p,p=p->next)
            if(p->price<p->next->price) /*交换两结点在链表中的位置*/
            {
                next=p->next;
                if(p!=pcom->next)
                    last->next=next;
                else pcom->next=next;
                p->next=next->next;
                next->next=p;
                p=next;
            }
            gotoxy(2,3) ;
            printf("the workers sale information:");
            gotoxy(3,3) ;
            for(t=pcom->next,r=1;t!=NULL;t=t->next,r++)
                printf("%d.%s\t%f\n",r,t->name,t->first->price);
                exit (-1);
}

void Ventary()/*盘存*/
{
    struct COMPANY *pcom;
    struct SALE1 *other;
    int a,b,c,d;
    char *str[20];
    create1(pcom);
    a=pcom->n ;
    output_sale(other);
    b=other->quantity;
    c=a-b;
    printf("the caculated number is:%d",c) ;
    printf("the true number is:\n");
    scanf ("%d",&d);
    printf("the one in charge is :");
    scanf("%s",str);
}
2008-09-01 10:48
xujun1207
Rank: 1
等 级:新手上路
帖 子:79
专家分:0
注 册:2008-7-15
收藏
得分:0 
二楼的太强了,啥时候我也能自已编写个这样的程序呀……
#include <bios.h>这个头文件没有命名,
2008-09-02 14:04
快速回复:求助!!!!!商店存货管理系统
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013851 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved