⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpp1.cpp

📁 本系统主要用于管理企业员工的基本信息及工资的计算。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		else cout<<"员工编号非经理"<<endl;}

	else cout<<"输入错误编号"<<endl;
f.close();

}
class xingzhengrenyuan:public ganbu//行政人员类
{public:
void salary();//计算行政人员工资
void print();//显示所有行政人员
};
void xingzhengrenyuan::print()//显示所有行政人员
{yuangong yg;
	fstream f;
	f.open("yuangong.dat",ios::in|ios::out);
	f.seekg(0,ios::end);
	long pos=f.tellg();
	f.seekg(0,ios::beg);
	cout<<setw(10)<<"编号"<<setw(10)<<"姓名"<<setw(10)<<"性别"<<setw(10)<<"年龄"<<setw(15)<<"职位"<<setw(10)<<"学历"<<setw(10)<<"职称"<<endl;
	do
		{	f.read((char *)&yg,sizeof(yuangong)); 
			if((strcmp(yg.state,"行政人员")==0))
				{
			     cout<<setw(10)<<yg.number<<setw(10)<<yg.name<<setw(10)<<yg.sex<<setw(10)<<yg.age<<setw(15)<<yg.state<<setw(10)<<yg.xueli<<setw(10)<<yg.zhicheng<<endl;
			}
		}while(f.tellg()!=pos);
		f.close();

}

void xingzhengrenyuan::salary()//计算行政人员工资
{	float m,n;
	int i;
	fstream f;
	yuangong yg;
	f.open("yuangong.dat",ios::in|ios::out);
	cout<<"请输入要计算工资的员工编号:";
	cin>>i;
	f.seekg(0,ios::end);
	long pos=f.tellg();
	f.seekg(0,ios::beg);
	do	
	{f.read((char *)&yg,sizeof(yuangong));  //搜索
	}while(yg.number!=i&&f.tellg()!=pos);
	if(yg.number==i)
	{	if(strcmp(yg.state,"行政人员")==0)
		{  
			if(strcmp(yg.zhicheng,"初级")==0)
			{m=700;}
			else if(strcmp(yg.zhicheng,"中级")==0)
			{m=900;}
			else {m=1100;}
			if(strcmp(yg.xueli,"中学或中专")==0)
			{n=1000;}
			else if(strcmp(yg.xueli,"大学或大专")==0)
			{n=1200;}
			else {n=1500;}
	      
			yg.salary=m+n;
	
	       f.seekg(-long(sizeof(yuangong)),ios::cur);
	       f.write((char *)&yg,sizeof(yuangong));
		  cout<<setw(8)<<"编号"<<setw(8)<<"姓名"<<setw(8)<<"性别"<<setw(8)<<"年龄"<<setw(12)<<"职位"<<setw(12)<<"学历"<<setw(8)<<"职称"<<setw(12)<<"工资"<<endl;
		   cout<<setw(8)<<yg.number<<setw(8)<<yg.name<<setw(8)<<yg.sex<<setw(8)<<yg.age<<setw(12)<<yg.state<<setw(12)<<yg.xueli<<setw(8)<<yg.zhicheng<<setw(12)<<yg.salary<<endl;}
			else cout<<"员工编号非行政人员"<<endl;}
	else cout<<"输入错误编号"<<endl;
	f.close();
}


class zhongdiangong:public gongren
{public:
void salary();//计算钟点工工资
void print();//显示所有钟点工

};

void zhongdiangong::print()//显示所有钟点工

 {yuangong yg;
	fstream f;
	f.open("yuangong.dat",ios::in|ios::out);
	f.seekg(0,ios::end);
	long pos=f.tellg();
	f.seekg(0,ios::beg);
    cout<<setw(10)<<"编号"<<setw(10)<<"姓名"<<setw(10)<<"性别"<<setw(10)<<"年龄"<<setw(15)<<"职位"<<endl;	
	do
		{	f.read((char *)&yg,sizeof(yuangong)); 
			if((strcmp(yg.state,"钟点工")==0))
				{
				cout<<setw(10)<<yg.number<<setw(10)<<yg.name<<setw(10)<<yg.sex<<setw(10)<<yg.age<<setw(15)<<yg.state<<endl;
				}
		}while(f.tellg()!=pos);
		f.close();

}
 
