diff --git a/LibManageSystem_Sever/addbook.cpp b/LibManageSystem_Sever/addbook.cpp index 41e2d0f54c4afd8bc4a63a97ac5ab974606177ee..8b6f072a0d6e1c3c83a1c2ee9e0ec1e7e15457f9 100644 --- a/LibManageSystem_Sever/addbook.cpp +++ b/LibManageSystem_Sever/addbook.cpp @@ -73,6 +73,7 @@ void addbook::on_pushButton_clicked() { case QMessageBox::Yes: emit ToEditWidget(); + removeTEXT(); break; default: break; } @@ -85,6 +86,7 @@ void addbook::on_pushButton_clicked() void addbook::on_returnBtn_clicked() { emit RetMagWidget(); + removeTEXT(); } diff --git a/LibManageSystem_Sever/dlandeditbook.cpp b/LibManageSystem_Sever/dlandeditbook.cpp index da86cc822f996b904425c6204daf5d92d820be6d..d24c885e4950b651121322df8246f184a58e0738 100644 --- a/LibManageSystem_Sever/dlandeditbook.cpp +++ b/LibManageSystem_Sever/dlandeditbook.cpp @@ -53,7 +53,7 @@ void DlandEdItbook::on_refreshBtn_clicked() int Id=model->data(model->index(index.row(),0)).toInt(); if(index.isValid()) { - EditDialog *w=new EditDialog(db,Id); + EditDialog *w=new EditDialog(db,Id,view,model); w->setWindowTitle("编辑书籍信息"); w->exec(); w->setAttribute(Qt::WA_DeleteOnClose); @@ -63,7 +63,6 @@ void DlandEdItbook::on_refreshBtn_clicked() } - void DlandEdItbook::on_deleteBtn_clicked() { QString Name=ui->namelineEdit->text().trimmed(); diff --git a/LibManageSystem_Sever/editdialog.cpp b/LibManageSystem_Sever/editdialog.cpp index 14bc9bc14bbc0433ba56f31158d0f71c15aea5e4..15d9a4c6d78563246eaad1ef3e9fb35b2624fad9 100644 --- a/LibManageSystem_Sever/editdialog.cpp +++ b/LibManageSystem_Sever/editdialog.cpp @@ -1,9 +1,10 @@ #include "editdialog.h" #include "ui_editdialog.h" -EditDialog::EditDialog(Operat* _db,int ID,QWidget *parent) : - QDialog(parent),ui(new Ui::EditDialog), - db(_db),Id(ID) +EditDialog::EditDialog(Operat* _db,int ID,QTableView *_view, + QSqlQueryModel *_model,QWidget *parent) : + QDialog(parent),view(_view), + model(_model),ui(new Ui::EditDialog),db(_db),Id(ID) { setWindowTitle("编辑书籍信息"); ui->setupUi(this); @@ -51,7 +52,7 @@ void EditDialog::on_EditBtn_clicked() book.append(","); book.append(ui->textEdit->toPlainText()); QStringList booklist=book.split(","); - db->editbook(Id,booklist); + db->editbook(Id,booklist,view,model); QMessageBox::information(this,"提示","编辑成功!"); this->close(); } diff --git a/LibManageSystem_Sever/editdialog.h b/LibManageSystem_Sever/editdialog.h index 281e75094126db508722940ad49738e5ed63e395..41e98c478f35a89c9ee5abfc9d202dd7083ac11c 100644 --- a/LibManageSystem_Sever/editdialog.h +++ b/LibManageSystem_Sever/editdialog.h @@ -13,9 +13,11 @@ class EditDialog : public QDialog Q_OBJECT public: - explicit EditDialog(Operat * _db, int ID, QWidget *parent = nullptr); + explicit EditDialog(Operat * _db, int ID,QTableView *_view, + QSqlQueryModel *_model, QWidget *parent = nullptr); ~EditDialog(); - + QTableView *view; + QSqlQueryModel *model; private slots: void on_EditBtn_clicked(); diff --git a/LibManageSystem_Sever/operat.cpp b/LibManageSystem_Sever/operat.cpp index b0c4252bce3716ca2c98085f2f11956026712cd9..6daed7ece9f2f2b6028d4a67b784b9b031e189bf 100644 --- a/LibManageSystem_Sever/operat.cpp +++ b/LibManageSystem_Sever/operat.cpp @@ -789,7 +789,7 @@ void Operat::deletebook(QString Name, QString ID, QTableView *view, QSqlQueryMod } else if(!index.isValid()&&(Name.isEmpty()&&ID.isEmpty())) QMessageBox::critical(NULL,"警告","您未填入书籍信息也未选中任何书籍条目!"); - searchbookinsever(Name,ID,view,model); + showAll(model,view); } void Operat::deletebookcase1(QString Name, QString ID) @@ -918,7 +918,7 @@ QString Operat::search(int id) return book; } -void Operat::editbook(int ID, QStringList book) +void Operat::editbook(int ID, QStringList book, QTableView *view, QSqlQueryModel *model) { QSqlQuery query; QString sqlupdate=QString("update book set bookname= ? , author= ? , press=?,printdate=?,num=?,type=?,price=?,isbn_code=?,description=? where ID=?"); @@ -934,10 +934,8 @@ void Operat::editbook(int ID, QStringList book) query.addBindValue(book[8]); query.addBindValue(ID); query.exec(); + showAll(model,view); } - - - void Operat::searchbookinsever(QString Name,QString ID,QTableView *view,QSqlQueryModel *model) { int Id=ID.toInt(); @@ -998,7 +996,6 @@ void Operat::searchbookinsever(QString Name,QString ID,QTableView *view,QSqlQuer { QMessageBox::critical(NULL,"错误","查无此书,请检查输入信息!"); } - } bool Operat::logininsever(QString account,QString password) { @@ -1079,7 +1076,7 @@ QString Operat::searchUser(QString account) return user; } -void Operat::deleteUser(QString account) +bool Operat::deleteUser(QString account) { QString SEX; QSqlQuery query; @@ -1095,8 +1092,13 @@ void Operat::deleteUser(QString account) QString sqldelete=QString("delete from User where account='")+account+"';"; query2.exec(sqldelete); QMessageBox::information(NULL,"操作成功","您已经成功删除该用户"); + return true; + } + else + { + QMessageBox::critical(NULL,"输入错误","不存在该用户,请检查输入信息是否错误"); + return false; } - else QMessageBox::critical(NULL,"输入错误","不存在该用户,请检查输入信息是否错误"); } void Operat::edituser(QString account,QStringList user) diff --git a/LibManageSystem_Sever/operat.h b/LibManageSystem_Sever/operat.h index 84b8013301c44432477bce1c0ebbcfed4df2ba9c..98d784c3fc65316be781e345331abeb36f42907f 100644 --- a/LibManageSystem_Sever/operat.h +++ b/LibManageSystem_Sever/operat.h @@ -50,7 +50,7 @@ public: void deletebookcase1(QString Name,QString ID); void deletebookcase2(QTableView *view,QSqlQueryModel *model); QString search(int id); - void editbook(int ID,QStringList book); + void editbook(int ID,QStringList book,QTableView *view,QSqlQueryModel *model); //搜索书籍 Name为书名,ID为书籍在数据库中的编号 void searchbookinsever(QString Name,QString ID,QTableView *view,QSqlQueryModel *model); //判断登录 account为管理员账号,password为管理员密码 @@ -62,7 +62,7 @@ public: //搜索用户 account为用户账号 QString searchUser(QString account); //删除用户 account为用户账号, - void deleteUser(QString account); + bool deleteUser(QString account); //修改用户信息 account为用户账号,QStringList类型的user依次为昵称,性别,电话,邮箱的组合 void edituser(QString account,QStringList user); //发送消息 account为用户账号,message为发送的消息 diff --git a/LibManageSystem_Sever/sendmessagedialog.cpp b/LibManageSystem_Sever/sendmessagedialog.cpp index cd6d3c5bc45438c954e6c6a4b4da0cd6009836b4..d6b70a9b5a578ca598cecddaf4c090d61e09baa2 100644 --- a/LibManageSystem_Sever/sendmessagedialog.cpp +++ b/LibManageSystem_Sever/sendmessagedialog.cpp @@ -1,9 +1,8 @@ #include "sendmessagedialog.h" #include "ui_sendmessagedialog.h" -sendmessageDialog::sendmessageDialog(Operat* _db,QString Account,QWidget *parent) : - QDialog(parent),ui(new Ui::sendmessageDialog), - db(_db),account(Account) +sendmessageDialog::sendmessageDialog(Operat* _db, QString Account, QWidget *parent) : + QDialog(parent),ui(new Ui::sendmessageDialog),db(_db),account(Account) { ui->setupUi(this); } diff --git a/LibManageSystem_Sever/sendmessagedialog.h b/LibManageSystem_Sever/sendmessagedialog.h index 0166e2c91d868a2784851b1a34b01a546cace474..09f78add948b61d76eac111ba9d16202cc6a5e7f 100644 --- a/LibManageSystem_Sever/sendmessagedialog.h +++ b/LibManageSystem_Sever/sendmessagedialog.h @@ -2,6 +2,8 @@ #define SENDMESSAGEDIALOG_H #include +#include +#include #include "operat.h" namespace Ui { class sendmessageDialog; @@ -15,7 +17,6 @@ public: explicit sendmessageDialog(Operat* _db,QString Account,QWidget *parent = nullptr); ~sendmessageDialog(); - private slots: void on_pushButton_clicked(); diff --git a/LibManageSystem_Sever/usermanage.cpp b/LibManageSystem_Sever/usermanage.cpp index bdca3e9901715a3a67afa33990b0db3ca95adc07..65a8d119796d23fcf2aa0509f3f8c1c1241750d6 100644 --- a/LibManageSystem_Sever/usermanage.cpp +++ b/LibManageSystem_Sever/usermanage.cpp @@ -114,10 +114,19 @@ void UserManage::on_SearchBtn_clicked() mod->setItem(4,0,new QStandardItem(userlist[12])); mod->setItem(4,1,new QStandardItem(userlist[13])); ui->appointedbookname->setText(userlist[14]); + open=1; } - else QMessageBox::critical(this,"错误","该用户不存在!"); + else + { + QMessageBox::critical(this,"错误","该用户不存在!"); + open=0; + } + } + else + { + QMessageBox::critical(this,"错误","请先输入账号!"); + open=0; } - else QMessageBox::critical(this,"错误","请先输入账号!"); } void UserManage::resetpassword() @@ -125,8 +134,12 @@ void UserManage::resetpassword() QString account=ui->AcolineEdit->text().trimmed(); if(!account.isEmpty()) { - db->reset(account); - QMessageBox::information(this,"提示","设置成功!"); + on_SearchBtn_clicked(); + if(open==1) + { + db->reset(account); + QMessageBox::information(this,"提示","设置成功!"); + } } else QMessageBox::critical(this,"错误","请先输入账号并查询该账号是否存在!"); } @@ -134,7 +147,15 @@ void UserManage::deleteUser() { QString account=ui->AcolineEdit->text().trimmed(); if(!account.isEmpty()) - db->deleteUser(account); + { + on_SearchBtn_clicked(); + if(open==1) + { + bool flag=db->deleteUser(account); + if(flag) + remove(); + } + } else QMessageBox::critical(this,"错误","请先输入账号并查询该账号是否存在!"); } @@ -143,10 +164,13 @@ void UserManage::sendmessage() QString account=ui->AcolineEdit->text().trimmed(); if(!account.isEmpty()) { - sendmessageDialog *w = new sendmessageDialog(db,account); - w->setWindowTitle("发送消息"); - w->exec(); - w->setAttribute(Qt::WA_DeleteOnClose); + on_SearchBtn_clicked(); + if(open==1) + { + sendmessageDialog *w = new sendmessageDialog(db,account); + w->setWindowTitle("发送消息"); + w->exec(); + } } else QMessageBox::critical(this,"错误","请先输入账号并查询该账号是否存在!"); } @@ -157,23 +181,23 @@ void UserManage::edit() QString phone=ui->PholineEdit->text().trimmed(); if(!account.isEmpty()&&phone.size()==11) { - QString USER=ui->NinlineEdit->text().trimmed(); - USER.append(","); - QString sex; - if(ui->radioBtn_1->isChecked()) - sex="男"; - else if(ui->radioBtn_2->isChecked()) - sex="女"; - USER.append(sex); - USER.append(","); - USER.append(ui->PholineEdit->text().trimmed()); - USER.append(","); - USER.append(ui->EmalineEdit->text().trimmed()); - QStringList user=USER.split(","); - db->edituser(account,user); - QMessageBox::information(this,"提示","您已经成功修改用户信息"); - } - else if(phone.size()<11) + QString USER=ui->NinlineEdit->text().trimmed(); + USER.append(","); + QString sex; + if(ui->radioBtn_1->isChecked()) + sex="男"; + else if(ui->radioBtn_2->isChecked()) + sex="女"; + USER.append(sex); + USER.append(","); + USER.append(ui->PholineEdit->text().trimmed()); + USER.append(","); + USER.append(ui->EmalineEdit->text().trimmed()); + QStringList user=USER.split(","); + db->edituser(account,user); + QMessageBox::information(this,"提示","您已经成功修改用户信息"); + } + else if(!account.isEmpty()&&phone.size()<11) { QMessageBox::critical(this,"错误","电话格式错误,请检查!"); } @@ -286,8 +310,8 @@ void UserManage::on_appoBtn_clicked() QString account=ui->AcolineEdit->text().trimmed(); QString appointed=ui->appointedbookname->text().trimmed(); QRegularExpression rgl("([0-9]+)([-])(.+)"); - QRegularExpressionMatch match = rgl.match(appointed); - if(!appointed.isEmpty() && match.hasMatch()) + QRegularExpressionMatch match=rgl.match(appointed); + if(!appointed.isEmpty()&&match.hasMatch()) { int id=(appointed.mid(0,appointed.indexOf("-"))).toInt(); int i=db->Appoint(id,account); @@ -319,5 +343,8 @@ void UserManage::on_EmalineEdit_textChanged(const QString &arg1) ui->EmalineEdit->setCompleter(complete_line); } } - +void UserManage::on_deleteBtn_clicked() +{ + remove(); +} diff --git a/LibManageSystem_Sever/usermanage.h b/LibManageSystem_Sever/usermanage.h index 02fd3fc5ac87670f5b9527cf98099779bacb79bc..017687d30a3bea6fe849e857641ae560618c4f84 100644 --- a/LibManageSystem_Sever/usermanage.h +++ b/LibManageSystem_Sever/usermanage.h @@ -59,11 +59,14 @@ private slots: void on_EmalineEdit_textChanged(const QString &arg1); + void on_deleteBtn_clicked(); + private: Ui::UserManage *ui; Operat* db; QStandardItemModel *mod; QMenu *popMenu; + bool open=0; }; #endif // USERMANAGE_H diff --git a/LibManageSystem_Sever/usermanage.ui b/LibManageSystem_Sever/usermanage.ui index 1638d2af315b5887523279722836033bbe0cfe57..04eedc5b9d6423c876fafc5e7b4d2ac0caccf2fd 100644 --- a/LibManageSystem_Sever/usermanage.ui +++ b/LibManageSystem_Sever/usermanage.ui @@ -384,8 +384,8 @@ - 220 - 260 + 190 + 220 41 22 @@ -403,8 +403,8 @@ - 290 - 260 + 270 + 220 41 22 @@ -419,6 +419,34 @@ + + + + 610 + 450 + 121 + 41 + + + + + 微软雅黑 + 12 + + + + PointingHandCursor + + + background-color:#B0171F; + border-radius:6px; + color:white; + + + + 清空 + + @@ -426,7 +454,7 @@ 0 0 800 - 23 + 28