diff --git a/LibManageSystem_Sever/mainwindow.cpp b/LibManageSystem_Sever/mainwindow.cpp index cf4ef6a00e98b83e5f9b068706f2f682cb45eccb..dfe9b9e5f644ba85fa0d2352cf3bf7b8db1a205c 100644 --- a/LibManageSystem_Sever/mainwindow.cpp +++ b/LibManageSystem_Sever/mainwindow.cpp @@ -31,7 +31,6 @@ MainWindow::MainWindow(Operat *_db, QWidget *parent) connect(server,&TcpServer::ThreadProgressUpdate,monitor_widget,&Monitor::ThreadProgressUpdate); connect(server,&TcpServer::ThreadErrorInfo,monitor_widget,&Monitor::ThreadErrorInfo); connect(server,&TcpServer::newWaitingConnection,monitor_widget,&Monitor::waitingConnection); - dataBase->Judgelogin("xqq105","12345678"); } MainWindow::~MainWindow() { diff --git a/LibManageSystem_Sever/operat.cpp b/LibManageSystem_Sever/operat.cpp index d56c0e37e4f91e90925da0b8a102b5b23111b6b8..b2494eda0ce1750b6c85b3cb130bfacf2140f3e0 100644 --- a/LibManageSystem_Sever/operat.cpp +++ b/LibManageSystem_Sever/operat.cpp @@ -3,6 +3,7 @@ //为了测试我加的,最后可以删除 Operat::Operat() { + } Operat::Operat(QString path) @@ -18,7 +19,7 @@ Operat::Operat(QString path) bool Operat::Borrow(int id,QString user) { //borbooki中存的内容为"书在数据库中编码-书名" - QString a,b,c,d,e;//存borbooki(i=1,2,3,4,5) + QString a,b,c,d,e,message,password;//存borbooki(i=1,2,3,4,5) QString book1,book2,book3,book4,book5;//存书名 QSqlQuery query; QString Num,bookName,BOR,appointedbook;//appointedbook为当前账户预约的书 @@ -69,12 +70,19 @@ bool Operat::Borrow(int id,QString user) e=query3.value("borbook5").toString(); book5=e.mid(e.indexOf("-")+1); appointedbook=query3.value("appointed").toString(); + message=query3.value("message").toString(); + password=query3.value("password").toString(); } //借过该书,不允许再借 if(book1==bookName||book2==bookName||book3==bookName||book4==bookName||book5==bookName) { return false; } + //如果逾期归还书,限制借阅 + if(message.contains("逾期未还书")) + { + return false; + } //borbook1为空,用户有借书的能力,将当前要借的书信息填入borbook1 if(a.isEmpty()) { @@ -90,6 +98,7 @@ bool Operat::Borrow(int id,QString user) if(appointedbook==BOR)//如果用户当前借的书是ta预约的书,清除预约消息 { CancelAppointed(user); + Judgelogin(user,password);//更新消息 } return true; } @@ -108,6 +117,7 @@ bool Operat::Borrow(int id,QString user) if(appointedbook==BOR)//如果用户当前借的书是ta预约的书,清除预约消息 { CancelAppointed(user); + Judgelogin(user,password);//更新消息 } return true; } @@ -125,6 +135,7 @@ bool Operat::Borrow(int id,QString user) if(appointedbook==BOR)//如果用户当前借的书是ta预约的书,清除预约消息 { CancelAppointed(user); + Judgelogin(user,password);//更新消息 } return true; } @@ -142,6 +153,7 @@ bool Operat::Borrow(int id,QString user) if(appointedbook==BOR)//如果用户当前借的书是ta预约的书,清除预约消息 { CancelAppointed(user); + Judgelogin(user,password);//更新消息 } return true; } @@ -160,6 +172,7 @@ bool Operat::Borrow(int id,QString user) if(appointedbook==BOR)//如果用户当前借的书是ta预约的书,清除预约消息 { CancelAppointed(user); + Judgelogin(user,password);//更新消息 } return true; } @@ -182,7 +195,7 @@ bool Operat::Borrow(int id,QString user) //还书 false是因为用户没有借该书,一般不会return false bool Operat::REturn(int id,QString user) { - QString a,b,c,d,e,bookname,appo; + QString a,b,c,d,e,password,bookname,appo; int bk1libcode,bk2libcode, bk3libcode, bk4libcode, bk5libcode; QSqlQuery query2; QString sqlSelect2=QString("select * from User where account='")+user+"';"; @@ -199,6 +212,7 @@ bool Operat::REturn(int id,QString user) bk4libcode=(d.mid(0,d.indexOf("-"))).toInt(); e=query2.value("borbook5").toString(); bk5libcode=(e.mid(0,e.indexOf("-"))).toInt(); + password=query2.value("password").toString(); } if(bk1libcode==id) { @@ -214,6 +228,7 @@ bool Operat::REturn(int id,QString user) query3.exec(sqlupdate2); QString sqlupdate3=QString("update User set returnddl1='' where account='")+user+"';"; query3.exec(sqlupdate3); + Judgelogin(user,password);//更新消息 return true; } else if(bk2libcode==id) @@ -229,6 +244,7 @@ bool Operat::REturn(int id,QString user) query3.exec(sqlupdate2); QString sqlupdate3=QString("update User set returnddl2='' where account='")+user+"';"; query3.exec(sqlupdate3); + Judgelogin(user,password); return true; } else if(bk3libcode==id) @@ -244,6 +260,7 @@ bool Operat::REturn(int id,QString user) query3.exec(sqlupdate2); QString sqlupdate3=QString("update User set returnddl3='' where account='")+user+"';"; query3.exec(sqlupdate3); + Judgelogin(user,password); return true; } else if(bk4libcode==id) @@ -259,6 +276,7 @@ bool Operat::REturn(int id,QString user) query3.exec(sqlupdate2); QString sqlupdate3=QString("update User set returnddl4='' where account='")+user+"';"; query3.exec(sqlupdate3); + Judgelogin(user,password); return true; } else if(bk5libcode==id) @@ -274,6 +292,7 @@ bool Operat::REturn(int id,QString user) query3.exec(sqlupdate2); QString sqlupdate3=QString("update User set returnddl5='' where account='")+user+"';"; query3.exec(sqlupdate3); + Judgelogin(user,password); return true; } else return false; @@ -620,8 +639,11 @@ bool Operat::Judgelogin(QString account, QString password) returnddl[3]=query3.value("returnddl4").toString(); returnddl[4]=query3.value("returnddl5").toString(); appoint=query3.value("appointed").toString(); - ap=appoint.mid(0,appoint.indexOf("-")); - id=ap.toInt(); + if(!appoint.isEmpty()) + { + ap=appoint.mid(0,appoint.indexOf("-")); + id=ap.toInt(); + } } for(int i=0;i<5;i++) { @@ -639,15 +661,15 @@ bool Operat::Judgelogin(QString account, QString password) } if(id!=-1) { - QString is_inlibrary; + QString Num; QSqlQuery querybook; - QString sqlselectbook=QString("select is_inlibrary from book where ID=%1").arg(id); + QString sqlselectbook=QString("select num from book where ID=%1").arg(id); querybook.exec(sqlselectbook); while(querybook.next()) { - is_inlibrary=querybook.value("is_inlibrary").toString(); + Num=querybook.value("num").toString(); } - if(is_inlibrary=="1") + if(Num.toInt()>0) { Message.append("你预约的书籍已经可以借阅了。"); }