第二部分
/*老板目录部分开始*/
menu22(struct Ritongji *head)
{
int yuangongxiaoshou=0;
int number,i;
struct Ritongji *p=head;
if(p==NULL)
{
cleardevice();
hanzishuru("无记录",0,0,GREEN);
getch();
return 0;
}
cleardevice();
hanzishuru("请输入要查询的员工",0,0,GREEN);
gotoxy(20,1);
scanf("%d",&number);
while (p!=NULL)
{
for(i=0;i<=4;i++)
{
yuangongxiaoshou+=p->Yuangong[number].p[i];
}
p=p->next;
}
printf("%d",yuangongxiaoshou);
getch();
}
menu23(struct Ritongji *head)
{
int yuangongxiaoshou=0;
int number,i;
struct Ritongji *p=head;
if(p==NULL)
{
cleardevice();
hanzishuru("无记录",0,0,GREEN);
getch();
return 0;
}
cleardevice();
hanzishuru("请输入要查询的产品",0,0,GREEN);
gotoxy(20,1);
scanf("%d",&number);
while (p!=NULL)
{
for(i=0;i<=3;i++)
{
yuangongxiaoshou+=p->Yuangong[i].p[number];
}
p=p->next;
}
printf("%d",yuangongxiaoshou);
getch();
}
menu24(int *tongji,int yuangong)
{
int k;
int yuangongxiaoshou;
for(k=0;k<=4;k++)
{
yuangongxiaoshou+=*(tongji+yuangong*5+k);
}
printf("%d",yuangongxiaoshou);
}
menu25(struct Ritongji *head) /*某日业绩查询。*/
{
struct Ritongji *p=head;
int year;
int month;
int day;
if(p==NULL)
{
cleardevice();
hanzishuru("无记录",0,0,GREEN);
getch();
return 0;
}
cleardevice();
hanzishuru("请输入年份",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&year);
cleardevice();
hanzishuru("请输入月份",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&month);
cleardevice();
hanzishuru("请输入日期",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&day);
getchar();
while(p!=NULL)
{
if((p->year==year)&&(p->month==month)&&(p->day==day))
{
shuchu(p);
getch();
return 0;
}
p=p->next ;
}
cleardevice();
hanzishuru("未找到",0,0,GREEN);
}
menu26(struct Ritongji *head)
{
struct Ritongji *p=head;
int year;
int month;
int day;
int leixing;
int j,k;
int chanping[31];
for(j=0;j<=30;j++)
{
chanping[j]=0;
}
if(p==NULL)
{
cleardevice();
hanzishuru("无记录",0,0,GREEN);
getch();
return 0;
}
cleardevice();
hanzishuru("请输入年份",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&year);
cleardevice();
hanzishuru("请输入月份",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&month);
cleardevice();
hanzishuru("请输入产品",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&leixing);
getchar();
while(p!=NULL)
{
if((p->year==year)&&(p->month==month))
{
for(j=0;j<=3;j++)
{
chanping[p->day]+=p->Yuangong[j].p[leixing];
}
}
p=p->next ;
}
showimage(31,chanping);
}
/*老板目录部分结束*/
/*其它功能代码*/
showimage(int daynumber,int *product)/*入口参数为这个月的天数和这个月的销售情况数列*/
{
/*此行用于函数内部测试 int product[31]={18,20,13,14,18,15,11,8,23,12,6,9,6,1,8,6,8,22,13,4,2,3,1,4,3,2,3,4,2,3,1}; */
int i=0,j,k; /*j,k用于画图时的循环变量*/
int maxproductday=0;/*记录产品最高的天是哪一天*/
daynumber--;
cleardevice();/*清屏函数*/
for(i=0;i<=daynumber;i++)
{
if(product[i]>23)
{
hanzishuru("产品数字过大(超过二十三),不支持",0,0,GREEN);
getch();
return 0;
}
}
for(i=1;i<=daynumber;i++)
{
if(product[i]>product[maxproductday])
maxproductday=i;
}
printf("\n");
for(j=0;j<=daynumber;j++) /*这是用于显示每一列的循环*/
{
for(k=0;k<=product[maxproductday]-product[j]-1;k++)
{
printf(" ");
gotoxy(wherex()-1,wherey()+1);
}/*用于显示每一列的空格*/
for(k=0;k<=product[j]-1;k++)
{
printf("%c",219);
gotoxy(wherex()-1,wherey()+1);
}/*用于显示每一列的实心方格数*/
if((j+1)%5==0)
{
printf(" %d\b\b",j+1);
if((j+1)>=10)
{
gotoxy(wherex()-2,wherey());
}
else
gotoxy(wherex()-1,wherey());
}
gotoxy(wherex(),wherey()-1);
gotoxy(wherex()+2,wherey()-product[maxproductday]+1);/*光标移动到行首*/
}
gotoxy(wherex(),wherey()+product[maxproductday]-1);
getch();
}
xianshibaobiao(int *tongji) /*用于报表的刷新*/
{
int j,k;
printf("\t");
gotoxy(0,0) ;
for(k=0;k<=4;k++)
{
printf("p");
printf("%d\t",k);
}
printf("\n");
gotoxy(2,0);
for(j=0;j<=3;j++)
{
printf("NO.");
printf("%d\t",j);
for(k=0;k<=4;k++)
{
printf("%d\t",*(tongji+j*5+k));
}
printf("\n");
}
}
int shuaxinbaobiao(struct Ritongji *head,int year,int month,int *tongji) /*用于报表的重新统计*/
{
int j,k;
struct Ritongji *p=head;
for(j=0;j<=3;j++)
{
for(k=0;k<=4;k++)
{
*(tongji+j*5+k)=0;
}
}
if(p==NULL)
{
hanzishuru("无记录",0,0,GREEN);
getch();
return 0;
}
while(p!=NULL)
{
if((p->year==year)&&(p->month==month))
{
for(j=0;j<=3;j++)
{
for(k=0;k<=4;k++)
{
*(tongji+j*5+k)+=p->Yuangong[j].p[k];
}
}
}
p=p->next ;
}
}
jilubaocun(struct Ritongji *head)/*链表记录保存*/
{
struct Ritongji *p1=head;
int j,k;
jiluwenjian=fopen("jilu.txt","w");
if(p1==NULL)
{
fprintf(jiluwenjian,"");
}
while(p1!=NULL)
{
fprintf(jiluwenjian,"%d %d %d ",p1->year,p1->month,p1->day);
for(j=0;j<=3;j++)
{
for(k=0;k<=4;k++)
{
fprintf(jiluwenjian,"%d ",p1->Yuangong[j].p[k]);
}
}
fprintf(jiluwenjian,"\n");
p1=p1->next;
}
fclose(jiluwenjian) ;
}
int duqujilu(struct Ritongji **head)/*链表记录读取*/ /* *head初始值必须是NULL*/
{
int j,k;
int year;
int day;
int month;
struct Ritongji **pr=head;
if((jiluwenjian=fopen("jilu.txt","r"))==NULL)
return 0;
fscanf(jiluwenjian,"%d");
if(feof(jiluwenjian))
return 0;
fseek(jiluwenjian,0,SEEK_SET);
while(!feof(jiluwenjian))
{
*pr=(struct Ritongji *)malloc(sizeof(struct Ritongji));
fscanf(jiluwenjian,"%d%d%d",&(*pr)->year,&(*pr)->month,&(*pr)->day);
(*pr)->next=NULL;
for(j=0;j<=3;j++)
{
for(k=0;k<=4;k++)
{
fscanf(jiluwenjian,"%d",&((*pr)->Yuangong[j].p[k]));
}
}
pr=&((*pr)->next);
fscanf(jiluwenjian,"\n");
}
}
int peizhiduqu(char *mima,int *zitipeizhi)
{
peizhiwenjian=fopen("peizhi.txt","r");
fscanf(peizhiwenjian,"%s",mima);
fscanf(peizhiwenjian,"%d",zitipeizhi);
fclose(peizhiwenjian);
}
int peizhibaocun(char *mima,int ziti)
{
peizhiwenjian=fopen("peizhi.txt","w");
fprintf(peizhiwenjian,"%s",mima);
fprintf(peizhiwenjian,"\n");
fprintf(peizhiwenjian,"%d",ziti);
fprintf(peizhiwenjian,"\n");
fclose(peizhiwenjian);
}
/*其它功能代码结束*/
main()
{
struct Ritongji *head=NULL;
struct Ritongji *p;
int i1,i2,i3,t;
int yuangong;
int tongji [4][5]; /*用于每个月报表的统计*/
int yuangongtongji[4]; /*用于员工销售额的统计*/
int year;
int month;
int day;
int zitipeizhi;
char * mima[15]={0};
char * mimahedui[15]={1};
int cuowucishu=0;
tuxingchushihua(); /*初始化图形界面*/
setbkcolor(BLACK);
peizhiduqu(mima,&zitipeizhi);
if(0==zitipeizhi)
{
if ((fp=fopen( "1hzk32", "rb"))==NULL)
{
printf("Can't open haz32,Please add it");
getch();
exit(0);
} /*打开字库文件*/
}
else
{
if ((fp=fopen( "2hzk32", "rb"))==NULL)
{
printf("Can't open haz32,Please add it");
getch();
exit(0);
} /*打开字库文件*/
}
if(strcmp(mima,"000000000000000"))
{
cleardevice();
hanzishuru("请输入密码",0,0,GREEN);
gotoxy(12,1);
scanf("%s",mimahedui);
while(strcmp(mimahedui,mima))
{
cleardevice();
hanzishuru("密码错误,请输入密码",0,0,GREEN);
gotoxy(22,1);
cuowucishu++;
if(cuowucishu==3)
{
cleardevice();
hanzishuru("密码错误超过三次,程序将退出",0,0,GREEN);
getch();
closegraph();
exit(0);
}
scanf("%s",mimahedui);
}
getchar();
}
duqujilu(&head);/*自动从文件中读取销售记录*/
while (1)
{
cleardevice();
setbkcolor(BLACK);
menu1();
gotoxy(44,18); /*显示基本目录*/
i1=getchar();
getchar();
switch(i1)
{
fflush(stdin);
case '1': fflush(stdin);
for(t=0;t!=1;)
{
cleardevice();
menuyuangong();
gotoxy(44,19);
i2=getchar();
getchar();
switch(i2)
{
case '1': head=menu11(head); break;
case '2': head=menu12(head); break; /*正常的记录模块*/
case '3': menu13(&head); break;
case '4': t=1; break;
default: ;
}
}
break;
case '2': for(t=0;t!=1;)
{
fflush(stdin);
cleardevice();
menulaoban();
gotoxy(34,19);
i3=getchar();
getchar();
switch(i3)
{
case '1':
{
cleardevice();
hanzishuru("输入要统计的年份",0,0,GREEN);
gotoxy(18,1);
scanf("%d",&year);
cleardevice();
hanzishuru("输入要统计的月份",0,0,GREEN);
gotoxy(18,1);
scanf("%d",&month);
cleardevice();
getchar();
shuaxinbaobiao(head,year,month,tongji);
xianshibaobiao(tongji);
getch();
break;
}
case '2':
{
menu22(head);
break;
}
case '3':menu23(head); break;
case '4':
{
cleardevice();
hanzishuru("请输入年份",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&year);
cleardevice();
hanzishuru("请输入月份",0,0,GREEN);
gotoxy(12,1);
scanf("%d",&month);
cleardevice();
hanzishuru("输入要查询的员工",0,0,GREEN);
gotoxy(18,1);
scanf("%d",&yuangong);
getchar();
shuaxinbaobiao(head,year,month,tongji);
menu24(tongji,yuangong);
getch();
break;
}
case '5': menu25(head); break;
case '6': menu26(head); break;
case '7': menusheding(mima,&zitipeizhi); getchar(); break;
case '8': t=1; break;
default: ;
}
}
break;
case '3':
jilubaocun(head);/*链表记录保存*/
peizhibaocun(mima,zitipeizhi);/*配置保存*/
closegraph();
exit(1);
default:;
}
}
}
/*
打开程序自动提取文件的配置信息和记录信息,没有则新建
关闭程序时自动保存配置信息和记录信息
*/
本文介绍了一个基于C语言开发的销售数据统计与分析系统,该系统能够实现销售记录的录入、查询、统计和图表展示等功能。通过链表结构存储数据,支持按不同维度进行查询与统计,并能以柱状图形式展现销售情况。
838

被折叠的 条评论
为什么被折叠?



