fix: 移资存在bug,已解决

This commit is contained in:
2024-08-01 11:26:02 +08:00
parent 2773d0e9f8
commit cad6542d8e
3 changed files with 31 additions and 4 deletions

View File

@@ -137,7 +137,12 @@ void MainWindow::on_newCardButton_clicked()
"where id = :userId");
query.bindValue(":userId", cardUserId);
bool success = query.exec();
if (!success || !query.next())
if (!success)
{
QMessageBox::warning(this, "提示", QString("数据库异常。\n重开卡失败,请重试。"));
return;
}
if (!query.next())
{
QMessageBox::warning(this, "提示", QString("数据库异常。\n重开卡失败,请重试。"));
return;
@@ -516,10 +521,15 @@ bool MainWindow::transferCard(int userId, QString newCardId, QString oldCardId,
// 查询旧卡余额
query.finish();
query.prepare("select balance from card "
"where userId = :userId;");
query.bindValue(":userId", oldCardId);
"where id = :cardId;");
query.bindValue(":cardId", oldCardId);
isExecuted = query.exec();
if (!isExecuted || query.next())
if (!isExecuted)
{
info = QString("数据库异常。");
return false;
}
if (!query.next())
{
info = QString("数据库异常。");
return false;