当前位置:文档之家› 人事管理系统(课程设计)源码

人事管理系统(课程设计)源码

急需一个公司的人事管理系统源代码(vc++编程)悬赏分:100 |解决时间:2008-1-8 09:58 |提问者:klak1某小型公司,主要有两类人员:经理、员工。

现在,需要存储这些人员的姓名、编号、身份证号码、业绩、级别(经理包括总经理、经理、副经理级别,员工包括高级员工、普通员工和临时工级别)、家庭住址、开始工作日期、所在部门、薪水等信息,并可以对这些信息进行检索。

要求:1)人员编号在生成人员信息时同时生成,每输入一个人员信息编号顺序加1;2)根据业绩的大小具有自动升降级别的功能;3)输入员工身份证号码号码后自动获取员工生日;4)输入员工开始工作日期后自动获取员工工龄;5)能按姓名或者编号显示、查找、增加、删除和保存各类人员的信息最佳答案#include <iostream.h>#include <iomanip.h>#include <string.h>#include <fstream.h>const int Maxr=100;class Employee //职工类{int tag;//删除标记int no;//职工编号char name[20];char zw[20];//职工姓名int salary;//职工工资public:Employee(){}char *getname() {return name;}//获取名字int gettag() {return tag;}//获取标记int getno() {return no;}//获取编号int getsalary(){return salary;}void setzw(char q[])//设置名字{strcpy(zw,q);}void setname(char na[])//设置名字{strcpy(name,na);}void getsalary(int sa){salary=sa;}void delna(){tag=1;}//删除void addemp(int n,int sa,char *na,char *q)//增加{tag=0;no=n;salary=sa;strcpy(name,na);strcpy(zw,q);}void disp()//显示职工信息{cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<salary <<"│"<<setw(10)<<zw<<"│"<<endl;cout<<"├—————┼—————┼—————┼—————┤"<<endl;}};class Database//职工数据类{int top;Employee read[Maxr];public:Database()//将职工信息从employee.txt读取到read[]中{ Employee s;top=-1;fstream file("employee.txt",ios::in);while (1){file.read((char *)&s,sizeof(s));if (!file) break;top++;read[top]=s;}file.close();}void clear()//删除所有top=-1;}int addemp (int n, int sa,char *na,char*q) //增加职工{Employee *p=query(n);if (p==NULL){top++;read[top].addemp(n,sa,na,q);return 1;}return 0;}Employee *query(int empid){for (int i=0;i<=top;i++)if (read[i].getno()==empid && read[i].gettag()==0) return &read[i];return NULL;}Employee *query1(char empna[20]){for (int i=0;i<=top;i++)if ((read[i].getname()==empna) && read[i].gettag()==0) return &read[i];return NULL;}void disp() //职工信息显示{for (int i=0;i<=top;i++)read[i].disp();}void empdata();~Database() //将read[]中的信息读如到employee.txt中{fstream file("employee.txt",ios::out);for (int i=0;i<=top;i++)if (read[i].gettag()==0)file.write((char *)&read[i],sizeof(read[i]));file.close();}void Database::empdata()//职工维护{int choice=1;int m=1;int b=1;char rname[20];int empid; int empsa;char q[20];Employee *r;while (choice!=0){cout<<"职工维护1:新增2:更改3:删除4:查找5:显示6:全删0:退出=>";cin>>choice;switch (choice){case 1:cout<<setw(50)<<" ┌—————————————┐\n";cout<<setw(50)<<" │ 请选择您所需的操作│\n";cout<<setw(50)<<" │ 经理:1,并按回车键│\n";cout<<setw(50)<<" │ 业务经理:2,并按回车键│\n";cout<<setw(50)<<" │ 普通职工:3,并按回车键│\n";cout<<setw(50)<<" └—————————————┘\n";cin>>m;while(m!=0){switch(m){case 1:cout<<"输入经理编号:";cin>>empid;cout<<"输入奖金: ";cin>>empsa;cout<<"输入经理姓名:";cin>>rname;addemp(empid,8000+empsa,rname,"经理");break;case 2:cout<<"输入业务经理编号:";cin>>empid;cout<<"输入月提成: ";cin>>empsa;cout<<"输入业务经理姓名:";cin>>rname;addemp(empid,4000+empsa,rname,"业务经理"); break;case 3:cout<<"输入职工编号:";cin>>empid;cout<<"输入工资: ";cin>>empsa;cout<<"输入职工姓名:";cin>>rname;addemp(empid,empsa,rname,"普通职工"); break;}break;}break;case 2:cout<<"输入职工编号:";cin>>empid;r=query(empid);if (r==NULL){cout<<"该职工不存在"<<endl;break;}cout<<"输入新的工资:"<<endl;cin>>empsa;r->getsalary(empsa);cout<<"请输入新的职务"<<endl;cin>>q;r->setzw(q);addemp(empid,empsa,rname,q);break;case 3:cout<<"输入职工编号:";cin>>empid;r=query(empid);if (r==NULL){cout<<"该读者不存在"<<endl;break;}break;case 4:cout<<setw(50)<<" ┌—————————————┐\n";cout<<setw(50)<<" │ 请选择您所需的操作│\n";cout<<setw(50)<<" │ 按编号查找1,并按回车键│\n";cout<<setw(50)<<" │ 返回2,并按回车键│\n";cout<<setw(50)<<" └—————————————┘\n";cin>>b;while(b!=0){switch(b){case 1:cout<<"输入职工编号:";cin>>empid;r=query(empid);if (r==NULL){cout<<"该职工不存在"<<endl;break;}cout<<"├—————┼—————┼—————┼—————┤"<<endl;cout<<"│"<<setw(10)<<"编号"<<"│"<<setw(10)<<"姓名"<<"│"<<setw(10)<<"工资"<<"│"<<setw(10)<<"职务"<<"│"<<endl;cout<<"├—————┼—————┼—————┼—————┤"<<endl; r->disp();break;case 2:break;}break;}break;case 5:cout<<"├—————┼—————┼—————┼—————┤"<<endl;cout<<"│"<<set w(10)<<"编号"<<"│"<<setw(10)<<"姓名"<<"│"<<setw(10)<<"工资"<<"│"<<setw(10)<<"职务"<<"│"<<endl;cout<<"├—————┼—————┼—————┼—————┤"<<endl; disp();break;clear();break;}}}void main(){int choice=1;Database EmpDB;while(choice!=0){cout<<"******************************************************************************** "<<endl;cout<<endl;cout<<endl;cout<<setw(20)<<"******************************欢迎使用职工管理系统******************************"<<endl;cout<<endl;cout<<endl;cout<<setw(50)<<" ┌—————————————┐\n";cout<<setw(50)<<" │ 请选择您所需的操作│\n";cout<<setw(50)<<" │ │\n";cout<<setw(50)<<" │ 操作1,并按回车键│\n";cout<<setw(50)<<" │ │\n";cout<<setw(50)<<" │ 返回0,并按回车键│\n";cou t<<setw(50)<<" └—————————————┘\n";cin>>choice;switch(choice){case 1:while(1){cout<<setw(20);EmpDB.empdata();break;break;}}}}。

相关主题