main.cpp的内容
代码语言:javascript复制#include"add.h"
#include
#include
#include
#include
#include
using namespace std;
void CreatAdmin();
int main()
{
char Choice;
string UserName,PassWord;
string InputUserName,InputPassWord;
ifstream fin("admin.dat",ios::in);
if(!fin)
{
cout<<"还未创建admin用户,请创建";
CreatAdmin();
fin.close();
}
fin.close();
fin.open("admin.dat",ios::in);
fin>>UserName;
fin>>PassWord;
cout<<"请输入admin用户名"<>InputUserName;
cout<<"请输入admin密码"<>InputPassWord;
if(UserName==InputUserName && InputPassWord==PassWord)
{
system("cls");
cout<<"已进入系统!"<>Choice;
while (1)
{
JusticeUsersChoice(Choice);
system("color 04");
cout<<"请选择操作n1.存入信息n2.删除信息n3.查找信息n4.遍历信息n5.修改信息"<>Choice;
}
}
else{
cout<<"用户名或者密码不正确"<>UserName;
cout<<"请输入admin密码"<>PassWord;
fout<
add.h的内容
#include
#include
#include
#include
using namespace std;
void GetUserInput();
void PrintWlecome(string UserName);
void GetUserInput();
void JusticeUsersChoice(char Choice);
void PointReadFile();
void ThroughAll();
void ReviseData();
bool DeletInfo();
void LogWrite();
class Person
{
private:
string name;
string id;
string numbers;
string address;
char sex;
string age;
double salary;
string diploma;
public:
void Set_value(string name1,string id1,string number,string address1,char sex1,double salary1,string age1,string diploma1)
{
name=name1;
id=id1;
numbers=number;
address=address1;
sex=sex1;
salary=salary1;
diploma=diploma1;
age=age1;
}
friend ofstream &operator<<(ofstream &fout,Person &a)
{
fout<>(ifstream &fin,Person &people)
{
fin>>people.id;
fin>>people.name;
fin>>people.address;
fin>>people.sex;
fin>>people.age;
fin>>people.salary;
fin>>people.diploma;
return fin;
}
};
void LogWrite(Person people,string operate)
{
SYSTEMTIME systime={0};
GetSystemTime(&systime);
ofstream fout("log.txt",ios::app);
fout<>id1>>name1>>number1>>address1>>sex1>>age1>>salary1>>diploma1;
people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
people.print();
people.Write();
LogWrite(people,"输入");
}
void JusticeUsersChoice(char Choice)
{
if(Choice=='1')
{
GetUserInput();
}
else if(Choice=='2')
{
DeletInfo();
}
else if(Choice=='3')
{
PointReadFile();
}
else if(Choice=='4')
{
ThroughAll();
}
else if(Choice=='5')
{
ReviseData();
}
else{
cout<<"好歹也要选择一个嘛"<>Choice;
if(Choice=='1')
{
cout<<"请输入id"<>FoundName;
}
else
{
cout<<"请输入学历"<>Diploma;
}
if(!fin)
{
cout<<"打开文件num.dat失败"<>id1;
fin>>name1;
fin>>number1;
fin>>address1;
fin>>sex1;
fin>>age1;
fin>>salary1;
fin>>diploma1;
people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
if(FoundName==id1)
{
break;
}
else if(Diploma==diploma1&&!fin.eof())
{
cout<<"id 名字 number 地址 性别 年龄 薪水 学历"<>FoundId;
while (point)
{
fin>>id1;
fin>>name1;
fin>>number1;
fin>>address1;
fin>>sex1;
fin>>age1;
fin>>salary1;
fin>>diploma1;
people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
point=!fin.eof();
if(point!=1)
{
break;
}
if(FoundId!=id1)
{
fout<>id1;
fin>>name1;
fin>>number1;
fin>>address1;
fin>>sex1;
fin>>age1;
fin>>salary1;
fin>>diploma1;
people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
point=!fin.eof();
if(point)
{
fout<>FoundId;
while (point)
{
fin>>id1;
fin>>name1;
fin>>number1;
fin>>address1;
fin>>sex1;
fin>>age1;
fin>>salary1;
fin>>diploma1;
people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
point=!fin.eof();
if(point!=1)
{
break;
}
if(FoundId!=id1)
{
fout<>id1>>name1>>number1>>address1>>sex1>>age1>>salary1>>diploma1;
people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
fout<>id1;
fin>>name1;
fin>>number1;
fin>>address1;
fin>>sex1;
fin>>age1;
fin>>salary1;
fin>>diploma1;
people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
point=!fin.eof();
if(point)
{
fout<>id1;
// fin>>name1;
// fin>>number1;
// fin>>address1;
// fin>>sex1;
// fin>>age1;
// fin>>salary1;
// fin>>diploma1;
fin>>people;
point=!fin.eof();
// people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
if(point!=1)
{
break;
}
cout<