/**
* @copyright 2012 Chunhui Wang
*
* wangchunhui@wangchunhui.cn
*
* 学生学籍管理系统(12.06)
*/ #include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <windows.h> using namespace std; #define M 100000
#define BACKSPACE 8 string P_No[M];
string P_name[M]; string A_ID[M];
string A_name[M];
string A_password[M];
int A_Jur[M]; string S_name[M];
string S_No[M];//学号
string S_password[M];
string s_ID[M];//身份证号 string S_address[M];
string S_Tel[M];
char S_sex[M]; string user;//当前用户名 int Jur;//权限等级 super--9 admin--1 stu--2 int welcome();
int student_login();
int admin_login();
int Smenu(int);
int Smenu_b(int);
int Smenu_c(int);
int Amenu(int);
int Amenu_b(int);
int Amenu_c(int);
int Amenu_q(); //string S_safeCHECK(string);
//string S_safeRECHECK(string);
string AZ(string);
string ZA(string); char *get_password(const char *prompt); class Pro //专业类---文件顺序 outfile<<PNo<<" "<<Pname<<" "<<endl;
{
private:
string PNo;
string Pname; public:
int Padd()
{
cout<<"请输入专业名称:";
cin>>Pname;
cin.sync();
cout<<"请输入专业代码:";
cin>>PNo;
cin.sync();
ofstream outfile("Pro..Hui3yer.dat",ios::app);//app---追加
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(0);
}
PNo = AZ(PNo);//字符串存取前
Pname = AZ(Pname);
outfile<<PNo<<" "<<Pname<<" "<<endl;
outfile.close();
}
int Pdelete()
{
int mark;
char s;
int k,i;
mark = Pshow();
if(mark==0)
{
cout<<"没有专业信息";
getchar();
return 0;
}
cout<<"请选择一个删除序号<放弃(0)>:";
cin>>k;cin.sync();
if(k==0)return 0;
cout<<"确定删除【y/n】?";
while(1)
{
cin>>s;cin.sync();
if(s=='y'||s=='Y')
{
ofstream outfile("Pro..Hui3yer.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<mark-1;i++)
{
if(i!=k-1)
{
P_No[i] = AZ(P_No[i]);
P_name[i] = AZ(P_name[i]);
outfile<<P_No[i]<<" "<<P_name[i]<<" "<<endl;
} }
outfile.close();
cout<<"删除成功!";
getchar();
return 0;
}
if(s=='n'||s=='N') return 0;
cout<<"输入有误:";
} }
int Pshow()
{
int mark,i;
ifstream infile("Pro..Hui3yer.dat",ios::in);
if(!infile)
{
cout<<"请先添加哦~亲!"<<endl;
getchar();
return 0;
}
cout<<"序号 专业代码 专业名称"<<endl;
for(i=0; !infile.eof(); i++)
{
infile>>P_No[i]>>P_name[i];
P_No[i] = ZA(P_No[i]);//字符串读取后
P_name[i] = ZA(P_name[i]);
}
mark=i;
for( i=0; i<mark-1;i++)
{
cout<<i+1<<" "<<P_No[i]<<" "<<P_name[i]<<endl;
}
infile.close();
getchar();
return mark;
}
int Psearch()
{
string temp;
int i;
ifstream infile("Pro..Hui3yer.dat",ios::in);
if(!infile)
{
cerr<<"无法查找!"<<endl;
return 0;
} //查找
cout<<"输入查找的专业代号或专业名称:";
cin>>temp; cin.sync();
for(i=0; !infile.eof(); i++)
{
infile>>P_No[i]>>P_name[i];
P_No[i] = ZA(P_No[i]);
P_name[i] = ZA(P_name[i]);
if(P_No[i]==temp)
{
cout<<"代码:"<<P_No[i]<<" 专业名:"<<P_name[i];
infile.close();
getchar();
return 0;
}
if(P_name[i]==temp)
{
cout<<"代码:"<<P_No[i]<<" 专业名:"<<P_name[i];
infile.close();
getchar();
return 0;
}
}
cout<<"查无此项!";
getchar();
infile.close();
}
int Pchange()
{
int mark;
char s;
int k,i;
mark = Pshow();
if(mark==0)
{
cout<<"专业不存在..." <<endl;
getchar();
return 0;
} cout<<"请选择一个序号进行修改<放弃修改(0)>:";
int choosemax=3;
while(i)
{
cin>>k;cin.sync();
if(k==0)
{
return 0;
}
if(k>0&&k<mark) break;
choosemax--;
if(!choosemax)
{
cout<<"WARNING!"<<endl;
getchar();
return 0;
}
cout<<"输入有误,重新输入:";
} cout<<"请输入专业名称:";
cin>>Pname;cin.sync();
cout<<"请输入专业代码:";
cin>>PNo;cin.sync();
cout<<"确定修改?【y/n】";
while(1)
{
cin>>s;cin.sync();
if(s=='y'||s=='Y')
{
ofstream outfile("Pro..Hui3yer.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<mark-1;i++)
{
if(i==k-1)
{
PNo = AZ(PNo);
Pname = AZ(Pname);
outfile<<PNo<<" "<<Pname<<" "<<endl;
}
else
{
P_No[i] = AZ(P_No[i]);
P_name[i] = AZ(P_name[i]);
outfile<<P_No[i]<<" "<<P_name[i]<<" "<<endl;
}
}
outfile.close();
cout<<"修改成功!";
getchar();
return 0;
}
if(s=='n'||s=='N') return 0;
cout<<"输入有误:";
}
}
}; class student : public Pro
{
private:
string SNo;//110405101--11:2011级,0405:计算机科学与技术专业,1:班级;07--学号
string Sname;
string Spassword;
string sID; string Saddress;
char Ssex;
string STel; public:
int Sadd()
{
cout<<"请输入学号:";cin>>SNo;cin.sync();
cout<<"请输入姓名:";cin>>Sname;cin.sync();
//cout<<"请输入姓名:";gets(Sname);cin.sync();
cout<<"请输入性别【M/F】:";cin>>Ssex;cin.sync();
cout<<"请输入密码:";cin>>Spassword;cin.sync();
//cout<<"请输入密码:";gets(Spassword);cin.sync();
cout<<"请输入身份证号:";cin>>sID;cin.sync();
cout<<"请输入电话:";cin>>STel;cin.sync();
cout<<"请输入家庭住址:";cin>>Saddress;cin.sync();
//cout<<"请输入家庭住址:";gets(Saddress);cin.sync();
ofstream outfile("stu..Hui3yer.dat",ios::app);//app---追加
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
SNo = AZ(SNo);
Sname = AZ(Sname);
Spassword = AZ(Spassword);
sID = AZ(sID);
STel = AZ(STel);
Saddress = AZ(Saddress);
outfile<<SNo<<" "<<Sname<<" "<<Ssex<<" "<<Spassword<<" "<<sID<<" "<<STel<<" "<<Saddress<<" "<<endl;
outfile.close();
}
int Sdelete()
{
int mark;
char s;
int k,i;
mark = Sshow();
if(mark == 0)
{
cout<<"请先添加哦~亲!"<<endl;
getchar();
return 0;
}
cout<<"请选择一个删除序号<放弃(0)>:";
cin>>k;cin.sync();
if(k==0) return 0;
cout<<"确定删除【y/n】?";
while(1)
{
cin>>s;cin.sync();
if(s=='y'||s=='Y')
{
ofstream outfile("stu..Hui3yer.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<mark-1;i++)
{
if(i!=k-1)
{
S_No[i] = AZ(S_No[i]);
S_name[i] = AZ(S_name[i]);
S_password[i] = AZ(S_password[i]);
s_ID[i] = AZ(s_ID[i]);
S_Tel[i] = AZ(S_Tel[i]);
S_address[i] = AZ(S_address[i]);
outfile<<S_No[i]<<" "<<S_name[i]<<" "<<S_sex[i]<<" "<<S_password[i]<<" "<<s_ID[i]<<" "<<S_Tel[i]<<" "<<S_address[i]<<" "<<endl;
} }
outfile.close();
cout<<"删除成功!";
getchar();
return 0;
}
if(s=='n'||s=='N') return 0;
cout<<"输入有误:";
} }
int Sshow()
{
int mark,i;
ifstream infile("stu..Hui3yer.dat",ios::in);//nocreat---不创建<不支持?why>
if(!infile)
{
return 0;
}
cout<<"序号 学号 姓名 性别 密码 身份证号 电话 家庭住址"<<endl;
for(i=0; !infile.eof(); i++)
{
infile>>S_No[i]>>S_name[i]>>S_sex[i]>>S_password[i]>>s_ID[i]>>S_Tel[i]>>S_address[i];
S_No[i] = ZA(S_No[i]);
S_name[i] = ZA(S_name[i]);
S_password[i] = ZA(S_password[i]);
s_ID[i] = ZA(s_ID[i]);
S_Tel[i] = ZA(S_Tel[i]);
S_address[i] = ZA(S_address[i]);
}
mark=i;
for( i=0; i<mark-1;i++)
{
cout<<i+1<<" "<<S_No[i]<<" "<<S_name[i]<<" "<<S_sex[i]<<" "<<S_password[i]<<" "<<s_ID[i]<<" "<<S_Tel[i]<<" "<<S_address[i]<<" "<<endl;
}
infile.close();
getchar();
return mark;
}
int Ssearch()
{
int Hui=0;
string temp;
int i;
ifstream infile("stu..Hui3yer.dat",ios::in);
if(!infile)
{
cerr<<"无法查找!"<<endl;
getchar();
return 0;
} //按学号查找
cout<<"输入查找的学号或姓名:";
cin>>temp; cin.sync();
for(i=0; !infile.eof(); i++)
{
infile>>S_No[i]>>S_name[i]>>S_sex[i]>>S_password[i]>>s_ID[i]>>S_Tel[i]>>S_address[i];
S_No[i] = ZA(S_No[i]);
S_name[i] = ZA(S_name[i]);
S_password[i] = ZA(S_password[i]);
s_ID[i] = ZA(s_ID[i]);
S_Tel[i] = ZA(S_Tel[i]);
S_address[i] = ZA(S_address[i]);
if(S_No[i]==temp)
{
cout<<"学号:"<<S_No[i]<<endl;
cout<<"姓名:"<<S_name[i]<<endl;
cout<<"性别:"<<S_sex[i]<<endl;
cout<<"密码:"<<S_password[i]<<endl;
cout<<"身份证号:"<<s_ID[i]<<endl;
cout<<"电话:"<<S_Tel[i]<<endl;
cout<<"家庭住址:"<<S_address[i]<<endl;
infile.close();
getchar();
return 0;
}
if(S_name[i]==temp)
{
cout<<"学号:"<<S_No[i]<<endl;
cout<<"姓名:"<<S_name[i]<<endl;
cout<<"性别:"<<S_sex[i]<<endl;
cout<<"密码:"<<S_password[i]<<endl;
cout<<"身份证号:"<<s_ID[i]<<endl;
cout<<"电话:"<<S_Tel[i]<<endl;
cout<<"家庭住址:"<<S_address[i]<<endl;
cout<<endl;
Hui=1; }
}
if(Hui)
{
getchar();
return 0;
}
cout<<"查无此项!";
getchar();
infile.close();
}
int Schange()
{
int mark;
char s;
int k,i;
mark = Sshow();
if(mark == 0)
{
cout<<"请先添加哦~亲!"<<endl;
getchar();
return 0;
}
cout<<"请选择一个序号进行修改<放弃(0)>:";
int choosemax = 3;
while(1)
{
cin>>k;cin.sync();
if(k==0) return 0;
if(k>0&&k<mark) break;
choosemax--;
if(!choosemax)
{
cout<<"WARNNING。。。";
getchar();
return 0;
}
cout<<"输入有误,请重新输入:";
} //cin>>k;cin.sync();
cout<<"请输入学号:";cin>>SNo;cin.sync();
cout<<"请输入姓名:";cin>>Sname;cin.sync();
//cout<<"请输入姓名:";gets(Sname);cin.sync();
cout<<"请输入性别【M/F】:";cin>>Ssex;cin.sync();
cout<<"请输入密码:";cin>>Spassword;cin.sync();
//cout<<"请输入密码:";gets(Spassword);cin.sync();
cout<<"请输入身份证号:";cin>>sID;cin.sync();
cout<<"请输入电话:";cin>>STel;cin.sync();
cout<<"请输入家庭住址:";cin>>Saddress;cin.sync();
//cout<<"请输入家庭住址:";gets(Saddress);cin.sync();
cout<<"确定修改?【y/n】";
while(1)
{
cin>>s;cin.sync();
if(s=='y'||s=='Y')
{
ofstream outfile("stu..Hui3yer.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<mark-1;i++)
{
if(i==k-1)
{
SNo = AZ(SNo);
Sname = AZ(Sname);
Spassword = AZ(Spassword);
sID = AZ(sID);
STel = AZ(STel);
Saddress = AZ(Saddress);
outfile<<SNo<<" "<<Sname<<" "<<Ssex<<" "<<Spassword<<" "<<sID<<" "<<STel<<" "<<Saddress<<" "<<endl;
}
else
{
S_No[i] = AZ(S_No[i]);
S_name[i] = AZ(S_name[i]);
S_password[i] = AZ(S_password[i]);
s_ID[i] = AZ(s_ID[i]);
S_Tel[i] = AZ(S_Tel[i]);
S_address[i] = AZ(S_address[i]);
outfile<<S_No[i]<<" "<<S_name[i]<<" "<<S_sex[i]<<" "<<S_password[i]<<" "<<s_ID[i]<<" "<<S_Tel[i]<<" "<<S_address[i]<<" "<<endl;
}
}
outfile.close();
cout<<"修改成功!";
getchar();
return 0;
}
if(s=='n'||s=='N') return 0;
cout<<"输入有误:";
}
}
int S_DOID(string S)
{
int j,i;
char s1[3];
char s2[5];
for(j=0;j<2;j++)
{
s1[j]=S[j];
}
s1[2]='\0';
for(j=2;j<6;j++)
{
s2[j-2]=S[j];
}
s2[4]='\0';
//cout<<S<<endl;
cout<<" 入学年份:20"<<s1<<"年 " ; ifstream infile("Pro..Hui3yer.dat",ios::in);//nocreat---不创建<不支持?why>
if(!infile)
{
cerr<<"<部分信息丢失!>"<<endl;
//getchar();
return 0;
}
for(i=0; !infile.eof(); i++)
{
infile>>P_No[i]>>P_name[i];
P_No[i] = ZA(P_No[i]);
P_name[i] = ZA(P_name[i]);
if((string)s2==P_No[i])
{
cout<<"专业:"<<P_name[i]<<endl;
infile.close();
// getchar();
return 0;
}
}
cout<<"<该学生专业信息不存在!>"<<endl;;
// getchar();
return 0;
} };
//student AD_stu;
//Pro AD_pro; class Admin : public student //管理员类
{
private:
string AID;
string Aname;
string Apassword;
int AJur;//权限 jurisdiction
//Pro Apro;
//student Astu;
public:
int Aadd()
{
int n;
cout<<"请输入管理员编号:";
cin>>AID;cin.sync();
cout<<"请输入管理员姓名(用户名):";
cin>>Aname;cin.sync();
//gets(Aname);cin.sync();
cout<<"请输入管理员用户密码:";
cin>>Apassword; cin.sync();
//gets(Apassword); cin.sync();
cout<<"请输入权限值:<Super--9 admin--1>";
cin>>AJur;cin.sync();
ofstream outfile("admin..Hui3yer.dat",ios::app);
if(!outfile)
{
cerr<<"open error!"<<endl;
getchar();
exit(1);
}
AID = AZ(AID);
Aname = AZ(Aname);
Apassword = AZ(Apassword);
//AJur = AZ(AJur);
outfile<<AID<<" "<<Aname<<" "<<Apassword<<" "<<AJur<<" "<<endl;
outfile.close();
// cout<<"请输入管理员权限等级(输入-1查看帮助):";
// cin>>n;cin.sync();
// if(n==-1)
// {
// cout<<"***********************************************"<<endl;
// cout<<"* 权限说明 *"<<endl;
// cout<<"* 1:管理员---可以查看修改删除专业及学生信息 *"<<endl;
// cout<<"* 9:super ---可以查看,修改全体学生信息 *"<<endl;
// cout<<"* ###其余无效### *"<<endl;
// cout<<"***********************************************"<<endl;
// cout<<"请选择:";
// cin>>Jur;cin.sync();
// }
// else Jur = n;
return 0;
}
int Adelete()
{
int mark;
char s;
int k,i;
mark = Ashow();
if(mark==0)
{
cout<<":( 没有添加哪里有得删呢?";
getchar();
return 0;
}
cout<<"请选择一个删除序号<放弃(0)>:";
cin>>k;cin.sync();
if(k==0) return 0;
cout<<"确定删除【y/n】?";
while(1)
{
cin>>s;cin.sync();
if(s=='y'||s=='Y')
{
ofstream outfile("admin..Hui3yer.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<mark-1;i++)
{
if(i!=k-1)
{
A_ID[i] = AZ(A_ID[i]);
A_name[i] = AZ(A_name[i]);
A_password[i] = AZ(A_password[i]);
outfile<<A_ID[i]<<" "<<A_name[i]<<" "<<A_password[i]<<" "<<A_Jur[i]<<" "<<endl;
} }
outfile.close();
cout<<"删除成功!";
getchar();
return 0;
}
if(s=='n'||s=='N') return 0;
cout<<"输入有误:";
} }
int Ashow()
{
int mark,i;
ifstream infile("admin..Hui3yer.dat",ios::in);
if(!infile)
{
getchar();
return 0;
}
cout<<"序号 ID 姓名 密码 权限"<<endl;
for(i=0; !infile.eof(); i++)
{
infile>>A_ID[i]>>A_name[i]>>A_password[i]>>A_Jur[i];
A_ID[i] = ZA(A_ID[i]);
A_name[i] = ZA(A_name[i]);
A_password[i] = ZA(A_password[i]);
}
mark=i;
for( i=0; i<mark-1;i++)
{
cout<<i+1<<" "<<A_ID[i]<<" "<<A_name[i]<<" "<<A_password[i]<<" "<<A_Jur[i]<<" "<<endl;
}
infile.close();
getchar();
return mark;
}
int Asearch()
{
string temp;
int i;
ifstream infile("admin..Hui3yer.dat",ios::in);
if(!infile)
{
cerr<<"无法查找!"<<endl;
getchar();
return 0;
} //按 XXX查找
cout<<"输入查找的ID:";
cin>>temp; cin.sync();
for(i=0; !infile.eof(); i++)
{
infile>>A_ID[i]>>A_name[i]>>A_password[i]>>A_Jur[i];
A_ID[i] = ZA(A_ID[i]);
A_name[i] = ZA(A_name[i]);
A_password[i] = ZA(A_password[i]);
if(A_ID[i]==temp)
{
cout<<"ID:"<<A_ID[i]<<endl;
cout<<"姓名:"<<A_name[i]<<endl;
cout<<"密码:"<<A_password[i]<<endl;
cout<<"权限:"<<A_Jur[i]<<endl;
infile.close();
getchar();
return 0;
}
}
cout<<"查无此项!";
getchar();
infile.close();
}
int Achange()
{
int mark;
char s;
int k,i;
mark = Ashow();
if(mark == 0)
{
cout<<"请先添加哦~亲!"<<endl;
getchar();
return 0;
}
cout<<"请选择一个序号进行修改<放弃(0)>:";
int choosemax = 5;
while(1)
{
cin>>k;cin.sync();
if(k==0) break;
if(k>0&&k<mark) break;
choosemax--;
if(!choosemax)
{
cout<<"WARNNING。。。";
getchar();
return 0;
}
cout<<"输入有误,请重新输入:";
} cout<<"请输入管理员编号:";
cin>>AID;cin.sync();
//gets(AID);cin.sync();
cout<<"请输入管理员姓名(用户名):";
cin>>Aname;cin.sync();
//gets(Aname);cin.sync();
cout<<"请输入管理员用户密码:";
cin>>Apassword; cin.sync();
//gets(Apassword); cin.sync();
cout<<"请输入权限值:";cin>>AJur;cin.sync();
cout<<"确定修改?【y/n】";
while(1)
{
cin>>s;cin.sync();
if(s=='y'||s=='Y')
{
ofstream outfile("admin..Hui3yer.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<mark-1;i++)
{
if(i=k-1)
{
AID = AZ(AID);
Aname = AZ(Aname);
Apassword = AZ(Apassword);
outfile<<AID<<" "<<Aname<<" "<<Apassword<<" "<<AJur<<" "<<endl;
}
else
{
A_ID[i] = AZ(A_ID[i]);
A_name[i] = AZ(A_name[i]);
A_password[i] = AZ(A_password[i]);
outfile<<A_ID[i]<<" "<<A_name[i]<<" "<<A_password[i]<<" "<<A_Jur[i]<<" "<<endl;
}
}
outfile.close();
cout<<"修改成功!";
getchar();
return 0;
}
if(s=='n'||s=='N') return 0;
cout<<"输入有误:";
}
}
}; int welcome()//主界面 --界面模版
{
char n;
int Mark;
while(1)
{
system("cls");
Mark=1;
cout<<"**********************************************************************"<<endl;
cout<<"* *"<<endl;
cout<<"* ★Hui3yer学生多功能管理系统★ *"<<endl;
cout<<"* 用户类型选择 *"<<endl;
cout<<"**********************************************************************"<<endl;
cout<<"* *"<<endl;
cout<<"* 请选择您的用户类型 *"<<endl;
cout<<"* *"<<endl;
cout<<"* 用户类型 请输入 *"<<endl;
cout<<"* *"<<endl;
cout<<"* ◆ 学生 1 *"<<endl;
cout<<"* *"<<endl;
cout<<"* ◆ 管理员 2 *"<<endl;
cout<<"* *"<<endl;
cout<<"* *"<<endl;
cout<<"* ● 退出管理系统 0 *"<<endl;
cout<<"* *"<<endl;
cout<<"**********************************************************************"<<endl;
cout<<"请选择功能:";
while(Mark)
{
cin>>n;cin.sync();
//if(n!=int(n)) n=-1;
switch(n)
{
case '1': Smenu(student_login());Mark=0;break;
case '2': Amenu(admin_login());Mark=0;break;
case '0': exit(0);
default : cout<<"\n输入有误,请重新输入:";
}
}
}
return 0;
} int student_login()
{
int i;
string password;
system("cls");
ifstream infile("stu..Hui3yer.dat",ios::in);
if(!infile)
{
cerr<<"\n\n\n\n\n\n 系统未开放使用!";
getchar();
exit(1);
}
infile.close();
cout<<"\n\n\n"<<endl;
cout<<" ***********************************"<<endl;
cout<<" * *"<<endl;
cout<<" * ★Hui3yer学生多功能管理系统★ *"<<endl;
cout<<" * 用户登录 *"<<endl;
cout<<" ***********************************"<<endl;
while(1)
{
cout<<"\n 用户名<学号>:";
cin>>user;cin.sync();
cout<<" 密码: ";
cin>>password;cin.sync();
ifstream infile("stu..Hui3yer.dat",ios::in);
for(i=0;!infile.eof();i++)
{
infile>>S_No[i]>>S_name[i]>>S_sex[i]>>S_password[i]>>s_ID[i]>>S_Tel[i]>>S_address[i];
S_No[i] = ZA(S_No[i]);
S_name[i] = ZA(S_name[i]);
S_password[i] = ZA(S_password[i]);
s_ID[i] = ZA(s_ID[i]);
S_Tel[i] = ZA(S_Tel[i]);
S_address[i] = ZA(S_address[i]);
if(user ==S_No[i] &&password == S_password[i])
{
cout<<"\n 登录成功...";
getchar();
return i;
}
}
cout<<"\n 用户名或密码错误...";
getchar(); infile.close();
}
} int admin_login()
{
int i;
string password;
system("cls");
cout<<"\n\n\n"<<endl;
cout<<" **********************************"<<endl;
cout<<" * *"<<endl;
cout<<" * ★Hui3yer学生多功能管理系统★ *"<<endl;
cout<<" * 管理员用户登录 *"<<endl;
cout<<" ***********************************"<<endl; ifstream infile("admin..Hui3yer.dat",ios::in);
if(!infile)
{
cout<<"\n 超级用户:";
cin>>user; cin.sync();
if(user=="admin")
{
i=3;
cout<<" 超级密码:";
while(i)
{
cin>>password;cin.sync();
//密码隐藏*************
//char *H_password;
//H_password = get_password( "" );
//*********************
if(password == "admin")
{
password="admin";
Jur=9;
cout<<"\n 登录已成功!";
getchar();
return 1;
}
else
{
i--;
cout<<"\n 密码错误请重新输入:";cin.sync();
}
}
system("cls");
cerr<<"\n\n\n\n\n\n 密码输入错误次数过多强制退出...";
getchar();
exit(1);
}
else
{
system("cls");
cerr<<"\n\n\n\n\n\n 无权限使用...";
getchar();
exit(1);
}
}
else
{
infile.close();
while(1)
{
user = "";
password = "";
cout<<"\n 用户名:";
cin>>user;cin.sync();
cout<<" 密码: ";
cin>>password;cin.sync();
ifstream infile("admin..Hui3yer.dat",ios::in);
for(i=0;!infile.eof();i++)
{
infile>>A_ID[i]; //A_ID[i] = ZA(A_ID[i]);
infile>>A_name[i]; //A_name[i] = ZA(A_name[i]);
infile>>A_password[i]; //A_password[i] = ZA(A_password[i]);
infile>>A_Jur[i];
if(user == A_name[i]&&password == A_password[i])
{
Jur=A_Jur[i];
cout<<"\n 登录成功...";
getchar();
infile.close();
return i;
}
}
cout<<"\n 用户名或密码错误...";
getchar();
}
}
return 0;
} int Smenu(int a)
{
char n;
int Mark;
int i;
int mark;
while(1)
{
system("cls");
student ST_stu;
//Pro ST_pro;
Mark=1;
cout<<"**********************************************************************"<<endl;
cout<<"* *"<<endl;
cout<<"* ★Hui3yer学生多功能管理系统★ *"<<endl;
cout<<"* 用户:"<<setw(10)<<user<<" *"<<endl;
cout<<"**********************************************************************"<<endl;
cout<<"* *"<<endl;
cout<<"* 请选择 *"<<endl;
cout<<"* *"<<endl;
cout<<"* ┌--------------------- 学生功能窗 --------------------------┐*"<<endl;
cout<<"* | | *"<<endl;
cout<<"* |◆查看个人信息 a ◆修改密码 c | *"<<endl;
cout<<"* |◆修改个人信息 b ◆学籍信息 d | *"<<endl;
cout<<"* └---------------------------------------------------------------┘*"<<endl;
cout<<"* *"<<endl;
cout<<"* ● 退出管理系统 0 *"<<endl;
cout<<"* *"<<endl;
cout<<"**********************************************************************"<<endl;
cout<<"请选择功能:";
while(Mark)
{
cin>>n;cin.sync();
switch(n)
{
case 'a': cout<<"学号:"<<S_No[a]<<endl;
cout<<"姓名:"<<S_name[a]<<endl;
cout<<"性别:"<<S_sex[a]<<endl;
//cout<<"密码:"<<S_password[a]<<endl;
cout<<"身份证号:"<<s_ID[a]<<endl;
cout<<"电话:"<<S_Tel[a]<<endl;
cout<<"家庭住址:"<<S_address[a]<<endl;
getchar();
Mark=0;break; case 'b': cout<<"~~~~~~~~~~~~~原始数据~~~~~~~~~~~~\n"<<endl;
cout<<"学号:"<<S_No[a]<<endl;
cout<<"姓名:"<<S_name[a]<<endl;
cout<<"性别:"<<S_sex[a]<<endl;
//cout<<"密码:"<<S_password[a]<<endl;
cout<<"身份证号:"<<s_ID[a]<<endl;
cout<<"电话:"<<S_Tel[a]<<endl;
cout<<"家庭住址:"<<S_address[a]<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"<<endl;
cout<<"是否修改【Y/N】?";
char z;
while(1)
{
cin>>z;cin.sync();
if(z=='Y'||z=='y')
{
Smenu_b(a);Mark=0;break;
}
else if(z=='N'||z=='n')
{
Mark=0;break;
}
}
break; case 'c': Smenu_c(a);Mark=0;break;
case 'd': ST_stu.S_DOID(S_No[a]);getchar();Mark=0;break;
case '0': exit(0);
default : cout<<"\n输入有误,请重新输入:";
}
}
}
return 0;
} int Smenu_b(int a)
{
int i,mark;
ifstream infile("stu..Hui3yer.dat",ios::in);
for(i=0;!infile.eof();i++)
{
infile>>S_No[i]>>S_name[i]>>S_sex[i]>>S_password[i]>>s_ID[i]>>S_Tel[i]>>S_address[i];
S_No[i] = ZA(S_No[i]);
S_name[i] = ZA(S_name[i]);
S_password[i] = ZA(S_password[i]);
s_ID[i] = ZA(s_ID[i]);
S_Tel[i] = ZA(S_Tel[i]);
S_address[i] = ZA(S_address[i]);
}
mark=i;
infile.close();
cout<<"请输入学号:";cin>>S_No[a];cin.sync();
cout<<"请输入姓名:";
cin>>S_name[a];cin.sync();
//gets(S_name[a]);cin.sync();
cout<<"请输入性别【M/F】:";cin>>S_sex[a];cin.sync();
cout<<"请输入身份证号:";cin>>s_ID[a];cin.sync();
cout<<"请输入电话:";cin>>S_Tel[a];cin.sync();
cout<<"请输入家庭住址:";
cin>>S_address[a];cin.sync();
//gets(S_address[a]);cin.sync(); ofstream outfile("stu..Hui3yer.dat",ios::out);
for(i=0;i<mark-1;i++)
{
S_No[i] = AZ(S_No[i]);
S_name[i] = AZ(S_name[i]);
S_password[i] = AZ(S_password[i]);
s_ID[i] = AZ(s_ID[i]);
S_Tel[i] = AZ(S_Tel[i]);
S_address[i] = AZ(S_address[i]);
outfile<<S_No[i]<<" "<<S_name[i]<<" "<<S_sex[i]<<" "<<S_password[i]<<" "<<s_ID[i]<<" "<<S_Tel[i]<<" "<<S_address[i]<<" "<<endl;
}
outfile.close();
return 0;
} int Smenu_c(int a)
{
int i,mark;
ifstream infile("stu..Hui3yer.dat",ios::in);
for(i=0;!infile.eof();i++)
{
infile>>S_No[i]>>S_name[i]>>S_sex[i]>>S_password[i]>>s_ID[i]>>S_Tel[i]>>S_address[i];
S_No[i] = ZA(S_No[i]);
S_name[i] = ZA(S_name[i]);
S_password[i] = ZA(S_password[i]);
s_ID[i] = ZA(s_ID[i]);
S_Tel[i] = ZA(S_Tel[i]);
S_address[i] = ZA(S_address[i]);
}
mark=i;
infile.close();
cout<<"请输入新密码:";
cin>>S_password[a];cin.sync();
//gets(S_password[a]);cin.sync();
ofstream outfile("stu..Hui3yer.dat",ios::out);
for(i=0;i<mark-1;i++)
{
S_No[i] = AZ(S_No[i]);
S_name[i] = AZ(S_name[i]);
S_password[i] = AZ(S_password[i]);
s_ID[i] = AZ(s_ID[i]);
S_Tel[i] = AZ(S_Tel[i]);
S_address[i] = AZ(S_address[i]);
outfile<<S_No[i]<<" "<<S_name[i]<<" "<<S_sex[i]<<" "<<S_password[i]<<" "<<s_ID[i]<<" "<<S_Tel[i]<<" "<<S_address[i]<<" "<<endl;
}
outfile.close();
return 0;
} int Amenu(int a)
{
system("MAX");
char n;
int Mark;
while(1)
{
system("cls");
//student AD_stu;
//Pro AD_pro;
Admin AD_admin;
Mark=1;
cout<<"**********************************************************************"<<endl;
cout<<"* *"<<endl;
cout<<"* ★Hui3yer学生多功能管理系统★ *"<<endl;
cout<<"* 用户:"<<setw(10)<<user<<" *"<<endl;
cout<<"**********************************************************************"<<endl;
cout<<"* *"<<endl;
cout<<"* 请选择 *"<<endl;
cout<<"* *"<<endl;
cout<<"* 功能名 请输入 功能名 请输入 *"<<endl;
cout<<"* ◆ 添加专业信息 1 ◆ 添加学生信息 6 *"<<endl;
cout<<"* ◆ 删除专业信息 2 ◆ 删除学生信息 7 *"<<endl;
cout<<"* ◆ 修改专业信息 3 ◆ 修改学生信息 8 *"<<endl;
cout<<"* ◆ 查找专业信息 4 ◆ 查找学生信息 9 *"<<endl;
cout<<"* ◆ 显示专业信息 5 ◆ 显示学生信息 s *"<<endl;
cout<<"* ◆ 显示学生学籍 q *"<<endl;
cout<<"* ┌-------------- 以下选项仅适用于Super管理员 ----------------┐*"<<endl;
cout<<"* | | *"<<endl;
cout<<"* |◆ 添加管理员 A ◆ 修改管理员 D | *"<<endl;
cout<<"* |◆ 删除管理员 B ◆ 查找管理员 E | *"<<endl;
cout<<"* |◆ 显示管理员 C | *"<<endl;
cout<<"* └---------------------------------------------------------------┘*"<<endl;
cout<<"* ┌--------------- 以下选项仅适用于普通管理员 ----------------┐*"<<endl;
cout<<"* | | *"<<endl;
cout<<"* |◆查看个人信息 a ◆修改密码 c | *"<<endl;
cout<<"* |◆修改个人信息 b | *"<<endl;
cout<<"* └---------------------------------------------------------------┘*"<<endl;
cout<<"* *"<<endl;
cout<<"* ● 退出管理系统 0 *"<<endl;
cout<<"* *"<<endl;
cout<<"**********************************************************************"<<endl;
cout<<"请选择功能:";
while(Mark)
{
cin>>n;cin.sync();
//if(n!=int(n)) n=-1;
switch(n)
{
case '1': AD_admin.Padd();Mark=0;break;
case '2': AD_admin.Pdelete();Mark=0;break;
case '3': AD_admin.Pchange();Mark=0;break;
case '4': AD_admin.Psearch();Mark=0;break;
case '5': AD_admin.Pshow();Mark=0;break;
case '6': AD_admin.Sadd();Mark=0;break;
case '7': AD_admin.Sdelete();Mark=0;break;
case '8': AD_admin.Schange();Mark=0;break;
case '9': AD_admin.Ssearch();Mark=0;break;
case 's': AD_admin.Sshow();Mark=0;break;
case 'q': Amenu_q();Mark=0;break; case 'A': AD_admin.Aadd();Mark=0;break;
case 'B': AD_admin.Adelete();Mark=0;break;
case 'C': AD_admin.Ashow();Mark=0;break;
case 'D': AD_admin.Achange();Mark=0;break;
case 'E': AD_admin.Asearch();Mark=0;break; case 'a': if(user=="admin")
{
cout<<"该选项不适用于超级管理员用户"<<endl;
getchar();
Mark=0;break;
}
cout<<"管理员ID:"<<A_ID[a]<<endl;
cout<<"管理员姓名:"<<A_name[a]<<endl;
//cout<<"密码:"<<A_password[a]<<endl;
cout<<"权限:"<<A_Jur[a]<<endl;
getchar();
Mark=0;break;
case 'b': Amenu_b(a);Mark=0;break;
case 'c': Amenu_c(a);Mark=0;break;
case '0': exit(0);
default : cout<<"\n输入有误,请重新输入:";
}
}
}
return 0;
} int Amenu_q()
{
student ST_stu;
int i,mark;
ifstream infile("stu..Hui3yer.dat",ios::in);
if(!infile)
{
cout<<"没有学生。。。"<<endl;getchar();
return 0;
}
for(i=0;!infile.eof();i++)
{
infile>>S_No[i]>>S_name[i]>>S_sex[i]>>S_password[i]>>s_ID[i]>>S_Tel[i]>>S_address[i];
S_No[i] = ZA(S_No[i]);
S_name[i] = ZA(S_name[i]);
S_password[i] = ZA(S_password[i]);
s_ID[i] = ZA(s_ID[i]);
S_Tel[i] = ZA(S_Tel[i]);
S_address[i] = ZA(S_address[i]);
}
mark=i;
for(i=0;i<mark-1;i++)
{
cout<<"序号:"<<i+1<<"学号"<<S_No[i]<<" 姓名:"<< S_name[i] ;
ST_stu.S_DOID(S_No[i]);
}
infile.close();
getwchar();
} int Amenu_b(int a)
{
int i,mark;
ifstream infile("admin..Hui3yer.dat",ios::in);
if(!infile)
{
cout<<"超级管理员无法修改!";
getchar();
return 0;
}
for(i=0;!infile.eof();i++)
{
infile>>A_ID[i]>>A_name[i]>>A_password[i]>>A_Jur[i];
A_ID[i] = ZA(A_ID[i]);
A_name[i] = ZA(A_name[i]);
A_password[i] = ZA(A_password[i]);
}
mark=i;
infile.close();
cout<<"请输入ID:";cin>>A_ID[a];cin.sync();
cout<<"请输入姓名:";
cin>>A_name[a];cin.sync();
//gets(A_name[a]);cin.sync();
//cout<<"请输入密码:";A_password[i];cin.sync();
cout<<"请输入权限:";A_Jur[i];cin.sync();
ofstream outfile("admin..Hui3yer.dat",ios::out);
for(i=0;i<mark-1;i++)
{
A_ID[i] = AZ(A_ID[i]);
A_name[i] = AZ(A_name[i]);
A_password[i] = AZ(A_password[i]);
outfile<<A_ID[i]<<" "<<A_name[i]<<" "<<A_password[i]<<" "<<A_Jur[i]<<" "<<endl;
}
outfile.close();
return 0;
} int Amenu_c(int a)
{
int i,mark;
ifstream infile("admin..Hui3yer.dat",ios::in);
if(!infile)
{
cout<<"超级管理员无法修改!";
getchar();
return 0;
}
for(i=0;!infile.eof();i++)
{
infile>>A_ID[i]>>A_name[i]>>A_password[i]>>A_Jur[i];
A_ID[i] = ZA(A_ID[i]);
A_name[i] = ZA(A_name[i]);
A_password[i] = ZA(A_password[i]);
}
mark=i;
infile.close();
cout<<"请输入新密码:";
cin>>A_password[a];cin.sync();
//gets(A_password[a]);cin.sync();
ofstream outfile("admin..Hui3yer.dat",ios::out);
for(i=0;i<mark-1;i++)
{
A_ID[i] = AZ(A_ID[i]);
A_name[i] = AZ(A_name[i]);
A_password[i] = AZ(A_password[i]);
outfile<<A_ID[i]<<" "<<A_name[i]<<" "<<A_password[i]<<" "<<A_Jur[i]<<" "<<endl;
}
outfile.close();
return 0;
} int main()
{
system("color 0E ");
welcome();
return 0;
} /*
system("color XX ");
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 A = 淡绿色
3 = 湖蓝色 B = 淡浅绿色
4 = 红色 C = 淡红色
5 = 紫色 D = 淡紫色
6 = 黄色 E = 淡黄色
7 = 白色 F = 亮白色 */ //用于解决字符串问题* NO! string AZ(string s)//字符串存取前
{
int len;
len = s.length();
for(int i=0; i<len; i++)
{
if(s[i]==' ')
s[i]='$';
}
return (string)s;
} string ZA(string s)//字符串读取后
{
int len;
len = s.length();
for(int i=0; i<len; i++)
{
if(s[i]=='$')
s[i]=' ';
}
return (string)s;
} char *get_password(const char *prompt) //密码隐藏 NO
{
static char buffer[128];
int i = 0;
char letter=NULL;
printf( prompt );
while ( ( i < 127 ) && ( letter!='\r' ) )
{
letter = getch();
if ( letter == BACKSPACE )
{
if( i > 0 )
{
buffer[ --i ] = NULL;
putchar( BACKSPACE );
putchar( ' ' );
putchar( BACKSPACE );
}
else
putchar( 7 );
}
else if ( letter != '\r' )
{
buffer[ i++ ] = letter;
putchar( '*' );
}
}
buffer[i] = '\0';
return buffer;
} /*
system("clor XX ");
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 A = 淡绿色
3 = 湖蓝色 B = 淡浅绿色
4 = 红色 C = 淡红色
5 = 紫色 D = 淡紫色
6 = 黄色 E = 淡黄色
7 = 白色 F = 亮白色 */ int NO()
{
int i;
string password;
system("cls");
cout<<"\n\n\n"<<endl;
cout<<" **********************************"<<endl;
cout<<" * *"<<endl;
cout<<" * ★Hui3yer学生多功能管理系统★ *"<<endl;
cout<<" * *"<<endl;
cout<<" ***********************************"<<endl<<endl<<endl;
cout<<" 没有权限!!! "<<endl<<endl<<endl;
getwchar();
return 0;
}

  

[C语言练习]学生学籍管理系统的更多相关文章

  1. 【C】C语言大作业——学生学籍管理系统

    文章目录 学生管理系统 界面 主界面 登陆界面 注册界面 管理界面 学生界面 退出界面 链接 注意 学生管理系统 学C语言时写的一个大作业,弄了一个带图形界面的,使用的是VS配合EasyX图形库进行实 ...

  2. “石家庄铁道大学软件工程系学生学籍管理系统2019版”java小程序制作分享

    首先附上完整代码: import java.util.Scanner; public class SocreInformation { public SocreInformation(){}; pub ...

  3. Java 石家庄铁道大学软件工程系 学生学籍管理系统 2019 版

    本系统的作用是简单实现一些学生成绩管理操作:录入,修改,绩点计算,以及系统退出等. 首先建一个主函数实现界面的实现,然后建一个数据类用来定义存放数据.之后建立一个工具类,用来实现所有要进行的操作.首先 ...

  4. Qt实现学生学籍管理系统(文件存储)

    记录 19:53 2019-07-30 在小学期学c++做完课设后萌生了把写完的课设放在博客上的想法,于是,我第一篇博客诞生了. 22:32:19 2019-07-30 下棋 16:04:56 201 ...

  5. C++实现控制台学生学籍管理系统

    操作流程 创建文件 创建管理类 ​ 管理类负责的内容如下: 提供与用户的沟通菜单界面 实现对职工增删改查的操作 数组数据与文件的读写交互 菜单功能实现 在StudentManager.h中定义Show ...

  6. 【C语言期末实训】学生学籍管理系统

    目录: 一,设计要求 ,总体要求: ,具体功能: 二,设计框架 三,程序代码 ,声明函数和头文件 ,声明结构体 ,声明全局变量 ,主体启动函数 ,主菜单函数 ,创建学生档案函数 ,编辑学生档案函数 , ...

  7. C语言练习-学生信息管理系统

    题目要求: 学生信息管理系统struct studentInfo{ int id; char name[128]; int age; char sex; int c_score; int cpp_sc ...

  8. C语言实现---学生成绩管理系统

    C语言实现了学生成绩管理系统,可以进行学生成绩的增加,删除,更新,查询,计算和展示. 完整代码如下: #include<stdio.h> #include<stdlib.h> ...

  9. 《C语言编写 学生成绩管理系统》

    /* (程序头部凝视開始) * 程序的版权和版本号声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名: 学生成绩管理 ...

随机推荐

  1. 蓝桥杯D1

    整数因式分解的问题.了解了一下筛法计算素数的算法.之前都是直接跑的sqrt(n)... 上方的genPrime()即筛法.大致意思是开一个标识数组,通过循环,下标为合数的位置置为false. #inc ...

  2. SQL Cast()函数

    sql cast()函数 2010-09-17 13:30:26| 分类: Sql | 标签:sql case() 函数 |字号大中小 订阅 (1).CAST()函数的参数是一个表达式,它包括用AS关 ...

  3. Struts2 初体验

    Sturts是一款优雅的,可扩展性很强的框架.它是由Struts开发团队和WebWord团队合作,共同开发的一个新的产品.新版本的Struts2 更加容易使用,更加接近Struts所追求的理念.从开发 ...

  4. static和extern关键字 对变量的作用

    本文目录 • 一.在Java中,全局变量的定义没有严格的位置规定 • 二.在C语言中,全局变量定义的位置是有限制的 • 三.重复定义同一个变量 • 四.不同源文件中的同名变量 • 五.static关键 ...

  5. Request和Response详解

    转自:http://zhidao.baidu.com/link?url=8BI0cjlcFdBSJKHTZlpo874eqtbTJoZfrh3miQgM_05RvSER8skPiBc1wSPZtXT8 ...

  6. poj1323--贪心算法

    题意:一群人打牌包括你,每人出一张牌,谁最大,谁就算赢一局,问你最少能赢几局? 给出人数N,每人的牌数M,及你的牌. 分析:1.这题需比较大小,就像我们打牌时要将牌排序以便出牌,显然要先将手上的牌进行 ...

  7. Python核心编程读笔 4

    第五章 数字 二.整形 1 布尔型 2 标准整数类型 3 长整型 数字后面加L,能表示非常非常大的数字 目前,整形和长整型逐渐统一!!! 三.双精度浮点数 四.复数 有关复数的几个概念: 表示虚数的语 ...

  8. java获得平台相关的行分隔符和java路径分隔符的方法

    System.getProperties(): 行分隔符在windows 下是 \r\n,在Linux下面是 \n, 在Mac下是 \r路径分隔符在windows下是 \ ,在LInux下是 / Sy ...

  9. APP分享抓取网页图片

    var getShareImages = { defaultimg:"defaultimg.png", _allImgs:null, init:function(){ getSha ...

  10. Thinkphp的时间判断

    在做项目的过程中,非常频繁地遇到时间这个问题,像时间的比较,特定时间执行某一操作,但是现在只解决了一部分问题,先说明一下时间的判断问题. 很简单,时间,不断使date(),now(),都是字符串类型的 ...