?? shujuku.cpp
字號:
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
const N=50; // 定義系統(tǒng)可錄入的員工最大數(shù)值
string Ename[N];
long Enum[N];
char Esex[N];
int Eage[N];
char Emarriage[N];
int Edepart[N];
int Eposition[N];
int Edegree[50];
int Eworktime[N];
float Epay[N];
class Employee
{
public:
string Employeename;
long Employeenum;
char Employeesex;
int Employeeage;
char Employeemarriage;
int Employeedepart;
int Employeeposition;
int Employeedegree;
int Employeeworktime;
float Employeepay;
static long EmployeeMaxNum;
static float EmployeeBasePay;
void NewInfo();
void ShowInfo();
void showall();
void showdepart(int depart);
void showdegree(int degree);
void showage(int min,int max);
void shownum(long number);
void RefreshInfo();
void DeleteInfo();
float Pay(int Employeegrade);
static int MaxNum();
};
class DBOperate
{
public:
string Employeename;
long Employeenum;
char Employeesex;
int Employeeage;
char Employeemarriage;
int Employeedepart;
int Employeeposition;
int Employeedegree;
int Employeeworktime;
float Employeepay;
static long EmployeeMaxNum;
static float EmployeeBasePay;
void WriteIn(int iflag);
void ReadOut();
void RefreshMaxNum(int iflag); //i=1 or -1 or 0
};
long Employee::EmployeeMaxNum = 1000;
float Employee::EmployeeBasePay = 1500;
int Employee::MaxNum() //返回系統(tǒng)已經(jīng)存儲的人數(shù)
{
int MN = 0;
ifstream myf;
myf.open("EmployeeMaxNum.txt");
myf>>MN;
cout<<MN<<endl;
myf.close();
return MN;
}
void Employee::NewInfo() //添加新成員函數(shù)
{
cout<<"新員工姓名: ";
cin>>Employee::Employeename;
Employee::Employeenum = EmployeeMaxNum + Employee::MaxNum()+1;
cout<<"新員工性別 (F為女性,M為男性): ";
cin>>Employee::Employeesex;
cout<<"新員工年齡: ";
cin>>Employee::Employeeage;
cout<<"新員工婚姻狀況(Y為已婚,N為未婚): ";
cin>>Employee::Employeemarriage;
cout<<"新員工學(xué)歷,請輸入相應(yīng)學(xué)歷的序號: "<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>Employee::Employeedegree;
while(Employee::Employeedegree !=1&&Employee::Employeedegree !=2&&Employee::Employeedegree !=3&&Employee::Employeedegree !=4&&Employee::Employeedegree !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士]";
cin>>Employee::Employeedegree;
}
cout<<"新員工所在部門,請輸入相應(yīng)部門的序號:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關(guān)部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
while(Employee::Employeedepart !=1&&Employee::Employeedepart !=2&&Employee::Employeedepart !=3&&Employee::Employeedepart !=4&&Employee::Employeedepart!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關(guān)部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
}
cout<<"新員工職位, 請輸入相應(yīng)職位的序號: "<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經(jīng)理 5:董事長] ";
cin>>Employee::Employeeposition;
while(Employee::Employeeposition !=1&&Employee::Employeeposition !=2&&Employee::Employeeposition !=3&&Employee::Employeeposition !=4&&Employee::Employeeposition !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經(jīng)理 5:董事長] ";
cin>>Employee::Employeeposition;
}
cout<<"新員工的工作時(不需要輸入單位): ";
cin>>Employee::Employeeworktime;
Employee::Employeepay = Employee::Pay(Employee::Employeeposition);
DBOperate dbo;
dbo.ReadOut();
int MaxNum = Employee::MaxNum();
Enum[MaxNum] = Employee::Employeenum;
Ename[MaxNum] = Employee::Employeename;
Esex[MaxNum] = Employee::Employeesex;
Eage[MaxNum] = Employee::Employeeage;
Emarriage[MaxNum] = Employee::Employeemarriage;
Edegree[MaxNum] = Employee::Employeedegree;
Edepart[MaxNum] = Employee::Employeedepart;
Eposition[MaxNum] = Employee::Employeeposition;
Eworktime[MaxNum] = Employee::Employeeworktime;
Epay[MaxNum] = Employee::Employeepay;
dbo.WriteIn(1);
cout<<" 添加新成員成功!"<<endl;
return;
}
void Employee::ShowInfo() //程序主體 數(shù)據(jù)輸出函數(shù)
{
int choice1,choice2,min,max;
long searchnum;
Employee e;
cout<<" 請選擇查詢方式:"<<endl;
cout<<"******************************************"<<endl;
cout<<"* 輸出全體職工信息--------------------- 1"<<endl;
cout<<"* 按職工部門輸出----------------------- 2"<<endl;
cout<<"* 按職工學(xué)歷輸出----------------------- 3"<<endl;
cout<<"* 按職工年齡輸出----------------------- 4"<<endl;
cout<<"* 按職工編號輸出----------------------- 5"<<endl;
cout<<"******************************************"<<endl;
cin>>choice1;
switch(choice1)
{
case 1: showall();break;
case 2: cout<<"請輸入要查詢職工的部門編號: [1:董事會 2:市場部 3:公關(guān)部 4:客服中心 5:信息中心] " ;
cin>>choice2;
e.showdepart(choice2);break;
case 3: cout<<"請輸入要查詢職工的學(xué)歷編號: [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>choice2;
e.showdegree(choice2);break;
case 4: cout<<"請輸入要查詢的年齡范圍: ";
cout<<"最小值: ";
cin>>min;
cout<<"最大值: ";
cin>>max;
e.showage(min,max);break;
case 5: cout<<"請輸入要查詢的員工號: ";
cin>>searchnum;
e.shownum(searchnum);break;
default: cout<<"出錯啦! "<<endl;break;
}
}
void Employee::showall() //全體員工輸出函數(shù)
{ int i;
long number;
for(i=0;i<Employee::MaxNum();i++)
{
number = Enum[i];
shownum(number);
}
}
void Employee::showdepart(int depart) //按員工所在部門輸出函數(shù)
{
int i;
switch(depart)
{
case 1: cout<<"董事會的成員有: >"<<endl; break;
case 2: cout<<"市場部的成員有: >"<<endl; break;
case 3: cout<<"公關(guān)部的成員有: >"<<endl; break;
case 4: cout<<"客服中心成員有: >"<<endl; break;
case 5: cout<<"信息中心成員有: >"<<endl; break;
default: cout<<"輸入錯誤!>"<<endl; break;
}
for(i=0;i<Employee::MaxNum();i++)
{
if(Edepart[i] == depart)
{
long number = Enum[i];
shownum(number);
} else continue;
}
}
void Employee::showdegree(int degree) //按員工學(xué)歷輸出函數(shù)
{
int i;
switch(degree)
{
case 1:cout<<"初中學(xué)歷的員工有:"<<endl;break;
case 2:cout<<"高中學(xué)歷的員工有:"<<endl;break;
case 3:cout<<"本科學(xué)歷的員工有:"<<endl;break;
case 4:cout<<"碩士學(xué)位的員工有:"<<endl;break;
case 5:cout<<"博士學(xué)位的員工有:"<<endl;break;
}
for(i=0;i<Employee::MaxNum();i++)
{
if(Edegree[i] == degree)
{
long number = Enum[i];
shownum(number);
} else continue;
}
}
void Employee::showage(int min,int max) //按員工年齡段輸出函數(shù)
{
int i;
for(i=0;i<Employee::MaxNum();i++)
{
if(Eage[i]>=min&&Eage[i]<=max)
{
long number = Enum[i];
shownum(number);
}
else continue;
}
}
void Employee::shownum(long number) //按員工編號輸出函數(shù)
{
int i;
for(i=0;i<Employee::MaxNum();i++)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -