// ------------------------------------------------------------------------ void MainWindow::saveActionPressed() { if(okToSave()) { if(!data->hasSaveName()) return saveAsActionPressed(); std::string filename = data->getSaveName(); saveData(filename); } }
void copyItem::sCopy() { XSqlQuery copyCopy; if (! okToSave()) return; int itemid = -1; copyCopy.prepare("SELECT copyItem(:source_item_id, :newItemNumber, :copyBOM, :copyItemCosts) AS itemid;"); copyCopy.bindValue(":source_item_id", _source->id()); copyCopy.bindValue(":newItemNumber", _targetItemNumber->text()); copyCopy.bindValue(":copyBOM", QVariant(_copyBOM->isChecked())); copyCopy.bindValue(":copyItemCosts", QVariant(_copyCosts->isChecked())); copyCopy.exec(); if (copyCopy.first()) { itemid = copyCopy.value("itemid").toInt(); if (itemid < 0) { systemError(this, storedProcErrorLookup("copyItem", itemid), __FILE__, __LINE__); return; } omfgThis->sItemsUpdated(itemid, TRUE); if (_copyBOM->isChecked()) omfgThis->sBOMsUpdated(itemid, TRUE); createItemSites(itemid); } else if (copyCopy.lastError().type() != QSqlError::NoError) { systemError(this, copyCopy.lastError().databaseText(), __FILE__, __LINE__); return; } if (_captive) done(itemid); else clear(); }
void copyItem::sCopy() { XSqlQuery copyCopy; if (! okToSave()) return; copyCopy.prepare("UPDATE item SET item_number=:item_number," " item_descrip1=:item_descrip1," " item_listprice=:item_listprice," " item_listcost=:item_listcost " "WHERE (item_id=:item_id);"); copyCopy.bindValue(":item_id", _newitemid); copyCopy.bindValue(":item_number", _targetItemNumber->text()); copyCopy.bindValue(":item_descrip1", _targetItemDescrip->text()); copyCopy.bindValue(":item_listprice", _listPrice->toDouble()); copyCopy.bindValue(":item_listcost", _listCost->toDouble()); copyCopy.exec(); if (copyCopy.lastError().type() != QSqlError::NoError) { systemError(this, copyCopy.lastError().databaseText(), __FILE__, __LINE__); return; } copyCopy.prepare("SELECT doUpdateCosts(:item_id, TRUE, :lowMaterial, :dirLabor, " " :lowDirLabor, :overhead, :lowOverhead, :machOverhead, " " :lowMachOverhead, :lowUser, :rollUp, :updateActual)"); copyCopy.bindValue(":item_id", _newitemid); copyCopy.bindValue(":lowMaterial", "t"); if (_metrics->boolean("Routings")) { copyCopy.bindValue(":dirLabor", "t"); copyCopy.bindValue(":lowDirLabor", "t"); copyCopy.bindValue(":overhead", "t"); copyCopy.bindValue(":lowOverhead", "t"); if (_metrics->value("TrackMachineOverhead") == "M") { copyCopy.bindValue(":machOverhead", "t"); copyCopy.bindValue(":lowMachOverhead", "t"); } else { copyCopy.bindValue(":machOverhead", "f"); copyCopy.bindValue(":lowMachOverhead", "f"); } } else { copyCopy.bindValue(":dirLabor", "f"); copyCopy.bindValue(":lowDirLabor", "f"); copyCopy.bindValue(":overhead", "f"); copyCopy.bindValue(":lowOverhead", "f"); copyCopy.bindValue(":machOverhead", "f"); copyCopy.bindValue(":lowMachOverhead", "f"); } copyCopy.bindValue(":lowUser", "t"); copyCopy.bindValue(":rollUp", "f"); copyCopy.bindValue(":updateActual", "t" ); copyCopy.exec(); if (copyCopy.lastError().type() != QSqlError::NoError) { systemError(this, copyCopy.lastError().databaseText(), __FILE__, __LINE__); return; } copyCopy.prepare( "SELECT doPostCosts(:item_id, TRUE, " " :material, :lowMaterial, :labor, :lowLabor, " " :overhead, :lowOverhead, :machOverhead, :lowMachOverhead, " " :user, :lowUser, :rollUp)" ); copyCopy.bindValue(":item_id", _newitemid); copyCopy.bindValue(":material", "t"); copyCopy.bindValue(":lowMaterial", "t"); if (_metrics->boolean("Routings")) { copyCopy.bindValue(":labor", "t"); copyCopy.bindValue(":lowLabor", "t"); copyCopy.bindValue(":overhead", "t"); copyCopy.bindValue(":lowOverhead", "t"); if (_metrics->value("TrackMachineOverhead") == "M") { copyCopy.bindValue(":machOverhead", "t"); copyCopy.bindValue(":lowMachOverhead", "t"); } else { copyCopy.bindValue(":machOverhead", "f"); copyCopy.bindValue(":lowMachOverhead", "f"); } } else { copyCopy.bindValue(":labor", "f"); copyCopy.bindValue(":lowLabor", "f"); copyCopy.bindValue(":overhead", "f"); copyCopy.bindValue(":lowOverhead", "f"); copyCopy.bindValue(":machOverhead", "f"); copyCopy.bindValue(":lowMachOverhead", "f"); } copyCopy.bindValue(":user", "t"); copyCopy.bindValue(":lowUser", "t"); copyCopy.bindValue(":rollUp", "f"); copyCopy.exec(); if (copyCopy.lastError().type() != QSqlError::NoError) { systemError(this, copyCopy.lastError().databaseText(), __FILE__, __LINE__); return; } copyCopy.exec("COMMIT;"); _inTransaction = false; omfgThis->sItemsUpdated(_newitemid, TRUE); if (_copyBOM->isChecked()) omfgThis->sBOMsUpdated(_newitemid, TRUE); if (_captive) done(_newitemid); else clear(); }