• 大小: 1.98MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-15
  • 语言: 数据库
  • 标签:

资源简介

利用QT连接MYSQL进行数据库课程实验的设计,压缩包里还有QT CREATOR的教程以及实验要求文档,对于想学习利用QT编写图形界面的同学有一定帮助。售票系统实现了管理员和用户的分离以及各种对数据库的基本操作。

资源截图

代码片段和文件信息

#include “bookcardlg.h“
#include “ui_bookcardlg.h“
#include 
#include 
#include 
#include 
#include ject>
#include 
#include 
#include 
#include 
#include 
bookcardlg::bookcardlg(QWidget *parent) :
    QDialog(parent)
    ui(new Ui::bookcardlg)
{
    ui->setupUi(this);
}

bookcardlg::~bookcardlg()
{
    delete ui;
}

void bookcardlg::on_buttonBox_2_accepted()
{
    QSqlQuery query1;
    QSqlQuery query2;
    QSqlQuery query3;
    QSqlQuery query4;
    int availnum;
    query1.prepare(“select * from cars where location=?“);
    query1.addBindValue(ui->lineEdit_2->text());
    query1.exec();
    if(query1.next()){   //找到指定地点的车辆
        availnum=query1.value(3).toInt();
        qDebug()<        if(availnum>=ui->lineEdit_3->text().toInt()){ //有车,可以预订
            query2.prepare(“select * from cutomers where custname=?“);
            query2.addBindValue(ui->lineEdit_4->text());
            query2.exec();
            if(query2.next()){    //老客户
                int pwd=query2.value(1).toInt();
                if(pwd!=ui->lineEdit_5->text().toInt()){ //密码不对
                     QMessageBox::warning(thistr(“failed“)tr(“sorry! the flight not exist“)QMessageBox::Close);
                }
                else{
                    query3.prepare(“update cars set numavail=numavail-? where location=?“); //修改车辆数据库
                    query3.addBindValue(ui->lineEdit_3->text().toInt());
                    query3.addBindValue(ui->lineEdit_2->text());
                    query3.exec();
                    query4.prepare(“insert into reservations values(????)“);
                    query4.addBindValue(ui->lineEdit_4->text());
                    query4.addBindValue(3);
                    query4.addBindValue(ui->lineEdit_2->text());
                    query4.addBindValue(ui->lineEdit_3->text().toInt());
                    query4.exec();
                    QMessageBox::warning(thistr(“SUCCESS“)tr(“BOOK SUCCESSFULLY!“)QMessageBox::Close);
                }
            }
            else{           //新客户
                query3.prepare(“insert into customers values(??)“);
                query3.addBindValue(ui->lineEdit_4->text());
                query3.addBindValue(ui->lineEdit_5->text().toInt());
                query3.exec();
                query3.prepare(“update cars set numavail=numavail-? where location=?“);
                query3.addBindValue(ui->lineEdit_3->text().toInt());
                query3.addBindValue(ui->lineEdit_2->text());
                query3.exec();
                query4.prepare(“insert into reservations values(????)“);
                query4.addBindValue(ui->lineEdit_4->text());
                query4.addBindValue(3);
                query4.addBindValue(ui->lineEdit_2->text());
                query4.addBindValue(ui->lineEdit_3

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4824  2011-05-24 20:51  travel\bookcardlg.cpp

     文件        436  2011-05-24 16:35  travel\bookcardlg.h

     文件       5608  2011-05-24 18:00  travel\bookcardlg.ui

     文件       7823  2011-05-25 23:15  travel\bookflidlg.cpp

     文件        508  2011-05-25 17:10  travel\bookflidlg.h

     文件      10306  2011-05-25 17:10  travel\bookflidlg.ui

     文件       4683  2011-05-24 22:53  travel\bookhoteldlg.cpp

     文件        415  2011-05-24 20:51  travel\bookhoteldlg.h

     文件       5605  2011-05-24 18:04  travel\bookhoteldlg.ui

     文件       2656  2011-05-24 13:45  travel\carsdlg.cpp

     文件        486  2011-05-23 23:21  travel\carsdlg.h

     文件       7297  2011-05-24 13:11  travel\carsdlg.ui

     文件       6874  2011-05-26 20:51  travel\chandlg.cpp

     文件        519  2011-05-24 17:04  travel\chandlg.h

     文件      10847  2011-05-24 17:08  travel\chandlg.ui

     文件        722  2011-05-23 18:11  travel\connection.h

     文件       2477  2011-05-24 13:05  travel\custdlg.cpp

     文件        523  2011-05-24 13:05  travel\custdlg.h

     文件       7332  2011-05-24 22:24  travel\custdlg.ui

     文件       1704  2011-05-24 21:40  travel\dingdandlg.cpp

     文件        399  2011-05-24 21:24  travel\dingdandlg.h

     文件       2652  2011-05-24 23:21  travel\dingdandlg.ui

     文件       2686  2011-05-24 13:05  travel\hoteldlg.cpp

     文件        494  2011-05-24 00:05  travel\hoteldlg.h

     文件       7296  2011-05-24 18:00  travel\hoteldlg.ui

     文件       1695  2011-05-24 21:56  travel\linedlg.cpp

     文件        338  2011-05-24 21:56  travel\linedlg.h

     文件       2642  2011-05-24 21:56  travel\linedlg.ui

     文件       2448  2011-05-25 14:57  travel\logindlg.cpp

     文件        441  2011-05-24 23:06  travel\logindlg.h

............此处省略67个文件信息

评论

共有 条评论

相关资源