您好,欢迎访问三七文档
#includestdio.h#includestdlib.h#includestring.h#includeconio.h#includeprocess.h#includectype.h#includemath.hstaticintMax,yue,t=0,m=0;typedefstruct{charnum[10];charname[10];floatgoods1;floatgoods2;floatgoods3;floatgoods4;floattotal;}Salesman;Salesmansal[99],hui[99];voidshuru(Salesmansal[],intn)/*输入若干条记录*/{inti=0;charsign,x[10];floatgoods1;floatgoods2;floatgoods3;floatgoods4;floattotal;while(sign!='n'&&sign!='N'){printf(输入销售员编号:);scanf(%s,sal[n+i].num);printf(输入销售员姓名:);scanf(%s,sal[n+i].name);printf(输入该销售员产品一销售量:);scanf(%f,&goods1);getchar();printf(输入该销售员产品二销售量:);scanf(%f,&goods2);getchar();printf(输入该销售员产品三销售量:);scanf(%f,&goods3);getchar();printf(输入该销售员产品四销售量:);scanf(%f,&goods4);sal[n+i].goods1=goods1;sal[n+i].goods2=goods2;sal[n+i].goods3=goods3;sal[n+i].goods4=goods4;total=goods1+goods2+goods3+goods4;sal[n+i].total=total;gets(x);/*清除多余的输入*/printf(是否继续输入?(Y/N):\n);scanf(%c,&sign);i++;}Max=i;}voidzengjia(Salesmansal[],intn)/*增加记录*/{inti=0;charsign,x[10];floatgoods1;floatgoods2;floatgoods3;floatgoods4;floattotal;while(sign!='n'&&sign!='N'){printf(输入销售员编号:);scanf(%s,sal[Max+i].num);printf(输入销售员姓名:);scanf(%s,sal[Max+i].name);printf(输入该销售员产品一、二、三、四销售量:);scanf(%f%f%f%f,&goods1,&goods2,&goods3,&goods4);sal[Max+i].goods1=goods1;sal[Max+i].goods2=goods2;sal[Max+i].goods3=goods3;sal[Max+i].goods4=goods4;total=goods1+goods2+goods3+goods4;sal[Max+i].total=total;gets(x);/*清除多余的输入*/printf(是否继续输入?(Y/N):\n);scanf(%c,&sign);i++;}Max=Max+i;}voidxiugai(Salesmansal[],intn)/*修改*/{voidshuru(Salesmansal[],intn);inti=0,choice=1;floatc,m,e,d;charx[10],xing[10],select;while(choice!=0){printf(请输入您要修改的销售员编号:\n);scanf(%s,x);for(i=0;;i++){if(strcmp(sal[i].num,x)==0)break;}printf(请选择您要修改的内容:\n);printf(----------------------\n);printf(|姓名请按1|\n);printf(|产品一请按2|\n);printf(|产品二请按3|\n);printf(|产品三请按4|\n);printf(|产品四请按5|\n);printf(|退出请按0|\n);printf(+----------------------+\n);printf(请输入您的选择:);scanf(%d,&choice);switch(choice){case0:break;case1:printf(请输入新姓名:);scanf(%s,&xing);printf(是否保存该项修改?(Y/N)\n);scanf(%c,&select);getchar();if(select!='N'&&select!='n'){strcpy(sal[i].name,xing);printf(修改成功!\n);}break;case2:printf(请输入新的产品一销售量:);scanf(%d,&c);printf(是否保存该项修改?(Y/N)\n);scanf(%c,&select);getchar();if(select!='N'&&select!='n'){strcpy(sal[i].name,xing);printf(修改成功!\n);}break;case3:printf(请输入新的产品二销售量:);scanf(%d,&m);printf(是否保存该项修改?(Y/N)\n);scanf(%c,&select);getchar();if(select!='N'&&select!='n'){strcpy(sal[i].name,xing);printf(修改成功!\n);}break;case4:printf(请输入新的产品三销售量:);scanf(%d,&e);printf(是否保存该项修改?(Y/N)\n);scanf(%c,&select);getchar();if(select!='N'&&select!='n'){strcpy(sal[i].name,xing);printf(修改成功!\n);}break;case5:printf(请输入新的产品四销售量:);scanf(%d,&d);printf(是否保存该项修改?(Y/N)\n);scanf(%c,&select);getchar();if(select!='N'&&select!='n'){strcpy(sal[i].name,xing);printf(修改成功!\n);}break;default:printf(\n无效选项!);break;getchar();}break;}return;}intshanchu(Salesmansal[],intn)/*按编号查找,删除一条记录*/{chars[20];inti;intj;i=0;printf(输入要删除记录的编号:);scanf(%s,s);for(i=0;iMax;i++){if(strcmp(sal[i].num,s)==0)break;}if(i==Max)printf(查无此人!\n);else{strcpy(hui[t].num,sal[i].num);strcpy(hui[t].name,sal[i].name);hui[t].goods1=sal[i].goods1;hui[t].goods2=sal[i].goods2;hui[t].goods3=sal[i].goods3;hui[t].goods4=sal[i].goods4;hui[t].total=sal[i].total;t++;for(j=i;jMax;j++)/*删除操作*/{strcpy(sal[j].num,sal[j+1].num);strcpy(sal[j].name,sal[j+1].name);sal[j].goods1=sal[j+1].goods1;sal[j].goods2=sal[j+1].goods2;sal[j].goods3=sal[j+1].goods3;sal[j].goods4=sal[j+1].goods4;sal[j].total=sal[j+1].total;Max--;}printf(DeleteSuccessed!\n);}return(n-1);}voidhuifu()//恢复操作//{intm;chara;printf(\n\n\n\n);printf(\t\t\t确认恢复('Y'or'y')?\n);scanf(%c,&a);getchar();if(a!='n'&&a!='N'){for(m=0;mt;m++){strcpy(sal[Max].num,hui[m].num);strcpy(sal[Max].name,hui[m].name);sal[Max].goods1=hui[m].goods1;sal[Max].goods2=hui[m].goods2;sal[Max].goods3=hui[m].goods3;sal[Max].goods4=hui[m].goods4;sal[Max].total=hui[m].total;Max++;}printf(恢复成功!\n);t=0;}}voidchaxun_xingming(Salesmansal[],intn)/*按姓名查找并显示一个记录*/{chars[20];inti=0;floatgoods1=sal[i].goods1;floatgoods2=sal[i].goods2;floatgoods3=sal[i].goods3;floatgoods4=sal[i].goods4;floattotal=sal[i].total;printf(输入姓名:);scanf(%s,s);for(i=0;iMax;i++){if(sal[i].name==s)break;}if(i==Max-1)printf(notfind!\n);else{printf(他的姓名、编号是:%s%s\n,s,sal[i].num);/*输出该销售员信息*/printf(产品一产品二产品三产品四销售业绩分别是:%.3f%.3f%.3f%.3f%.3f\n,goods1,goods2,goods3,goods4,total);}}voidchaxun_bianhao(Salesmansal[],intn)/*按编号查找并显示一个记录*/{chars[10];inti=0;floatgoods1=sal[i].goods1;floatgoods2=sal[i].goods2;floatgoods3=sal[i].goods3;floatgoods4=sal[i].goods4;floattotal=sal[i].total;printf(输入编号:);scanf(%s,s);for(i=0;iMax;i++){if(sal[i].num==s)break;}if(i==Max-1)printf(notfind!\n);else{printf(他的姓名、编号是:%s%s\n,sal[i].name,sal[i].num);/*输出该销售员信息*/printf(产品一产品二产品三产品四销售业绩分别是:%.3f%.3f%.3f%.3f%.3f\n,goods1,goods2,goods3,goods4,total);}}voidpaixu_number(Salesmansal[],intn)/*按编号排序*/{inti,j;floaty,p,q,r,w;charx[20],t[10];for(i=0;sal[i].num!=0;i++)/*冒泡法排序*/for(j=i;jMax;j++)if(strcmp(sal[j].num,sal[i].num)0){strcpy(t,sal[j].num);st
本文标题:销售管理系统
链接地址:https://www.777doc.com/doc-1630977 .html