| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 984 人关注过本帖
标题:大神们,帮我看看!下午验收的程序!
只看楼主 加入收藏
flyme
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-5-17
收藏
 问题点数:0 回复次数:10 
大神们,帮我看看!下午验收的程序!
问题有:
1、文件导入的时候无法进行查询
2、输入出库时,无法在出库里查询,反而在入库查询,查到


#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <wincon.h>
#include <string.h>
#include <ctype.h>

struct worker *WOR;
#define HEADER "|--------|--------|------------|-------|\n"

COORD pos1_1 = {0,0};

extern WINBASEAPI HWND WINAPI GetConsoleWindow();

struct date/*结构数组放日期信息*/
{  
    int year;
    int month;
    int day;
}D[100];

struct cangku/*结构数组放仓库信息*/
{
    char num[50];
    char name[50];
    char manager[50];
}ck[5];

struct chanpin/*结构数组放产品信息*/
{
    char num[50];
    char name[50];
    char standard[50];
}cp[10];

typedef struct churu/*定义产品出入链表结构*/
{
    char cknum[50];
    char cpnum[50];
    char count[50];
    char date[50];
    char kind[20];
    struct churu *next;
}CR;

/*******函数原型*******/
void printheader();            /*输出表头信息*/
int  date_legal(char *date);    /*定义一个函数,判断日期是否合法*/
void input(CR *head);          /*产品入库*/
void output(CR *head);         /*产品出库*/
void searchon_cpnum_input(CR *head);   /*查询指定产品编号的入库记录*/
void searchon_cpnum_output(CR *head);  /*查询指定产品编号的出库记录*/
void menu_select(CR *head);   /*功能函数*/
void cls();
void read(CR *head);
void xiugai(CR *head);
void del(CR *head);
void save();

/*******主函数*******/
main()
{
    int i=0;
    CR *head;
    head=malloc(sizeof(CR));
    head->next=NULL;
   
    strcpy(cp[0].name,"屏幕");
    strcpy(cp[0].num,"201300000");
    strcpy(cp[0].standard,"A类");
   
    strcpy(cp[1].name,"CPU");
    strcpy(cp[1].num,"201300001");
    strcpy(cp[1].standard,"A类");
   
    strcpy(cp[2].name,"GPU");
    strcpy(cp[2].num,"201300002");
    strcpy(cp[2].standard,"A类");
   
    strcpy(cp[3].name,"电池");
    strcpy(cp[3].num,"201300003");
    strcpy(cp[3].standard,"A类");
   
    strcpy(cp[4].name,"天线");
    strcpy(cp[4].num,"201300004");
    strcpy(cp[4].standard,"A类");
   
    strcpy(cp[5].name,"麦克风");
    strcpy(cp[5].num,"201300005");
    strcpy(cp[5].standard,"A类");
   
    strcpy(cp[6].name,"按键");
    strcpy(cp[6].num,"201300006");
    strcpy(cp[6].standard,"A类");
   
    strcpy(cp[7].name,"WiFi");
    strcpy(cp[7].num,"201300007");
    strcpy(cp[7].standard,"A类");
   
    strcpy(cp[8].name,"内存");
    strcpy(cp[8].num,"201300008");
    strcpy(cp[8].standard,"A类");
   
    strcpy(cp[9].name,"芯片组");
    strcpy(cp[9].num,"201300009");
    strcpy(cp[9].standard,"A类");        /*已知产品默认信息*/
   
    strcpy(ck[0].name,"一号仓库");
    strcpy(ck[0].num,"10001");
    strcpy(ck[0].manager,"杜喆");
   
    strcpy(ck[1].name,"二号仓库");
    strcpy(ck[1].num,"10002");
    strcpy(ck[1].manager,"魏德胜");
   
    strcpy(ck[2].name,"三号仓库");
    strcpy(ck[2].num,"10003");
    strcpy(ck[2].manager,"罗周全");
   
    strcpy(ck[3].name,"四号仓库");
    strcpy(ck[3].num,"10004");
    strcpy(ck[3].manager,"王庙");
   
    strcpy(ck[4].name,"五号仓库");
    strcpy(ck[4].num,"10005");
    strcpy(ck[4].manager,"聂先洲");    /*已知仓库默认信息*/
   
    menu_select(head);
}