void zhongdiangong::salary() // 计算钟点工工资
{	yuangong yg;
	float m;
	float n;
	int i,h;
	fstream f;
	f.open("yuangong.dat",ios::in|ios::out);
	cout<<"请输入要计算工资的员工编号:";
	cin>>i;
	f.seekg(0,ios::end);
	long pos=f.tellg();
	f.seekg(0,ios::beg);
	do
	{f.read((char *)&yg,sizeof(yuangong));  //搜索
	}while(yg.number!=i&&f.tellg()!=pos);
	if(yg.number==i)
	{if(strcmp(yg.state,"钟点工")==0)
		{
			cout<<"请输入时薪:";
			cin>>m;
			cout<<"请输入工作小时:";
			cin>>h;
			n=m*h;
		 yg.salary=n;
		f.seekg(-long(sizeof(yuangong)),ios::cur);
		f.write((char *)&yg,sizeof(yuangong));
        cout<<setw(8)<<"编号"<<setw(8)<<"姓名"<<setw(8)<<"性别"<<setw(8)<<"年龄"<<setw(12)<<"职位"<<setw(8)<<"工资"<<endl;
		cout<<setw(8)<<yg.number<<setw(8)<<yg.name<<setw(8)<<yg.sex<<setw(8)<<yg.age<<setw(12)<<yg.state<<setw(8)<<yg.salary<<endl;}
          else {cout<<"员工编号非工件工"<<endl;}}
		 else cout<<"输入错误编号"<<endl;
f.close();
}
class gongjiangong:public gongren//工件工类
{public:
void salary();//计算工件工工资
void print();//显示所有工件工
//件数
//单件报酬
};

void gongjiangong::print()//显示所有工件工
{yuangong yg;
	fstream f;
	f.open("yuangong.dat",ios::in|ios::out);
	f.seekg(0,ios::end);
	long pos=f.tellg();
	f.seekg(0,ios::beg);
	cout<<setw(10)<<"编号"<<setw(10)<<"姓名"<<setw(10)<<"性别"<<setw(10)<<"年龄"<<setw(15)<<"职位"<<endl;
	do
		{	f.read((char *)&yg,sizeof(yuangong)); 
			if((strcmp(yg.state,"工件工")==0))
				{	cout<<setw(10)<<yg.number<<setw(10)<<yg.name<<setw(10)<<yg.sex<<setw(10)<<yg.age<<setw(15)<<yg.state<<endl;
				}
		}while(f.tellg()!=pos);
		f.close();

}

void gongjiangong::salary()//计算工件工工资
{	yuangong yg;
	fstream f;
	float m;
	float n;
	int i;
	f.open("yuangong.dat",ios::in|ios::out);
	cout<<"请输入要计算工资的员工编号:";
	cin>>i;
	f.seekg(0,ios::end);
	long pos=f.tellg();
	f.seekg(0,ios::beg);
	do	
	{f.read((char *)&yg,sizeof(yuangong));  //搜索
	}while(yg.number!=i&&f.tellg()!=pos);
	if(yg.number==i)
	{if(strcmp(yg.state,"工件工")==0)
			
	{cout<<"请输入加工单件报酬:";
       cin>>m;

	   cout<<"请输入月累积总件数:";
	   cin>>i;
	   n=m*i;
		yg.salary=n;	
		f.seekg(-long (sizeof(yuangong)),ios::cur);
		f.write((char *)&yg,sizeof(yuangong));
		
	    cout<<setw(10)<<"编号"<<setw(8)<<"姓名"<<setw(8)<<"性别"<<setw(8)<<"年龄"<<setw(12)<<"职位"<<setw(8)<<"工资"<<endl;
		cout<<setw(10)<<yg.number<<setw(8)<<yg.name<<setw(8)<<yg.sex<<setw(8)<<yg.age<<setw(12)<<yg.state<<setw(8)<<yg.salary<<endl;}
          else {cout<<"员工编号非工件工"<<endl;}}
		 else cout<<"输入错误编号"<<endl;

f.close();}

