Exemplo n.º 1
0
//三级函数 of TeaStuManage
void TeaStuAdd(void)
{
	int s, again;
	Student stuNew;
	string name; long id; string Class;
	do
	{
		do
		{
			system("cls");
			cin.clear();
			cin.sync();
			
			cout<<strTeaSA1;
			cin>>name;
			cout<<strTeaSA2;
			INPUT_INT_L(id,1);
			cout<<strTeaSA3;
			cin>>Class;

			cout<<strTeaSAConfirm1<<name<<' '<<id<<' '<<Class<<' ';
			cout<<strTeaSAConfirm2<<strStuPassword<<strTeaSAConfirm3;
			
			INPUT_INT_LU(s,0,2);
		}while(s==2);
		if(s==0)	return;
		//else  (s==1)
		stuNew.SetName(name);
		stuNew.SetId(id);
		stuNew.SetClass(Class);
		stuNew.SetPassword(strStuPassword);	//初始密码

		if(data.AddStu(stuNew))
			cout<<strTeaSAS;
		else
			cout<<strTeaSAF;	//学号冲突
		INPUT_INT_LU(again,0,1);
	}while(again==1);
	return;
}
Exemplo n.º 2
0
void TeaStuChange(void)
{
	Student* student;
	long id;
	int again;
	do
	{
		system("cls");
		cin.clear();
		cin.sync();

		cout<<strTeaSC1;
		INPUT_INT_L(id,1);
		student=data.StuSearch(id);
		if(student==NULL)
			cout<<strTeaSCF;
		else
		{
			cout<<strTeaSCConfirm1<<student->GetName()<<strTeaSCConfirm2<<student->GetId();
			cout<<strTeaSCConfirm3<<student->GetClass()<<strTeaSCConfirm4;
			int i;
			INPUT_INT_LU(i,0,1);
			if(i)
			{
				string Class;
				cout<<strTeaSC2;
				cin>>Class;
				student->SetClass(Class);
				cout<<strTeaSCS;
			}
		}
		cout<<strTeaSC3;
		INPUT_INT_LU(again,0,1);
	}while(again);
	return;
}
Exemplo n.º 3
0
void StartProcess(void)
{
	fstream file("data.dat", ios_base::in);// attempt open for read
	if (!file)
	{
		// file doesn't exist; create a new one
		file.open("data.dat", ios_base::out); 
		file.close();
		return;
	}
	else //ok, file exists
	{
		int iStudent=0, iCourse=0;
		string TeaPassword;

		file>>iStudent;
		for(int i=0; i<iStudent; ++i)
		{
			Student temStu;
			string name;
			long id;
			string Class;
			string password;
			file>>name>>id>>Class>>password;
			temStu.SetName(name);
			temStu.SetId(id);
			temStu.SetClass(Class);
			temStu.SetPassword(password);

			int n;
			file>>n;
			int *cn=new int[n], *grade=new int[n];
			for(int i=0; i<n; ++i)
				file>>cn[i]>>grade[i];
			temStu.Initialize(n,cn,grade);
			delete[] cn;
			delete[] grade;

			data.AddStu(temStu);
			{}
		}
		file>>iCourse;
		for(int i=0; i<iCourse; ++i)
		{
			
			Course temCou;
			string name;
			int Number;
			int credit;
			file>>name>>Number>>credit;
			temCou.SetName(name);
			temCou.SetNumber(Number);
			temCou.SetCredit(credit);

			int n;
			file>>n;
			int *id=new int[n], *grade=new int[n];
			for(int i=0; i<n; ++i)
				file>>id[i]>>grade[i];
			temCou.Initialize(n,id,grade);
			delete[] id;
			delete[] grade;

			data.AddCou(temCou);
		}
		file>>TeaPassword;
		data.SetTeaPassword(TeaPassword);
		file.close();
	}
	return;
}