|
|
|
@ -0,0 +1,295 @@
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<windows.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
#define MAX_NOTE 150//最大便条数150
|
|
|
|
|
FILE *fp;
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int sno;//销售员代号
|
|
|
|
|
int p1;//产品1号
|
|
|
|
|
int p2;//产品2号
|
|
|
|
|
int p3;//产品3号
|
|
|
|
|
int p4;//产品4号
|
|
|
|
|
int p5;//产品5号
|
|
|
|
|
}SELL;
|
|
|
|
|
SELL s[MAX_NOTE];
|
|
|
|
|
void add_note();
|
|
|
|
|
void menu();
|
|
|
|
|
void visit_sale();
|
|
|
|
|
void sale_sort();
|
|
|
|
|
void sale_data();
|
|
|
|
|
void pro_sort();
|
|
|
|
|
void clear_all();
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
menu();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
void menu()//主菜单
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 0B");
|
|
|
|
|
int choice;
|
|
|
|
|
printf("\n\n\n\n\t\t\t\t");
|
|
|
|
|
printf("-*-*-*-*欢迎进入销售管理系统-*-*-*-*-\n");
|
|
|
|
|
printf("\t\t\t\t|1.便条信息录入\n");
|
|
|
|
|
printf("\t\t\t\t|2.查看销售情况\n");
|
|
|
|
|
printf("\t\t\t\t|3.清除数据\n");
|
|
|
|
|
printf("\t\t\t\t|4.退出系统\n");
|
|
|
|
|
printf("\n\n\n\n\t\t\t\t请输入您的选择(1-3):");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
add_note();//录入便条
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
visit_sale();//进入销售情况主菜单
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
clear_all();//清除所有数据
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("输入有误!请重新输入:");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
menu();
|
|
|
|
|
getchar();
|
|
|
|
|
}
|
|
|
|
|
void clear_all()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
fp=fopen("note.dat","wb+");
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("\n\n\n\n\t\t\t\t数据清除成功!");
|
|
|
|
|
system("pause");
|
|
|
|
|
menu();
|
|
|
|
|
}
|
|
|
|
|
void add_note()//便条信息录入
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
int i,n,k=1;
|
|
|
|
|
//SELL s[MAX_NOTE];
|
|
|
|
|
fp=fopen("note.dat","rb+");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
fp=fopen("note.dat","wb+");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("file open fail!\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fseek(fp,0,SEEK_END);
|
|
|
|
|
printf("\n\n\n\n\t\t\t\t输入你要添加的便条数:");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t\t\t-*-*-*-*-*-*-*-\n");
|
|
|
|
|
printf("\t\t\t\t-----便条%d------",k++);
|
|
|
|
|
printf("\n\t\t\t\t|销售员代号:");
|
|
|
|
|
scanf("%d",&s[i].sno);
|
|
|
|
|
printf("\n\t\t\t\t| **产品1号:");
|
|
|
|
|
scanf("%d",&s[i].p1);
|
|
|
|
|
printf("\n\t\t\t\t| **产品2号:");
|
|
|
|
|
scanf("%d",&s[i].p2);
|
|
|
|
|
printf("\n\t\t\t\t| **产品3号:");
|
|
|
|
|
scanf("%d",&s[i].p3);
|
|
|
|
|
printf("\n\t\t\t\t| **产品4号:");
|
|
|
|
|
scanf("%d",&s[i].p4);
|
|
|
|
|
printf("\n\t\t\t\t| **产品5号:");
|
|
|
|
|
scanf("%d",&s[i].p5);
|
|
|
|
|
printf("\n\t\t\t\t-*-*-*-*-*-*-*-\n");
|
|
|
|
|
fwrite(&s[i],sizeof(SELL),1,fp);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("\t\t\t\t便条数据记录成功!3秒后返回上一级...");
|
|
|
|
|
sleep(3);
|
|
|
|
|
menu();
|
|
|
|
|
}
|
|
|
|
|
void visit_sale()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
int choice;
|
|
|
|
|
printf("\n\n\n\t\t\t\t----销售情况查看----");
|
|
|
|
|
printf("\n\t\t\t\t1.查看销售员的销售额");
|
|
|
|
|
printf("\n\t\t\t\t2.销售员业绩排名");
|
|
|
|
|
printf("\n\t\t\t\t3.产品受欢迎情况");
|
|
|
|
|
printf("\n\t\t\t\t4.返回主界面");
|
|
|
|
|
printf("\n\t\t\t\t5.退出系统");
|
|
|
|
|
printf("\n\n\n\t\t\t\t请输入您的选择(1-5):");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
getchar();
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
sale_data();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
sale_sort();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
pro_sort();
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
exit(1);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("输入错误!按任意键退出...");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
visit_sale();
|
|
|
|
|
getchar();
|
|
|
|
|
}
|
|
|
|
|
void sale_data()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
int i,k,ch;
|
|
|
|
|
int v1,v2,v3,v4,v5;
|
|
|
|
|
v1=v2=v3=v4=v5=0;
|
|
|
|
|
fp=fopen("note.dat","rb+");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("\n\n\n\t\t\t\tfile open fail!");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
rewind(fp);
|
|
|
|
|
printf("\n\n\n\t\t\t\t请输入所要查的销售员代号(1-4):");
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
fread(&s,sizeof(SELL),1,fp);
|
|
|
|
|
for(i=0;i<MAX_NOTE;i++)
|
|
|
|
|
{
|
|
|
|
|
fread(&s[i],sizeof(SELL),1,fp);
|
|
|
|
|
if(s[i].sno==k)
|
|
|
|
|
{
|
|
|
|
|
v1+=s[i].p1;
|
|
|
|
|
v2+=s[i].p2;
|
|
|
|
|
v3+=s[i].p3;
|
|
|
|
|
v4+=s[i].p4;
|
|
|
|
|
v5+=s[i].p5;
|
|
|
|
|
fread(&s[i],sizeof(SELL),1,fp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n\t\t\t\t产品1号销售总额:%d",v1);
|
|
|
|
|
printf("\n\t\t\t\t产品2号销售总额:%d",v2);
|
|
|
|
|
printf("\n\t\t\t\t产品3号销售总额:%d",v3);
|
|
|
|
|
printf("\n\t\t\t\t产品4号销售总额:%d",v4);
|
|
|
|
|
printf("\n\t\t\t\t产品5号销售总额:%d",v5);
|
|
|
|
|
printf("\n\n\n\t\t\t\t按0键返回,其他键退出:");
|
|
|
|
|
scanf("%d",&ch);
|
|
|
|
|
if(ch==0)
|
|
|
|
|
visit_sale();
|
|
|
|
|
else
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
void sale_sort()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
int i,j,t,ch,g=1;
|
|
|
|
|
int sum[4],b[4]={1,2,3,4};
|
|
|
|
|
int s1,s2,s3,s4;
|
|
|
|
|
s1=s2=s3=s4=0;
|
|
|
|
|
fp=fopen("note.dat","rb+");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("file open fail!\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
fread(&s,sizeof(SELL),1,fp);
|
|
|
|
|
for(i=0;i<MAX_NOTE;i++)
|
|
|
|
|
{
|
|
|
|
|
fread(&s[i],sizeof(SELL),1,fp);
|
|
|
|
|
if(s[i].sno==1)
|
|
|
|
|
s1+=(s[i].p1+s[i].p2+s[i].p3+s[i].p4+s[i].p5);
|
|
|
|
|
if(s[i].sno==2)
|
|
|
|
|
s2+=(s[i].p1+s[i].p2+s[i].p3+s[i].p4+s[i].p5);
|
|
|
|
|
if(s[i].sno==3)
|
|
|
|
|
s3+=(s[i].p1+s[i].p2+s[i].p3+s[i].p4+s[i].p5);
|
|
|
|
|
if(s[i].sno==4)
|
|
|
|
|
s4+=(s[i].p1+s[i].p2+s[i].p3+s[i].p4+s[i].p5);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
sum[0]=s1;sum[1]=s2;sum[2]=s3;sum[3]=s4;
|
|
|
|
|
for(i=0;i<4;i++)
|
|
|
|
|
{
|
|
|
|
|
for(j=i+1;j<4;j++)
|
|
|
|
|
{
|
|
|
|
|
if(sum[i]<sum[j])
|
|
|
|
|
{
|
|
|
|
|
t=sum[j];
|
|
|
|
|
sum[j]=sum[i];
|
|
|
|
|
sum[i]=t;
|
|
|
|
|
t=b[j];
|
|
|
|
|
b[j]=b[i];
|
|
|
|
|
b[i]=t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n\n\n\t\t\t\t-----销售员业绩排名-----\n");
|
|
|
|
|
printf("\t\t\t\t排名\t销售员代号 销售总额\n");
|
|
|
|
|
for(i=0;i<4;i++)
|
|
|
|
|
printf("\t\t\t\t%-10d%-10d%-15d\n",g++,b[i],sum[i]);
|
|
|
|
|
printf("\n\n\n\t\t\t\t按0键返回,其他键退出:");
|
|
|
|
|
scanf("%d",&ch);
|
|
|
|
|
if(ch==0)
|
|
|
|
|
visit_sale();
|
|
|
|
|
else
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
void pro_sort()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
int g=1;
|
|
|
|
|
int s1,s2,s3,s4,s5,ch;
|
|
|
|
|
int i,j,t,sum[5],b[5]={1,2,3,4,5};
|
|
|
|
|
s1=s2=s3=s4=s5=0;
|
|
|
|
|
fp=fopen("note.dat","rb+");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("file open fail!\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
fread(&s,sizeof(SELL),1,fp);
|
|
|
|
|
for(i=0;i<MAX_NOTE;i++)
|
|
|
|
|
{
|
|
|
|
|
fread(&s[i],sizeof(SELL),1,fp);
|
|
|
|
|
s1+=s[i].p1;
|
|
|
|
|
s2+=s[i].p2;
|
|
|
|
|
s3+=s[i].p3;
|
|
|
|
|
s4+=s[i].p4;
|
|
|
|
|
s5+=s[i].p5;
|
|
|
|
|
}
|
|
|
|
|
sum[0]=s1;sum[1]=s2;sum[2]=s3;sum[3]=s4;sum[4]=s5;
|
|
|
|
|
for(i=0;i<5;i++)
|
|
|
|
|
{
|
|
|
|
|
for(j=i+1;j<5;j++)
|
|
|
|
|
{
|
|
|
|
|
if(sum[i]<sum[j])
|
|
|
|
|
{
|
|
|
|
|
t=sum[j];
|
|
|
|
|
sum[j]=sum[i];
|
|
|
|
|
sum[i]=t;
|
|
|
|
|
t=b[j];
|
|
|
|
|
b[j]=b[i];
|
|
|
|
|
b[i]=t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n\n\n\t\t\t\t-----产品销售额排名-----\n");
|
|
|
|
|
printf("\t\t\t\t排名\t产品代号 销售总额\n");
|
|
|
|
|
for(i=0;i<5;i++)
|
|
|
|
|
printf("\t\t\t\t%-10d%-10d%-15d\n",g++,b[i],sum[i]);
|
|
|
|
|
printf("\n\n\n\t\t\t\t按0键返回,其他键退出:");
|
|
|
|
|
scanf("%d",&ch);
|
|
|
|
|
if(ch==0)
|
|
|
|
|
visit_sale();
|
|
|
|
|
else
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|