File size: 1,996 Bytes
eebf7a4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
#include "createRide.h"
#include "ui_createRide.h"
createRide::createRide(QWidget *parent) :
QDialog(parent),
ui(new Ui::createRide)
{
ui->setupUi(this);
this->setWindowTitle("Create new ride");
}
createRide::~createRide()
{
delete ui;
}
void createRide::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QPixmap pix;
pix.load(":/images/rose2.png");
painter.drawPixmap(0,0,pix);
}
void createRide::on_submitBtn_clicked()
{
getInput();
sql.prepare("Insert Into vehicles(carName,carModel,carCapacity,engineCapacity,colour,carOwner)"
"Values (:carName, :carModel, :carCapacity, :engineCapacity, :colour, :carOwner)");
sql.bindValue(":carName", newCarName);
sql.bindValue(":carModel", newCarModel);
sql.bindValue(":carCapacity", newCarCapacity);
sql.bindValue(":engineCapacity", newCarEngine);
sql.bindValue(":colour", newCarColor);
sql.bindValue(":carOwner", newCarOwner);
if(newCarName.isEmpty() || newCarModel.isEmpty() || newCarEngine.isEmpty()
|| newCarColor.isEmpty() || newCarOwner.isEmpty())
{
QMessageBox::information(this, "failed", "please fill in all inforamtion");
}
else if(sql.exec())
{
QMessageBox::information(this, "Submited", "Submited successful");
this->hide();
clearInput();
}
else
{
QMessageBox::about(this, "failed", "Submited failed, please check all the informations");
qDebug()<<sql.lastError();
}
}
void createRide::getInput()
{
newCarName = ui->carName->text();
newCarModel = ui->carModel->text();
newCarCapacity = ui->carCapacity->text();
newCarEngine = ui->carEngine->text();
newCarColor = ui->carColor->text();
newCarOwner = ui->carOwner->text();
}
void createRide::clearInput()
{
ui->carName->clear();
ui->carModel->clear();
ui->carCapacity->clear();
ui->carEngine->clear();
ui->carColor->clear();
ui->carOwner->clear();
}
|