diff --git a/park/QQ图片20250113203119.jpg b/park/QQ图片20250113203119.jpg new file mode 100644 index 0000000..918f517 Binary files /dev/null and b/park/QQ图片20250113203119.jpg differ diff --git a/park/ai.cpp b/park/ai.cpp new file mode 100644 index 0000000..d863b2a --- /dev/null +++ b/park/ai.cpp @@ -0,0 +1,227 @@ +// ai.cpp +#include "ai.h" +#include "ui_ai.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "message.h" +#include +#include +#include + +ai::ai(QWidget *parent) : + QWidget(parent), + ui(new Ui::ai) +{ + // 显示车牌图片 + lb_pix = new QLabel; + lb_pix->setFixedSize(490, 350); + lb_pix->setScaledContents(true); + // 加载并显示名为 'fen.png' 的图片 + QPixmap pixmap(":/fen.png"); // 假设图片文件已添加到 Qt 的资源文件中 + pixmap = pixmap.scaled(lb_pix->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + lb_pix->setPixmap(pixmap); + + // 设置窗口的背景图片 + lb_pix->setStyleSheet("background-image: url(:/fen.png);" + "background-position: center;" + "background-repeat: no-repeat;" + "background-size: cover;"); + + // 设置载入车牌按钮 + btn_load = new QPushButton("载入车牌"); + btn_load->setFixedSize(90, 45); + btn_load->setStyleSheet("QPushButton {" + "background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, " + "stop:0.0112994 rgba(173, 216, 230, 255), " + "stop:1 rgba(204, 229, 255, 255)); " + "color: rgb(255, 255, 255); " + "border: 2px solid rgba(170, 255, 255, 200); " + "border-radius: 10px; " + "padding: 5px 10px; " + "font: 16pt \"Candara\"; " + "box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);" + "}" + "QPushButton:hover {" + "background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, " + "stop:0.0112994 rgba(204, 229, 255, 255), " + "stop:1 rgba(173, 216, 230, 255)); " + "border: 2px solid rgba(173, 216, 230, 255);" + "}" + "QPushButton:pressed {" + "background-color: rgba(204, 229, 255, 150); " + "box-shadow: inset 0px 0px 5px rgba(0, 0, 0, 0.2);" + "}"); + + // 设置识别按钮 + btn_decode = new QPushButton("识别"); + btn_decode->setFixedSize(90, 45); + btn_decode->setStyleSheet("QPushButton {" + "background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, " + "stop:0.0112994 rgba(173, 216, 230, 255), " + "stop:1 rgba(204, 229, 255, 255)); " + "color: rgb(255, 255, 255); " + "border: 2px solid rgba(170, 255, 255, 200); " + "border-radius: 10px; " + "padding: 5px 10px; " + "font: 16pt \"Candara\"; " + "box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);" + "}" + "QPushButton:hover {" + "background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, " + "stop:0.0112994 rgba(204, 229, 255, 255), " + "stop:1 rgba(173, 216, 230, 255)); " + "border: 2px solid rgba(173, 216, 230, 255);" + "}" + "QPushButton:pressed {" + "background-color: rgba(204, 229, 255, 150); " + "box-shadow: inset 0px 0px 5px rgba(0, 0, 0, 0.2);" + "}"); + + + // 设置车牌路径输入框 + le_path = new QLineEdit; + le_path->setPlaceholderText("车牌图片路径:"); + le_path->setMinimumHeight(30); + le_path->setStyleSheet("QLineEdit {" + "border: 1px solid rgba(170, 255, 255, 200); " + "border-radius: 10px; " + "padding: 5px 10px; " + "font: 15pt \"微软雅黑\";" + "}"); + + + // 设置识别结果输入框 + le_code = new QLineEdit; + le_code->setPlaceholderText("识别结果:"); + le_code->setMinimumHeight(33); + le_code->setStyleSheet("QLineEdit {" + "border: 1px solid rgba(170, 255, 255, 200); " + "border-radius: 10px; " + "padding: 5px 10px; " + "font: 18pt \"微软雅黑\";" + + "}"); + + speeker = new QTextToSpeech; + httpmanager = new QNetworkAccessManager; + connect(httpmanager, SIGNAL(finished(QNetworkReply*)), this, SLOT(read_ack(QNetworkReply*))); + +// // 2. 排版 + QHBoxLayout *hbox = new QHBoxLayout; + hbox->addWidget(btn_load); + hbox->addWidget(btn_decode); + + QVBoxLayout *mainbox = new QVBoxLayout; +// 车牌图片 + mainbox->addWidget(lb_pix); + + mainbox->addWidget(le_path); + mainbox->addWidget(le_code); + + mainbox->addLayout(hbox); + setLayout(mainbox); + + // 5. 前后台挂接 + connect(btn_load, SIGNAL(clicked(bool)), this, SLOT(load_pix())); + connect(btn_decode, SIGNAL(clicked(bool)), this, SLOT(decode_pix())); + mes = new message; + connect(this, SIGNAL(mySignals(QString)), mes, SLOT(mySlot(QString))); + connect(this, SIGNAL(Signal_out(QString)), mes, SLOT(Slot_out(QString))); + +} + +void ai::load_pix() +{ + QString filename = QFileDialog::getOpenFileName(this, "打开车牌照片", ".", "Images (*.png *.bmp *.jpg)"); + if (filename.isEmpty()) { + return; // 如果没有选择文件,直接返回 + } + + QPixmap pixmap(filename); + if (!pixmap.isNull()) { + // 调整图片大小,以适应QLabel的大小 + pixmap = pixmap.scaled(lb_pix->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + lb_pix->setPixmap(pixmap); + } else { + + qDebug() << "无法加载图片"; + } + le_path->setText(filename); +} + + +void ai::decode_pix() +{ + // 向百度发送一个二维码识别请求(HTTP) + QNetworkRequest myrequset; + + // 填充请求url + myrequset.setUrl(QUrl("https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate?access_token=24.45460c2347791a4df2f2eaf275fe956c.2592000.1737857078.282335-116856660")); + // 填充header + myrequset.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); + + // 填充请求的body + // 1. 挖出照片内容 + QFile file(le_path->text()); + file.open(QIODevice::ReadOnly); + QByteArray buf = file.readAll(); + + // 2. 转成base64及urlcode + QByteArray buf64 = buf.toBase64().toPercentEncoding(); + QByteArray body = "image=" + buf64; + // 发送完整的一次识别请求 + httpmanager->post(myrequset, body); +} + +// 结果解析 +void ai::read_ack(QNetworkReply *r) +{ + // 提取json格式的返回 + QByteArray buf = r->readAll(); + qDebug() << buf; + + // 提取json中的内容 + QJsonDocument myjson = QJsonDocument::fromJson(buf); + QJsonObject node = myjson.object(); + QJsonObject arr = node.value("words_result").toObject(); + QString text = arr.value("number").toString(); + le_code->setText(text); + speeker->say(text+"已识别"); + speeker->setVolume(1.0); // 设置最大音量 + speeker->setRate(-0.2); //放慢速度 + + + // 判断是否已经进入 + QSqlDatabase db = QSqlDatabase::database("text01"); // 使用相同的连接名 "text01" + if (!db.isOpen() && !db.open()) { + qDebug() << "数据库连接失败!"; + return; + } + + QString number = QString("SELECT * FROM car_number WHERE number='%1'").arg(text); + QSqlQuery query(db); + + if (query.exec(number) && query.next()) { + emit Signal_out(text); + } else { + emit mySignals(text); + } +} + +ai::~ai() +{ + delete ui; + delete mes; +} diff --git a/park/ai.h b/park/ai.h new file mode 100644 index 0000000..26c965b --- /dev/null +++ b/park/ai.h @@ -0,0 +1,58 @@ +#ifndef AI_H +#define AI_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#include "message.h" + +namespace Ui { +class ai; +} + +class ai : public QWidget +{ + Q_OBJECT + +public: + // 构造函数和析构函数 + explicit ai(QWidget *parent = nullptr); + ~ai(); + + // UI 控件声明 + QLabel *lb_pix; // 显示图片的标签 + QLabel *lb; // 可以用于额外的显示信息 + QLineEdit *le_path; // 输入车牌图片路径 + QLineEdit *le_code; // 显示识别结果 + QPushButton *btn_load; // 加载图片按钮 + QPushButton *btn_decode; // 识别图片按钮 + QNetworkAccessManager *httpmanager; // 网络请求管理器 + QTextToSpeech *speeker; // 语音合成对象 + + QByteArray toBase64(const QImage &image); // 转换图片为base64编码 + +public slots: + void read_ack(QNetworkReply* reply); // 处理请求回调 + void load_pix(); // 加载图片的槽函数 + void decode_pix(); // 识别图片的槽函数 + +signals: + void mySignals(QString str); // 自定义信号,向外发送车牌号 + void Signal_out(QString str); // 发送车牌号给外部系统 + +private: + Ui::ai *ui; // UI对象,用于管理和更新界面 + message *mes; // 业务逻辑对象,用于处理信息 +}; + +#endif // AI_H diff --git a/park/ai.ui b/park/ai.ui new file mode 100644 index 0000000..4814fbd --- /dev/null +++ b/park/ai.ui @@ -0,0 +1,22 @@ + + + ai + + + + 0 + 0 + 600 + 420 + + + + Form + + + background-color: rgb(255, 255, 255); + + + + + diff --git a/park/car.gif b/park/car.gif new file mode 100644 index 0000000..2ff2724 Binary files /dev/null and b/park/car.gif differ diff --git a/park/car.mp4 b/park/car.mp4 new file mode 100644 index 0000000..624b7a5 Binary files /dev/null and b/park/car.mp4 differ diff --git a/park/car.png b/park/car.png new file mode 100644 index 0000000..cf3e140 Binary files /dev/null and b/park/car.png differ diff --git a/park/change_ui.cpp b/park/change_ui.cpp new file mode 100644 index 0000000..5f5c0aa --- /dev/null +++ b/park/change_ui.cpp @@ -0,0 +1,6 @@ +#include "change_ui.h" + +change_ui::change_ui() +{ + +} diff --git a/park/change_ui.h b/park/change_ui.h new file mode 100644 index 0000000..227a628 --- /dev/null +++ b/park/change_ui.h @@ -0,0 +1,11 @@ +#ifndef CHANGE_UI_H +#define CHANGE_UI_H + + +class change_ui +{ +public: + change_ui(); +}; + +#endif // CHANGE_UI_H \ No newline at end of file diff --git a/park/charge_rules.cpp b/park/charge_rules.cpp new file mode 100644 index 0000000..402a419 --- /dev/null +++ b/park/charge_rules.cpp @@ -0,0 +1,40 @@ +#include "charge_rules.h" +#include "ui_charge_rules.h" +#include +#include + +charge_rules::charge_rules(QWidget *parent) : + QDialog(parent), + ui(new Ui::charge_rules) +{ + ui->setupUi(this); + rule=new cost; + connect(this,SIGNAL(Signal_rules(double,double,double,double)),rule,SLOT(Slot_rules(double,double,double,double))); + this->setWindowTitle("收费规则"); +} + +charge_rules::~charge_rules() +{ + delete ui; + delete rule; +} + +void charge_rules::on_pushButton_2_clicked() +{ + this->close(); +} + +void charge_rules::on_pushButton_clicked() +{ + QString T=ui->lineEdit->text(); + QString money=ui->lineEdit_2->text(); + QString free=ui->lineEdit_3->text(); + QString max=ui->lineEdit_4->text(); + double t=T.toDouble(); + double m=money.toDouble(); + double f=free.toDouble(); + double mm=max.toDouble(); + emit Signal_rules(t,m,f,mm); + QMessageBox::about(NULL, "消息框", "修改成功"); + this->close(); +} diff --git a/park/charge_rules.h b/park/charge_rules.h new file mode 100644 index 0000000..197ce6f --- /dev/null +++ b/park/charge_rules.h @@ -0,0 +1,33 @@ +#ifndef CHARGE_RULES_H +#define CHARGE_RULES_H + +#include +#include "cost.h" + +namespace Ui { +class charge_rules; +} + +class charge_rules : public QDialog +{ + Q_OBJECT + +public: + explicit charge_rules(QWidget *parent = 0); + ~charge_rules(); + +private slots: + void on_pushButton_2_clicked(); + + void on_pushButton_clicked(); + +signals: + void Signal_rules(double t,double m,double f,double max); + +private: + Ui::charge_rules *ui; + cost *rule; + +}; + +#endif // CHARGE_RULES_H diff --git a/park/charge_rules.ui b/park/charge_rules.ui new file mode 100644 index 0000000..4379bd9 --- /dev/null +++ b/park/charge_rules.ui @@ -0,0 +1,192 @@ + + + charge_rules + + + + 0 + 0 + 500 + 400 + + + + + 500 + 400 + + + + + 500 + 400 + + + + Dialog + + + + + 90 + 280 + 101 + 51 + + + + + 14 + + + + 更改 + + + + + + 300 + 280 + 91 + 51 + + + + + 14 + + + + 返回 + + + + + + 40 + 40 + 401 + 201 + + + + + + + + + + 14 + + + + 计费周期(分钟): + + + + + + + + 14 + + + + 周期收费(元): + + + + + + + + 14 + + + + 免费时长(分钟): + + + + + + + + 14 + + + + 最高收费(元): + + + + + + + + + + + + 14 + + + + 30 + + + + + + + + 14 + + + + + + + 1.5 + + + + + + + + 14 + + + + + + + 15 + + + + + + + + 14 + + + + + + + 30 + + + + + + + + + + + diff --git a/park/cost.h b/park/cost.h new file mode 100644 index 0000000..fb83578 --- /dev/null +++ b/park/cost.h @@ -0,0 +1,34 @@ +#ifndef COST_H +#define COST_H + +#include +#include "message.h" + +namespace Ui { +class cost; +} +class message; +class cost : public QDialog +{ + Q_OBJECT + +public: + explicit cost(QWidget *parent = 0); + ~cost(); + + double T,money,free,max; + +private slots: + void on_pushButton_clicked(); + void Slot_cost(int time,QString number); + void Slot_rules(double t,double m,double f,double max); + +private: + Ui::cost *ui; + message *m; + +signals: + void Signal_message(QString number,int total,double pay); +}; + +#endif // COST_H diff --git a/park/cost.ui b/park/cost.ui new file mode 100644 index 0000000..0d5ea91 --- /dev/null +++ b/park/cost.ui @@ -0,0 +1,129 @@ + + + cost + + + + 0 + 0 + 400 + 300 + + + + + 400 + 300 + + + + + 400 + 300 + + + + + 4 + 0 + + + + Dialog + + + + + 20 + 40 + 341 + 141 + + + + + + + + + + 14 + + + + 停车时长(分钟): + + + + + + + + 14 + + + + 收费总额(元): + + + + + + + + + + + + 16777215 + 35 + + + + + 14 + + + + + + + + + 16777215 + 35 + + + + + 14 + + + + + + + + + + + + 130 + 210 + 111 + 51 + + + + + 14 + + + + 返回 + + + + + + diff --git a/park/fen.jpg b/park/fen.jpg new file mode 100644 index 0000000..d7326f1 Binary files /dev/null and b/park/fen.jpg differ diff --git a/park/fen.png b/park/fen.png new file mode 100644 index 0000000..547fcc2 Binary files /dev/null and b/park/fen.png differ diff --git a/park/house.jpg b/park/house.jpg new file mode 100644 index 0000000..95348d2 Binary files /dev/null and b/park/house.jpg differ diff --git a/park/huoche.png b/park/huoche.png new file mode 100644 index 0000000..fad5c01 Binary files /dev/null and b/park/huoche.png differ diff --git a/park/images.qrc b/park/images.qrc new file mode 100644 index 0000000..db0e3f3 --- /dev/null +++ b/park/images.qrc @@ -0,0 +1,12 @@ + + + car.gif + house.jpg + pig.gif + sun.gif + huoche.png + tian.png + fen.png + car.png + + diff --git a/park/login.cpp b/park/login.cpp new file mode 100644 index 0000000..257d023 --- /dev/null +++ b/park/login.cpp @@ -0,0 +1,98 @@ +#include "login.h" +#include "ui_login.h" +#include +#include "signal.h" +#include +#include +#include +#include "widget.h" +#include //设置阴影 +#include // 包含QMovie的头文件 + +#include +#include +#include + +login::login(QWidget *parent) : QDialog(parent), + ui(new Ui::login) +{ + ui->setupUi(this); + sign = new sign_in; + w = new Widget; + + QMediaPlaylist *musicList = new QMediaPlaylist(this); // 创建音乐播放列表 + musicList->addMedia(QUrl::fromLocalFile("D:/sparking111dui/111/park/yun.wav")); // 添加本地音乐文件 + + QMediaPlayer *soundPlayer = new QMediaPlayer(this); // 创建音乐播放器 + soundPlayer->setPlaylist(musicList); // 设置音乐播放列表 + soundPlayer->play(); // 播放音乐 + + // 如果只有一首音乐,设置为循环播放 + musicList->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); + soundPlayer->setVolume(80); + + //插入图片 + QPixmap house(":/house.jpg"); + ui->label_3->setPixmap(house); + //设置阴影 + QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this); + shadow->setOffset(-3, 0); + shadow->setColor(QColor("#888888")); + shadow->setBlurRadius(30); + ui->label_3->setGraphicsEffect(shadow); + + //动图 + QMovie *movie = new QMovie(":/sun.gif"); + ui->label_2->setMovie(movie); + movie->start(); + + connect(ui->pass, &QLineEdit::returnPressed, this, &login::on_login_2_clicked); + + this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); + +} + +login::~login() +{ + delete ui; + delete sign; + delete w; +} + +void login::on_exit_clicked() +{ + close(); +} + +void login::on_login_2_clicked() +{ + QString username = ui->name->text(); + QString userpwd = ui->pass->text(); + + // 使用在 main 中创建的数据库连接 + QSqlDatabase db = QSqlDatabase::database("text01"); + + if (!db.isOpen()) { + QMessageBox::warning(this, tr("警告!"), tr("数据库未打开!"), QMessageBox::Yes); + return; + } + + QString userQuery = QString("select * from user where name='%1' and pass='%2' ").arg(username).arg(userpwd); + QSqlQuery query(db); // 使用 db 对象来执行查询 + if (query.exec(userQuery) && query.next()) { + w->show(); + this->hide(); + } else { + QMessageBox::warning(this, tr("警告!"), tr("用户名或密码错误!"), QMessageBox::Yes); + ui->name->clear(); + ui->pass->clear(); + ui->name->setFocus(); + } +} + + + +void login::on_pushButton_clicked() +{ + sign->exec(); +} diff --git a/park/login.h b/park/login.h new file mode 100644 index 0000000..ac899fb --- /dev/null +++ b/park/login.h @@ -0,0 +1,36 @@ +#ifndef LOGIN_H +#define LOGIN_H + +#include +#include "sign_in.h" +#include "widget.h" + +#include +#include + +namespace Ui { +class login; +} + +class login : public QDialog +{ + Q_OBJECT + +public: + explicit login(QWidget *parent = nullptr); + ~login(); + +private slots: + void on_exit_clicked(); + + void on_login_2_clicked(); + + void on_pushButton_clicked(); + +private: + Ui::login *ui; + sign_in *sign; + Widget *w; +}; + +#endif // LOGIN_H diff --git a/park/login.ui b/park/login.ui new file mode 100644 index 0000000..f7a65b9 --- /dev/null +++ b/park/login.ui @@ -0,0 +1,276 @@ + + + login + + + + 0 + 0 + 600 + 420 + + + + + 0 + 0 + + + + + 600 + 420 + + + + + 600 + 420 + + + + Dialog + + + background-color: rgb(255, 255, 255); + + + + + 190 + 370 + 61 + 31 + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 14pt "Candara"; + + + 注册 + + + + + + 300 + 0 + 300 + 420 + + + + + 300 + 420 + + + + + + + true + + + + + + 110 + 380 + 80 + 21 + + + + font: 10pt "宋体"; + + + 没有账号?去注册 + + + + + + -10 + 0 + 151 + 141 + + + + + 16 + + + + + + + true + + + + + + 20 + 160 + 241 + 41 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: rgb(247, 247, 247); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + 请输入用户名 + + + + + + 20 + 230 + 241 + 41 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: rgb(247, 247, 247); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + QLineEdit::Password + + + 请输入密码 + + + + + + 170 + 290 + 81 + 40 + + + + + 0 + 40 + + + + + 100 + 16777215 + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 20pt "Candara"; + + + 退出 + + + + + + 30 + 290 + 81 + 40 + + + + + 0 + 40 + + + + + 100 + 16777215 + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 20pt "Candara"; + + + 登录 + + + + + + 90 + 90 + 201 + 61 + + + + + 微软雅黑 + 24 + 9 + false + false + + + + font: 75 24pt "微软雅黑"; + + + <html><head/><body><p align="center">阳光小区欢迎您!</p></body></html> + + + + + + diff --git a/park/main.cpp b/park/main.cpp new file mode 100644 index 0000000..377d429 --- /dev/null +++ b/park/main.cpp @@ -0,0 +1,33 @@ +#include "widget.h" +#include +#include "login.h" +#include "ai.h" +#include +#include + +int main(int argc, char *argv[]) +{ + + if(QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication a(argc, argv); // 放在这一句的前面 + + // 创建并打开数据库连接 + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "text01"); + db.setDatabaseName("D:\\parking\\sqlite-tools-win-x64-3470200\\test01.db"); + + if (!db.open()) { + QMessageBox::critical(nullptr, "错误", "数据库连接失败!"); + return -1; // 连接失败,程序退出 + } + + qDebug() << "数据库连接成功!"; + + login l; + l.setWindowTitle("登录"); + l.show(); + + + + return a.exec(); +} diff --git a/park/message.cpp b/park/message.cpp new file mode 100644 index 0000000..1e2314f --- /dev/null +++ b/park/message.cpp @@ -0,0 +1,98 @@ +#include "message.h" +#include +#include +#include +#include +#include +#include "widget.h" +#include + +message::message() +{ +} + +void message::mySlot(QString str) +{ + // 使用在 main 中创建的数据库连接 + QSqlDatabase db = QSqlDatabase::database("text01"); + + if (!db.isOpen()) { + QMessageBox::warning(this, tr("警告!"), tr("数据库未打开!"), QMessageBox::Yes); + return; + } + + // 查询空车位数量 + QString temp_car = QString("select * from cnt where number='%1' ").arg("number_of_c"); + QSqlQuery temp_query(db); // 使用 db 对象来执行查询 + temp_query.exec(temp_car); + temp_query.next(); + int temp_cnt = temp_query.value(1).toInt(); + if (temp_cnt == 0) { + QMessageBox::warning(this, tr("警告!"), tr("停车场已无车位"), QMessageBox::Yes); + } else { + // 进入操作 + QString number = QString("select * from message where number='%1' ").arg(str); + QSqlQuery query(db), query_1(db), query_2(db); + int times; + // 存储进入次数 + if (query.exec(number) && query.next()) { + // 修改已有信息 + times = query.value(1).toInt(); + times++; + QString temp = QString("update message set times = '%1' where number = '%2'").arg(times).arg(str); + query.exec(temp); + } else { + // 第一次进入 + QString s = QString("insert into message(number, times, total_time, pay) values('%1', '%2', '%3', '%4')") + .arg(str).arg(1).arg(0).arg(0); + query_2.exec(s); + } + + // 更改车场信息 + temp_cnt--; + QString temp_change = QString("update cnt set cnt = '%1' where number = '%2'").arg(temp_cnt).arg("number_of_c"); + temp_query.exec(temp_change); + + // 获取当前时间 + QDateTime dateTime(QDateTime::currentDateTime()); + QString time = dateTime.toString("yyyy-MM-dd hh:mm:ss"); + + // 存储车牌和进入时间 + QString ch = QString("insert into car_number(number, time) values('%1', '%2')").arg(str).arg(time); + query_1.exec(ch); + } +} + +void message::Slot_out(QString str) +{ + // 使用在 main 中创建的数据库连接 + QSqlDatabase db = QSqlDatabase::database("text01"); + + if (!db.isOpen()) { + QMessageBox::warning(this, tr("警告!"), tr("数据库未打开!"), QMessageBox::Yes); + return; + } + + QString Str = QString("select * from car_number where number='%1' ").arg(str); + QSqlQuery query(db); + query.exec(Str); + query.next(); + QString time = query.value(1).toString(); + QDateTime time_1 = QDateTime::fromString(time, "yyyy-MM-dd hh:mm:ss"); + QDateTime time_2 = QDateTime::currentDateTime(); + int second = time_1.secsTo(time_2); // 计算时间差 + + // 删除数据库中车牌号 + QString a = QString("delete from car_number where number = '%1'").arg(str); + query.exec(a); + + // 更改车场信息 + QString temp_car = QString("select * from cnt where number='%1' ").arg("number_of_c"); + QSqlQuery temp_query(db); + temp_query.exec(temp_car); + temp_query.next(); + int temp_cnt = temp_query.value(1).toInt(); + temp_cnt++; + QString temp_change = QString("update cnt set cnt = '%1' where number = '%2'").arg(temp_cnt).arg("number_of_c"); + temp_query.exec(temp_change); +} diff --git a/park/message.h b/park/message.h new file mode 100644 index 0000000..274b5ca --- /dev/null +++ b/park/message.h @@ -0,0 +1,28 @@ +#ifndef MESSAGE_H +#define MESSAGE_H +#include +#include +#include + +class ai; +class cost; +class message:public QWidget +{ + Q_OBJECT +public: + + message(); + + +public slots: + void mySlot(QString str); + void Slot_out(QString str); + +signals: + void Signal_cost(int time,QString number); + +private: + cost *cos; +}; + +#endif // MESSAGE_H diff --git a/park/moon.gif b/park/moon.gif new file mode 100644 index 0000000..bfb50ee Binary files /dev/null and b/park/moon.gif differ diff --git a/park/music.qrc b/park/music.qrc new file mode 100644 index 0000000..7646d2b --- /dev/null +++ b/park/music.qrc @@ -0,0 +1 @@ + diff --git a/park/number_of_car.cpp b/park/number_of_car.cpp new file mode 100644 index 0000000..3c481f3 --- /dev/null +++ b/park/number_of_car.cpp @@ -0,0 +1,55 @@ +#include "number_of_car.h" +#include "ui_number_of_car.h" +#include +#include +#include +#include +#include // 包含QMovie的头文件 + +number_of_car::number_of_car(QWidget *parent) : QDialog(parent), + ui(new Ui::number_of_car) +{ + ui->setupUi(this); + this->setWindowTitle("车场信息"); + + //动图 + QMovie *movie = new QMovie(":/car.png"); + ui->label_3->setMovie(movie); + movie->start(); + + this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); + +} + +number_of_car::~number_of_car() +{ + delete ui; +} + +void number_of_car::on_pushButton_clicked() +{ + this->close(); +} + +void number_of_car::cnt_slot() +{ + + // 使用在 main 中创建的数据库连接,获取当前车场内车辆数 + QSqlDatabase db = QSqlDatabase::database("text01"); + + if (!db.isOpen()) { + QMessageBox::warning(this, tr("警告!"), tr("数据库未打开!"), QMessageBox::Yes); + return; + } + + QString str = QString("select * from cnt where number='%1' ").arg("number_of_c"); + QSqlQuery query(db); + query.exec(str); + query.next(); + int cnt = query.value(1).toInt(); + QString cnt_str_1 = QString::number(cnt); + QString cnt_str_2 = QString::number(100 - cnt); + // 显示信息 + ui->textBrowser->setText(cnt_str_1); + ui->textBrowser_2->setText(cnt_str_2); +} diff --git a/park/number_of_car.h b/park/number_of_car.h new file mode 100644 index 0000000..7d307cd --- /dev/null +++ b/park/number_of_car.h @@ -0,0 +1,26 @@ +#ifndef NUMBER_OF_CAR_H +#define NUMBER_OF_CAR_H + +#include + +namespace Ui { +class number_of_car; +} + +class number_of_car : public QDialog +{ + Q_OBJECT + +public: + explicit number_of_car(QWidget *parent = nullptr); + ~number_of_car(); + +private slots: + void on_pushButton_clicked(); + void cnt_slot(); + +private: + Ui::number_of_car *ui; +}; + +#endif // NUMBER_OF_CAR_H diff --git a/park/number_of_car.ui b/park/number_of_car.ui new file mode 100644 index 0000000..b8aed12 --- /dev/null +++ b/park/number_of_car.ui @@ -0,0 +1,221 @@ + + + number_of_car + + + + 0 + 0 + 600 + 420 + + + + + 600 + 420 + + + + + 600 + 420 + + + + false + + + false + + + Dialog + + + background-color: rgb(255, 255, 255); + + + + + 0 + -10 + 601 + 431 + + + + + + + true + + + + + + 200 + 120 + 71 + 31 + + + + + Candara + 16 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(255, 207, 255, 255), +stop:1 rgbargb(255, 255, 255)); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 16pt "Candara"; + + + 返回 + + + + + + 140 + 20 + 141 + 41 + + + + + 16777215 + 100 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(255, 220, 255, 255), +stop:1 rgbargb(179, 226, 255)); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + + + + + + 140 + 70 + 141 + 41 + + + + + 16777215 + 100 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(255, 220, 255, 255), +stop:1 rgbargb(179, 226, 255)); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + + + + + + 40 + 70 + 91 + 41 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(255, 220, 255, 255), +stop:1 rgbargb(179, 226, 255)); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + + + <html><head/><body><p align="center">停车场车辆:</p></body></html> + + + + + + 40 + 20 + 91 + 41 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(255, 220, 255, 255), +stop:1 rgbargb(179, 226, 255)); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + + + <html><head/><body><p align="center">空位数:</p></body></html> + + + + + + diff --git a/park/park.pro b/park/park.pro new file mode 100644 index 0000000..c3f189d --- /dev/null +++ b/park/park.pro @@ -0,0 +1,67 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-08-17T19:06:56 +# +#------------------------------------------------- + +QT += core gui network texttospeech +QT += sql +QT += network +QT += texttospeech + + +INCLUDEPATH += D:/sparking111dui/OpenSSL-Win64/include + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +TARGET = park +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + widget.cpp \ + login.cpp \ + ai.cpp \ + sign_in.cpp \ + message.cpp \ + number_of_car.cpp \ + serch.cpp + +HEADERS += \ + widget.h \ + login.h \ + ai.h \ + sign_in.h \ + message.h \ + number_of_car.h \ + serch.h + +FORMS += \ + widget.ui \ + login.ui \ + ai.ui \ + sign_in.ui \ + number_of_car.ui \ + serch.ui + +RESOURCES += \ + images.qrc + +INCLUDEPATH += D:\sparking111dui\111\OpenSSL-Win64\include + +LIBS += D:\sparking111dui\111\OpenSSL-Win64\lib\libeay32.lib \ + D:\sparking111dui\111\OpenSSL-Win64\lib\ssleay32.lib + +QT += multimedia + diff --git a/park/park.pro.user b/park/park.pro.user new file mode 100644 index 0000000..5157200 --- /dev/null +++ b/park/park.pro.user @@ -0,0 +1,598 @@ + + + + + + EnvironmentId + {775bc719-e320-4834-8d84-fdf7ebf0144e} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.12.3 MinGW 64-bit + Desktop Qt 5.12.3 MinGW 64-bit + qt.qt5.5123.win64_mingw73_kit + 0 + 0 + 0 + + D:/sparking111/111/build-park-Desktop_Qt_5_12_3_MinGW_64_bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + D:/sparking111/111/build-park-Desktop_Qt_5_12_3_MinGW_64_bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + D:/sparking111/111/build-park-Desktop_Qt_5_12_3_MinGW_64_bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + park + + Qt4ProjectManager.Qt4RunConfiguration:D:/sparking111dui/111/park/park.pro + + 3768 + false + true + true + false + false + true + + D:/sparking111/111/build-park-Desktop_Qt_5_12_3_MinGW_64_bit-Debug + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop Qt 5.12.3 MinGW 32-bit + Desktop Qt 5.12.3 MinGW 32-bit + qt.qt5.5123.win32_mingw73_kit + 0 + 0 + 0 + + D:/sparking111/111/build-park-Desktop_Qt_5_12_3_MinGW_32_bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + D:/sparking111/111/build-park-Desktop_Qt_5_12_3_MinGW_32_bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + D:/sparking111/111/build-park-Desktop_Qt_5_12_3_MinGW_32_bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + park + park2 + Qt4ProjectManager.Qt4RunConfiguration:D:/sparking111dui/111/park/park.pro + + 3768 + false + true + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 21 + + + Version + 21 + + diff --git a/park/park.pro.user.360982c.4.8-pre1 b/park/park.pro.user.360982c.4.8-pre1 new file mode 100644 index 0000000..e5dcd84 --- /dev/null +++ b/park/park.pro.user.360982c.4.8-pre1 @@ -0,0 +1,318 @@ + + + + + + EnvironmentId + {360982ca-123b-45be-8195-e3d14adba110} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.10.0 MinGW 32bit + Desktop Qt 5.10.0 MinGW 32bit + qt.qt5.5100.win32_mingw53_kit + 0 + 0 + 0 + + C:/Users/86176/Desktop/QT/build-park-Desktop_Qt_5_10_0_MinGW_32bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + C:/Users/86176/Desktop/QT/build-park-Desktop_Qt_5_10_0_MinGW_32bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + C:/Users/86176/Desktop/QT/build-park-Desktop_Qt_5_10_0_MinGW_32bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + 在本地部署 + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + park + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/86176/Desktop/QT/park/park.pro + true + + park.pro + false + + C:/Users/86176/Desktop/QT/build-park-Desktop_Qt_5_10_0_MinGW_32bit-Debug + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/park/pig.gif b/park/pig.gif new file mode 100644 index 0000000..fe868bc Binary files /dev/null and b/park/pig.gif differ diff --git a/park/register.cpp b/park/register.cpp new file mode 100644 index 0000000..8d39ad5 --- /dev/null +++ b/park/register.cpp @@ -0,0 +1,14 @@ +#include "rgt.h" +#include "ui_register.h" + +register::register(QWidget *parent) : + QWidget(parent), + ui(new Ui::register) +{ + ui->setupUi(this); +} + +register::~register() +{ +delete ui; +} diff --git a/park/register.ui b/park/register.ui new file mode 100644 index 0000000..bdefa89 --- /dev/null +++ b/park/register.ui @@ -0,0 +1,119 @@ + + + register + + + + 0 + 0 + 385 + 324 + + + + Form + + + + + 50 + 30 + 291 + 141 + + + + + + + + + + 15 + + + + 用户名 + + + + + + + + 15 + + + + 密码 + + + + + + + + + + + + + + + + + + + + + 50 + 190 + 301 + 81 + + + + + + + + 0 + 50 + + + + + 100 + 16777215 + + + + 注册 + + + + + + + + 0 + 50 + + + + + 100 + 16777215 + + + + 退出 + + + + + + + + + diff --git a/park/rgt.h b/park/rgt.h new file mode 100644 index 0000000..d104eea --- /dev/null +++ b/park/rgt.h @@ -0,0 +1,22 @@ +#ifndef REGISTER_H +#define REGISTER_H + +#include + +namespace Ui { +class register; +} + +class register : public QWidget +{ + Q_OBJECT + +public: + explicit register(QWidget *parent = 0); + ~register(); + +private: + Ui::register *ui; +}; + +#endif // REGISTER_H diff --git a/park/serch.cpp b/park/serch.cpp new file mode 100644 index 0000000..b761e65 --- /dev/null +++ b/park/serch.cpp @@ -0,0 +1,90 @@ +#include "serch.h" +#include "ui_serch.h" +#include +#include +#include +#include +#include //设置阴影 + +serch::serch(QWidget *parent) : QDialog(parent), + ui(new Ui::serch) +{ + ui->setupUi(this); + this->setWindowTitle("查询"); + + //插入图片 + QPixmap tian(":/tian.png"); + ui->label_4->setPixmap(tian); + //设置阴影 + QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this); + shadow->setOffset(-3, 0); + shadow->setColor(QColor("#aaffff")); + shadow->setBlurRadius(80); + ui->label_4->setGraphicsEffect(shadow); + + // 确保数据库连接已经成功建立 + QSqlDatabase db = QSqlDatabase::database("text01", false); // 使用已共享的数据库连接 + if (!db.isOpen()) { + QMessageBox::critical(this, "错误", "数据库未连接成功!"); + return; + } + + this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); + +} + +serch::~serch() +{ + // 可以选择在这里显式关闭数据库连接 + QSqlDatabase::database("text01").close(); + delete ui; +} + +void serch::on_pushButton_2_clicked() +{ + // 清除查询条件和显示区域 + ui->lineEdit->clear(); + ui->textBrowser_4->clear(); + ui->textBrowser_5->clear(); + this->close(); +} + +void serch::on_pushButton_clicked() +{ + // 获取用户输入的车辆号码 + QString str = ui->lineEdit->text(); + + if (str.isEmpty()) { + QMessageBox::warning(this, "警告", "请输入车辆号码!"); + return; + } + + // 获取共享的数据库连接 + QSqlDatabase db = QSqlDatabase::database("text01", false); + if (!db.isOpen()) { + QMessageBox::critical(this, "错误", "数据库未连接成功!"); + return; + } + + // 查询语句 + QString temp = QString("SELECT * FROM message WHERE number='%1'").arg(str); + QSqlQuery query(db); // 使用数据库连接 db + if (query.exec(temp) && query.next()) { + // 数据库查询成功,获取并显示数据 + int t = query.value(1).toInt(); // 假设字段顺序是:t, m + int m = query.value(2).toInt(); + + QString times = QString::number(t); + QString total_time = QString::number(m); + + ui->textBrowser_4->setText(times); + ui->textBrowser_5->setText(total_time); + } + else { + // 查询失败,显示警告 + QMessageBox::warning(this, "警告", "车辆未进入过停车场!", QMessageBox::Yes); + ui->lineEdit->clear(); + ui->textBrowser_4->clear(); + ui->textBrowser_5->clear(); + } +} diff --git a/park/serch.h b/park/serch.h new file mode 100644 index 0000000..91fafe0 --- /dev/null +++ b/park/serch.h @@ -0,0 +1,26 @@ +#ifndef SERCH_H +#define SERCH_H + +#include + +namespace Ui { +class serch; +} + +class serch : public QDialog +{ + Q_OBJECT + +public: + explicit serch(QWidget *parent = nullptr); + ~serch(); + +private slots: + void on_pushButton_2_clicked(); + void on_pushButton_clicked(); + +private: + Ui::serch *ui; +}; + +#endif // SERCH_H diff --git a/park/serch.ui b/park/serch.ui new file mode 100644 index 0000000..980e763 --- /dev/null +++ b/park/serch.ui @@ -0,0 +1,333 @@ + + + serch + + + + 0 + 0 + 600 + 420 + + + + + 600 + 420 + + + + + 600 + 420 + + + + Dialog + + + background-color: rgb(255, 255, 255); + + + + + 300 + 0 + 300 + 420 + + + + + + + true + + + + + + 20 + 310 + 271 + 81 + + + + + 50 + 50 + + + + + 143434 + 16777215 + + + + + + + + 81 + 40 + + + + + 81 + 40 + + + + + Candara + 16 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(200, 255, 190, 255), +stop:1 rgbargb(255, 255, 255)); + + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 16pt "Candara"; + + + 查询 + + + + + + + + 75 + 40 + + + + + 81 + 16777215 + + + + + Candara + 16 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(200, 255, 190, 255), +stop:1 rgbargb(255, 255, 255)); + + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 16pt "Candara"; + + + 返回 + + + + + + + + + 20 + 230 + 131 + 31 + + + + + 微软雅黑 + 18 + 50 + false + false + + + + font: 18pt "微软雅黑"; + + + <html><head/><body><p align="center">停车时长(分钟):</p></body></html> + + + + + + 70 + 260 + 200 + 40 + + + + + 16777215 + 40 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(254, 255, 190, 255), +stop:1 rgbargb(170, 255, 255)); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + + + + + + -10 + 130 + 141 + 31 + + + + + 微软雅黑 + 18 + 50 + false + false + + + + font: 18pt "微软雅黑"; + + + <html><head/><body><p align="center">进入次数:</p></body></html> + + + + + + 70 + 160 + 200 + 40 + + + + + 16777215 + 16777215 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(254, 255, 190, 255), +stop:1 rgbargb(170, 255, 255)); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + + + + + + 70 + 60 + 200 + 40 + + + + + 16777215 + 16777215 + + + + + 微软雅黑 + 12 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(254, 255, 190, 255), +stop:1 rgbargb(170, 255, 255)); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 12pt "微软雅黑"; + + + + + 请输入车牌号 + + + + + + 0 + 30 + 101 + 21 + + + + + 微软雅黑 + 18 + 50 + false + false + + + + font: 18pt "微软雅黑"; + + + <html><head/><body><p align="center">车牌号:</p></body></html> + + + + + + diff --git a/park/sign_in.cpp b/park/sign_in.cpp new file mode 100644 index 0000000..b9c9e8a --- /dev/null +++ b/park/sign_in.cpp @@ -0,0 +1,85 @@ +#include "sign_in.h" +#include "ui_sign_in.h" +#include +#include +#include +#include +#include //设置阴影 + +sign_in::sign_in(QWidget *parent) : QDialog(parent), + ui(new Ui::sign_in) +{ + ui->setupUi(this); + this->setWindowTitle("注册"); + + // 使用在 main 中创建的数据库连接 + QSqlDatabase db = QSqlDatabase::database("text01"); + + if (!db.isOpen()) { + QMessageBox::warning(this, "警告", "数据库连接失败"); + } else { + qDebug() << "数据库连接成功!"; + } + + //插入图片 + QPixmap house(":/house.jpg"); + ui->label_3->setPixmap(house); + + //设置阴影 + QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this); + shadow->setOffset(-3, 0); + shadow->setColor(QColor("#888888")); + shadow->setBlurRadius(30); + ui->label_3->setGraphicsEffect(shadow); + + this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); + +} + +sign_in::~sign_in() +{ + delete ui; +} + +void sign_in::on_pushButton_2_clicked() +{ + this->close(); +} + +void sign_in::on_pushButton_clicked() +{ + QString namestr = ui->lineEdit->text(); + QString password = ui->lineEdit_2->text(); + + // 使用在 main 中创建的数据库连接 + QSqlDatabase db = QSqlDatabase::database("text01"); + + if (!db.isOpen()) { + QMessageBox::warning(this, tr("警告!"), tr("数据库未打开!"), QMessageBox::Yes); + return; + } + + QSqlQuery query(db); + QString userQuery = QString("select * from user where name='%1' ").arg(namestr); + if (query.exec(userQuery) && query.next()) { + QMessageBox::warning(this, tr("警告!"), tr("用户名已存在!"), QMessageBox::Yes); + ui->lineEdit->clear(); + ui->lineEdit_2->clear(); + ui->lineEdit->setFocus(); + } else { + if (namestr == "" || password == "") { + QMessageBox::warning(this, tr("警告!"), tr("用户名或密码不能为空!"), QMessageBox::Yes); + ui->lineEdit->clear(); + ui->lineEdit_2->clear(); + ui->lineEdit->setFocus(); + } else { + QString insertStr = QString("insert into user(name, pass) values('%1', '%2')").arg(namestr).arg(password); + if (query.exec(insertStr)) { + + close(); + } else { + QMessageBox::warning(this, tr("警告!"), tr("注册失败!"), QMessageBox::Yes); + } + } + } +} diff --git a/park/sign_in.h b/park/sign_in.h new file mode 100644 index 0000000..82d7593 --- /dev/null +++ b/park/sign_in.h @@ -0,0 +1,27 @@ +#ifndef SIGN_IN_H +#define SIGN_IN_H + +#include + +namespace Ui { +class sign_in; +} + +class sign_in : public QDialog +{ + Q_OBJECT + +public: + explicit sign_in(QWidget *parent = nullptr); + ~sign_in(); + +private slots: + void on_pushButton_2_clicked(); + + void on_pushButton_clicked(); + +private: + Ui::sign_in *ui; +}; + +#endif // SIGN_IN_H diff --git a/park/sign_in.ui b/park/sign_in.ui new file mode 100644 index 0000000..342ea11 --- /dev/null +++ b/park/sign_in.ui @@ -0,0 +1,211 @@ + + + sign_in + + + true + + + + 0 + 0 + 600 + 420 + + + + + 600 + 420 + + + + + 600 + 520 + + + + background-color: rgb(255, 255, 255); + + + + + 300 + 260 + 271 + 111 + + + + + + + + 81 + 40 + + + + + 81 + 40 + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 14pt "Candara"; + + + 注册 + + + + + + + + 81 + 40 + + + + + 81 + 16777215 + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 14pt "Candara"; + + + 返回 + + + + + + + + + 320 + 100 + 241 + 51 + + + + background-color: rgb(247, 247, 247); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 10pt "微软雅黑"; + + + 由小写字母组成 + + + + + + 320 + 210 + 241 + 51 + + + + background-color: rgb(247, 247, 247); +border:1px groove gray;border-radius: +7px;padding:2px 4px; +font: 10pt "微软雅黑"; + + + QLineEdit::Password + + + 由数字组成 + + + + + + -10 + 0 + 300 + 420 + + + + + + + true + + + + + + 320 + 60 + 89 + 31 + + + + + 微软雅黑 + 14 + 50 + false + false + + + + font: 14pt "微软雅黑"; + + + <html><head/><body><p align="center">用户名</p></body></html> + + + + + + 320 + 170 + 89 + 31 + + + + + 微软雅黑 + 14 + 50 + false + false + + + + font: 14pt "微软雅黑"; + + + <html><head/><body><p align="center">密码</p></body></html> + + + + + + diff --git a/park/signin.cpp b/park/signin.cpp new file mode 100644 index 0000000..f37d724 --- /dev/null +++ b/park/signin.cpp @@ -0,0 +1,14 @@ +#include "signin.h" +#include "ui_signin.h" + +SignIn::SignIn(QWidget *parent) : + QDialog(parent), + ui(new Ui::SignIn) +{ + ui->setupUi(this); +} + +SignIn::~SignIn() +{ + delete ui; +} diff --git a/park/signin.h b/park/signin.h new file mode 100644 index 0000000..4e9c5f1 --- /dev/null +++ b/park/signin.h @@ -0,0 +1,22 @@ +#ifndef SIGNIN_H +#define SIGNIN_H + +#include + +namespace Ui { +class SignIn; +} + +class SignIn : public QDialog +{ + Q_OBJECT + +public: + explicit SignIn(QWidget *parent = 0); + ~SignIn(); + +private: + Ui::SignIn *ui; +}; + +#endif // SIGNIN_H diff --git a/park/signin.ui b/park/signin.ui new file mode 100644 index 0000000..035fe6e --- /dev/null +++ b/park/signin.ui @@ -0,0 +1,119 @@ + + + SignIn + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 60 + 30 + 291 + 141 + + + + + + + + + + 15 + + + + 用户名 + + + + + + + + 15 + + + + 密码 + + + + + + + + + + + + + + + + + + + + + 60 + 190 + 301 + 81 + + + + + + + + 0 + 50 + + + + + 100 + 16777215 + + + + 注册 + + + + + + + + 0 + 50 + + + + + 100 + 16777215 + + + + 退出 + + + + + + + + + diff --git a/park/sun.gif b/park/sun.gif new file mode 100644 index 0000000..ce41f3d Binary files /dev/null and b/park/sun.gif differ diff --git a/park/tian.jpg b/park/tian.jpg new file mode 100644 index 0000000..9190385 Binary files /dev/null and b/park/tian.jpg differ diff --git a/park/tian.png b/park/tian.png new file mode 100644 index 0000000..8c0e33e Binary files /dev/null and b/park/tian.png differ diff --git a/park/widget.cpp b/park/widget.cpp new file mode 100644 index 0000000..2e8e9c5 --- /dev/null +++ b/park/widget.cpp @@ -0,0 +1,76 @@ +#include "widget.h" +#include "ui_widget.h" +#include "ai.h" +#include +#include +#include +#include +#include // 包含QMovie的头文件 +#include //设置阴影 + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + car_ai=new ai; + + ser=new serch; + + num=new number_of_car; + connect(this,SIGNAL(cnt_signal()),num,SLOT(cnt_slot())); + this->setWindowTitle("主界面"); + + //动图 + QMovie *movie = new QMovie(":/huoche.png"); + ui->label_1->setMovie(movie); + movie->start(); + + //设置阴影 + QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this); + shadow->setOffset(-3, 0); + shadow->setColor(QColor("#fcc9ff")); + shadow->setBlurRadius(80); + ui->label_1->setGraphicsEffect(shadow); + + QMovie *movie2 = new QMovie(":/pig.gif"); + ui->label_3->setMovie(movie2); + movie2->start(); + connect(movie2, &QMovie::finished, [=]() { + // 当动画播放完成时,重新启动动画 + movie2->start(); + }); + +} + +Widget::~Widget() +{ + delete ui; + delete car_ai; + delete ser; + delete rules; + delete num; +} + +void Widget::on_pushButton_clicked() +{ + car_ai->show(); +} + + +void Widget::on_pushButton_2_clicked() +{ + emit cnt_signal(); + num->exec(); + +} + +void Widget::on_pushButton_4_clicked() +{ + close(); +} + +void Widget::on_pushButton_5_clicked() +{ + ser->exec(); +} diff --git a/park/widget.h b/park/widget.h new file mode 100644 index 0000000..7cd80ac --- /dev/null +++ b/park/widget.h @@ -0,0 +1,47 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include +#include "message.h" +#include "ai.h" +#include "number_of_car.h" +#include "charge_rules.h" +#include "serch.h" + +namespace Ui { +class Widget; +} +class message; +class ai; +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + + +private slots: + void on_pushButton_clicked(); + + void on_pushButton_2_clicked(); + + void on_pushButton_4_clicked(); + + void on_pushButton_5_clicked(); + +private: + Ui::Widget *ui; + ai *car_ai; + number_of_car *num; + cost *pay; + charge_rules *rules; + serch *ser; + +signals: + void cnt_signal(); + +}; + +#endif // WIDGET_H diff --git a/park/widget.ui b/park/widget.ui new file mode 100644 index 0000000..f014337 --- /dev/null +++ b/park/widget.ui @@ -0,0 +1,262 @@ + + + Widget + + + + 0 + 0 + 600 + 420 + + + + + 600 + 420 + + + + + 16777215 + 16777215 + + + + Widget + + + background-color: rgb(255, 255, 255); + + + + + 0 + 0 + 300 + 420 + + + + + + + true + + + + + + 380 + -20 + 281 + 221 + + + + + + + true + + + + + + 320 + 110 + 151 + 41 + + + + color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +font: 20pt "黑体"; + + + 请选择您的操作 + + + + + + 350 + 150 + 201 + 261 + + + + + 0 + 60 + + + + + 1514664 + 16777215 + + + + + + + + 70 + 40 + + + + + 200 + 16777215 + + + + + Candara + 16 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 16pt "Candara"; + + + 车牌识别 + + + + + + + + 0 + 40 + + + + + 200 + 16777215 + + + + + Candara + 16 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 16pt "Candara"; + + + 车场信息 + + + + + + + + 0 + 40 + + + + + 200 + 16777215 + + + + + Candara + 16 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 16pt "Candara"; + + + 查询车辆 + + + + + + + + 0 + 30 + + + + + 200 + 40 + + + + + Candara + 16 + 50 + false + false + + + + background-color: qlineargradient(spread:pad, x1:0.52, y1:1, x2:0.54, y2:0, +stop:0.0112994 rgba(64, 145, 252, 255), +stop:1 rgbargb(255, 170, 127)); +color: rgb(255, 255, 255); + +border:0px groove gray;border-radius: +7px;padding:2px 4px; +font: 16pt "Candara"; + + + 退出 + + + + + + + + + + diff --git a/park/yun.wav b/park/yun.wav new file mode 100644 index 0000000..1b2c332 Binary files /dev/null and b/park/yun.wav differ