Exemplo n.º 1
0
void dbInterface::deleteGymnast(QString& p_strFirstName, QString& p_strLastName)
{

    if (m_bInitialized)
    {
        QSqlDatabase db = QSqlDatabase::database("ConnMG");
        QSqlQuery query(db);
        QString strQuery = "DELETE FROM athlete WHERE first_name='" + p_strFirstName
                + "' AND last_name='" + p_strLastName.trimmed() + "'";
        bool bRet = query.exec(strQuery);

        if (bRet)
        {
            qInfo() << "Athlete removed: " << p_strFirstName << " " << p_strLastName;
        }
        else
        {
            QString strErr = "Athlete NOT removed: " + p_strFirstName + " " + p_strLastName
                    +  "\n" + query.lastError().text();
            qCritical() << strErr;

            MessageBox cMsgBox;
            cMsgBox.SetTitle("Warning");
            cMsgBox.SetText(strErr);
            cMsgBox.Show();
        }
    }
    else
    {
        qInfo() << "dbInterface::deleteGymnast(): Db not initialized";
    }
}
Exemplo n.º 2
0
void SaveScore::onSaveScore(QString p_strGymnastFullTxt,
                            QString p_strApparatus,
                            QString p_strStartScore,
                            QString p_strFinalScore,
                            bool p_bFinalApparatus)
{
    QString strFinalApparatus = p_bFinalApparatus ? "FinalApparatus" : "";
    qDebug() << "onSaveScore(): " << p_strGymnastFullTxt <<  ", "
                << p_strApparatus <<  ", "
                << p_strStartScore <<  ", "
                << p_strFinalScore <<   ", "
                << strFinalApparatus;

    QString strErr = "";
    bool bConvStartScoreOk = false;
    float fStartScore = CheckStartScore(p_strStartScore, &bConvStartScoreOk);

    if (!bConvStartScoreOk)
    {
        strErr = "Nota di partenza non é tra 0 e 10";
    }

    bool bConvFinalScoreOk = false;
    float fFinalScore = CheckFinalScore(p_strFinalScore, &bConvFinalScoreOk);

    if (!bConvFinalScoreOk)
    {
        if (!strErr.isEmpty())
            strErr += "\n";

        strErr += "Nota finale non é tra 0 e 20";
    }

    // save it to DB
    SendToDb(p_strGymnastFullTxt, p_strApparatus, fStartScore, fFinalScore, p_bFinalApparatus);

    // Show it to the user
    if ((!bConvStartScoreOk) || (!bConvFinalScoreOk))
    {
        MessageBox cMsgBox;
        cMsgBox.SetTitle("Warning");
        cMsgBox.SetText(strErr);
        cMsgBox.Show();
    }
}