#include<iostream.h>
#include<stdlib.h>
#include<fstream.h>
#include<string.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
/*卡类/
class Card{
private:
char name[15];
char sex[3];
char code[10];
char id[10];
char money[15];
char tag[3];//----------------一个有用的变量
char enable[3];//-----------------int
char expense[15];//----------余额还是。。。
public:
void disp(){
cout<<“姓名:”<<name<<endl;
cout<<“性别:”<<sex<<endl;
cout<<“卡号:”<<id<<endl;
cout<<“金额:”<<money<<endl;
}
void setinfo(){
char code1[10];
int i=0;
cout<<“输入姓名:”;
cin>>name;
cout<<“输入性别:”;
cin>>sex;
cout<<“输入卡号:”;
cin>>id;
strcpy(enable,“1”);//------------------可以改下
strcpy(money,“0”);
strcpy(expense,“0”);
while(1){
if(i)
cout<<“请重新输入密码::”;
else
cout<<“请输入密码::”;
cin>>code;
cout<<“请再输一次:”;
cin>>code1;
if(!strcmp(code1,code))
break;
else cout<<“对不起,两次输入的密码不一样!”<<endl;
}
}
char *getname(){
return name;
}
char *getsex(){
return sex;
}
char *getid(){
return id;
}
char *getcode(){
return code;
}
char *getmoney(){
return money;
}
char *getexpence(){
return expense;
}
};
class Studentcard:public Card{
private:
char major[25];
public:
void disp(){
Card::disp();
cout<<“学生卡信息:”<<endl;
cout<<“专业:”<<major<<endl;
}
void setinfo(){
Card::setinfo();
cout<<“请输入专业:”;
cin>>major;
}
char *getmajor(){
return major;
}
char *gettype(){
return “S”;
}
};
class Teachercard:public Card{
private:
char academy[25];
public:
void disp(){
cout<<“教师卡信息:”<<endl;
Card::disp();
cout<<“学院:”<<academy;
}
void setinfo(){
Card::setinfo();
cout<<“输入专业:”;
cin>>academy;
}
char getacademy(){
return academy;
}
char gettype(){
return “T”;
}
};
struct cardst{
char name[15];
char sex[3];
char code[10];
char id[10];
char money[15];
char c[3];
char enable[3];//--------------------------改为int型的即可。。。
char type[25];
char expense[15];
};
/user function/
void Szhuce(Studentcard &stu){
cardst card;
ofstream ofile(“card.txt”,ios::app);
char tag=‘n’,c=’ ‘,ch1[2];
int i;
system(“cls”);
cout<<"***********************************************************\n"<<endl;
cout<<"-------------------------学生卡注册------------------------\n\n";
while(tag==‘n’||tag==‘N’){
stu.setinfo();
ifstream ifile(“card.txt”,ios::in);
while(!ifile.eof()){
ifile.getline(card.name,15,’ ‘);
ifile.getline(card.sex,6,’ ‘);
ifile.getline(card.code,10,’ ‘);
ifile.getline(card.id,10,’ ‘);
ifile.getline(card.money,15,’ ‘);
ifile.getline(card.expense,16,’ ‘);
ifile.getline(card.c,6,’ ‘);
ifile.getline(card.type,25,’ ‘);
ifile.getline(card.enable,6,’ ‘);
ifile.getline(ch1,6,’\n’);
if(!strcmp(card.id,stu.getid())){
cout<<“对不起,你的卡号已被注册,请输入其它卡号!”<<endl;
cout<<“按任意键继续…”;
getch();
ifile.close();
ofile.close();
return;
}
}
cout<<“是否确认保存信息-----是y 否n-----”;
cout<<" 请选择:";
cin>>tag;
while(tag!=‘y’&&tag!=‘Y’&&tag!=‘n’&&tag!=‘N’){
cout<<“请输入正确的选择:”;
cin>>tag;
}
if(tag==‘y’||tag==‘Y’){
ofile<<stu.getname()<<c<<stu.getsex()<<c<<stu.getcode()<<c<<stu.getid()<<c<<stu.getmoney()<<c<<stu.getexpence()<<c<<“S”<<c<<stu.getmajor()<<c<<“1”<<c<<’\n’;
cout<<“Registration successful!”<<endl;
}
else{
cout<<“注册失败!”<<endl;
cout<<“按任意键继续…\n”;
getch();
return;
}
}
cout<<“输入任意键继续…\n”;
getch();
ofile.close();
}
void Szhuce(Teachercard &t){
cardst p;
ofstream ofile(“card.txt”,ios::app);
char tag=‘n’,c=’ ',ch1[2];
int i;
system(“cls”);
cout<<“\n"<<endl;
cout<<"-------------------------教师卡注册------------------------\n\n";
while(tag==‘n’||tag==‘N’){
t.setinfo();
ifstream ifile(“card.txt”,ios::in);
while(!ifile.eof()){
ifile.getline(p.name,15,’ ‘);
ifile.getline(p.sex,6,’ ‘);
ifile.getline(p.code,10,’ ‘);
ifile.getline(p.id,10,’ ‘);
ifile.getline(p.money,15,’ ‘);
ifile.getline(p.expense,16,’ ‘);
ifile.getline(p.c,6,’ ‘);
ifile.getline(p.type,25,’ ‘);
ifile.getline(p.enable,6,’ ‘);
ifile.getline(ch1,6,’\n’);
if(!strcmp(p.id,t.getid())){
cout<<“对不起,你的卡号已被注册,请输入其它卡号!”<<endl;
cout<<“按任意键继续…”;
getch();
ifile.close();
ofile.close();
return;
}
}
cout<<“是否确认保存信息-----是y 否n-----”;
cout<<" 请选择:";
cin>>tag;
while(tag!=‘y’&&tag!=‘Y’&&tag!=‘n’&&tag!=‘N’)
cin>>tag;
if(tag==‘y’||tag==‘Y’){
ofile<<t.getname()<<c<<t.getsex()<<c<<t.getcode()<<c<<t.getid()<<c<<t.getmoney()<<c<<t.getexpence()<<c<<“S”<<c<<t.getacademy()<<c<<“1”<<c<<’\n’;
cout<<“Registration successful!”<<endl;
}
else{
cout<<“Registration fail!”<<endl;
cout<<“按任意键继续…”;
getch();
return;
}
}
cout<<“按任意键继续…”;
getch();
ofile.close();
}
void zhuce(){
Teachercard t;
Studentcard stu;
int i;
while(1){
system(“cls”);
cout<<"\t****”<<endl;
cout<<"\t~\n"<<endl;一卡通注册
cout<<"\t*** 1、学生卡注册 "<<endl;
cout<<"\t 2、老师卡注册 "<<endl;
cout<<"\t 0、返回 \n"<<endl;
cout<<"\t************************************************************"<<endl;
cout<<“请选择(0-2):”;
cin>>i;
while(!(i>=0&&i<=2)){
cout<<“请选择正确的项目:”;
cin>>i;
}
switch(i){
case 0:return;
case 1:Szhuce(stu);break;
case 2:Szhuce(t);break;
}
}
}
/display/
void disp(char ch[]){
cardst p;
int i=0;
char ch1[2];
ifstream infile(“card.txt”,ios::in);
while(!infile.eof()){
infile.getline(p.name,15,’ ‘);
infile.getline(p.sex,6,’ ‘);
infile.getline(p.code,10,’ ‘);
infile.getline(p.id,10,’ ‘);
infile.getline(p.money,15,’ ‘);
infile.getline(p.expense,16,’ ‘);
infile.getline(p.c,6,’ ‘);
infile.getline(p.type,25,’ ‘);
infile.getline(p.enable,6,’ ‘);
infile.getline(ch1,6,’\n’);
if(!strcmp(p.id,ch)){
i=1;
break;
}
}
if(i)
if(!strcmp(p.enable,“1”)){
cout<<“"<<endl;
cout<<“你的信息:”<<endl;
cout<<" 姓名:"<<p.name<<endl;
cout<<" 性别:"<<p.sex<<endl;
cout<<" 学号:"<<p.id<<endl;
cout<<" 专业:"<<p.type<<endl;
cout<<" 金额:"<<p.money<<“RMB”<<endl;
cout<<" 费用:"<<p.expense<<“RMB”<<endl;
cout<<“卡的类型:”<<p.c<<" card"<<endl;
cout<<"”<<endl;
}
else cout<<“sorry,This card should be “<<endl,cout<<”\t\treported by the application!”<<endl,cout<<“Please contact the administrator!”<<endl;
else cout<<“you have no register!”<<endl;
cout<<“press any number key to continue:”;
cin>>i;
infile.close();
}
/充值**********/
void recharge(char ch[]){
cardst p[100];
int i=0,tag=-2;
double n,m;
char ch1[3],temp[15];
char c=’ ‘;
fstream ffile(“card.txt”,ios::in||ios::out);//以可读可写方式打开文件card.txt
ffile.seekg(0,ios::beg);//seekg是对输入文件定位
while(!ffile.eof())//文件没有读取到末尾
{
ffile.getline(p[i].name,15,’ ‘);
ffile.getline(p[i].sex,6,’ ‘);
ffile.getline(p[i].code,10,’ ‘);
ffile.getline(p[i].id,10,’ ‘);
ffile.getline(p[i].money,15,’ ‘);
ffile.getline(p[i].expense,16,’ ‘);
ffile.getline(p[i].c,6,’ ‘);
ffile.getline(p[i].type,25,’ ‘);
ffile.getline(p[i++].enable,6,’ ‘);
ffile.getline(ch1,6,’\n’);
if(!strcmp(p[i-1].id,ch)) tag=i-1;
}
ffile.close();
if(tag!=-2)
if(!strcmp(p[tag].enable,“1”)){
cout<<“"<<endl;
cout<<" Name:"<<p[tag].name<<endl;
cout<<" Sex:"<<p[tag].sex<<endl;
cout<<" Id:"<<p[tag].id<<endl;
cout<<" Major:"<<p[tag].type<<endl;
cout<<" Balance:"<<p[tag].money<<“RMB”<<endl;
cout<<" Expence:"<<p[tag].expense<<“RMB”<<endl;
cout<<“card type:”<<p[tag].c<<" card"<<endl;
cout<<"”<<endl;
cout<<“input recharge money:”;
cin>>temp;
n=atof(p[tag].money);
m=atof(temp);
n=m+n;
_itoa(n,p[tag].money,10);//数值转换
ofstream ofile("card.txt");
tag=0;
while(tag<i-1){
ofile<<p[tag].name<<c<<p[tag].sex<<c<<p[tag].code<<c<<p[tag].id<<c<<p[tag].money<<c<<p[tag].expense<<c<<p[tag].c<<c<<p[tag].type<<c<<p[tag].enable<<c<<'\n';
tag++;
}
}
else {
cout<<"sorry,This card should be "<<endl,cout<<"\t\tpreported by the application!"<<endl,cout<<"Please contact the administrator!"<<endl;
cout<<"press any number key to continue:";
cin>>i;
return;
}
else {
cout<<"you have no register!"<<endl;
cout<<"按任意继续...";
getch();
return;
}
ffile.close();
cout<<"充值成功!"<<endl;
cout<<"按任意键继续...";
getch();
}
void lost(char ch[]){
cardst p;
double i=0;
long pos;
char ch1[2];
fstream ffile(“card.txt”,ios::in|ios::out);
while(!ffile.eof()){
ffile.getline(p.name,15,’ ‘);
ffile.getline(p.sex,6,’ ‘);
ffile.getline(p.code,10,’ ‘);
ffile.getline(p.id,10,’ ‘);
ffile.getline(p.money,16,’ ‘);
ffile.getline(p.expense,16,’ ‘);
ffile.getline(p.c,6,’ ‘);
ffile.getline(p.type,25,’ ‘);
pos=ffile.tellg();
ffile.getline(p.enable,6,’ ‘);
ffile.getline(ch1,6,’\n’);
if(!strcmp(p.id,ch)){i=1; break;}
}
if(i){
strcpy(p.enable,“0”);
ffile.seekg(pos);
ffile<<p.enable;
cout<<“你的卡已经被挂失!”<<endl;
}
else cout<<“你没有注册!”<<endl;
cout<<“按任意键继续…”;
getch();
}
void destory(char ch[]){
cardst p[100];
int i=0,tag=-2,tag2;
char ch1[3],tag1;
char c=’ ‘;
fstream ffile(“card.txt”,ios::in||ios::out);
ffile.seekg(0,ios::beg);
while(!ffile.eof()){
ffile.getline(p[i].name,15,’ ‘);
ffile.getline(p[i].sex,6,’ ‘);
ffile.getline(p[i].code,10,’ ‘);
ffile.getline(p[i].id,10,’ ‘);
ffile.getline(p[i].money,15,’ ‘);
ffile.getline(p[i].expense,16,’ ‘);
ffile.getline(p[i].c,6,’ ‘);
ffile.getline(p[i].type,25,’ ‘);
ffile.getline(p[i++].enable,6,’ ‘);
ffile.getline(ch1,6,’\n’);
if(!strcmp(p[i-1].id,ch)){tag=i-1; }
}
ffile.close();
if(tag!=-2)
if(!strcmp(p[tag].enable,“1”)){
cout<<“"<<endl;
cout<<" Name:"<<p[tag].name<<endl;
cout<<" Sex:"<<p[tag].sex<<endl;
cout<<" Id:"<<p[tag].id<<endl;
cout<<" Major:"<<p[tag].type<<endl;
cout<<" Balance:"<<p[tag].money<<“RMB”<<endl;
cout<<" Expence:"<<p[tag].expense<<“RMB”<<endl;
cout<<“card type:”<<p[tag].c<<" card"<<endl;
cout<<"”<<endl;
cout<<“Confirm the cancellation(Y or N):”;
cin>>tag1;
while(tag1!=‘y’&&tag1!=‘Y’&&tag1!=‘n’&&tag1!=‘N’)
cin>>tag1;
if(tag1==‘Y’||tag1==‘y’){
ofstream ofile(“card.txt”);
tag2=0;
while(tag2<i-1){
if(tag==tag2){tag2++;continue;}
ofile<<p[tag2].name<<c<<p[tag2].sex<<c<<p[tag2].code<<c<<p[tag2].id<<c<<p[tag2].money<<c<<p[tag2].expense<<c<<p[tag2].c<<c<<p[tag2].type<<c<<p[tag2].enable<<c<<’\n’;
tag2++;
}
}
else cout<<“This operation already be subject to cancellation!”<<endl;
}
else {
cout<<“sorry,This card should be “<<endl,cout<<”\t\treported by the application!”<<endl,cout<<“Please contact the administrator!”<<endl;
cout<<“按任意键继续…”;
getch();
return;
}
else cout<<“你没有注册!”<<endl;
ffile.close();
cout<<“按任意键继续…”;
getch();
}
int menu1(){
int i;
system(“cls”);
cout<<"\t********************************************************\n";
cout<<"\t----------------一卡通管理平台--------------------------"<<endl;
cout<<"\t— 1、一卡通信息 —"<<endl;
cout<<"\t— 2、一卡通充值 —"<<endl;
cout<<"\t— 3、一卡通挂失 —"<<endl;
cout<<"\t— 4、一卡通销毁 —"<<endl;
cout<<"\t— 5、一卡通消费 —"<<endl;
cout<<"\t— 0、安全退出 —"<<endl;
cout<<"\t--------------------------------------------------------"<<endl;
cout<<"\t请选择(0-5):";
cin>>i;
while(!(i>=0&&i<=5))
cin>>i;
return i;
}
void user_card(char ch[]){
int i;
while(1){
i=menu1();
switch(i){
case 0: return;
case 1:disp(ch);break;
case 2:recharge(ch);break;
case 3:lost(ch);break;
case 4:destory(ch);break;
// case 5:shopping(ch);break;
}
}
}
void user_enter(){
cardst p;
int i=0;
char ch[10],ch1[10];
ifstream infile(“card.txt”,ios::in);
cout<<“please enter id:”;
cin>>ch;
cout<<“please enter code:”;
cin>>ch1;
while(!infile.eof()){
infile.getline(p.name,15,’ ‘);
infile.getline(p.sex,6,’ ‘);
infile.getline(p.code,10,’ ‘);
infile.getline(p.id,10,’ ‘);
infile.getline(p.money,15,’ ‘);
infile.getline(p.expense,16,’ ‘);
infile.getline(p.c,6,’ ‘);
infile.getline(p.type,25,’ ‘);
infile.getline(p.enable,6,’ ');
if(!strcmp(p.id,ch)){
i=1;
break;
}
}
if(i)
if(!strcmp(ch1,p.code))
if(!strcmp(p.enable,“1”))
{
cout<<“登入成功!”<<endl;
cout<<“press any number key to continue:”;
cin>>i;
return;
}
else{
cout<<“密码错误!”<<endl;
cout<<“press any number key to continue:”;
cin>>i;
return;
}
else {
cout<<“没有该记录信息!”<<endl;
cout<<“press any number key to continue:”;
cin>>i;
return;
}
cout<<“按任意键继续…”;
getch();
infile.close();
user_card(ch);
}
void userway(){
int i;
system(“cls”);
cout<<"**********\n";
cout<<"\t用户界面"<<endl;
cout<<"\t** 1、注册 "<<endl;
cout<<"\t 2、登入 "<<endl;
cout<<"\t 0、退出 "<<endl;
cout<<"\t************************************************************"<<endl;
cout<<"\t请选择(0-2):";
cin>>i;
while(!(i>=0&&i<=2))
cin>>i;
switch(i){
case 0:return;
case 1:zhuce();break;
case 2:user_enter();break;
}
}
/**manage function/
void total(){
}
void detail(){
}
void expense(){
int i;
while(1){
system(“cls”);
cout<<“\n";
cout<<"\t消费管理界面"<<endl;
cout<<"\t 1、营业额统计 “<<endl;
cout<<”\t 2、消费明细 “<<endl;
cout<<”\t 0、退出 “<<endl;
cout<<”\t**************************************************”<<endl;
cout<<"\t请选择(0-2):";
cin>>i;
while(!(i>=0&&i<=2))
cin>>i;
switch(i){
case 0:return;
case 1:total();break;
case 2:detail();break;
}
}
}
/*********************************************************************************************************************/
void Modify(){
}
void Delete(){
system(“cls”);
cardst p[100];
int i=0,j=0,k=0,tag[10];
char ch1[3],tag1;
char c=’ ‘;
ifstream infile(“card.txt”,ios::in);
while(!infile.eof()){
infile.getline(p[i].name,15,’ ‘);
infile.getline(p[i].sex,6,’ ‘);
infile.getline(p[i].code,10,’ ‘);
infile.getline(p[i].id,10,’ ‘);
infile.getline(p[i].money,15,’ ‘);
infile.getline(p[i].expense,16,’ ‘);
infile.getline(p[i].c,6,’ ‘);
infile.getline(p[i].type,25,’ ‘);
infile.getline(p[i++].enable,6,’ ‘);
infile.getline(ch1,6,’\n’);
if(strcmp(p[i-1].enable,“1”)&&strcmp(p[i-1].enable,“0”)) break;
}
if(i0||i1){
cout<<“The file have no data”<<endl;
cout<<“按任意键继续…”<<endl;
getch();
return;
}
for(int m=0;m<i-1;m++){
cout<<“记录:”<<m+1<<endl;
cout<<“"<<endl;
cout<<" Name:"<<p[m].name<<endl;
cout<<" Sex:"<<p[m].sex<<endl;
cout<<" Id:"<<p[m].id<<endl;
cout<<" Major:"<<p[m].type<<endl;
cout<<" Balance:"<<p[m].money<<“RMB”<<endl;
cout<<" Expence:"<<p[m].expense<<“RMB”<<endl;
cout<<“card type:”<<p[m].c<<" card"<<endl;
cout<<"”<<endl<<endl;
}
infile.close();
cout<<"\n提示:\n 输入非法数字数据即为结束,一次最多删除十个记录!"<<endl;
cout<<"按任意键继续...";
getch();
while(j>0&&j<i&&k<10){
tag[k++]=j-1;
cin>>j;
}
if(!k){
cout<<"This operation will be cancelled"<<endl;
cout<<"press any number key to continue:"<<endl;
cin>>i;
return;
}
cout<<"Confirm the cancellation(Y or N):";
cin>>tag1;
while(tag1!='y'&&tag1!='Y'&&tag1!='n'&&tag1!='N')
cin>>tag1;
if(tag1=='Y'||tag1=='y'){
ofstream ofile("card.txt");
j=0;
while(j<i-1){
for(int m=0;m<k;m++)
if(j==tag[m]){j++;continue;}
ofile<<p[j].name<<c<<p[j].sex<<c<<p[j].code<<c<<p[j].id<<c<<p[j].money<<c<<p[j].expense<<c<<p[j].c<<c<<p[j].type<<c<<p[j].enable<<c<<'\n';
j++;
}
ofile.close();
}
else cout<<"This operation already be subject to cancellation!"<<endl;
cout<<"按任意键继续...";
getch();
}
void Disp_Stu(){
cardst p;
int i=0,j=0;
long pos=0;
char ch1[2];
system(“cls”);
ifstream infile(“card.txt”,ios::in);
cout<<"\t====================================================================== “<<endl;
cout<<”\t\3 \3 \3\t\tStudent Card \3 \3 \3"<<endl;
cout<<"\t\3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 “<<endl;
cout<<”*******************************************************************************"<<endl;
while(!infile.eof()){
infile.getline(p.name,15,’ ‘);
infile.getline(p.sex,6,’ ‘);
infile.getline(p.code,10,’ ‘);
infile.getline(p.id,10,’ ‘);
infile.getline(p.money,15,’ ‘);
infile.getline(p.expense,16,’ ‘);
infile.getline(p.c,6,’ ‘);
infile.getline(p.type,25,’ ‘);
infile.getline(p.enable,6,’ ‘);
infile.getline(ch1,6,’\n’);
if(!strcmp(p.c,“S”))
if(!strcmp(p.enable ,“1”)){
cout<<"\t\t Name:"<<p.name<<endl;
cout<<"\t\t Sex:"<<p.sex<<endl;
cout<<"\t\t Id:"<<p.id<<endl;
cout<<"\t\t Major:"<<p.type<<endl;
cout<<"\t\t Balance:"<<p.money<<“RMB”<<endl;
cout<<"\t\t Expence:"<<p.expense<<“RMB”<<endl;
cout<<"\t\tCard type:"<<p.c<<" card"<<endl<<endl;
}
else i++;
}
cout<<endl;
cout<<"*******************************************************************************"<<endl;
cout<<"NOTE:"<<endl;
if(i)
cout<<" "<<i<<" Student card"<<" is preported by the application!"<<endl;
else cout<<" Have no card preported by the application!"<<endl;
cout<<"按任意键继续...";
getch();
infile.close();
}
void Disp_T(){
cardst p;
int i=0;
long pos=0;
char ch1[2];
system(“cls”);
ifstream infile(“card.txt”,ios::in);
cout<<"\t\3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 “<<endl;
cout<<”\t\3 \3 \3\t\tTeacher Card \3 \3 \3"<<endl;
cout<<"\t\3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3 “<<endl;
cout<<“"<<endl;
while(!infile.eof()){
infile.getline(p.name,15,’ ‘);
infile.getline(p.sex,6,’ ‘);
infile.getline(p.code,10,’ ‘);
infile.getline(p.id,10,’ ‘);
infile.getline(p.money,15,’ ‘);
infile.getline(p.expense,16,’ ‘);
infile.getline(p.c,6,’ ‘);
infile.getline(p.type,25,’ ‘);
infile.getline(p.enable,6,’ ‘);
infile.getline(ch1,6,’\n’);
if(!strcmp(p.c,“T”))
if(!strcmp(p.enable ,“1”)){
cout<<"\t\t Name:"<<p.name<<endl;
cout<<"\t\t Sex:"<<p.sex<<endl;
cout<<"\t\t Id:"<<p.id<<endl;
cout<<"\t\t Major:"<<p.type<<endl;
cout<<"\t\t Balance:"<<p.money<<“RMB”<<endl;
cout<<"\t\t Expence:"<<p.expense<<“RMB”<<endl;
cout<<"\t\tCard type:"<<p.c<<" card"<<endl<<endl;
}
else i++;
}
cout<<"”<<endl;
cout<<“NOTE:”<<endl;
if(i)
cout<<” “<<i<<” Teacher card"<<" is preported by the application!"<<endl;
else cout<<" Have no card preported by the application!"<<endl;
cout<<“按任意键继续…”;
getch();
infile.close();
}
void DisPlay(){
system(“cls”);
int i;
while(1){
system(“cls”);
cout<<"\t*******************************************************************"<<endl;
cout<<"\t信息统计*************"<<endl;
cout<<"\t**** 1、学生信息 "<<endl;
cout<<"\t 2、老师信息 "<<endl;
cout<<"\t 0、退出 "<<endl;
cout<<"\t***************************************************************"<<endl;
cout<<"\t请选择(0-2):";
cin>>i;
while(!(i>=0&&i<=2))
cin>>i;
switch(i){
case 0:return;
case 1:Disp_Stu();break;
case 2:Disp_T();break;
}
}
}
void Remove_lost(){
cardst p[100];
int i=0,tag=-2;
char ch1[3],ch[10];
char c=’ ‘;
fstream ffile(“card.txt”,ios::in||ios::out);
cout<<“input the card’s ID:”;
cin>>ch;
while(!ffile.eof()){
ffile.getline(p[i].name,15,’ ‘);
ffile.getline(p[i].sex,6,’ ‘);
ffile.getline(p[i].code,10,’ ‘);
ffile.getline(p[i].id,10,’ ‘);
ffile.getline(p[i].money,15,’ ‘);
ffile.getline(p[i].expense,16,’ ‘);
ffile.getline(p[i].c,6,’ ‘);
ffile.getline(p[i].type,25,’ ‘);
ffile.getline(p[i++].enable,6,’ ‘);
ffile.getline(ch1,6,’\n’);
if(!strcmp(p[i-1].id,ch)) tag=i-1;
}
ffile.close();
if(tag!=-2)
if(strcmp(p[tag].enable,“1”)){
strcpy(p[tag].enable,“1”);
ofstream ofile(“card.txt”);
tag=0;
while(tag<i-1){
ofile<<p[tag].name<<c<<p[tag].sex<<c<<p[tag].code<<c<<p[tag].id<<c<<p[tag].money<<c<<p[tag].expense<<c<<p[tag].c<<c<<p[tag].type<<c<<p[tag].enable<<c<<’\n’;
tag++;
}
}
else {
cout<<“该卡没有解挂!”<<endl;
cout<<“胺任意键继续…”;
getch();
return;
}
else {
cout<<“对不起,该卡没有注册!”<<endl;
cout<<“按任意键继续…”;
getch();
return;
}
ffile.close();
cout<<“注销成功!”<<endl;
cout<<“按任意键继续…”;
getch();
}
void card_control(){
int i;
while(1){
system(“cls”);
cout<<"\t*********************************************************"<<endl;
cout<<"\t---------------一一卡通管理界面--------------------------"<<endl;
cout<<"\t 1、修改记录 \n"<<endl;
cout<<"\t 2、删除记录 \n"<<endl;
cout<<"\t 3、信息一览 \n"<<endl;
cout<<"\t 4、解除挂失 \n"<<endl;
cout<<"\t 0、返回上一菜单 \n"<<endl;
cout<<"\t---------------一----------------------------------------"<<endl;
cout<<"\t请选择(0-4):";
cin>>i;
while(!(i>=0&&i<=4))
cin>>i;
switch(i){
case 0:return;
case 1:Modify();break;
case 2:Delete();break;
case 3:DisPlay();break;
case 4:Remove_lost();break;
}
}
}
int menu3(){
int i;
system(“cls”);
cout<<"\t***************************************************"<<endl;
cout<<"\t---------------一管理员界面------------------------\n"<<endl;
cout<<"\t 1、消费管理 \n"<<endl;
cout<<"\t 2、一卡通管理 \n"<<endl;
cout<<"\t 0、返回上一菜单 \n"<<endl;
cout<<"\t---------------------------------------------------\n"<<endl;
cout<<"\t请选择(0-2):";
cin>>i;
return i;
}
void manageway(){
char code[10];
int i;
cout<<“请输入密码:”;
cin>>code;
if(!strcmp(code,“111111”)){
while(1){
i=menu3();
switch(i){
case 0:return;
case 1:expense();break;
case 2:card_control();break;
}
}
}
else cout<<“密码错误!”;
}
/main()/
int menu(){
int i;
system(“cls”);
cout<<endl<<endl;
cout<<"\t**************************************************************"<<endl;
cout<<"\t* “<<endl;
cout<<”\t一卡通管理系统*"<<endl;
cout<<"\t* “<<endl;
cout<<”\t 1、管理员通道 “<<endl;
cout<<”\t “<<endl;
cout<<”\t 2、用户通道 “<<endl;
cout<<”\t “<<endl;
cout<<”\t 0、安全退出 “<<endl;
cout<<”\t “<<endl;
cout<<”\t***************************************************************"<<endl;
cout<<"\t请选择(0-2):";
cin>>i;
while(!(i>=0&&i<=2))
cin>>i;
return i;
}
void main(){
int i;
while(1){
system(“cls”);
i=menu();
switch(i){
case 0:cout<<“您已经安全退出!”<<endl;return;
case 1:manageway();break;
case 2:userway();break;
}
}
}