added safety query before to prevent starting same race again
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using std::vector;
|
||||
|
||||
MainWindow::MainWindow(QWidget * parent)
|
||||
@@ -65,6 +67,46 @@ void MainWindow::NewWindowSettings() {
|
||||
}
|
||||
|
||||
void MainWindow::WindowRennen() {
|
||||
|
||||
// check if a valid racelist has been created
|
||||
// get last race id
|
||||
string statement = "select aktRennen.id_rennen from aktRennen order by "
|
||||
"id_rennen DESC limit 1";
|
||||
|
||||
try {
|
||||
string raceId =
|
||||
this->db->getData2(statement, 1).at(0).at(0).toStdString();
|
||||
std::stringstream ss;
|
||||
ss << "select count(*) from Zeiten where zeiten.id_rennen like "
|
||||
<< raceId;
|
||||
int res = this->db->getData2(ss.str(), 1).at(0).at(0).toInt();
|
||||
if (res > 0) {
|
||||
// current race was raced before
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(
|
||||
"Aktuelles Rennen wurde bereits gefahren! Trotzdem fahren?");
|
||||
msgBox.setInformativeText("");
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
switch (ret) {
|
||||
case QMessageBox::No:
|
||||
return;
|
||||
|
||||
case QMessageBox::Yes:
|
||||
// do nothing
|
||||
break;
|
||||
default:
|
||||
// should never be reached
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (std::exception & e) {
|
||||
Q_UNUSED(e);
|
||||
}
|
||||
|
||||
this->interfaceRace = new WindowRace(this->db, this);
|
||||
this->interfaceRace->show();
|
||||
this->interfaceRennliste = new WindowRennliste(this->db, this);
|
||||
|
||||
Reference in New Issue
Block a user