销售管理系统源文件.doc_第1页
销售管理系统源文件.doc_第2页
销售管理系统源文件.doc_第3页
销售管理系统源文件.doc_第4页
销售管理系统源文件.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#define N 30#define person-name name1#define object-name name2#include#includestruct production/*定义产品信息结构体*/int number;/*产品编号*/ char name120;/*销售人名称*/ char name220;/*产品名称*/ int inprice;/*进价*/ int outprice;/*售价*/ int quantity;/*产品数量*/ productionN;/*结构体数组*/void welcome();/*主菜单*/void input();/*输入函数*/void input1(int i);/*辅助输入函数*/save();/*保存数据*/void output();/*读出已保存数据*/int insert();/*插入数据*/delete();/*删除数据*/void change();/*修改数据*/void display();/*显示数据*/void search_number();/*按号码搜索*/void search_name1();/*按姓名搜索*/void profit();/*计算收益*/void sort();/*利润排序*/void welcome()/*欢迎界面*/int c;printf( n); printf( -welcome-n); printf( #* *#n); printf( #* sale of production management system *#n);/*销售管理系统*/ printf( #* *#n); printf( -=!what do you want to do!=-n); printf(n); printf( * 1 input *n);/*输入新数据*/ printf( * 2 insert *n);/*插入一组新数据*/ printf( * 3 delete *n);/*删除数据*/ printf( * 4 change *n);/*修改数据*/ printf( * 5 display *n);/*列出所有数据*/ printf( * 6 search_number *n);/*按产品编号查找数据*/ printf( * 7 search_name1 *n);/*按人员名称查找数据*/ printf( * 8 profit *n);/*统计各产品的收益及总收益*/ printf( * 9 sort *n);/*按产品销售额从小到大排序并输出排序后的结果*/ printf( * 10 exit *n);/*退出*/ printf(n); printf( -n); printf(n); printf(please input you choice(A number between 1 and 10):n);void input1(int i)/*输入单组数据*/ printf(Please input the data:n);/*输入数据*/ printf(please input the number:n);/*输入产品编号*/ scanf(%d,&productioni.number); printf(please input the name1:n);/*输入人员名称*/ scanf(%s,&1); printf(please input the name2:n);/*输入产品名称*/ scanf(%s,&2); printf(please input the inprice:n);/*输入产品进价*/ scanf(%d,&productioni.inprice); printf(please input the outprice:n);/*输入产品售价*/ scanf(%d,&productioni.outprice); printf(please input the quantity:n);/*输入产品数量*/ scanf(%d,&productioni.quantity); save();save()/*保存数据到文件*/ FILE *fp; int i,m=0; fp=fopen(production,w);/*打开要保存数据的文件*/ for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;for(i=0;im;i+)if(fwrite(&productioni,sizeof(struct production),1,fp)!=1)/*读入数据*/printf(file write errorn);fclose(fp);/*关闭文件*/void input()/*连续输入多组数据*/int i,m=0;char x;for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;for(i=m;iN-1;i+)input1(i); printf(Do you want to continue inputing new data(Y/N)n);/*是否继续输入*/ x=getch();if(x=y|x=Y)/*继续输入*/continue;if(x=n|x=N)/*中断输入*/break; save();void output()/*读取保存的数据*/int i;FILE *fp;fp=fopen(production,r);/*打开文件*/for(i=0;iN;i+)fread(&productioni,sizeof(struct production),1,fp);/*读取数据*/fclose(fp);/*关闭文件*/int insert()/*插入一组新数据*/int i,m=0; for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;input1(m);/*输入此数据*/ save();delete()/*删除数据*/char n10;int i,j,k,b=0,m=0; output(); for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;printf(Enter the name of the production which you want to delete!n);/*输入要删除的数据的名称*/ scanf(%s,&n); printf(Display the original date you want todeleten); for(i=0;im;i+) if(strcmp(1,n)=0)/*校验名称*/ printf(The number: %dn,productioni.number);/*输出编号*/ printf(The name1: %sn,1);/*输出人员名称*/printf(The name2: %sn,2);/*输出产品名称*/printf(The inprice: %dn,productioni.inprice);/*输出产品进价*/printf(The outprice: %dn,productioni.outprice);/*输出产品售价*/printf(The quantity: %dn,productioni.quantity);/*输出产品数量*/printf(n);break; printf(Do really want todelete it,press 1,if not,press 0n); scanf(%d,&k); if(k=1) for(j=i;j=m;j+) productionj=productionj+1;/*删除数据*/b=1; if(k=0) printf(You may enter 0 to back to Welcome to look you choices!n);if(b=0) printf(Not find you data!n);/*没有要找的数据*/if(b=1) printf(Succeed!The data has been deleted!n);/*成功删除数据*/ save(); display();void change()/*修改数据*/char n10;char cname1;char cname2;int cinprice;/*定义局部变量*/int coutprice;int cquantity;int i,j,r,k,c,t,m=0;output();for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;printf(Enter the name of the person whose date you want to change!n);/*输入要修改的数据的人员名称*/scanf(%s,&n);printf(Display the original date you want to changen);for(i=0;i5|c1)printf(nnot find please go on!n); /*超出选择范围*/doswitch(c) /*选择要修改的项,并进行修改*/case 1:printf(the person name is: );scanf(%,&cname1);strcpy(1,cname1);break;case 2:printf(the objections name is: );scanf(%s,&cname2);strcpy(2,cname2);break;case 3:printf(the inprice is: ); scanf(%d,&cinprice);productioni.inprice=cinprice;break; case 4:printf(the outprice is: );scanf(%d,&coutprice);productioni.outprice=coutprice;break;case 5:printf(the quantity is: );scanf(%d,&cquantity);productioni.quantity=cquantity;break;printf(n);printf(nDo you really want to change?n Y please press 1 ; N,repeat to change press 2: n);/*是否确认修改*/scanf(%d,&t);while (t=2);save(); printf(nDisplay the changed date:);/*输出修改后的结果*/ printf(The number: %dn,productioni.number);/*输出编号*/ printf(The name1: %sn,1);/*输出人员名称*/ printf(The name2: %sn,2);/*输出产品名称*/ printf(The inprice: %dn,productioni.inprice);/*输出产品进价*/printf(The outprice: %dn,productioni.outprice);/*输出产品售价*/printf(The quantity: %dn,productioni.quantity);/*输出产品数量*/printf(n);printf(nGo on to change press 1,stop press 0n);scanf(%d,&r);switch(r)case 1:change();break;case 0:break;default :break;save();void display()/*输出全部数据*/int i,m=0; output(); for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;printf(Disply all the data below:n);for(i=0;im;i+)printf(The number: %dn,productioni.number);/*输出编号*/printf(The name1: %sn,1);/*输出人员名称*/printf(The name2: %sn,2);/*输出产品名称*/printf(The inprice: %dn,productioni.inprice);/*输出产品进价*/printf(The outprice: %dn,productioni.outprice);/*输出产品售价*/printf(The quantity: %dn,productioni.quantity);/*输出产品数量*/printf(n);void search_number()/*按产品编号查找*/int number,i,flag=0;printf(Please enter number which you want to search:);/*输入要查找的产品的编号*/scanf(%d,&number);for(i=0;iN;i+)if(productioni.number=number)/*校验产品编号*/printf(the information of this number:n);printf(Number: %dnName: %snInprice: %dnOutprice: %dnQuantity: %dn,productioni.number,1,productioni.inprice,productioni.outprice,productioni.quantity);/*输出要查找的数据的编号、品名、进价、售价、数量*/flag=1;if(flag=0)printf(The number is not exist !n);/*所输入的编号不存在*/void search_name1()/*按人名查找*/char name20;int i,flag=0;printf(Please enter name1 which you want to search:);/*输入要查找的人的名字*/scanf(%s,&name);for(i=0;iN;i+)if(strcmp(1,name)=0)/*校验人名*/printf(the information of this name:n);printf(Number: %dnName: %snInprice: %dnOutprice: %dnQuantity: %dn,productioni.number,1,productioni.inprice,productioni.outprice,productioni.quantity);/*输出要查找的数据的编号、品名、进价、售价、数量*/flag=1;if(flag=0)printf(The name is not exist !n);/*所输入的品名不存在*/void profit()/*统计各产品的收益及总收益的函数*/int pN,pr=0,i,m=0;for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;for(i=0;im;i+)pi=(productioni.outprice-productioni.inprice)*productioni.quantity;/*计算产品i的收益*/pr=pr+pi;printf(Name: %-7stNumber: %-7dtprofit: %-10dn,1,productioni.number,pi);/*输出产品i的收益*/printf(Total Profit: %dn,pr);/*输出总收益*/void sort()/*按销售利润排序*/int i,j,t,s,m=0,bN,aN;for(i=0;iN;i+)if(strlen(1)!=0)/*计算已有的数据个数*/m+;for(i=0;im;i+)bi=productioni.outprice*productioni.quantity;/*将产品销售利润放入数组bi*/ai=productioni.number;/*将编号放入数组ai*/printf(Before sorted:n);for(i=0;im;i+) /*输出排序前的结果,编号和销售利润*/printf(Number: %-5dtProfit: %-10dn,ai,bi);for(i=1;im;i+)for(j=0;jbj+1)t=bj;bj=bj+1;bj+1=t;/*冒泡法排序*/s=aj;aj=aj+1;aj+1=s;printf(After sorted:n); /*输出排序后的结果,编号和销售利润*/for(i=0;im;i+)printf(Number: %-5dtProfit: %-10dn,ai,bi);main()/*主函数*/int c;welcome();while(1)scanf(%d,&c);/*输入选择项*/switch(c)case 0:clrscr();welcome();break;/*清屏并显示欢迎界面*/ case 1:input();printf(You may enter 0 to back to Welcome to look you choices!n);break;/*输入数据并保存,提示输入0以返回欢迎界面查看选项*/ case 2:insert();printf(You may enter 0 to back to Welcome to look you choices!n);break;/*插入一组新数据并提示输

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论