fix: Improve error handling in product composition insertion and fix ItemNumberDelegate::setEditorData
This commit is contained in:
+13
-2
@@ -308,11 +308,22 @@ void formProduct::save()
|
|||||||
|
|
||||||
if(!qry.exec())
|
if(!qry.exec())
|
||||||
{
|
{
|
||||||
// todo: barrar lo creado
|
// barrar lo creado: eliminar las composiciones ya insertadas para este producto
|
||||||
|
if (!insertedElementCodes.isEmpty())
|
||||||
|
{
|
||||||
|
QSqlQuery qryDel = QSqlQuery(dApp->Enterprise());
|
||||||
|
qryDel.prepare(QString("DELETE FROM ELEMENTCOMPOSITION WHERE CODE = :CODE AND ELEMENT_CODE IN (%1)").arg(QString(insertedElementCodes.size(), '?').replace('?', ":ELEMENT_CODE")));
|
||||||
|
qryDel.bindValue(":CODE", ui->editCode->text());
|
||||||
|
for (int j = 0; j < insertedElementCodes.size(); ++j)
|
||||||
|
{
|
||||||
|
qryDel.bindValue(QString(":ELEMENT_CODE%1").arg(j), insertedElementCodes.at(j));
|
||||||
|
}
|
||||||
|
qryDel.exec();
|
||||||
|
}
|
||||||
qDebug() << "Error ejecutando el query: " << qry.lastError().text() << "\n";
|
qDebug() << "Error ejecutando el query: " << qry.lastError().text() << "\n";
|
||||||
dApp->Enterprise().close();
|
dApp->Enterprise().close();
|
||||||
return;
|
return;
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ QWidget *ItemNumberDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
|||||||
|
|
||||||
void ItemNumberDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
void ItemNumberDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QString val = index.model()->data(index, Qt::EditRole).toString();
|
double value = index.model()->data(index, Qt::EditRole).toDouble();
|
||||||
val.replace(QString(","), QString("."));
|
|
||||||
double value = val.toDouble(); //index.model()->data(index, Qt::EditRole).toDouble();
|
|
||||||
static_cast<QDoubleSpinBox*>(editor)->setValue(value);
|
static_cast<QDoubleSpinBox*>(editor)->setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user