void currency::sSave() { XSqlQuery currencySave; sConfirmBaseFlag(); QList<GuiErrorCheck> errors; errors << GuiErrorCheck(_currName->text().trimmed().isEmpty(), _currName, tr("Currency name is required.")) << GuiErrorCheck(_currAbbr->text().trimmed().isEmpty() && _currSymbol->text().trimmed().isEmpty(), _currSymbol, tr("Either the currency symbol or abbreviation must be " "supplied.\n(Both would be better).")) << GuiErrorCheck(_currAbbr->text().length() > 3, _currAbbr, tr("The currency abbreviation must have " "3 or fewer characters.\n" "ISO abbreviations are exactly 3 characters long.")) ; if (GuiErrorCheck::reportErrors(this, tr("Cannot Save Currency"), errors)) return; if (_mode == cNew) { currencySave.prepare( "INSERT INTO curr_symbol " "( curr_name, curr_symbol, curr_abbr, curr_base ) " "VALUES " "( :curr_name, :curr_symbol, :curr_abbr, :curr_base );" ); } else if (_mode == cEdit) { currencySave.prepare( "UPDATE curr_symbol " "SET curr_name=:curr_name, curr_symbol=:curr_symbol, " " curr_abbr=:curr_abbr, curr_base = :curr_base " "WHERE (curr_id=:curr_id);" ); currencySave.bindValue(":curr_id", _currid); } currencySave.bindValue(":curr_name", _currName->text().trimmed()); currencySave.bindValue(":curr_symbol", _currSymbol->text().trimmed()); currencySave.bindValue(":curr_abbr", _currAbbr->text().trimmed()); currencySave.bindValue(":curr_base", QVariant(_currBase->isChecked())); currencySave.exec(); if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Saving Currency Information"), currencySave, __FILE__, __LINE__)) { return; } done(_currid); }
void currency::sSave() { sConfirmBaseFlag(); if (_currName->text().isEmpty()) { QMessageBox::critical(this, tr("Name Required") .arg(__FILE__) .arg(__LINE__), tr("Currency name is required.")); _currName->setFocus(); return; } if (_currAbbr->text().isEmpty() && _currSymbol->text().isEmpty()) { QMessageBox::critical(this, tr("Symbol or Abbreviation Required") .arg(__FILE__) .arg(__LINE__), tr("Either the currency symbol or abbreviation must be " "supplied.\n(Both would be better.)") ); _currSymbol->setFocus(); return; } if (_currAbbr->text().length() > 3) { QMessageBox::critical(this, tr("Abbreviation Too Long") .arg(__FILE__) .arg(__LINE__), tr("The currency abbreviation must have " "3 or fewer characters.\n" "ISO abbreviations are exactly 3 characters long.") ); return; } if (_mode == cNew) { q.prepare( "INSERT INTO curr_symbol " "( curr_name, curr_symbol, curr_abbr, curr_base ) " "VALUES " "( :curr_name, :curr_symbol, :curr_abbr, :curr_base );" ); } else if (_mode == cEdit) { q.prepare( "UPDATE curr_symbol " "SET curr_name=:curr_name, curr_symbol=:curr_symbol, " " curr_abbr=:curr_abbr, curr_base = :curr_base " "WHERE (curr_id=:curr_id);" ); q.bindValue(":curr_id", _currid); } q.bindValue(":curr_name", _currName->text()); q.bindValue(":curr_symbol", _currSymbol->text()); q.bindValue(":curr_abbr", _currAbbr->text()); q.bindValue(":curr_base", QVariant(_currBase->isChecked())); q.exec(); if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } done(_currid); }