当前位置:网站首页>Design of sales management system for C language course (big homework)
Design of sales management system for C language course (big homework)
2022-07-01 06:25:00 【Ordinary senior】

One 、 Design function ( The article is for reference only )
Try to design a note management system , It can provide the following functions :
1、 The system works as a menu
2、 Note information entry function ( Note information is saved in a file )-- Input
3、 After collecting all the notes from last month , Read sales
1) Calculate the sales of each product for each person .
2) Sort salesmen by sales , Output sorting results ( Salesman code )
3) Count the total sales of each product , For these products, from top to bottom , Output sorting results ( Need to output product code and sales )( optional )
Two 、 Function display



3、 ... and 、 Mind mapping

Four 、 Program source code
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#define Z 5
#define R 4 /* Defining macro constants facilitates the generalization of programs */ /*R Indicates the number of salesmen */
typedef struct /* Shorten the structure variable name */
{
int shangpin[Z]; /* Define the structure to facilitate the storage, reading and writing of information , identify */
}data; /*R It means the kind of goods , The last one is the total of the salesperson's products */
void menu()
{
system("cls"); /* Clear screen command */
printf("\n\n");
printf("\t ┏━━━━━━━━━━━━ The main menu ━━━━━━━━━━┓\n");
printf("\t ┃ 1. Calculate the sales of each product per person last month ┃\n");
printf("\t ┃ 2. Sort salesmen by sales , Output sorting results ┃\n");
printf("\t ┃ 3. Count the total sales of each product , Output sorting results ┃\n");
printf("\t ┃ 4. Output statistical reports ┃\n");
printf("\t ┃ 5. End operation ┃\n");
printf("\t ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
}
void f1(data *x) /* Calculate the sales of each product per person last month */
{
FILE *fp;
char fname[10],hitkey;
int j,t; /* Used to control the cycle */
int i,k,s; /* Used to define employee serial number , Product serial number , Product quantity */
system("cls"); /* Clear screen command */
printf(" Which month do you want to calculate ?\n");
printf(" Please enter the month :"); /* Input file name , In this way, the information of each month can be written */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"wb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0); /* normal exit(0); End procedure */
}
for(j=0;j<R;j++) /* Clear the commodity quantity */
for(t=0;t<Z;t++)
(x+j)->shangpin[t]=0;
printf(" Please enter :\n Employee number Product number sales volumes \n"); /* Prompt the user to write the format of the information */
for(j=0;hitkey!=27;j++)
{
scanf("%d%d%d",&i,&k,&s);
if(i>R||i<0||k>Z||k<0)
{
printf(" Wrong information !\n"); /* Hint , Avoid input errors */
continue;
}
else
(x+i-1)->shangpin[k-1]=(x+i-1)->shangpin[k-1]+s; /* Count the quantity of various products of each individual ,-1 To match the ordinal number in the array */
printf(" To continue typing, press enter , To finish typing, press esc\n");
printf("━━━━━━━━━━━━━━━━━━━━━━\n");
hitkey=getch();
for (;hitkey!=13&&hitkey!=27;)
hitkey=getch();
}
for(j=0;j<R;j++)
if(fwrite((x+j),sizeof(data),1,fp)!=1) /* Write the information into the file and you will be called later */
printf("write error!\n");
fclose(fp); /* Close the file to avoid missing information */
printf("\n\n\n\n\n\n\t\t\t Saved successfully , Press any key to return to the main menu !");
getch();
}
void f2(data *x) /* Sort salesmen by sales , Output sorting results */
{
FILE *fp;
char fname[10];
int i,k,j,t,bianhao[R]={
0},z;
system("cls"); /* Clear screen command */
printf(" Which month do you want ?\n");
printf(" Please enter the month :"); /* Input file name , In this way, the information of each month can be read */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0);
}
for(i=0;i<R;i++) /* Read the message */
if(fread(x+i,sizeof(data),1,fp)!=1)
printf(" Error reading information !"); /* Read in information prompt */
for(i=0;i<R;) /* Used to store employee numbers */
bianhao[i]=i++;
printf(" Please enter by which product \n");
scanf("%d",&k);
k=k-1; /* It is convenient to correspond to the array value in the structure */
for(i=0;i<R;i++) /* Press K Sort salespeople by product , Sorting by selection */
{
t=i;
for(j=i+1;j<R;j++)
if((x+bianhao[t])->shangpin[k]<(x+bianhao[j])->shangpin[k])/* Call the number of products in the corresponding structure of employees */ t=j;
if(t!=i)
{
z=bianhao[i];
bianhao[i]=bianhao[t];
bianhao[t]=z;
}
}
printf("\t\t\t Press %d The order of products to salespeople is :\n",k+1);
printf("━━━━━━━━━━━━━━━━━━━━━\n");
for(i=0;i<R;i++)
printf("\t\t\t The first %d The name is : staff %d\n",i+1,bianhao[i]+1);
printf("\n\n\n\t\t\t Press any key to return to the previous main menu !");
getch();
fclose(fp); /* Close the read in file */
}
void f3(data *x) /* Count the total sales of each product , Output sorting results */
{
FILE *fp;
char fname[10];
int i,j,sum[Z]={
0},bianhao[Z]={
0},z,t,k;
system("cls"); /* Clear screen command */
printf(" Which month do you want to calculate ?\n");
printf(" Please enter the month :"); /* Input file name , In this way, the information of each month can be read */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0);
}
for(i=0;i<R;i++) /* Read the message */
if(fread(x+i,sizeof(data),1,fp)!=1)
printf(" Error reading information !");
for(i=0;i<Z;i++) /* Sum up all kinds of goods */
for(j=0;j<R;j++)
sum[i]=sum[i]+(x+j)->shangpin[i];
for(i=0;i<Z;) /* Used to store item numbers */
bianhao[i]=i++;
for(i=0;i<Z;i++)
printf("%3d",bianhao[i]);
for(i=0;i<Z;i++) /* Rank products from high to low , Sorting by selection */
{
t=i;
for(j=i+1;j<Z;j++) /* When the product changes , The product number also changes , Easy to output */
if(sum[t]<sum[j])
t=j;
if(t!=i)
{
k=sum[i];
sum[i]=sum[t];
sum[t]=k;
z=bianhao[i];
bianhao[i]=bianhao[t];
bianhao[t]=z;
}
}
printf(" Output product sorting \n");
printf(" Product number Number \n");
printf("━━━━━━━━━━━━━\n");
for(i=0;i<Z;i++)
printf(" product %-7d%-1d\n",bianhao[i]+1,sum[i]);
printf("\n\n\n\t\t\t Press any key to return to the main menu !");
getch();
fclose(fp); /* Close the read in file */
}
void f4(data *x) /* Output statistical reports */
{
FILE *fp;
char fname[10];
int i,j,sum[Z+1]={
0};
system("cls"); /* Clear screen command */
printf(" Which month do you want to calculate ?\n");
printf(" Please enter the month :"); /* In fact, enter a file name , In this way, the information of each month can be read */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0);
}
for(i=0;i<R;i++) /* Read the message */
if(fread(x+i,sizeof(data),1,fp)!=1)
printf(" Error reading information !");
for(i=0;i<Z;i++) /* Sum up all kinds of goods */
for(j=0;j<R;j++)
sum[i]=sum[i]+(x+j)->shangpin[i];
for(i=0;i<Z;i++) /* Sum up goods */
sum[Z]=sum[Z]+sum[i];
printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
printf(" The output statistical report is as follows :\n"); /* Output statistics as required */
printf(" Salesman code Product code Sum of sales \n");
for(i=0;i<R;i++)
for(j=0;j<Z;j++)
printf(" staff %-8d product %-6d Number %-10d\n",i+1,j+1,(x+i)->shangpin[j]);
printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
for(i=0;i<Z;i++)
{
if(i==0)
printf(" product %d The sum of the %-10d The sum of the %-10d\n",i+1,sum[i],sum[Z]);
else
printf(" product %d The sum of the %-10d\n",i+1,sum[i]);
}
printf("\n\n\n\t\t\t Press any key to return to the main menu !");
getch();
}
main()
{
int i,choice;
data sxy[R]; /*R Indicates the number of employees , The previous macro constants */
printf("\n\n\n\n\n\n\t━━━━━━━━━━━━━━━━━━━━━━━━━\n");
printf("\t--------------- Welcome to the commodity sales system !-------------\n");
printf("\t━━━━━━━━━━━━━━━━━━━━━━━━━\n");
printf("\n\n\n\n\n\n\t\t\t Press any key to enter the main menu !");
getch();
for(i=0;;i++)
{
system("cls"); /* Clear screen command */
menu(); /* The main menu function prompts the user how to choose */
printf(" What do you want to do ?\n");
printf(" Please select :"); /* Enter the operation to be performed */
scanf("%d",&choice);
if(choice==5)
{
system("cls"); /* Clear screen command */
printf("\n\n\n\n\n\n\t━━━━━━━━━━━━━━━━━━━━━━━━━\n\n");
printf("\t--------------- Thank you for using the commodity sales system !-------------\n\n");
printf("\t━━━━━━━━━━━━━━━━━━━━━━━━━\n\n");
printf("\n\n\n\n\n\n\t\t\t Press any key to exit !(^.^)");
getch();
break; /* Quit the whole program */
}
else
switch(choice)
{
case 1 : f1(sxy); break; /* Calculate the sales of each product per person last month */
case 2 : f2(sxy); break; /* Sort the sales of salespersons by sales amount , And output the sorting result */
case 3 : f3(sxy); break; /* Count the total sales of each product , And output the sorting result */
case 4 : f4(sxy); break; /* Output statistical reports */
}
}
}

You can pay attention to it, and it will be updated continuously in the future 0.0( Thank you first )
边栏推荐
猜你喜欢
随机推荐
【ManageEngine卓豪 】助力世界顶尖音乐学院--茱莉亚学院,提升终端安全
[network security tool] what is the use of USB control software
HCM Beginner (I) - Introduction
让厦门灌口镇田头村变甜头村的特色农产品之一是蚂蚁新村
Minio error correction code, construction and startup of distributed Minio cluster
Freeswitch dial the extension number
HDU - 1501 zipper (memory deep search)
ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
C语言课设物业费管理系统(大作业)
【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】
How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
JMM详解
C语言课设学生考勤系统(大作业)
请求模块(requests)
Self confidence is indispensable for technology
Factorial divisor (unique decomposition theorem)
Mysql 表分区创建方法
Save data in browser to local file
数据库产生死锁了请问一下有没有解决办法
Ant new village is one of the special agricultural products that make Tiantou village in Guankou Town, Xiamen become Tiantou village







![[summary of knowledge points] chi square distribution, t distribution, F distribution](/img/a6/bb5cabbfffb0edc9449c4c251354ae.png)

