程设小组作业——计算机配件的进货/销售管理系统

modify.h 修改函数

//////////////////////////////////////////////////
 /*
     修改函数 
     3.29 
 */ 
 void modify(int type){
     FILE *fp;
     char judge,judge_add;
     char part[20],model[20],mfts[20],name[20];
     int No,judge_time;
     printf("Do you want to add a new record?(Y/N):");
     getchar();
     scanf("%c",&judge_add);
     if(judge_add=='Y'||judge_add=='y')
     {
         insert(type_link);
         return;
     }
 modify_start:
     print_information_code(1,head);
     printf("                please input which imform you want to modify:");
     scanf("%d",&No);
     plink previous=inquire_information_code(head,No);
     plink p=previous;
     plink node=(plink)malloc(sizeof(link));
     node->time.day=p->time.day;
     node->time.month=p->time.month;
     node->time.minute=p->time.minute;
     node->time.hour=p->time.hour;
     node->judge_delete=p->judge_delete;
     node->mfts=p->mfts;
     node->model=p->model;
     node->name=p->name;
     node->num=p->num;
     node->part=p->part;
     node->total=p->total;
     node->unit=p->unit;
 modify:
     printf("                _________________________________________ \n");
     printf("               |                    Modify System                    |\n");
     printf("               |Current funds:%12.2f                           |\n",current_funds);
     printf("               |_________________________________________|\n");
     printf("               |Please choose the information you want to modify :   |\n");
     printf("               |                    1:time                           |\n");
     printf("               |                    2:mfts(Manufacturer)             |\n");
     printf("               |                    3:Supplier                       |\n");
     printf("               |                    4:Customer                       |\n");
     printf("               |                    5:Parts name                     |\n");
     printf("               |                    6:models                         |\n");
     printf("               |                    7:delete this record             |\n");
     printf("               |                    8:Back to record chosen menu     |\n");
     printf("               |                    9:Exit system                    |\n");
     printf("               |_________________________________________|\n");
     printf("                Your option:");
     int option=(int)malloc(sizeof(int));
     scanf("%d", option);
     switch(option){
         case 1:
         modify_input_time:
             printf("                please input new time(month,day,hour,minute):");
             int month,day,hour,minute;
             scanf("%d%d%d%d",&month,&day,&hour,&minute);
             node->time.month=month;
             node->time.day=day;
             node->time.hour=hour;
             node->time.minute=minute;
             judge_time=judge_date(2019,month,day,hour,minute);
             if(judge_time==0)
             {
                 printf("\n");
                 goto modify_input_time;
              }
             break;
         case 2:
             printf("                please input new mfts:");
             char mfts[20];
             scanf("%s",mfts);
             int mfts_int=switch_name_to_int(1,mfts);
             node->mfts=mfts_int;
             break;
         case 3: 
            printf("                please input new supplier:");
             char supplier[20];
             scanf("%s",supplier);
             int supplier_int=switch_name_to_int(1,supplier);
             node->name=supplier_int;
             break;
         case 4:
             printf("                please input new customer:");
             char customer[20];
             scanf("%s",customer);
             int customer_int=switch_name_to_int(1,customer);
             node->name=customer_int;
             break;
         case 5:
             printf("                please input new part name:");
             char parts[20];
             scanf("%s",parts);
             int parts_int=switch_name_to_int(4,parts);
             node->part=parts_int;
             break;
         case 6:
             printf("                please input new model:");
             char model[20];
             scanf("%s",model);
             int model_int=switch_name_to_int(5,model);
             node->model=model_int;
             break;
         case 7:
             printf("                the information will be deleted,are you confirm?:");
             getchar();
             scanf("%c",&judge);
             if(judge=='Y'||judge=='y')
             {
                 p->judge_delete=1;
                 printf("                Complete!");                 system("cls");
                 goto modify_start;
             }
             else
             {
                 goto modify;
             }
             break;
         case 8:
             system("cls");
             goto modify_start;
             break;
         case 9:
             save(type);
             printf("\n                Thank you for your use\n");
             Sleep(500);
             printf("\n                The system is about to exit");
             Sleep(300);
             printf(".");
             Sleep(300);
             printf(".");
             Sleep(300);
             printf(".");
             Sleep(300);
             system("cls");
             exit(0);
         default:
             printf("                error:can't find option\n");
             printf("                please check your option and input again\n");
             animate();
             system("cls");
             goto modify;
     }
         if(option!=7)
         {
             printf("\n                the revised record is as follows,please confirm:\n");
             printf("                ___________________________________________________________________________________ \n");
             printf("               |No.|Time_|Part|Model|Mfts|Unit|Num|Total|Name|\n");
             printf("               | %2d  | %2d,",No,node->time.month);
             if(node->time.day<=9)//统一格式(若数值小于10,则打印0X)                  printf("0");             printf("%d ",node->time.day);
             if(node->time.hour<=9)                 printf("0");             printf("%d:",node->time.hour);
             if(node->time.minute<=9)                 printf("0");             printf("%d ",node->time.minute);
             switch_int_to_name(4,node->part,part);
             switch_int_to_name(5,node->model,model);
             switch_int_to_name(1,node->mfts,mfts);
             switch_int_to_name(1,node->name,name);
             printf("|%10s|%11s|%10s|%10.2f|%7d|%11.2f|%10s|\n",part,model,mfts,node->unit,node->num,node->total,name);
             //printf("|%10d|%11d|%10d|%10.2f|%7d|%11.2f|%10d|\n",node->part,node->model,node->mfts,node->unit,node->num,node->total,node->name);
             printf("               ||______|_|__|_|_|||__|\n");
             printf("do you confirm?(Y/N):");
             getchar();
             scanf("%c",&judge);
             if(judge=='Y'||judge=='y')
             {
                 p->time.month=node->time.month;
                 p->time.day=node->time.day;
                 p->time.hour=node->time.hour;
                 p->time.minute=node->time.minute;
                 p->mfts=node->mfts;
                 p->model=node->model;
                 p->name=node->name;
                 p->num=node->num;
                 p->part=node->part;
                 p->total=node->total;
                 p->unit=node->unit;
                 //sale_stastics_modify(node->total,type);
                 head=sort(head);
                 save(type_link);
                 free(node);
                 free(option);
                 Sleep(500);
                 printf("the change has already saved\n");
                 Sleep(500);
                 printf("Back to menu");
                 Sleep(200);
                 printf(".");
                 Sleep(200);
                 printf(".");
                 Sleep(200);
                 printf(".");
                 system("cls");
                 goto modify_start;
             }
             else
             {
                 free(node);
                 free(option);
                 system("cls");
                 goto modify_start;
             }
         }
 }

点赞

发表评论