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