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

📄 edit.cpp

📁 程序类型:学校人员管理系统 功能:具有查找、增、删、修改等功能。
💻 CPP
字号:
//修改数据
#include<iostream.h>
#include"main.h"
#include"classes.h"
void edit()
{
	int choice;
	student st;
	teacher te;
	graduatestudent gr;
	doctor dc;
	char key[23];
	fstream f;
	f.seekp(0,ios::end);
	long posEnd=f.tellp();		//记录文件末尾位置
	cout<<"修改记录*\n";
	while(1)
	{cout<<"请键入操作选择\n"
	<<"1:修改记录\t"
	<<"0:退出\n";
	cin>>choice;
	switch(choice)
	{case 1:
	{
		fstream f;
		fstream iof("student.dat",ios::binary|ios::in|ios::out);
		f.seekp(0,ios::end);
		long posEnd=f.tellp();
		f.seekp(0,ios::beg);		//从文件头开始检索
		cout<<"编号:\n?";
		cin>>key[23];
		do
		{f.read((char*)&st,sizeof(250));
		}while(st.number!=key&&f.tellg()!=posEnd);
		if(st.number==key)
		{
			cout<<st.number
				<<'\t'<<st.idcard
				<<'\t'<<st.name
				<<'\t'<<st.sex
				<<'\t'<<st.birthday
				<<'\t'<<st.politics
				<<'\t'<<st.marriage
				<<'\t'<<st.knowledge
				<<'\t'<<st.job
				<<'\t'<<st.worktime
				<<'\t'<<st.state
				<<'\t'<<st.entertime
				<<'\t'<<st.educationalsystem 
				<<'\t'<<st.institute
				<<'\t'<<st.specialty
				<<'\t'<<st.grade
				<<'\t'<<st.theclass
				<<'\t'<<st.theclass
				<<endl;
//	cout<<"销售数量:\n?";
//修改   输入


/*	cin>>num;
			if(num>0&&book.balance>=num)	//修改库存量
				book.balance-=num;
			else
				{cout<<"数量输入错误\n";
				continue;
				}

*/
				f.seekp(-long(sizeof(250)),ios::cur);		//文件指针复位
				f.write((char*)&st,sizeof(250));		//修改文件记录
//?	cout<<"新记录"<<book.balance<<endl;
		}
		else
			cout<<"书号输入错误\n";
		iof.close();
		
		
		
		fstream iof1("teacher.dat",ios::binary|ios::in|ios::out);
		f.seekp(0,ios::end);
		posEnd=f.tellp();
		f.seekp(0,ios::beg);		//从文件头开始检索
		do
		{f.read((char*)&te,sizeof(240));
		}while(te.number!=key&&f.tellg()!=posEnd);
		if(te.number==key)
		{
			cout<<te.number
				<<'\t'<<te.idcard
				<<'\t'<<te.name
				<<'\t'<<te.sex
				<<'\t'<<te.birthday
				<<'\t'<<te.politics
				<<'\t'<<te.marriage
				<<'\t'<<te.knowledge
				<<'\t'<<te.job
				<<'\t'<<te.worktime
				<<'\t'<<te.state
				<<'\t'<<te.salary
				<<'\t'<<te.cteacher 
				<<'\t'<<te.forclass
				<<'\t'<<te.lesson
				<<endl;
//	cout<<"销售数量:\n?";
//修改   输入


/*	cin>>num;
			if(num>0&&book.balance>=num)	//修改库存量
				book.balance-=num;
			else
				{cout<<"数量输入错误\n";
				continue;
				}

*/
				f.seekp(-long(sizeof(240)),ios::cur);		//文件指针复位
				f.write((char*)&st,sizeof(240));		//修改文件记录
//?	cout<<"新记录"<<book.balance<<endl;
		}
		else
			cout<<"书号输入错误\n";
		iof1.close();
		
		
		fstream iof2("graduatestudent.dat",ios::binary|ios::in|ios::out);
		f.seekp(0,ios::end);
		posEnd=f.tellp();
		f.seekp(0,ios::beg);		//从文件头开始检索
		do
		{f.read((char*)&gr,sizeof(290));
		}while(gr.number!=key&&f.tellg()!=posEnd);
		if(gr.number==key)
		{
			cout<<gr.number
				<<'\t'<<gr.idcard
				<<'\t'<<gr.name
				<<'\t'<<gr.sex
				<<'\t'<<gr.birthday
				<<'\t'<<gr.politics
				<<'\t'<<gr.marriage
				<<'\t'<<gr.knowledge
				<<'\t'<<gr.job
				<<'\t'<<gr.worktime
				<<'\t'<<gr.state
				<<'\t'<<gr.entertime
				<<'\t'<<gr.educationalsystem 
				<<'\t'<<gr.institute
				<<'\t'<<gr.specialty
				<<'\t'<<gr.grade
				<<'\t'<<gr.theclass
				<<'\t'<<gr.cteacher
				<<'\t'<<gr.forclass
				<<'\t'<<gr.salary
				<<endl;
//	cout<<"销售数量:\n?";
//修改   输入


/*	cin>>num;
			if(num>0&&book.balance>=num)	//修改库存量
				book.balance-=num;
			else
				{cout<<"数量输入错误\n";
				continue;
				}

*/
				f.seekp(-long(sizeof(290)),ios::cur);		//文件指针复位
				f.write((char*)&st,sizeof(290));		//修改文件记录
//?	cout<<"新记录"<<book.balance<<endl;
		}
		else
			cout<<"书号输入错误\n";
		iof2.close();
		
		
		fstream iof3("doctor.dat",ios::binary|ios::in|ios::out);
		f.seekp(0,ios::end);
		posEnd=f.tellp();
		f.seekp(0,ios::beg);		//从文件头开始检索
		do
		{
			f.read((char*)&dc,sizeof(270));
		}while(dc.number!=key&&f.tellg()!=posEnd);
		if(dc.number==key)
		{cout<<dc.number
		<<'\t'<<dc.idcard
		<<'\t'<<dc.name
		<<'\t'<<dc.sex
		<<'\t'<<dc.birthday
		<<'\t'<<dc.politics
		<<'\t'<<dc.marriage
		<<'\t'<<dc.knowledge
		<<'\t'<<dc.job
		<<'\t'<<dc.worktime
		<<'\t'<<dc.state
		<<'\t'<<dc.salary
		<<'\t'<<dc.forclass 
		<<'\t'<<dc.lesson
		<<'\t'<<dc.treatment
		<<endl;
//	cout<<"销售数量:\n?";
//修改   输入


/*	cin>>num;
			if(num>0&&book.balance>=num)	//修改库存量
				book.balance-=num;
			else
				{cout<<"数量输入错误\n";
				continue;
				}

*/
		f.seekp(-long(sizeof(270)),ios::cur);		//文件指针复位
		f.write((char*)&st,sizeof(270));		//修改文件记录
//?	cout<<"新记录"<<book.balance<<endl;
		}
		else
			cout<<"书号输入错误\n";
		iof3.close();
		break;
		}
		case 0:return;
	}
}
}

⌨️ 快捷键说明

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