void main()
{	int key1 ,key2;
	cout<<"你好!!Administrant!!!你是第一次登陆,请输入你的密码!!"<<endl;
start:;
		cin>>key1;
	cout<<"你好,请确认密码!!"<<endl;
	cin>>key2;
	if(key1==key2){cout<<"密码确认成功!!!"<<endl;}
	   else 
	   {cout<<"请重新输入密码!!"<<endl;
	   goto start;
	   }
	   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
	cout<<"                      员工基本信息管理及工资计算                               "<<endl;
	cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
	cout<<endl;
	cout<<endl;
a:	
	cout<<"                请选择操作:?"<<endl;
	cout<<"               1.增加员工."<<endl;
	cout<<"               2.输出全部员工基本信息."<<endl;
	cout<<"               3.查询单个员工具体信息."<<endl;
	cout<<"               4.显示所有干部基本信息."<<endl;
	cout<<"               5.显示所有工人基本信息."<<endl;
	cout<<"               6.计算员工工资."<<endl;
	cout<<"               7.退出。                   "<<endl;
	cout<<endl;
    cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
	cout<<endl;
	int a;
	cin>>a;
	switch(a){
		case 1: { cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
				cout<<endl;
					yuangong yg;
		   		yg.append();
				cout<<endl;
			
			   cout<<endl;
			   yg.display();}
			   cout<<"已增加员工"<<endl;
			   cout<<endl;
			   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
			   goto a;break;
			   
		case 2:{cout<<"***********************************************************************"<<endl;
				cout<<endl;
				yuangong yg;
				yg.display();
				cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
				goto a;break;}


        case 3:{ cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
				cout<<endl;
			   yuangong yg;
			   yg.display();
			   yg.search();
			   cout<<endl;
			   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
			   goto a;break;}

		case 4:	 { cout<<"***********************************************************************"<<endl;
				cout<<endl;
				ganbu gb;
				gb.print();
		        cout<<endl;
			   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
			   goto a;break;}
			   
		case 5:	  { cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
				   cout<<endl;
				   gongren gr;
				   gr.print();
                	cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
			   goto a;break;}		   
			   
		case 6: { cout<<"***********************************************************************"<<endl;
j:                 cout<<endl;
				   cout<<"                请选择:?"<<endl;
				   cout<<"                1.计算经理工资"<<endl;
                   cout<<"                2.计算行政人员工资"<<endl;
                   cout<<"                3.计算技术人员工资"<<endl;
                   cout<<"                4.计算工件工工资"<<endl;
                   cout<<"                5.计算钟点工工资"<<endl;
                   cout<<"                6.返回主菜单   "<<endl;
				   cout<<endl;
				
				   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
				   int k;
				  cin>>k;
				 switch (k){
				 case 1:{
					    yuangong yg;
					   yg.display();
					   cout<<endl;
					   cout<<"是经理的有:"<<endl;
				       cout<<endl;
					   jingli jl;
					   jl.print();
					   cout<<endl;
					   jl.salary();
                        
					   	cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
			           goto j; break;
					   }
				
				case 2:{
					   yuangong yg;
					   yg.display();
				       cout<<"是行政人员的有:"<<endl;
				       cout<<endl;
					   xingzhengrenyuan xj;
					   xj.print();
					   cout<<endl;
					   xj.salary();
                       	
					   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
			           goto j; break;
					   }
				
				case 3:{yuangong yg;
					   yg.display();
				       cout<<"是技术人员的有:"<<endl;
				       cout<<endl;
					   jishurenyuan js;
					   js.print();
					   cout<<endl;
					   js.salary();
                       	
					   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
					goto j;	break;
					   }

				case 4:{yuangong yg;
					   yg.display();
				       cout<<"是工件工的有:"<<endl;
				       cout<<endl;
					   gongjiangong gjg;
					   gjg.print();
					   cout<<endl;
					   gjg.salary();
                       
					   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
					goto j;break;
					   }

                case 5:{yuangong yg;
					   yg.display();
				       cout<<"是工件工的有:"<<endl;
				       cout<<endl;
					   zhongdiangong zdg;
					   zdg.print();
					   cout<<endl;
					   zdg.salary();
                       
					   cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
						goto j;break;
				
					   }

                case 6:{goto a;}
				default: cout<<"输入错误!!"<<endl;goto j;
					
				
				
				goto a;
				}
				
				
				
  case 7:return;}

		default:  cout<<"输入错误!!"<<endl;goto a;}
}











⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -