用mysql数据库实现的C++图书管理系统由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“数据库图书管理系统c”。
#include #include #include #include #include
#include #include #include #include
#include //改变字体颜色
#define NONE “ 33[m” #define RED “ 33[0;32;31m” #define GREEN “ 33[0;32;32m” #define BLUE “ 33[0;32;34m” #define YELLOW “ 33[1;33m”
#define LIGHT_RED “ 33[1;31m” #define LIGHT_GREEN “ 33[1;32m” #define LIGHT_BLUE “ 33[1;34m” /* 在编译程序之前,请先开启mysql服务器(命令为 sudo mysqld_safe &),然后再登录mysql客户端(命令为 mysql-u root-p)建立数据库 stu;建立数据表reader,book;具体操作语句如下:
create database stu;
create table reader(stu_name varchar(20),stu_phone varchar(15),stu_paword varchar(10),stu_num int,debt float,lend_time double,back_time double,count int);
create table book(book_name varchar(40),book_aut varchar(40),book_pre varchar(40),book_num int,book_mux int,book_con int);
编译时用如下命令:
g++ $(mysql_config--cflags)110.cpp-o t $(mysql_config--libs)*/
//定义mysql数据库变量
MYSQL
mysql;MYSQL_RES * results;
MYSQL_FIELD *fileds;
MYSQL_ROW rows;
char strHost[] = “localhost”;
char strUser[] = “root”;
char strPawd[] = “3335599”;
char strDb[] = “stu”;char strSQL[200];
unsigned int num_fields;/* 程序导读:
1.程序中对书的操作,可通过书名,编号来进行,flag=0按书名来操作,flag=1按书编号来操作
2.程序中对用户的操作,也可通过姓名,用户ID号或编号两种方式来进行,flag=0按姓名来操作,flag=1按用户ID号或编号来操作
3.本程序分5个部分,具体已标识如(1)图书管理...4.本程序即可实现将数据保存至本地即stu.txt,book.txt,又可将数据保存至mysql数据库,只
需稍加修改,具体如何修改,在此就不做说明 */
using namespace std;cla Book { public: string book_name;string book_num;//编号
string book_pre;//出版社
string book_aut;//作者
int book_con;//这样的书还有几本
int book_mux;//这样的书总共有几本
public: Book(){book_con=0;book_mux=0;} void show_book();
};
/****************************************(1)图书管理*******************************************/ void Book::show_book(){ cout
cla BookNode { public: Book book;BookNode *next;};BookNode *headbook=NULL;
void savebook(BookNode *p);//保存图书信息到数据库
void del_sql_book(BookNode *p);//将图书信息从数据库中删除
cla BookManage {
public: int totolbook;public: BookManage(){totolbook=0;} void addbook();
void delbook(string s,int num,int flag);void findbook(string s,int flag);//查询图书 };
void BookManage::addbook(){ string h;
cout>h;if(h==“-1”)return;else if(h==“0”)while(1){
if(h==“-1”)break;else if(h==“0”){
string na,nu,p1,aut;int con;BookNode *p=new BookNode;cout>na;p->book.book_name=na;cout>nu;p->book.book_num=nu;cout>p1;p->book.book_pre=p1;cout>aut;p->book.book_aut=aut;cout>con;p->book.book_con=con;p->book.book_mux=con;p->next=headbook;headbook=p;savebook(p);//添加至数据库 BookManage::totolbook+=con;
cout
cin>>h;
}
else
cout
void BookManage::delbook(string s,int num,int flag){ BookNode *p=headbook;if(headbook!=NULL){
switch(flag)
{
case 0:
if(headbook->book.book_name==s)
{
if(headbook->book.book_con>1)
{headbook->book.book_con-=num;headbook->book.book_mux-=num;}
else { headbook=p->next;totolbook-=num;
del_sql_book(p);//从数据库中删除
//delete p;
}
}
else if(p->next)
{
for(p=headbook;p->next!=NULL&&p!=NULL;p=p->next)
{
if(p->next->book.book_name==s)
{
if(p->next->book.book_con>1)
{
p->next->book.book_con-=num;headbook->book.book_mux-=num;
break;
}
else
{
p->next=p->next->next;
totolbook-=num;
del_sql_book(p->next);//从数据库中删除
//delete p->next;
break;
}
}
}
if(p->next==NULL)
cout
break;case 1:
if(headbook->book.book_num==s){
if(headbook->book.book_con>1)
{headbook->book.book_con-=num;headbook->book.book_mux-=num;}
else
{
headbook=p->next;
totolbook-=num;
del_sql_book(p);//从数据库中删除
//delete p;
}
}
else if(p->next)
{
for(p=headbook;p->next!=NULL&&p!=NULL;p=p->next)
{
if(p->next->book.book_num==s)
{
if(p->next->book.book_con>1)
{
p->next->book.book_con-=num;headbook->book.book_mux-=num;
break;
}
else
{
p->next=p->next->next;
totolbook-=num;
del_sql_book(p->next);//从数据库中删除
//delete p->next;
break;
}
}
}
if(p->next==NULL)
cout
}
break;
default:
cout
} } }
void BookManage::findbook(string s,int flag){ BookNode *p;int h=0;switch(flag){
case 0:
for(p=headbook;p!=NULL;p=p->next)//先查看是否有此书
{
if(p->book.book_name==s)break;} if(NULL==p)coutnext)//查看名为s的图书共有几本 { if(p->book.book_name==s)h++;} if(h>0)coutnext)//查看图书,把所有名为s的图书的信息都{
if(p->book.book_name==s){ p->book.show_book();//显示出图书的基本信息
if(p->book.book_con==0)
打印出来
}
cout
cout
} } break;case 1: for(p=headbook;p!=NULL;p=p->next){
if(p->book.book_num==s)
{
p->book.show_book();
if(p->book.book_con==0)
cout
} } if(NULL==p)cout
}
/****************************************(*******************************************/
cla Admin//管理员 { public: string adm_name;//帐号
string adm_paw;//密码
public: Admin(){
adm_name=“adm”;
adm_paw=“123”;} };
cla LendBook { public: string bookname[3];int count;//借多少本数
time_t lend_time;time_t back_time;LendBook(){count=0;} };
cla Stu { public: string stu_name;
};
2)用户管理
string stu_phone;//联系方式
string stu_num;//学号(登录帐号)string paword;//密码 float debt;//欠费额
LendBook lendbook;//用户借书信息
public: void show_stu();//把此人所有信息(包括借书)显示出来
void Stu::show_stu(){ cout
cla StuNode { public: Stu stu;StuNode *next;};StuNode *headstu=NULL;
void savestu(StuNode *p);//保存读者信息到数据库
void del_sql_stu(StuNode *p);//将读者信息从数据库中删除
cla StuManage:public BookManage { private: int totolstu;//用户总数
public: StuManage(){totolstu=0;} void addstu();//增加用户
void delstu(string s,int flag);//删除用户
void findstu(string s,int flag);//查找用户
void lendbook(string ,string s,int flag);//借书
void backbook(string ,string s,int flag);//还书
void paydebt(string s);//还款
void mux_stu_book();//查询图书管总的图书量与总的用户量 };
void StuManage::addstu(){ string h;
cout>h;if(h==“-1”)return;else if(h==“0”)while(1){
if(h==“-1”)break;else if(h==“0”){
string na,num,p1,pa,pa1,pa2;
StuNode *p=new StuNode;
cout
cin>>na;
p->stu.stu_name=na;
cout>p1;p->stu.stu_phone=p1;cout>num;p->stu.stu_num=num;p->stu.lendbook.lend_time=0;p->stu.lendbook.back_time=0;while(1){
cout>pa1;cout>pa2;if(pa1==pa2){ pa=pa2;p->stu.paword=pa;break;} else coutstu.debt=0;p->next=headstu;headstu=p;savestu(p);//保存至数据库
(StuManage::totolstu)++;//用户总数加一
cout>h;
} else cout
void StuManage::delstu(string s,int flag){ StuNode *p=headstu;if(headstu!=NULL){
switch(flag)
{
case 0:
if(headstu->stu.stu_name==s)//当要删除的用户位于链表的头结点位置 { headstu=p->next;StuManage::totolstu--;del_sql_stu(p);//从数据库中删除
delete p;}
else if(p->next)//非头结点位置 {
for(p=headstu;p->next!=NULL&&p!=NULL;p=p->next){
if(p->next->stu.stu_name==s)
{
p->next=p->next->next;
totolstu--;
del_sql_stu(p->next);//从数据库中删除
//delete p->next;
break;
}
}
if(p->next==NULL)
cout
break;case 1:
if(headstu->stu.stu_name==s){
headstu=p->next;totolstu--;del_sql_stu(p);//从数据库中删除
delete p;}
else if(p->next){
for(p=headstu;p->next!=NULL&&p!=NULL;p=p->next){
if(p->next->stu.stu_name==s)
{
p->next=p->next->next;
totolstu--;
del_sql_stu(p->next);//从数据库中删除
//delete p->next;
break;
}
}
if(p->next==NULL)
cout
}
break;
default:
cout
} } }
void StuManage::findstu(string s,int flag){ StuNode *p;int h=0,m=1;switch(flag){
case 0:
for(p=headstu;p!=NULL;p=p->next)
{
if(p->stu.stu_name==s)
break;
}
if(p==NULL)
cout
for(p=headstu;p!=NULL;p=p->next)
{
if(p->stu.stu_name==s)h++;} if(h>0)coutnext){ if(p->stu.stu_name==s){
p->stu.show_stu();
if(p->stu.lendbook.count>=3)
{
coutstu.lendbook.count;if(i>0)
“NONE
cout
while(i)
{
coutstu.lendbook.bookname[i-1]
}
cout
}
else
{
int i=p->stu.lendbook.count;
if(i>0)
cout
while(i)
{
coutstu.lendbook.bookname[i-1]
}
} } break;case 1:
}
coutstu.lendbook.countstu.lendbook.count
for(p=headstu;p!=NULL;p=p->next)
{
if(p->stu.stu_num==s)
{
p->stu.show_stu();
if(p->stu.lendbook.count>=3)
{
cout
int i=p->stu.lendbook.count;
cout
//输出用户所借书的名字 coutstu.lendbook.bookname[i-1]
}
cout
}
else
{
int i=p->stu.lendbook.count;
cout
while(i)
{ //输出用户所借书的名字
coutstu.lendbook.bookname[i-1]
}
coutstu.lendbook.count
coutstu.lendbook.count
cout
}
break;
}
}
if(p==NULL)
cout
break;
default:
cout
}
void StuManage::mux_stu_book(){ StuNode *p;BookNode *q;int i=0,j=0,h=0;for(p=headstu;p!=NULL;p=p->next)i++;coutnext){
h+=q->book.book_mux;
j+=q->book.book_con;}
} coutnext){
if(q->stu.stu_num==)
{del_sql_stu(q);break;}//丛数据库中删除
} if(q==NULL){cout
switch(flag){
case 0:
for(p=headbook;p!=NULL;p=p->next)
{
if(p->book.book_name==s)
{
”NONE
del_sql_book(p);//从数据库中删除 int i=q->stu.lendbook.count;if(i>=3||q->stu.debt>0){ if((i>=3)&&(q->stu.debt==0)){cout
if((istu.debt>0))
{cout
欠费再借!“NONE
if((i>=3)&&(q->stu.debt>0))
{cout
}
else
{
//记录下所借书的名字存入用户信息中
q->stu.lendbook.bookname[i]=p->book.book_name;
time_t now;
time(&now);
q->stu.lendbook.lend_time=time(&now);//保存借书时间
q->stu.lendbook.count++;//所借书数目加一
p->book.book_con--;//同样的书的个数减一
}
break;
}
}
if(p==NULL)
cout
break;
case 1:
for(p=headbook;p!=NULL;p=p->next)
{
if(p->book.book_num==s)
{
del_sql_book(p);//从数据库中删除
int i=q->stu.lendbook.count;
if(i>=3||q->stu.debt>0)
{
if((i>=3)&&(q->stu.debt==0))
{cout
if((istu.debt>0))
{cout
if((i>=3)&&(q->stu.debt>0))
{cout
}
else
{
}
q->stu.lendbook.bookname[i]=p->book.book_name;
time_t now;
time(&now);
q->stu.lendbook.lend_time=time(&now);
q->stu.lendbook.count++;
p->book.book_con--;//同样的书的个数减一
}
break;
} } if(p==NULL)
cout
break;default:
cout
void StuManage::backbook(string ,string s,int flag)//还书 { BookNode *p;StuNode *q;for(q=headstu;q!=NULL;q=q->next){
if(q->stu.stu_num==)
{del_sql_stu(q);break;}//丛数据库中删除
} if(q==NULL){cout
switch(flag){
case 0:
for(p=headbook;p!=NULL;p=p->next)
{
if(p->book.book_name==s)
{
del_sql_book(p);//从数据库中删除
time_t now;
time(&now);
q->stu.lendbook.back_time=time(&now);
q->stu.lendbook.count--;
p->book.book_con++;//同样的书的个数加一
time_t s=difftime(q->stu.lendbook.lend_time,q->stu.lendbook.back_time);
if(s>2592000)//2592000为一个月的秒数
{
int t=ceil((s-2592000)/86400);
q->stu.debt=t*0.1;
}
break;} } if(p==NULL)
cout
break;
case 1:
for(p=headbook;p!=NULL;p=p->next)
{
if(p->book.book_num==s)
{
del_sql_book(p);//从数据库删除
time_t now;
time(&now);
q->stu.lendbook.back_time=time(&now);
q->stu.lendbook.count--;
p->book.book_con++;//同样的书的个数加一
//计算借用图书的时间,超过一个月,开始计费
time_t s=difftime(q->stu.lendbook.lend_time,q->stu.lendbook.back_time);
}
if(s>2592000)//2592000为一个月的秒数
{
int t=ceil((s-2592000)/86400);
q->stu.debt=t*0.1;
}
break;
} } if(p==NULL)cout
savestu(q);savebook(p);
}
void StuManage::paydebt(string s){ StuNode *p;
for(p=headstu;p!=NULL;p=p->next)//查找用户 { if(p->stu.stu_num==s){
p->stu.debt=0;
cout
stream
stream >> stu_str;//从i中抽取前面插入的string值
return stu_str;}
void savestu(StuNode *p)//保存读者信息到数据库 {
memset((void*)strSQL,0,200);sprintf(strSQL,”insert into reader values(%s,%s,%s,%s,%f,%ld,%ld,%d)“,change_char(p->stu.stu_name),change_char(p->stu.stu_phone),change_char(p->stu.paword),change_char(p->stu.stu_num),p->stu.debt,(long)(p->stu.lendbook.lend_time),(long)(p->stu.lendbook.back_time),p->stu.lendbook.count);if(mysql_real_query(&mysql,strSQL,strlen(strSQL))!= 0)
printf(”记录插入失败!n“);}
void savebook(BookNode *p)//保存图书信息到数据库 { memset((void*)strSQL,0,200);sprintf(strSQL,”insert into book values(%s,%s,%s,%s,%d,%d)“,change_char(p->book.book_name),change_char(p->book.book_aut),change_char(p->book.book_pre),change_char(p->book.book_num),p->book.book_mux,p->book.book_con);if(mysql_real_query(&mysql,strSQL,strlen(strSQL))!= 0)
printf(”记录插入失败!n“);
}
void del_sql_stu(StuNode *p)//将读者信息从数据库中删除 {
memset((void*)strSQL,0,200);sprintf(strSQL,”delete from reader where stu_name='%s'“,change_char(p->stu.stu_name));if(mysql_real_query(&mysql,strSQL,strlen(strSQL))!= 0)
printf(”记录删除失败!n“);}
void del_sql_book(BookNode *p)//将图书信息从数据库中删除 { memset((void*)strSQL,0,200);sprintf(strSQL,”delete from book book_name='%s'“,change_char(p->book.book_name));if(mysql_real_query(&mysql,strSQL,strlen(strSQL))!= 0)
printf(”记录删除失败!n“);
} /* void savestu()//保存读者信息文件 { ofstream outfile(”./stu.txt“,ios::out);
if(!outfile){
cerr
return;} StuNode *p;
for(p=headstu;p!=NULL;p=p->next)//数据写入文件
{
outfilestu.stu_namestu.stu_phone;
outfilestu.pawordstu.stu_num;
where
outfilestu.debt;
outfilestu.lendbook.lend_time;
outfilestu.lendbook.back_time;
outfilestu.lendbook.count;
outfile
} outfile.close();}
void savebook()//保存图书信息文件 { ofstream outfile(”./book.txt“,ios::out);
if(!outfile){
cerr
return;} BookNode *p;
for(p=headbook;p!=NULL;p=p->next)//数据写入文件
{
outfilebook.book_namebook.book_num;
outfilebook.book_prebook.book_aut;
outfilebook.book_mux;
outfilebook.book_con;
outfile
void loadstu()//从学生数据数据库reader中读取 { int i = 0;memset((void*)strSQL,0,100);
strcpy(strSQL,”select * from reader“);
mysql_query(&mysql,strSQL);
//查询
results = mysql_store_result(&mysql);
//获取记录
num_fields = mysql_num_fields(results);
//获取字段数
fileds = mysql_fetch_fields(results);
//获取字段数组
while((rows = mysql_fetch_row(results))!= NULL)
//循环显示
{
while(i
{
StuNode *p=new StuNode;
p->stu.stu_name =(rows[i]?rows[i++]:”NULL“);
p->stu.stu_phone =(rows[i]?rows[i++]:”NULL“);
p->stu.paword =(rows[i]?rows[i++]:”NULL“);
p->stu.stu_num =(rows[i]?rows[i++]:”NULL“);
p->stu.debt = atof(rows[i]?rows[i++]:”NULL“);
p->stu.lendbook.lend_time =(time_t)(rows[i]?rows[i++]:”NULL“);
p->stu.lendbook.back_time =(time_t)(rows[i]?rows[i++]:”NULL“);
p->stu.lendbook.count = atoi(rows[i]?rows[i++]:”NULL“);
p->next=headstu;//建立用户链表
headstu=p;
}
i = 0;} }
void loadbook()//从书数据库中读取 { int i = 0;memset((void*)strSQL,0,100);
strcpy(strSQL,”select * from book“);
mysql_query(&mysql,strSQL);
//查询
results = mysql_store_result(&mysql);
//获取记录
num_fields = mysql_num_fields(results);
//获取字段数
fileds = mysql_fetch_fields(results);
//获取字段数组
while((rows = mysql_fetch_row(results))!= NULL)
//循环显示
{
while(i
{
BookNode *p=new BookNode;
p->book.book_name =(rows[i]?rows[i++]:”NULL“);
p->book.book_aut =(rows[i]?rows[i++]:”NULL“);
p->book.book_pre =(rows[i]?rows[i++]:”NULL“);
p->book.book_num =(rows[i]?rows[i++]:”NULL“);
p->book.book_mux = atoi(rows[i]?rows[i++]:”NULL“);
p->book.book_con = atoi(rows[i]?rows[i++]:”NULL“);
p->next=headbook;//建立用户链表
headbook=p;
}
i = 0;} }
/* void loadstu()//从学生数据文件读取 { ifstream infile(”./stu.txt“,ios::in);
if(!infile){
cout
return;} if(infile.eof()){
cout
infile.close();} else {
while(infile.peek()!=EOF)//数据从文件读出
{
StuNode *p=new StuNode;
infile>>p->stu.stu_name>>p->stu.stu_phone;
infile>>p->stu.paword>>p->stu.stu_num;
infile>>p->stu.debt>>p->stu.lendbook.lend_time;
infile>>p->stu.lendbook.back_time>>p->stu.lendbook.count;
if(p->stu.stu_name!=”“)
{
p->next=headstu;//建立用户链表
headstu=p;
}
else
delete p;
}
infile.close();} }
void loadbook()//从书数据文件读取 {
ifstream infile(”./book.txt“,ios::in);
if(!infile){
} cout
while(infile.peek()!=EOF)//数据从文件读出
{
BookNode *p=new BookNode;infile>>p->book.book_name>>p->book.book_num;infile>>p->book.book_pre>>p->book.book_aut;infile>>p->book.book_mux>>p->book.book_con;
if(p->book.book_name!=”“){ p->next=headbook;//建立图书链表
headbook=p;} else delete p;
} } */ } infile.close();/****************************************(*******************************************/
void MenuAdmin(){
4)界面部分 cout>>>>>>>>>>>>>>>>>>>>>>>>>>>欢迎来到图书管理系统
$”NONE
增加新书
$“NONE
$”NONE
删除书目
$“NONE
$”NONE
cout
借书
$“NONE
$”NONE
cout
还书
$“NONE
$”NONE
查询图书
$“NONE
$”NONE
增加读者
$“NONE
$”NONE
删除读者
$“NONE
$”NONE
查询用户
$“NONE
cout
$”NONE
用户交费
$“NONE
$”NONE
查询用户总数与图书总数
$“NONE
$”NONE
0 退出
$“NONE
$”NONE>>>>>>>>>>>>>>>>>>>>>>>>>[请字)]
void MenuStu(){
选
择
(输
入
相
应
数 cout>>>>>>>>>>>>>>>>>>>>>>>>>>>欢迎来到图书管理系统
cout
$“NONE
cout
借书
$”NONE
$“NONE
cout
还书
$”NONE
$“NONE
查询图书
$”NONE
$“NONE
个人信息
$”NONE
$“NONE
0 退出
$”NONE
cout
$“NONE>>>>>>>>>>>>>>>>>>>>>>>>>[请选择(输入相应数字)]
int getch()//密码不回显函数1 { int c=0;
struct termios org_opts, new_opts;
int res=0;
//-----store old settings-----------
res=tcgetattr(STDIN_FILENO, &org_opts);
aert(res==0);
//----set new terminal parms--------
memcpy(&new_opts, &org_opts, sizeof(new_opts));
new_opts.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ECHOPRT | ECHOKE | ICRNL);
tcsetattr(STDIN_FILENO, TCSANOW, &new_opts);
c=getchar();
//------restore old settings---------
res=tcsetattr(STDIN_FILENO, TCSANOW, &org_opts);
aert(res==0);
return c;}
string set_pawd()//密码不回显函数2 { string result;char pd[128];int i;getch();/* 当帐号和密码一起输入,且刚输完帐号后就要输入密码时,set_pawd会把帐号结束时的回车赋‘n’拿过来作为自己的第一个输入,这样容易造成密码输入的错 误,为避免
这种情况的发生,所以就可以在for循环之前假如了getch()把‘n’吸收掉 */
for(i=0;;i++)
{
pd[i]=getch();
if(pd[i]=='n')
{
pd[i]=' ';
break;
}
if(pd[i]==127)
{
printf(”b b“);
i=i-2;
}
else
printf(”*“);
if(i
pd[0]=' ';
} stringstream stream;stream
stream >> result;//从stream中抽取前面插入的char值
return result;}
/****************************************(5)主函数部分*******************************************/
int main(){ mysql_init(&mysql);//数据库初始化
if(!mysql_real_connect(&mysql,strHost,strUser,strPawd,strDb,0,NULL,0))//连接数据库
{
printf(”连接数据库失败!/n“);
return 0;
} loadstu();loadbook();
mysql_free_result(results);//释放数据库结果集
BookManage bookmanage;StuManage stumanage;
Admin admin;int i;string s;int num,flag;string s1,s2,;StuNode *p;system(”clear“);//清理屏幕
cout
~Welecome to come in~”NONE>i;
switch(i){
case 0:
break;
case 1:
while(1)
{
cout
cin>>s1;
if(s1==“0”)
return 0;
cout
s2=set_pawd();
cout
if(admin.adm_name==s1)
{
while(1)
{
if(admin.adm_paw==s2)
break;
else
{
cout
s2=set_pawd();cout
if(s2==“0”)return 0;
//cin>>s2
}
}
}
if(s1!=admin.adm_name)
cout
else
break;
}
while(1){ MenuAdmin();int t;cin>>t;switch(t){
“
”
case 0: //savestu();savebook();
mysql_close(&mysql);//关闭数据库链接
return 0;break;
case 1:bookmanage.addbook();//增加书本
system(“clear”);break;//清理屏幕
case 2:
cout
cin>>flag;
if(flag==0)
{cout>s;}
else if(flag==1)
{cout>s;}
else
cout
cout
cin>>num;
bookmanage.delbook(s,num,flag);//删除书本
system(“clear”);//清理屏幕
break;
case 3:
cout
cin>>flag;
if(flag==0)
{cout>s;}
else if(flag==1)
{cout>s;}
else
cout
cout
cin>>;
stumanage.lendbook(,s,flag);
system(“clear”);//清理屏幕
break;
case 4: cout
“
cin>>flag;if(flag==0)
{cout>s;} else if(flag==1){cout>s;} else
”
“
”
cout>;stumanage.backbook(,s,flag);system(“clear”);//清理屏幕
break;case 5: cout>flag;if(flag==0){cout>s;} else if(flag==1){cout>s;}
else cout
system(“clear”);//清理屏幕
break;case 7: cout>flag;
if(flag==0){cout>s;} else if(flag==1){cout>s;} else cout
system(“clear”);//清理屏幕
break;case 8: cout
cin>>flag;
if(flag==0)
{cout>s;} else if(flag==1)
{cout>s;} else cout
break;case 9:
cout>s;
stumanage.paydebt(s);system(“clear”);//清理屏幕
break;case 10: stumanage.mux_stu_book();system(“clear”);//清理屏幕
break;default:
cout
}
}
break;case 2: while(1){
cout
cin>>s1;
if(s1==“0”){return 0;}
coutnext){ if(p->stu.stu_name==s1){
while(1)
{
if(p->stu.paword==s2)
break;
else
0“NONE
{
if(s2==”0“)return 0;
cout
”
“
s2=set_pawd();
cout
//cin>>s2
}
}
break;
} } if(p==NULL)cout
break;}
while(1){ MenuStu();int t;cin>>t;switch(t){
case 0: //savestu();savebook();
mysql_close(&mysql);//关闭数据库链接
return 0;break;
case 1:
cout
cin>>flag;
if(flag==0)
{cout>s;}
else if(flag==1)
{cout>s;}
else
cout
stumanage.lendbook(s1,s,flag);
system(”clear“);//清理屏幕
break;
case 2: cout
cin>>flag;if(flag==0)
{cout>s;} else if(flag==1)
{cout>s;} else
cout
”
}
system(“clear”);//清理屏幕
break;case 3: cout
cin>>flag;if(flag==0)
{cout>s;} else if(flag==1)
} {cout>s;} else cout
break;
case 4: stumanage.findstu(s1,1);system(“clear”);//清理屏幕
break;
default: cout
} break;default: cout