Stock PgsqlDataProvider::getStock(uint32_t id) { nontransaction command(*conn); string query = "SELECT id, price FROM get_stock(" + to_string(id) + ");"; result queryResult(command.exec(query)); if (verbose) cout << "Result of " << query << ": " << endl; if (queryResult.size() != 1) { cerr << "getStock: Incorrect number of results: " << queryResult.size() << endl; throw invalid_argument("getStock: Incorrect number of results."); } if (queryResult[0][0].is_null()) { cerr << "getStock: Stock id = " << id << " does not exist." << endl; throw invalid_argument("getStock: Stock does not exist."); } Stock stock; stock.setId(queryResult[0][0].as<int>()); stock.setPrice(Decimal(queryResult[0][1].as<string>())); if (verbose) cout << "Stock: id = " << stock.getId() << ", price = " << stock.getPrice() << endl; return stock; }
bool LaminatTask::form2Entity(Entity *task) { Process *process = Process::getInstance(); task->fields["task_process"] = processId; task->fields["task_weight"] = process->getWeight(processId); task->fields["equipment_id"] = ui->equip->getEquip()->getId(); Stock *stock = ui->product->getParam(); if (stock == NULL) { return false; } task->fields["product_id"] = stock->fields["product_id"]; task->fields["stock_id"] = stock->getId(); task->fields["task_total"] = ui->totalInput->getMoney().cents; return true; }