/*******功能函数*******/
void menu_select(CR *head)
{
    HWND hwnd;
    HDC hdc;
    int xy=0,i;
   
    INPUT_RECORD mouseRec;
    DWORD state = 0, res=0;
    POINT pt;
    HPEN pn;
    RECT rt,rt0,rt1,rt2,rt3,rt4,rt5,rt6,rt7,rt8,rt9;
    HANDLE hOut;
    HANDLE hIn;
    hwnd=GetConsoleWindow();
    hdc = GetDC(hwnd);
   
    rt0.top=5;
    rt0.left=340;
    rt0.right=540;
    rt0.bottom=30;
   
    rt1.top=40;
    rt1.left=400;
    rt1.right=545;
    rt1.bottom=60;
   
    rt2.top=70;
    rt2.left=400;
    rt2.right=545;
    rt2.bottom=90;
   
    rt3.top=100;
    rt3.left=400;
    rt3.right=545;
    rt3.bottom=120;
   
    rt4.top=130;
    rt4.left=425;
    rt4.right=520;
    rt4.bottom=150;
   
    rt5.top=160;
    rt5.left=425;
    rt5.right=520;
    rt5.bottom=180;
   
    rt6.top=190;
    rt6.left=393;
    rt6.right=552;
    rt6.bottom=210;
   
    rt7.top=220;
    rt7.left=393;
    rt7.right=552;
    rt7.bottom=240;
   
    rt8.top=250;
    rt8.left=540;
    rt8.right=603;
    rt8.bottom=270;
   
    rt9.top=280;
    rt9.left=510;
    rt9.right=643;
    rt9.bottom=300;
   
    hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    hIn=GetStdHandle(STD_INPUT_HANDLE);
    pn=CreatePen(PS_SOLID,1,RGB(200,10,200));
   
    GetClientRect(hwnd, &rt);
    SelectObject(hdc, pn);
    SetTextColor(hdc,255);
    SetBkMode(hdc,TRANSPARENT);
    MoveToEx(hdc,350,32,NULL);
    LineTo(hdc,630,32);
   
    Rectangle(hdc,rt1.left,rt1.top,rt1.right,rt1.bottom);
    Rectangle(hdc,rt2.left,rt2.top,rt2.right,rt2.bottom);
    Rectangle(hdc,rt3.left,rt3.top,rt3.right,rt3.bottom);
    Rectangle(hdc,rt4.left,rt4.top,rt4.right,rt4.bottom);
    Rectangle(hdc,rt5.left,rt5.top,rt5.right,rt5.bottom);
    Rectangle(hdc,rt6.left,rt6.top,rt6.right,rt6.bottom);
    Rectangle(hdc,rt7.left,rt7.top,rt7.right,rt7.bottom);
    Rectangle(hdc,rt8.left,rt8.top,rt8.right,rt8.bottom);
   
    DrawText(hdc,"                     仓库管理系统",33,&rt0,NULL);
    DrawText(hdc,"导入产品的入库信息",18,&rt1,NULL);
    DrawText(hdc,"输入产品的入库信息",18,&rt2,NULL);
    DrawText(hdc,"输入产品的出库信息",18,&rt3,NULL);
    DrawText(hdc,"修改入库数量",12,&rt4,NULL);
    DrawText(hdc,"删除入库记录",12,&rt5,NULL);
    DrawText(hdc,"查询指定产品入库记录",20,&rt6,NULL);
    DrawText(hdc,"查询指定产品出库记录",20,&rt7,NULL);
    DrawText(hdc,"保存退出",8,&rt8,NULL);
    DrawText(hdc,"系统制作:林佳文",16,&rt9,NULL);
   
    LineTo(hdc,630,278);
    LineTo(hdc,350,278);
    LineTo(hdc,350,32);
   
    ShowWindow(hwnd,SW_SHOW);
    for(;;)
    {        
        ReadConsoleInput(hIn, &mouseRec, 1, &res);
        Sleep(100);
        if (mouseRec.EventType == MOUSE_EVENT)
        {
            if (mouseRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
            {        
                GetCursorPos(&pt);
                ScreenToClient(hwnd,&pt);
                SetConsoleTextAttribute(hOut, 4);
                SetConsoleCursorPosition(hOut, pos1_1);
               
                if(pt.x>rt1.left && pt.x<rt1.right &&pt.y>rt1.top && pt.y<rt1.bottom)
                {
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    read(head);
                    continue;
                }
               
                else if(pt.x>rt2.left && pt.x<rt2.right &&pt.y>rt2.top && pt.y<rt2.bottom)
                {
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    input(head);               
                    continue;
                }
               
                else if(pt.x>rt3.left && pt.x<rt3.right &&pt.y>rt3.top && pt.y<rt3.bottom)
                {
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    output(head);
                    continue;
                }
               
                else if(pt.x>rt4.left && pt.x<rt4.right &&pt.y>rt4.top && pt.y<rt4.bottom)
                {
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    xiugai(head);
                    continue;
                }
               
                else if(pt.x>rt5.left && pt.x<rt5.right &&pt.y>rt5.top && pt.y<rt5.bottom)
                {
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    del(head);
                    continue;
                }
               
                else if(pt.x>rt6.left && pt.x<rt6.right &&pt.y>rt6.top && pt.y<rt6.bottom)
                {
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    searchon_cpnum_input(head);
                    continue;
                }
               
                else if(pt.x>rt7.left && pt.x<rt7.right &&pt.y>rt7.top && pt.y<rt7.bottom)
                {
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    searchon_cpnum_output(head);
                    continue;
                }
               
                else if(pt.x>rt8.left && pt.x<rt8.right &&pt.y>rt8.top && pt.y<rt8.bottom)
                {   
                    SetConsoleCursorPosition(hOut, pos1_1);
                    cls();
                    SetConsoleCursorPosition(hOut, pos1_1);
                    save();
                    break;
                }
               
            };
            
        }
        
    }
    ReleaseDC(hwnd,hdc);
    return 0;
}

void read(CR *head)
{
    int i;
    char filename[32];
    FILE * fp ;
    CR *p,*temp;
    p=head;
    while(p->next!=NULL)
        p=p->next;
    temp=malloc(sizeof(CR));
    temp->next=NULL;
    printf("请输入文件路径:");
    gets(filename);
    fp=fopen(filename,"r");
    if(fp==NULL){
        printf("文件不存在\n");
        exit(0);
    }
    printf("\n仓库编号--产品编号-----入库日期--入库数");
    for(i=0;i<5;i++)
    {
        fscanf(fp,"%s%s%s%s",temp->cknum,temp->cpnum,temp->date,temp->count);
        printf("\n%s    %s     %s     %s\n",temp->cknum,temp->cpnum,temp->date,temp->count);
    }
    printf("\t\n文件导入成功\n");
    p->next=temp;
    fclose(fp);
}


/*******输出表头信息*******/
void printheader()
{
    printf("|仓库编号|产品编号| 日      |数   量\n");
}


/*******产品入库*******/
void input(CR *head)
{
    int i=0,a=0,b=0,c=0,m=1;  
    char s[50];
    CR *p,*temp;
    p=head;
    while(p->next!=NULL)
        p=p->next;
    temp=malloc(sizeof(CR));
    temp->next=NULL;
    printf("请输入入库产品信息!\n");
   
    printf("仓库编号:   ");
    scanf("%s",temp->cknum);
    do
    {
        i=0;    /***判断仓库编号是否存在***/
        while(i<5)
        {
            if(strcmp(ck[i].num,temp->cknum)==0)
                b=1; i++;
        }
        if(b==0)
        {
            printf("无此仓库编号!\n  请重输入\n  ");
            printf("  仓库编号:   ");
            scanf("%s",temp->cknum);
        }
    }while(strcmp(ck[i].num,temp->cknum)!=0&&b==0);
   
    printf("产品编号:   ");
    scanf("%s",temp->cpnum);
    do
    {
        i=0;
        while(i<10)    /***判断产品编号是否存在***/
        {
            if(strcmp(cp[i].num,temp->cpnum)==0)
                c=1;  i++;
        }
        if(c==0)
        {
            printf("无此产品编号!\n请重输入\n  ");
            printf("产品编号:   ");
            scanf("%s",temp->cpnum);
        }
    }while(strcmp(cp[i].num,temp->cpnum)!=0&&c==0);
   
   
    printf("入库日期:   ");
    scanf("%s",temp->date);
   
    if(date_legal(temp->date)==0)   /***判断日期格式是否正确***/
    {
        do{
            
            printf("\n 请重输入\n  ");
            printf("入库日期:    ");
            scanf("%s",temp->date);
        }while(date_legal(temp->date)==0);
    }
    do
    {
        if(m<=0)
            printf("入库数量应大于0,请重输\n");
        printf("入库数量:   ");
        scanf("%s",temp->count);
        m=atoi(temp->count);
    }while(m<=0);
    printf("操作类型:   ");
    scanf("%s",temp->kind);
   
   
    if(b&&c)
    {
        printf("入库成功,并保存!\n");
        p->next=temp;
    }
    else        
        free(temp);    /***释放存储区间***/
}




/*******产品出库*******/
void output(CR *head)
{
    int a=0,b=0,c=0,i=0,sum1=0,sum2=0,m1=0,m2=0,n1=0,n2=0,m3=0,n3=0,n4=1;  
    char s[50];
    CR *p,*q,*m,*n;
    p=head;   
    m=head;
    n=head;
    while(p->next!=NULL)
        p=p->next;
    q=malloc(sizeof(CR));
    q->next=NULL;
    printf("请输出库产品信息:\n");
    printf("仓库编号:    ");
    scanf("%s",q->cknum);
    do
    {
        i=0;    /***判断仓库编号是否存在***/
        while(i<5)
        {
            if(strcmp(ck[i].num,q->cknum)==0)
                m3=1; i++;
        }
        if(m3==0)
        {
            printf("无此仓库编号!\n  请重输入\n  ");
            printf("  仓库编号:   ");
            scanf("%s",q->cknum);
        }
    }while(strcmp(ck[i].num,q->cknum)!=0&&m3==0);
   
    printf("产品编号:    ");
    scanf("%s",q->cpnum);
    do
    {
        i=0;
        while(i<10)    /***判断产品编号是否存在***/
        {
            if(strcmp(cp[i].num,q->cpnum)==0)
                n3=1;  i++;
        }
        if(n3==0)
        {
            printf("无此产品编号!\n请重输入\n  ");
            printf("产品编号:   ");
            scanf("%s",q->cpnum);
        }
    }while(strcmp(cp[i].num,q->cpnum)!=0&&n3==0);
   
   
    printf("出库日期:    ");
    scanf("%s",q->date);           
    if(date_legal(q->date)==0)   /***判断日期格式是否正确***/
    {
        do{
            
            printf("\n 请重输入\n  ");
            printf("出库日期:    ");
            scanf("%s",q->date);
        }while(date_legal(q->date)==0);
    }
    do
    {if(n4<=0)
        printf("入库数量应大于0,请重输\n");
    printf("出库数量:   ");
    scanf("%s",q->count);
    n4=atoi(q->count);
    }while(n4<=0);
          printf("操作类型:    ");
          scanf("%s",q->kind);
         
          while(m!=NULL)
          {
              m1=atoi(m->cknum);
              m2=atoi(q->cknum);
              n1=atoi(m->cpnum);
              n2=atoi(q->cpnum);
              if(m1==m2&&n1==n2)   /***判断编号是否存在***/
              {
                  c=atoi(m->count);
                  a=atoi(m->kind);
                  if(a==1)   
                      sum1=sum1+c;
                  if(a==-1)
                      sum2=sum2+c;
                  i++;
              }
              m=m->next;
          }
          if(i==0)      
              printf("无需出库产品的相应记录!\n");
          b=atoi(q->count);
          if(b<=(sum1-sum2))
          {
              printf("产品出库成功,并记录!\n");
              p->next=q;
          }
          else
              printf("对不起!该产品在%s仓库中库存不够。\n\n",q->cknum);
}

/*******查询指定产品编号的入库记录*******/

void searchon_cpnum_input(CR *head)
{
    CR *p;
    char a[20];
    int i=0,c=0;
    p=head->next;
    printf("请输入产品编号:   ");
    scanf("%s",a);
    do
    {
        i=0;
        while(i<10)    /***判断产品编号是否存在***/
        {
            if(strcmp(cp[i].num,a)==0)
                c=1;
            i++;
        }
        if(c==0)
        {
            printf("无此产品编号!\n请重输入\n  ");
            printf("产品编号:   ");
            scanf("%s",a);
        }
    }while(strcmp(cp[i].num,a)!=0&&c==0);
    printheader();    /***打印表头***/
    while(p!=NULL)
    {
        c=atoi(p->kind);
        if(c==1&&strcmp(a,p->cpnum)==0)
        {
            printf(HEADER);
            printf("\n%s    %s   %s     %s\n",p->cknum,p->cpnum,p->date,p->count);                    
            i++;
        }
        p=p->next;
    }
    if(i==0)
    {
        printf("您要查找的产品无入库记录!\n\n");
    }
}

/*******查询指定产品编号的出库记录*******/

void searchon_cpnum_output(CR *head)
{
    CR *p;
    char a[20];
    int i=0,c=0;
    p=head->next;
    printf("请输入产品编号:   ");
    scanf("%s",a);
    do
    {
        i=0;
        while(i<10)    /***判断产品编号是否存在***/
        {
            if(strcmp(cp[i].num,a)==0)
                c=1;  i++;
        }
        if(c==0)
        {
            printf("无此产品编号!\n请重输入\n  ");
            printf("产品编号:   ");
            scanf("%s",a);
        }
    }while(strcmp(cp[i].num,a)!=0&&c==0);
    printheader();    /***打印表头***/
    while(p!=NULL)
    {
        c=atoi(p->kind);
        if(c==-1&&strcmp(a,p->cpnum)==0)
        {
            printf(HEADER);
            printf("\n%s    %s   %s     %s\n",p->cknum,p->cpnum,p->date,p->count);            
            i++;
        }
        p=p->next;/*移动结点*/
    }
    if(i==0)
        printf("您要查找的产品无出库记录!\n");
}



/*定义一个函数,判断日期是否合法*/
int date_legal(char *date)
{
    static int i=0;
    int leap;
    int year,month,day;     /*  2009-09-10*/
    int flag=1;
    if(strlen(date)==10)
    {
        if(date[4]=='-'&&date[7]=='-')
        {  
            year = (date[0]-48)*1000+(date[1]-48)*100+(date[2]-48)*10+(date[3]-48)*1;/*转化为整数*/
            month = (date[5]-48)*10+(date[6]-48)*1;
            day = (date[8]-48)*10+(date[9]-48)*1;
            D[i].year=year;
            D[i].month=month;
            D[i].day=day;
            i++;
            
            if(month==2)
            {
                leap=(year%4==0&&year%100!=0||year%400==0);/*判断是否为闰年*/
                if(leap==1&&day>29){
                    printf("该年是闰年,二月是29天,输入错误!\n");
                    flag=0;
                }
                if(leap==0&&day>28){
                    printf("平年二月是28天,输入错误!\n");
                    flag=0;
                }
            }
            if(month==4||month==6||month==9||month==11)
            {
                if(day>30)
                {  
                    printf("该月是30天,输入错误!\n");
                    flag=0;
                }
               
            }
            if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
               
            {
                if(day>31)
                {   
                    printf("该月是31天,输入错误!\n");
                    flag=0;
                }
            }
            if(month>12||month<1)/*月份的判断*/
            {
                printf("错啦!月份1~12!\n");
                flag=0;
            }
        }
        else
        {
            printf("日期输入格式错误(格式为YYYY-MM-DD)!\n");
            flag=0;
        }
    }   
    else
    {
        printf("日期输入长度错误!\n");
        flag=0;
    }
    if(i>=2)
    {
        if(D[i-1].year==D[i-2].year)
        {
            if(D[i-1].month==D[i-2].month )   
            {
                if(D[i-1].day<D[i-2].day)
                {printf("日期晚于上一次输入时日期!");flag=0;}
            }
            else if(D[i-1].month<D[i-2].month)
            {printf("日期晚于上一次输入时日期!");flag=0;}
        }   
        else if(D[i-1].year<D[i-2].year)
        {printf("日期晚于上一次输入时日期!");flag=0;}
    }
   
   
    return flag;
}


void cls()
{
    int i,n=20;
    HANDLE hOut;
    COORD pos,pos1;
    pos.X=0;
    pos.Y=0;
    SetConsoleCursorPosition(hOut, pos1_1);
    for(i=0;i<=n;i++)
    {
        pos1.X=pos.X;
        pos1.Y=pos.Y+i;
        SetConsoleCursorPosition(hOut, pos1);
        printf("                                         \n");
    }
    SetConsoleCursorPosition(hOut, pos1_1);
}

void xiugai(CR *head)
{
    CR *p;
    int n,i=0,b=0,c=0,m;
    char cknum[50];
    char cpnum[50];
    char count[50];
    char date[50];
    char kind[20];
    printf("请输入修改方式:\n1、通过产品编号;\n2、通过入库日期;\n");
    scanf("%d",&n);
    p=head;
    switch(n)
    {
    case 1:
        {
            printf("请输入要修改的产品编号:\n");
            scanf("%s",cpnum);
            do
            {
                i=0;
                while(i<10)    /***判断产品编号是否存在***/
                {
                    if(strcmp(cp[i].num,cpnum)==0)
                        c=1;
                    i++;
                }
                if(c==0)
                {
                    printf("无此产品编号!\n请重输入\n  ");
                    printf("产品编号:   ");
                    scanf("%s",cpnum);
                }
            }while(strcmp(cp[i].num,cpnum)!=0&&c==0);        
            
            while(p->next!=NULL)
            {
                if(cpnum==p->cpnum)
                    break;
                p=p->cpnum;
            }
            if(cpnum==p->cpnum)
            {
                printf("请输入修改后的信息:");
                printf("仓库编号:   ");
                scanf("%s",cknum);
                do
                {
                    i=0;    /***判断仓库编号是否存在***/
                    while(i<5)
                    {
                        if(strcmp(ck[i].num,cknum)==0)
                            b=1;
                        i++;
                    }
                    if(b==0)
                    {
                        printf("无此仓库编号!\n  请重输入\n  ");
                        printf("  仓库编号:   ");
                        scanf("%s",cknum);
                    }
                }while(strcmp(ck[i].num,cknum)!=0&&b==0);
               
                printf("产品编号:   ");
                scanf("%s",cpnum);
                do
                {
                    i=0;
                    while(i<10)    /***判断产品编号是否存在***/
                    {
                        if(strcmp(cp[i].num,cpnum)==0)
                            c=1;
                        i++;
                    }
                    if(c==0)
                    {
                        printf("无此产品编号!\n请重输入\n  ");
                        printf("产品编号:   ");
                        scanf("%s",cpnum);
                    }
                }while(strcmp(cp[i].num,cpnum)!=0&&c==0);
                printf("入库日期:   ");
                scanf("%s",date);
               
                if(date_legal(date)==0)   /***判断日期格式是否正确***/
                {
                    do{                    
                        printf("\n 请重输入\n  ");
                        printf("入库日期:    ");
                        scanf("%s",date);
                    }while(date_legal(date)==0);
                }
                do
                {
                    if(m<=0)
                        printf("入库数量应大于0,请重输\n");
                    printf("入库数量:   ");
                    scanf("%s",count);
                    m=atoi(count);
                }while(m<=0);
            
                printf("操作类型:   ");
                scanf("%s",kind);
                strcpy(p->cknum,cknum);
                strcpy(p->cpnum,cpnum);
                strcpy(p->date,date);
                strcpy(p->count,count);
                strcpy(p->kind,kind);
                printf("信息已修改\n");            
            }
            break;
        }
    case 2:
        {
            printf("请输入要修改的入库时间:");
            scanf("%s",date);
            if(date_legal(date)==0)   /***判断日期格式是否正确***/
            {
                do{
                    
                    printf("\n 请重输入\n  ");
                    printf("入库日期:    ");
                    scanf("%s",date);
                }while(date_legal(date)==0);
            }
            cls();
            while(p->next!=NULL)
            {
                if(date==p->date)
                    break;
                p=p->date;
            }
            if(date==p->date)
            {
                printf("请输入修改后的信息:");
                printf("仓库编号:   ");
                scanf("%s",cknum);
                do
                {
                    i=0;    /***判断仓库编号是否存在***/
                    while(i<5)
                    {
                        if(strcmp(ck[i].num,cknum)==0)
                            b=1;
                        i++;
                    }
                    if(b==0)
                    {
                        printf("无此仓库编号!\n  请重输入\n  ");
                        printf("  仓库编号:   ");
                        scanf("%s",cknum);
                    }
                }while(strcmp(ck[i].num,cknum)!=0&&b==0);
                printf("产品编号:   ");
                scanf("%s",cpnum);
                do
                {
                    i=0;
                    while(i<10)    /***判断产品编号是否存在***/
                    {
                        if(strcmp(cp[i].num,cpnum)==0)
                            c=1;
                        i++;
                    }
                    if(c==0)
                    {
                        printf("无此产品编号!\n请重输入\n  ");
                        printf("产品编号:   ");
                        scanf("%s",cpnum);
                    }
                }while(strcmp(cp[i].num,cpnum)!=0&&c==0);
                printf("入库日期:   ");
                scanf("%s",date);
               
                if(date_legal(date)==0)   /***判断日期格式是否正确***/
                {
                    do{                    
                        printf("\n 请重输入\n  ");
                        printf("入库日期:    ");
                        scanf("%s",date);
                    }while(date_legal(date)==0);
                }
                do
                {
                    if(m<=0)
                        printf("入库数量应大于0,请重输\n");
                    printf("入库数量:   ");
                    scanf("%s",count);
                    m=atoi(count);
                }while(m<=0);
                printf("操作类型:   ");
                scanf("%s",kind);
                strcpy(p->cknum,cknum);
                strcpy(p->cpnum,cpnum);
                strcpy(p->date,date);
                strcpy(p->count,count);
                strcpy(p->kind,kind);
                printf("信息已修改\n");            
            }
            break;
        }
    default:
        {
            printf("输入错误!\n");
            break;
        }
    }
}

void del(CR *head)
{
    CR *p1,*p2;
    int n,i,c=0;
    char ch;
    char cpnum[50];
    char date[50];
    printf("请输入删除方式:\n1、通过产品编号;\n2、通过入库日期;\n");
    scanf("%d",&n);
    p1=head;
    switch(n)
    {
    case 1:
        {
            do
            {
                if(head==NULL)
                {
                    printf("暂无有效信息\n");
                    return 0;
                }
                p1=head;
                printf("请输入要删除的产品编号:\n");
                scanf("%s",cpnum);
                do
                {
                    i=0;
                    while(i<10)    /***判断产品编号是否存在***/
                    {
                        if(strcmp(cp[i].num,cpnum)==0)
                            c=1;
                        i++;
                    }
                    if(c==0)
                    {
                        printf("无此产品编号!\n请重输入\n  ");
                        printf("产品编号:   ");
                        scanf("%s",cpnum);
                    }
                }while(strcmp(cp[i].num,cpnum)!=0&&c==0);
                while(p1->next!=NULL)
                {
                    if(cpnum==p1->cpnum)
                        break;
                    p2=p1;
                    p1=p1->next;
                    
                }
                if(cpnum==p1->cpnum)
                {
                    if(p1==head)
                        head=p1->next;
                    else
                        p2->next=p1->next;
                    printf("该信息已删除\n");
                }
                else
                    printf("该信息不存在!\n");
                printf("\n是否继续删除操作?(Y/N)");
                ch=getchar();
                ch=getchar();
            }while(ch!='n'&&ch!='N');
            break;
        }
    case 2:
        {
            do
            {
                if(head==NULL)
                {
                    printf("暂无有效信息\n");
                    return 0;
                }
                p1=head;
                printf("请输入要删除的入库日期:\n");
                scanf("%s",date);
                if(date_legal(date)==0)   /***判断日期格式是否正确***/
                {
                    do{                    
                        printf("\n 请重输入\n  ");
                        printf("入库日期:    ");
                        scanf("%s",date);
                    }while(date_legal(date)==0);
                }
                while(p1->next!=NULL)
                {
                    if(date==p1->date)
                        break;
                    p2=p1;
                    p1=p1->next;
                    
                }
                if(date==p1->date)
                {
                    if(p1==head)
                        head=p1->next;
                    else
                        p2->next=p1->next;
                    printf("该信息已删除\n");
                }
                else
                    printf("该信息不存在!\n");
                printf("\n是否继续删除操作?(Y/N)");
                ch=getchar();
                ch=getchar();
            }while(ch!='n'&&ch!='N');
            break;
        }
    default:
        printf("输入错误!\n");
        break;
    }
}

void save()
{
    char name1[20];
    CR *p1;
    FILE *fp;
    p1=WOR;        
    fp=fopen("1.txt","w");
    while(p1!=NULL)
    {
        fprintf(fp,"%c  %c  %c   %c\n",p1->cknum,p1->cpnum,p1->date,p1->count);
        p1=p1->next;
    }
    printf("已经保存成功\n");
    fclose(fp);
    return(WOR);
}
搜索更多相关主题的帖子: 查询 include 
2013-05-17 13:44
a64924374
Rank: 2
等 级:论坛游民
帖 子:33
专家分:61
注 册:2013-3-11
收藏
得分:0 
表示程序太长了
2013-05-17 13:51
Han_FlyB
Rank: 6Rank: 6
等 级:侠之大者
帖 子:143
专家分:424
注 册:2013-3-25
收藏
得分:0 
好吧,程序太长了,没耐心看
2013-05-17 14:10
秦殇
Rank: 2
等 级:论坛游民
帖 子:61
专家分:77
注 册:2013-3-13
收藏
得分:0 
这么长。。
2013-05-17 14:17
笑傲
Rank: 8Rank: 8
来 自:迪拜
等 级:蝙蝠侠
威 望:5
帖 子:223
专家分:856
注 册:2013-3-9
收藏
得分:0 
还没写过这么长的程序呢,呵呵!

练就一身本领,只为笑傲江湖!
2013-05-17 14:17
你的小九九
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-4-16
收藏
得分:0 
大神啊,表示有压力!
2013-05-17 15:50
书生等待
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:8
帖 子:280
专家分:689
注 册:2013-2-22
收藏
得分:0 
太长啦,只能友情帮顶了
2013-05-17 16:27
Ryker
Rank: 6Rank: 6
等 级:侠之大者
威 望:1
帖 子:145
专家分:420
注 册:2013-2-19
收藏
得分:0 
..今天一下午撸了400行..还以为挺多的...

和楼主一比....
2013-05-17 17:22
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
祝楼主验收幸运!

授人以渔,不授人以鱼。
2013-05-17 18:45
我叫沃恩
Rank: 12Rank: 12Rank: 12
来 自:Asia
等 级:贵宾
威 望:10
帖 子:1234
专家分:3865
注 册:2013-3-29
收藏
得分:0 
我虽然很想帮你,不过看这程序,一时半会也没头绪啊!祝楼主好运!!

因为我是菜鸟,所以应该被骂! 细节+坚持=成功!
2013-05-17 21:37
快速回复:大神们,帮我看看!下午验收的程序!
数据加载中...
 
   



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

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