当前位置:网站首页>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 )
边栏推荐
- 【企业数据安全】升级备份策略 保障企业数据安全
- What is a port scanning tool? What is the use of port scanning tools
- B-树系列
- Kubedm builds kubenetes cluster (Personal Learning version)
- Solve the problem of garbled files uploaded by Kirin v10
- 浅谈SIEM
- golang panic recover自定义异常处理
- UOW of dev XPO comparison
- HCM Beginner (II) - information type
- 【ManageEngine卓豪】局域网监控的作用
猜你喜欢

虚幻 简单的屏幕雨滴后处理效果
![[ManageEngine] how to realize network automatic operation and maintenance](/img/8a/75332d3180f92c6a6482d881032bbf.png)
[ManageEngine] how to realize network automatic operation and maintenance

SystemVerilog learning-08-random constraints and thread control
![[unity shader amplify shader editor (ASE) Chapter 9]](/img/f5/f0f6786406e149187e71c8e12cde0d.png)
[unity shader amplify shader editor (ASE) Chapter 9]
![[unity shader ablation effect _ case sharing]](/img/e3/464f1cf426e8c03ce3d538ed9cf4bc.png)
[unity shader ablation effect _ case sharing]

【Unity Shader 消融效果_案例分享】

【KV260】利用XADC生成芯片温度曲线图

C# ManualResetEvent 类的理解

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

Teach you how to implement a deep learning framework
随机推荐
SystemVerilog learning-07-class inheritance and package use
SystemVerilog learning-06-class encapsulation
ABP 学习解决方案中的项目以及依赖关系
libpng12.so. 0: cannot open shared object file: no such file or directory
kubeadm搭建kubenetes 集群(个人学习版)
【ManageEngine】终端管理系统,助力华盛证券数字化转型
C语言课设销售管理系统设计(大作业)
What is a port scanning tool? What is the use of port scanning tools
C# ManualResetEvent 类的理解
分布式锁实现
SQL中DML语句(数据操作语言)
How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
Although pycharm is marked with red in the run-time search path, it does not affect the execution of the program
[postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map
[summary of knowledge points] chi square distribution, t distribution, F distribution
Excel visualization
[ManageEngine Zhuohao] the role of LAN monitoring
JMM详解
【#Unity Shader#自定义材质面板_第一篇】
Design of sales management system for C language course (big homework)