当前位置:网站首页>C language course is provided with employee information management system (large operation)
C language course is provided with employee information management system (large operation)
2022-07-01 06:26:00 【Ordinary senior】

One 、 Design function ( The article is for reference only )
Employee information includes : Job number , full name , Gender , date of birth , Marital status , The title , Home address , Telephone ,E-mail etc. . Design a staff information management system , It can provide the following functions :
(1) Employee information entry function ( Student information is saved in files )— Input
(2) Employee information browsing function — Output
(3) Query by job No
(4) Search by name
(5) Query by professional title
(7) Exit the system
(6) Deletion and modification of employee information
Two 、 Function display




3、 ... and 、 Mind mapping


Four 、 Program source code
#include <stdio.h>
#include <windows.h>
#include <time.h>
#include <string.h>
#define N 100
struct employee
{
int num;
char name[10];
char sex;
int age;
char xueli[30];
int wage;
char addr[30];
long int tel;
}em[100]; /* Define a structure */
void menu();
void input();
void save(int);
void display();
void del();
void add();
void search();
void search_num();
void search_xueli();
void search_tel();
void modify(); /* Define each function */
void menu() /* Menu functions */
{
printf("\n");
printf("\n");
printf(" ****************** Employee information management ****************\n"); printf(" 1. Enter employee information ");
printf(" 2. Browse employee information \n");
printf(" 3. Query employee information ");
printf(" 4. Delete employee information \n");
printf(" 5. Add employee information ");
printf(" 6. Modify employee information \n");
printf(" 7. sign out \n");
printf(" ******************** Thank you for using. ******************\n"); printf("\n");
printf("\n");
}
int main()
{
menu(); /* Call menu function */
int n,flag;
char a;
do
{
printf(" Please select the steps you need to operate (1--7):\n");
scanf("%d",&n);
if(n>=1&&n<=7)
{
flag=1;
break;
}
else
{
flag=0;
printf(" Your input is wrong , Please reselect !");
}
}
while(flag==0);
while(flag==1)
{
switch(n)
{
case 1:printf(" ◆◆◆ Enter employee information ◆◆◆\n");printf("\n");input();break;
case 2:printf(" ◆◆◆ Browse employee information ◆◆◆\n");printf("\n");display();break;
case 3:printf(" ◆◆◆ Query employee information by employee number ◆◆◆\n");printf("\n");search();break;
case 4:printf(" ◆◆◆ Delete employee information ◆◆◆\n");printf("\n");del();break;
case 5:printf(" ◆◆◆ Add employee information ◆◆◆\n");printf("\n");add();break;
case 6:printf(" ◆◆◆ Modify employee information ◆◆◆\n");printf("\n");modify();break;
case 7:exit(0);break;
default :break;
}
getchar();
printf("\n");
printf(" Whether to continue (y or n):\n");
scanf("%c",&a);
if(a=='y')
{
flag=1;
menu(); /* Call menu function */
printf(" Please select the steps you need to operate again (1--6):\n");
scanf("%d",&n);
printf("\n");
}
else
exit(0);
}
}
void input() /* Input function */
{
int i,m;
printf(" Please enter the number of employees who need to create information (1--100):\n");
scanf("%d",&m);
for (i=0;i<m;i++)
{
printf(" Employee number : ");
if(em[i].num!=em[i-1].num)
printf("%8d ",em[i].num);
printf("\n");
printf(" Please enter a name : ");
scanf("%s",em[i].name);
getchar();
printf(" Please enter gender (f-- Woman m-- male ): ");
scanf("%c",&em[i].sex);
printf(" Please enter age : ");
scanf("%d",&em[i].age);
printf(" Please enter your education : ");
scanf("%s",em[i].xueli);
printf(" Please input salary : ");
scanf("%d",&em[i].wage);
printf(" Please enter address : ");
scanf("%s",em[i].addr);
printf(" Please input the phone number : ");
scanf("%d",&em[i].tel);
printf("\n");
}
printf("\n Creation completed !\n");
save(m);
}
void save(int m) /* Save file function */
{
int i;
FILE*fp;
if ((fp=fopen("employee_list","wb"))==NULL) /* Create a file and determine whether it can be opened */
{
printf ("cannot open file\n");
exit(0);
}
for (i=0;i<m;i++) /* Output the information in memory to disk file */
if (fwrite(&em[i],sizeof(struct employee),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}
int load() /* Import function */
{
FILE*fp;
int i=0;
if((fp=fopen("employee_list","rb"))==NULL)
{
printf ("cannot open file\n");
exit(0);
}
else
{
do
{
fread(&em[i],sizeof(struct employee),1,fp);
i++;
}
while(feof(fp)==0);
}
fclose(fp);
return(i-1);
}
void display() /* Browse functions */
{
int i;
int m=load();
printf("\n Employee number \t full name \t Gender \t Age \t Education \t Wages \t address \t Telephone \n");
for(i=0;i<m;i++) /*m Is the number of employees in the input section */
printf("\n %d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
}
void del() /* Delete function */
{
int m=load();
int i,j,n,t,flag;
char name[20];
printf("\n Original employee information :\n");
display(); /* Call the browse function */
printf("\n");
printf(" Please enter the name of the employee to be deleted :\n");
scanf("%s",name);
for(flag=1,i=0;flag&&i<m;i++)
{
if(strcmp(em[i].name,name)==0)
{
printf("\n This person has been found , The original record is :\n");
printf("\n Employee number \t full name \t Gender \t Age \t Education \t Wages \t address \t Telephone \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
printf("\n Are you sure you want to delete this person's information, press 1, If you don't want to delete, please press 0\n");
scanf("%d",&n);
if(n==1) /* If you remove , Then the other information moves up one line */
{
for(j=i;j<m-1;j++)
{
strcpy(em[j].name,em[j+1].name);
em[j].num=em[j+1].num;
em[j].sex=em[j+1].sex;
em[j].age=em[j+1].age;
strcpy(em[j].xueli,em[j+1].xueli);
em[j].wage=em[j+1].wage;
strcpy(em[j].addr,em[j+1].addr);
em[j].tel=em[j+1].tel;
}
flag=0;
}
}
}
if(!flag)
m=m-1;
else
printf("\n I'm sorry , Check no one !\n");
printf("\n Browse all employee information after deletion :\n");
save(m); /* Call the save function */
display(); /* Call the browse function */
printf("\n To continue deleting, press 1, To not delete again, press 0\n");
scanf("%d",&t);
switch(t)
{
case 1:del();break;
case 0:break;
default :break;
}
}
void add()/* Add function */
{
FILE*fp;
int n;
int count=0;
int i;
int m=load();
printf("\n Original employee information :\n");
display(); /* Call the browse function */
printf("\n");
fp=fopen("emploee_list","a");
printf(" Please enter the number of employees you want to increase :\n"); scanf("%d",&n);
for (i=m;i<(m+n);i++)
{
printf("\n Please enter the information of the new employee :\n"); printf(" Please enter the employee number : ");
if(em[i].num!=em[i-1].num)
printf("%8d ",em[i].num);
printf("\n");
printf(" Please enter a name : ");
scanf("%s",em[i].name);
getchar();
printf(" Please enter gender (f-- Woman m-- male ): "); scanf("%c",&em[i].sex);
printf(" Please enter age : ");
scanf("%d",&em[i].age);
printf(" Please enter your education : ");
scanf("%s",em[i].xueli);
printf(" Please input salary : ");
scanf("%d",&em[i].wage);
printf(" Please enter address : ");
scanf("%s",em[i].addr);
printf(" Please input the phone number : ");
scanf("%d",&em[i].tel);
printf("\n");
count=count+1;
printf(" The number of people who have increased :\n");
printf("%d\n",count);
}
printf("\n Add completed !\n");
m=m+count;
printf("\n Browse all the added employee information :\n"); printf("\n");
save(m);
display();
fclose(fp);
}
void search()/* Query function */
{
int t,flag;
do
{
printf("\n For inquiry by employee No., please press 1 ; To query by education background, please press 2 ; For enquiries by phone number, please press 3, Enter the main function and press 4\n");
scanf("%d",&t);
if(t>=1&&t<=4)
{
flag=1;
break;
}
else
{
flag=0;
printf(" Your input is wrong , Please reselect !");
}
}
while(flag==0);
while(flag==1)
{
switch(t)
{
case 1:printf(" Query by employee No \n");search_num();break;
case 2:printf(" Query by educational background \n");search_xueli();break;
case 3:printf(" Inquire by phone number \n");search_tel();break;
case 4:main();break;
default:break;
}
}
}
void search_num()
{
int num;
int i,t;
int m=load();
printf(" Please enter the employee number you want to find (20001111---20009999):\n");
scanf("%d",&num);
for(i=0;i<m;i++)
if(num==em[i].num)
{
printf("\n This person has been found , It is recorded as :\n");
printf("\n Employee number \t full name \t Gender \t Age \t Education \t Wages \t address \t Telephone \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
break;
}
if(i==m)
printf("\n I'm sorry , Check no one \n");
printf("\n");
printf(" To return the query function, press 1, To continue to query the employee number, please press 2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2: break;
default:break;
}
}
void search_xueli()
{
char xueli[30];
int i,t;
int m=load();
printf(" Please enter the education you want to find :\n");
scanf("%s",xueli);
for(i=0;i<m;i++)
if(strcmp(em[i].xueli,xueli)==0)
{
printf("\n Already found , It is recorded as :\n");
printf("\n Employee number \t full name \t Gender \t Age \t Education \t Wages \t address \t Telephone \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
}
if(i==m)
printf("\n I'm sorry , Check no one \n");
printf("\n");
printf(" To return the query function, press 1, Please press to continue the inquiry 2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2:break;
default :break;
}
}
void search_tel()
{
long int tel;
int i, t;
int m=load();
printf(" Please enter the phone number you want to find :\n");
scanf("%ld",&tel);
for(i=0;i<m;i++)
if(tel==em[i].tel)
{
printf("\n This person has been found , It is recorded as :\n");
printf("\n Employee number \t full name \t Gender \t Age \t Education \t Wages \t address \t Telephone \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
break;
}
if(i==m)
printf("\n I'm sorry , Check no one \n");
printf("\n");
printf(" To return the query function, press 1, Please press... To continue the inquiry 2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2:break;
default :break;
}
}
void modify() /* Modify the function */
{
int num;
char name[10];
char sex;
int age;
char xueli[30];
int wage;
char addr[30];
long int tel;
int b,c,i,n,t,flag;
int m=load(); /* Import the information in the file */
printf("\n Original employee information :\n");
display(); /* Call the browse function */
printf("\n");
printf(" Please enter the name of the employee to be modified :\n");
scanf("%s",name);
for(flag=1,i=0;flag&&i<m;i++)
{
if(strcmp(em[i].name,name)==0)
{
printf("\n This person has been found , The original record is :\n");
printf("\n Employee number \t full name \t Gender \t Age \t Education \t Wages \t address \t Telephone \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
printf("\n If you really want to modify this person's information, press 1 ; If not, please press 0\n");
scanf("%d",&n);
if(n==1)
{
printf("\n Options that need to be modified \n 1. Employee number 2. full name 3. Gender 4. Age 5. Education 6. Wages 7. address 8. Telephone \n");
printf(" Please enter the serial number of the item you want to modify :\n");
scanf("%d",&c);
if(c>8||c<1)
printf("\n Wrong choice , Please reselect !\n");
}
flag=0;
}
}
if(flag==1)
printf("\n I'm sorry , Check no one !\n");
do
{
switch(c) /* Because when you find the first i When an employee ,for After the statement i Self added 1, Therefore, the following should assign the changed information to the second i-1 personal */
{
case 1:printf(" The employee number is changed to : ");
scanf("%d",&num);
em[i-1].num=num;
break;
case 2:printf(" Name changed to : ");
scanf("%s",name);
strcpy(em[i-1].name,name);
break;
case 3:printf(" Gender changed to : ");
getchar();
scanf("%c",&sex);
em[i-1].sex=sex;
break;
case 4:printf(" Change the age to : ");
scanf("%d",&age);
em[i-1].age=age;
break;
case 5:printf(" Education changed to : ");
scanf("%s",xueli);
strcpy(em[i-1].xueli,xueli);
break;
case 6:printf(" The salary is changed to : ");
scanf("%d",wage);
break;
case 7:printf(" Change your address to : ");
scanf("%s",addr);
strcpy(em[i-1].addr,addr);
break;
case 8:printf(" Change the phone number to : ");
scanf("%ld",&tel);
em[i-1].tel=tel;
break;
}
printf("\n");
printf("\n Whether to confirm the modified information ?\n yes Please press 1 ; No , Revise Please press 2: \n"); scanf("%d",&b);
}
while(b==2);
printf("\n Browse all the modified employee information :\n");
printf("\n");
save(m);
display();
printf("\n To continue modifying, please press 1, If you don't want to modify it again, please press 0\n");
scanf("%d",&t);
switch(t)
{
case 1:modify();break;
case 0:break;
default :break;
}
}

You can pay attention to it, and it will be updated continuously in the future 0.0( Thank you first )
边栏推荐
- C语言课设物业费管理系统(大作业)
- 记磁盘扇区损坏导致的Mysql故障排查
- 10-golang运算符
- Kubedm builds kubenetes cluster (Personal Learning version)
- webapck打包原理--启动过程分析
- Self confidence is indispensable for technology
- 【ManageEngine卓豪】用统一终端管理助“欧力士集团”数字化转型
- How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
- sql中TCL语句(事务控制语句)
- 连续四年入选Gartner魔力象限,ManageEngine卓豪是如何做到的?
猜你喜欢

图片服务器项目测试

To sort out the anomaly detection methods, just read this article!

Understanding of C manualresetevent class

高阶-二叉搜索树详解
![[self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage](/img/54/f187e22ad69f3985d30376bad1fa03.png)
[self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage

C language course set up property fee management system (big work)

Uniapp tree level selector

Record MySQL troubleshooting caused by disk sector damage

【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】

VS2019如何永久配置本地OpenCV4.5.5使用
随机推荐
高阶-二叉搜索树详解
Differences between in and exists in MySQL
C语言课设职工信息管理系统(大作业)
三分钟带你快速了解网站开发的整个流程
[unity shader ablation effect _ case sharing]
【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】
子类调用父类的同名方法和属性
记磁盘扇区损坏导致的Mysql故障排查
Pol8901 LVDS to Mipi DSI supports rotating image processing chip
10 golang operator
Three minutes to quickly understand the whole process of website development
C# ManualResetEvent 类的理解
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
Treasure taking from underground palace (memory based deep search)
[ManageEngine Zhuohao] helps Huangshi Aikang hospital realize intelligent batch network equipment configuration management
Ant new village is one of the special agricultural products that make Tiantou village in Guankou Town, Xiamen become Tiantou village
Design of sales management system for C language course (big homework)
HCM Beginner (II) - information type
Picture server project test
Make: g++: command not found