#include "adminframe.h"
#include "ui_adminframe.h"
#include <qmessagebox.h>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <qdebug.h>
using namespace std;
using namespace DataManagement;
using namespace UserManagement;
using namespace BookManagement;
void adminframe::hidetxtbtn(){
ui->label_2->hide();ui->label_3->hide();
ui->resultAccount->hide();ui->resultKind->hide();
ui->changeButton_2->hide();ui->newpassEdit_2->hide();
ui->deleteButton->hide();
ui->newpassEdit->clear();ui->newpassEdit_2->clear();
}
void adminframe::showtxtbtn(){
ui->label_2->show();ui->label_3->show();
ui->resultAccount->show();ui->resultKind->show();
ui->changeButton_2->show();ui->newpassEdit_2->show();
ui->deleteButton->show();
}
adminframe::adminframe(QWidget *parent) :
QDialog(parent),
ui(new Ui::adminframe)
{
addAccountFrame = new addaccount();
addAccountFrame->hide();
addBookFrame = new addbook();
addBookFrame->hide();
ui->setupUi(this);
hidetxtbtn();
connect(this,SIGNAL(exittoindex()),parent,SLOT(showagain()));
resultHide();
flag = -1;
}
adminframe::~adminframe()
{
delete ui;
}
void adminframe::showagain(){
this->show();
}
void adminframe::receive(QString str){
accountReceive = str;
ui->labelAccount->setText(accountReceive);
ui->labelAccount->adjustSize();
}
void adminframe::on_exitButton_clicked()
{
hidetxtbtn();
resultHide();
ui->warn->clear();ui->searchbook->clear();ui->searchbook->show();ui->warn->show();
ui->pushButton->show();ui->pushButton_2->hide();
emit exittoindex();
reject();
}
void adminframe::on_adduserButton_clicked()
{
addAccountFrame->show();
}
void adminframe::on_changeButton_clicked()
{
if(ui->newpassEdit->text().isEmpty()){
QMessageBox::warning(this,tr("Warning"),QString::fromLocal8Bit("请输入所要修改的密码!"),QMessageBox::Ok);
}
else{
if(UpdataUserPassword(q_s(ui->labelAccount->text()),q_s(ui->newpassEdit->text()))){
QMessageBox::information(this,tr("Prompt"),QString::fromLocal8Bit("修改成功"),QMessageBox::Ok);
ui->newpassEdit->clear();
}
else{
QMessageBox::information(this,tr("Prompt"),QString::fromLocal8Bit("修改成功"),QMessageBox::Ok);
ui->newpassEdit->clear();
}
}
}
void adminframe::on_searchButton_clicked()
{
hidetxtbtn();
if(ui->searchEdit->text().isEmpty()){
QMessageBox::warning(this,tr("Warning"),QString::fromLocal8Bit("请输入所要查询内容!"),QMessageBox::Ok);
}
else{
User *resultuser = SelectUser(q_s(ui->searchEdit->text()));
if(resultuser!=nullptr){
ui->resultAccount->setText(s_q(resultuser->Name));
if(!strcmp(q_s(resultuser->type).c_str(),"admin")){
ui->resultKind->setText(s_q("管理员"));
}
else if(!strcmp(q_s(resultuser->type).c_str(),"user")){
ui->resultKind->setText(s_q("用户"));
}
else{
ui->resultKind->clear();
}
showtxtbtn();
}
else{
QMessageBox::information(this,tr("Prompt"),QString::fromLocal8Bit("不存在该用户"),QMessageBox::Ok);
hidetxtbtn();
ui->searchEdit->clear();
}
ui->searchEdit->clear();
}
}
void adminframe::on_changeButton_2_clicked()
{
if(ui->newpassEdit_2->text().isEmpty()){
QMessageBox::warning(this,tr("Warning"),QString::fromLocal8Bit("请输入所要修改的密码!"),QMessageBox::Ok);
}
else{
if(UpdataUserPassword(q_s(ui->resultAccount->text()),q_s(ui->newpassEdit_2->text()))){
QMessageBox::information(this,tr("Prompt"),QString::fromLocal8Bit("修改成功"),QMessageBox::Ok);
ui->newpassEdit_2->clear();
}
else{
QMessageBox::information(this,tr("Prompt"),QString::fromLocal8Bit("修改失败"),QMessageBox::Ok);
ui->newpassEdit_2->clear();
}
}
}
void adminframe::on_deleteButton_clicked()
{
if(!strcmp(q_s(ui->resultAccount->text()).c_str(),"root")){
QMessageBox::warning(this,tr("Warning"),QString::fromLocal8Bit("还想玩不,系统总管理员不允许删除!"),QMessageBox::Ok);
}
else if(!strcmp(q_s(ui->labelAccount->text()).c_str(),q_s(ui->resultAccount->text()).c_str())){
QMessageBox::warning(this,tr("Warning"),QString::fromLocal8Bit("不允许自己删自己啊~亲"),QMessageBox::Ok);
}
else{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Delete user", QString::fromLocal8Bit("确认删除用户?"),QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes)
{
int deleteresult = UserManagement::DeleteUser(q_s(ui->resultAccount->text()));
if (deleteresult == -1) {
QMessageBox::warning(this,tr("Faile"),QString::fromLocal8Bit("该用户有在借书籍!删除失败,请督促还书!"),QMessageBox::Yes);
}else if (deleteresult == 1){
QMessageBox::information(this,tr("Success"),QString::fromLocal8Bit("删除成功"),QMessageBox::Yes);
hidetxtbtn();
}
else{
QMessageBox::warning(this,tr("Fail"),QString::fromLocal8Bit("删除失败"),QMessageBox::Yes);
}
}
else{}
}
}
void adminframe::on_addbookButton_clicked()
{
addBookFrame->show();
}
void adminframe::bottomShow(){
ui->bottom2->clear();
ui->bottom1->show();
ui->bottom2->show();
ui->bottom3->show();
ui->bottom4->show();
}
void adminframe::bottomHide(){
ui->bottom2->clear();
ui->bottom1->hide();
ui->bottom2->hide();
ui->bottom3->hide();
ui->bottom4->hide();
}
void adminframe::resultHide(){
ui->result1->clear();ui->result2->clear();ui->result3->clear();ui->result4->clear();
ui->result1->hide();ui->result2->hide();ui->result3->hide();ui->result4->hide();
ui->result01->hide();ui->result02->hide();ui->result03->hide();ui->result04->hide();
ui->borrowButton->hide();ui->returnButton->hide();ui->deleteBook->hide();
bottomHide();
}
void adminframe::resultShow(){
ui->result1->show();ui->result2->show();ui->result3->show();ui->result4->show();
ui->result01->show();ui->result02->show();ui->result03->show();ui->result04->show();
ui->borrowButton->show();ui->returnButton->show();ui->deleteBook->show();
}
void adminframe::on_pushButton_clicked()
{
ui->returnButton->setStyleSheet("border-radius:5px;background:#fe7023;color:#ffffff;font: 10pt");
ui->borrowButton->setStyleSheet("border-radius:5px;background:#fe7023;color:#ffffff;font: 10pt");
ui->deleteBook->setStyleSheet("border-radius:5px;background:#fe7023;color:#ffffff;font: 10pt");
ui->returnButton->setEnabled(true);ui->borrowButton->setEnabled(true);ui->deleteBook->setEnabled(true);
resultHide();
ui->warn->clear();
if(ui->searchbook->text().isEmpty()){
QMessageBox::warning(this,tr("Warning"),QString::fromLocal8Bit("请输入查询内容!"),QMessageBox::Ok);
}
else{
QString strPatt = "^\\d+$";
QRegExp rx(strPatt);
if(!rx.exactMatch(ui->searchbook->text())){
ui->warn->setText(s_q("请输入正确的索书号(非负整数)!"));
}
else{
string str = q_s(ui->searchbook->text());
searchID = atoi(str.c_str());
Book* tBook = SelectID<Book>(searchID);
if(tBook->ID == -1){
ui->warn->setText(s_q("不存在此索书号书籍,请返回主界面查询确定"));
}
else{
if(tB
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!! 本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!! 本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!!
资源推荐
资源详情
资源评论
收起资源包目录
C++文件操作-图书馆管理系统:UML课程作业,采用Qt开发.zip (40个子文件)
content
addbook.h 622B
adminframe.png 30KB
addaccount.ui 4KB
addaccount.cpp 3KB
userframe.ui 15KB
data.h 6KB
TwoLibrary.pro 925B
login.cpp 2KB
addaccount.h 530B
TwoLibrary.pro.user 33KB
adminframe.h 1KB
bookmanagement.h 2KB
bookinfo.h 505B
login.png 26KB
bookinfo.cpp 3KB
configure.h 488B
bookinfo.ui 6KB
login.ui 3KB
data.cpp 7KB
userframe.png 27KB
main.cpp 164B
userframe.h 918B
index.h 1019B
bg.png 37KB
usermanagement.cpp 2KB
adminframe.ui 17KB
index.cpp 9KB
addbook.png 26KB
addbook.cpp 4KB
images.qrc 301B
adminframe.cpp 15KB
userframe.cpp 12KB
configure.cpp 164B
bookmanagement.cpp 8KB
bookinfo.png 26KB
addbook.ui 7KB
usermanagement.h 806B
addaccount.png 25KB
index.ui 15KB
login.h 604B
共 40 条
- 1
资源评论
白话机器学习
- 粉丝: 9364
- 资源: 7681
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- GreatHomework.zip
- phpstorm2023.1.5安装包
- 基于电压PI外环+电流PR内环控制的PFC仿真(PSIM)
- Huawei 大型 WLAN 组网 AC 间漫游
- 2024 单回路控制系统整定实验 参考 (1).doc
- 数据库课程设计mysql-查询示例.pdf
- python代码所有文件都在里面
- yolov5-v5.0检测接口,改写的detect.py,改成了一个函数,输入图像,返回检测结果,可用于做可视化界面调用接口
- C语音学习代码实例 - 31 - 40
- yolov5-v6.0检测接口,改写的detect.py,改成了一个函数,输入图像,返回检测结果,可用于做可视化界面调用接口
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功