假如你是大一学生,请你写一个c语言程序设计作业关于企业员工管理系统
时间: 2024-05-16 10:14:54 浏览: 142
c语言程序设计__企业员工管理系统
3星 · 编辑精心推荐
好的,下面是一个简单的企业员工管理系统的C语言程序设计作业:
题目:企业员工管理系统
要求:
1. 实现员工信息的录入、修改、删除、查询功能;
2. 实现员工信息的打印功能,可以按照姓名、工号、职位等排序;
3. 实现员工工资的计算功能,包括基本工资、津贴、奖金等;
4. 实现员工考勤管理功能,包括请假、加班、旷工等;
5. 实现员工绩效考核功能,包括KPI、年度评估等;
6. 实现员工晋升、晋级、调整等管理功能;
7. 实现员工离职、退休、转岗等管理功能;
8. 采用文件存储方式,实现员工信息的永久保存;
9. 最好能够有图形化界面。
提示:
1. 可以采用结构体存储员工信息;
2. 可以采用链表、二叉树等数据结构实现员工信息的排序;
3. 可以采用文件读写、数据库等方式实现员工信息的永久保存;
4. 可以采用QT、MFC等框架实现图形化界面。
参考代码:
由于该企业员工管理系统比较复杂,且需要涉及到多个功能,因此这里只提供一个简单的参考代码,供大家参考:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_NAME 20
#define MAX_ID 10
#define MAX_DEPARTMENT 20
// 员工结构体
typedef struct Employee {
char name[MAX_NAME]; // 姓名
char id[MAX_ID]; // 工号
char department[MAX_DEPARTMENT]; // 部门
float salary; // 薪资
int attendance; // 考勤
int performance; // 绩效
struct Employee *next; // 指向下一个员工的指针
} Employee;
// 用链表存储员工信息
Employee *head = NULL;
// 打印菜单
void print_menu()
{
printf("=====================================\n");
printf("= 菜单 =\n");
printf("=====================================\n");
printf("= 1. 录入员工信息 =\n");
printf("= 2. 修改员工信息 =\n");
printf("= 3. 删除员工信息 =\n");
printf("= 4. 查询员工信息 =\n");
printf("= 5. 打印员工信息 =\n");
printf("= 6. 计算员工工资 =\n");
printf("= 7. 考勤管理 =\n");
printf("= 8. 绩效考核 =\n");
printf("= 9. 员工管理 =\n");
printf("= 10. 保存员工信息到文件 =\n");
printf("= 11. 从文件中读取员工信息 =\n");
printf("= 0. 退出 =\n");
printf("=====================================\n");
}
// 录入员工信息
void input_employee()
{
Employee *new_employee = (Employee *)malloc(sizeof(Employee));
printf("请输入员工姓名:");
scanf("%s", new_employee->name);
printf("请输入员工工号:");
scanf("%s", new_employee->id);
printf("请输入员工部门:");
scanf("%s", new_employee->department);
printf("请输入员工薪资:");
scanf("%f", &new_employee->salary);
printf("请输入员工考勤:");
scanf("%d", &new_employee->attendance);
printf("请输入员工绩效:");
scanf("%d", &new_employee->performance);
new_employee->next = NULL;
if (head == NULL) {
head = new_employee;
} else {
Employee *p = head;
while (p->next != NULL) {
p = p->next;
}
p->next = new_employee;
}
printf("录入成功!\n");
}
// 修改员工信息
void modify_employee()
{
char id[MAX_ID];
printf("请输入要修改的员工工号:");
scanf("%s", id);
Employee *p = head;
while (p != NULL) {
if (strcmp(p->id, id) == 0) {
printf("请输入员工姓名:");
scanf("%s", p->name);
printf("请输入员工部门:");
scanf("%s", p->department);
printf("请输入员工薪资:");
scanf("%f", &p->salary);
printf("请输入员工考勤:");
scanf("%d", &p->attendance);
printf("请输入员工绩效:");
scanf("%d", &p->performance);
printf("修改成功!\n");
return;
}
p = p->next;
}
printf("该员工不存在!\n");
}
// 删除员工信息
void delete_employee()
{
char id[MAX_ID];
printf("请输入要删除的员工工号:");
scanf("%s", id);
Employee *p = head;
Employee *prev = NULL;
while (p != NULL) {
if (strcmp(p->id, id) == 0) {
if (prev == NULL) {
head = p->next;
} else {
prev->next = p->next;
}
free(p);
printf("删除成功!\n");
return;
}
prev = p;
p = p->next;
}
printf("该员工不存在!\n");
}
// 查询员工信息
void query_employee()
{
char id[MAX_ID];
printf("请输入要查询的员工工号:");
scanf("%s", id);
Employee *p = head;
while (p != NULL) {
if (strcmp(p->id, id) == 0) {
printf("姓名:%s\n", p->name);
printf("工号:%s\n", p->id);
printf("部门:%s\n", p->department);
printf("薪资:%.2f\n", p->salary);
printf("考勤:%d\n", p->attendance);
printf("绩效:%d\n", p->performance);
return;
}
p = p->next;
}
printf("该员工不存在!\n");
}
// 打印员工信息
void print_employee()
{
Employee *p = head;
printf("=====================================\n");
printf("= 员工信息 =\n");
printf("=====================================\n");
printf("姓名\t工号\t部门\t薪资\t考勤\t绩效\n");
while (p != NULL) {
printf("%s\t%s\t%s\t%.2f\t%d\t%d\n", p->name, p->id, p->department, p->salary, p->attendance, p->performance);
p = p->next;
}
}
// 计算员工工资
void calculate_salary()
{
char id[MAX_ID];
printf("请输入要计算工资的员工工号:");
scanf("%s", id);
Employee *p = head;
while (p != NULL) {
if (strcmp(p->id, id) == 0) {
float salary = p->salary;
// 计算津贴
if (strcmp(p->department, "技术部") == 0) {
salary += 1000;
} else if (strcmp(p->department, "市场部") == 0) {
salary += 800;
} else if (strcmp(p->department, "人事部") == 0) {
salary += 500;
}
// 计算奖金
if (p->attendance >= 20) {
salary += 1000;
}
if (p->performance >= 90) {
salary += 1000;
}
printf("员工工资为:%.2f\n", salary);
return;
}
p = p->next;
}
printf("该员工不存在!\n");
}
// 考勤管理
void attendance_management()
{
char id[MAX_ID];
printf("请输入要管理考勤的员工工号:");
scanf("%s", id);
Employee *p = head;
while (p != NULL) {
if (strcmp(p->id, id) == 0) {
int attendance;
printf("请输入考勤记录:");
scanf("%d", &attendance);
p->attendance = attendance;
printf("考勤管理成功!\n");
return;
}
p = p->next;
}
printf("该员工不存在!\n");
}
// 绩效考核
void performance_assessment()
{
char id[MAX_ID];
printf("请输入要考核绩效的员工工号:");
scanf("%s", id);
Employee *p = head;
while (p != NULL) {
if (strcmp(p->id, id) == 0) {
int performance;
printf("请输入绩效记录:");
scanf("%d", &performance);
p->performance = performance;
printf("绩效考核成功!\n");
return;
}
p = p->next;
}
printf("该员工不存在!\n");
}
// 员工管理
void employee_management()
{
char id[MAX_ID];
printf("请输入要管理的员工工号:");
scanf("%s", id);
Employee *p = head;
while (p != NULL) {
if (strcmp(p->id, id) == 0) {
printf("请选择要进行的操作:\n");
printf("1. 晋升\n");
printf("2. 晋级\n");
printf("3. 调整\n");
printf("4. 离职\n");
printf("5. 退休\n");
int choice;
scanf("%d", &choice);
if (choice == 1) {
printf("晋升成功!\n");
} else if (choice == 2) {
printf("晋级成功!\n");
} else if (choice == 3) {
printf("调整成功!\n");
} else if (choice == 4) {
delete_employee();
} else if (choice == 5) {
printf("退休成功!\n");
} else {
printf("无效选项!\n");
}
return;
}
p = p->next;
}
printf("该员工不存在!\n");
}
// 保存员工信息到文件
void save_employee()
{
FILE *fp;
if ((fp = fopen("employee.txt", "w")) == NULL) {
printf("文件打开失败!\n");
return;
}
Employee *p = head;
while (p != NULL) {
fprintf(fp, "%s %s %s %.2f %d %d\n", p->name, p->id, p->department, p->salary, p->attendance, p->performance);
p = p->next;
}
fclose(fp);
printf("员工信息已保存到文件!\n");
}
// 从文件中读取员工信息
void load_employee()
{
FILE *fp;
if ((fp = fopen("employee.txt", "r")) == NULL) {
printf("文件打开失败!\n");
return;
}
Employee *p = head;
while (p != NULL) {
Employee *temp = p->next;
free(p);
p = temp;
}
head = NULL;
char name[MAX_NAME];
char id[MAX_ID];
char department[MAX_DEPARTMENT];
float salary;
int attendance;
int performance;
while (fscanf(fp, "%s %s %s %f %d %d", name, id, department, &salary, &attendance, &performance) != EOF) {
Employee *new_employee = (Employee *)malloc(sizeof(Employee));
strcpy(new_employee->name, name);
strcpy(new_employee->id, id);
strcpy(new_employee->department, department);
new_employee->salary = salary;
new_employee->attendance = attendance;
new_employee->performance = performance;
new_employee->next = NULL;
if (head == NULL) {
head = new_employee;
} else {
Employee *p = head;
while (p->next != NULL) {
p = p->next;
}
p->next = new_employee;
}
}
fclose(fp);
printf("员工信息已从文件中读取!\n");
}
// 主函数
int main()
{
int choice;
while (1) {
print_menu();
printf("请选择要进行的操作:");
scanf("%d", &choice);
switch (choice) {
case 1:
input_employee();
break;
case 2:
modify_employee();
break;
case 3:
delete_employee();
break;
case 4:
query_employee();
break;
case 5:
print_employee();
break;
case 6:
calculate_salary();
break;
case 7:
attendance_management();
break;
case 8:
performance_assessment();
break;
case 9:
employee_management();
break;
case 10:
save_employee();
break;
case 11:
load_employee();
break;
case 0:
printf("谢谢使用!\n");
return 0;
default:
printf("无效选项!\n");
break;
}
}
return 0;
}
```
注意:该代码仅供参考,实际开发中需要根据具体情况进行修改和完善。
阅读全文