diff --git a/gui/formproduct.cpp b/gui/formproduct.cpp index 2481883..1e9dd9a 100644 --- a/gui/formproduct.cpp +++ b/gui/formproduct.cpp @@ -308,11 +308,22 @@ void formProduct::save() 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"; dApp->Enterprise().close(); return; - } + }} } } diff --git a/itemnumberdelegate.cpp b/itemnumberdelegate.cpp index fd2c91e..11a7431 100644 --- a/itemnumberdelegate.cpp +++ b/itemnumberdelegate.cpp @@ -28,9 +28,7 @@ QWidget *ItemNumberDelegate::createEditor(QWidget *parent, const QStyleOptionVie void ItemNumberDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { - QString val = index.model()->data(index, Qt::EditRole).toString(); - val.replace(QString(","), QString(".")); - double value = val.toDouble(); //index.model()->data(index, Qt::EditRole).toDouble(); + double value = index.model()->data(index, Qt::EditRole).toDouble(); static_cast(editor)->setValue(value); }