fix: 移资存在bug,已解决

This commit is contained in:
Jingfan Ke 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;

View File

@ -114,6 +114,11 @@ void MainWindow::on_userRecordQueryButton_clicked()
{
ui->queryCardStatusLabel->setText(QString("已被挂失"));
}
if (cardStatus == 1)
{
ui->queryCardStatusLabel->setText(QString("启用中"));
}
userId = query.value("userId").toInt();
balance = query.value("balance").toDouble();
ui->queryBalanceShowEdit->setText(QString::number(balance, 'f', 2));
@ -337,6 +342,10 @@ void MainWindow::on_cardRecordQueryButton_clicked()
{
ui->queryCardStatusLabel->setText(QString("已被挂失"));
}
if (cardStatus == 1)
{
ui->queryCardStatusLabel->setText(QString("启用中"));
}
balance = query.value("balance").toDouble();
ui->queryBalanceShowEdit->setText(QString::number(balance, 'f', 2));
}

View File

@ -65,6 +65,14 @@ void MainWindow::on_reportLossButton_clicked()
return;
}
QString info, prompt = QString("如需挂失该学/工号绑定的卡,请输入密码。");
success = verifyUser(userId, prompt, info);
if (!success)
{
QMessageBox::warning(this, "提示", info + QString("\n验证用户失败。挂失失败,请重试。"));
return;
}
// 将该学/工号的卡设置为挂失状态
query.prepare(QString("update card "
"set `status` = -1 "