#include <iostream.h>
#include <string.h>
#include <vector.h>
using namespace std;
class Info{
public:
string para1,para2,para3,para4;
int para5,para6,para7,para8,sum_cost;
void data_in_1(){
cout<<"请输入员工的姓名: "<<endl;cin>>para1;
cout<<"请输入员工的工号: "<<endl;cin>>para2;
cout<<"请输入员工的住址: "<<endl;cin>>para3;
cout<<"请输入员工的待遇: "<<endl;cin>>para4;
cout<<"录入完毕 "<<endl;
}
void data_in_2(){
cout<<"当月旅行费用: "<<endl;cin>>para5;
cout<<"当月住宿费用: "<<endl;cin>>para6;
cout<<"当月交通费用: "<<endl;cin>>para7;
cout<<"当月额外费用: "<<endl;cin>>para8;
cout<<"录入完毕 "<<endl;
}
void count(){sum_cost=para5+para6+para7+para8;}
void data_out_1(){
cout<<"员工的姓名:"<<para1<<" "<<endl;;
cout<<"员工的工号:"<<para2<<" "<<endl;
cout<<"员工的住址:"<<para3<<" "<<endl;
cout<<"员工的待遇:"<<para4<<" "<<endl;
}
void data_out_2(){
cout<<"当月旅行费用:"<<para5<<endl;
cout<<"当月住宿费用:"<<para6<<" "<<endl;
cout<<"当月交通费用:"<<para7<<" "<<endl;
cout<<"当月额外费用:"<<para8<<" "<<endl;
}
};
vector<Info>infoList;
void fuc1();
void fuc2();
void fuc3();
void fuc4();
void fuc5();
void fuc6();
using namespace std;
void menu(){
system("color a");
system("title 小型公司差旅财务管理系统 ");
cout<<endl<<"=============================================="<<endl;
cout<<endl<<"小型公司差旅财务管理系统 "<<endl<<endl<<endl;
cout<<"选择: "<<endl;
cout<<"1-员工的信息录入 "<<endl;
cout<<"2-对应员工财务信息的录入 "<<endl;
cout<<"3-按照员工姓名查询信息 "<<endl;
cout<<"4-按照员工姓名查询财务 "<<endl;
cout<<"5-浏览所有员工信息 "<<endl;
cout<<"6-退出 "<<endl;
cout<<endl<<"=============================================="<<endl;
int tempchoise;
cin>>tempchoise;
switch (tempchoise)
{case 1:
fuc1();
break;
case 2:
fuc2();
break;
case 3:
fuc3();
break;
case 4:
fuc4();
break;
case 5:
fuc5();
break;
case 6:
exit(0);
break;
default: system("cls ");
cout<<"Incorrect options. Try again "<<endl;
menu();
}
}
void fuc1(){
Info temp;
temp.data_in_1();
infoList.push_back(temp);
system("pause");
menu();
}
void fuc2(){
string tempstr;cout<<"请输入将要输入的员工信息的名字"<<endl;cin>>tempstr;int flag=0;
for(vector<Info>::iterator it = infoList.begin(); it < infoList.end(); ++it){
if(tempstr ==(*it).para1){
cout<<"已找到,请开始输入:"<<endl;
(*it).data_in_2();
flag++;
}
};
if(flag!=0)cout<<"没有找到该员工"<<endl;
system("pause");
menu();
}
void fuc3(){
string tempstr;cout<<"请输入将要查询的员工财务信息的名字"<<endl;cin>>tempstr;int flag=0;
for(vector<Info>::iterator it = infoList.begin(); it < infoList.end(); ++it){
if(tempstr ==(*it).para1){
cout<<"已找到,信息如下:"<<endl;
(*it).data_out_1();
flag++;
}
};
if(flag!=0)cout<<"没有找到该员工"<<endl;
system("pause");
menu();
}
void fuc4(){
string tempstr;cout<<"请输入将要查询的员工财务信息的名字"<<endl;cin>>tempstr;int flag=0;
for(vector<Info>::iterator it = infoList.begin(); it < infoList.end(); ++it){
if(tempstr ==(*it).para1){
cout<<"已找到,财务记录如下:"<<endl;
(*it).data_out_2();
flag++;
}
};
if(flag!=0)cout<<"没有找到该员工"<<endl;
system("pause");
menu();
}
void fuc5(){
cout<<"所有信息如下:"<<endl;
for(vector<Info>::iterator it = infoList.begin(); it < infoList.end(); ++it){
(*it).data_out_1();
(*it).data_out_2();
};
system("pause");
menu();
}
int main(int argc, char *argv[])
{
menu();
return 0;
}
代码