src/EditEquipment.cpp

changeset 527
84091b9cb800
parent 462
1654ff5446c7
equal deleted inserted replaced
526:3b9abdae181e 527:84091b9cb800
65 ui->chiller_typeEdit->setCurrentIndex(query.value("chiller_type").toInt()); 65 ui->chiller_typeEdit->setCurrentIndex(query.value("chiller_type").toInt());
66 ui->chiller_to79Edit->setValue(query.value("chiller_to79").toDouble()); 66 ui->chiller_to79Edit->setValue(query.value("chiller_to79").toDouble());
67 ui->chiller_lossEdit->setValue(query.value("chiller_loss").toDouble()); 67 ui->chiller_lossEdit->setValue(query.value("chiller_loss").toDouble());
68 ui->chiller_volumeEdit->setValue(query.value("chiller_volume").toDouble()); 68 ui->chiller_volumeEdit->setValue(query.value("chiller_volume").toDouble());
69 ui->chiller_lpmEdit->setValue(query.value("chiller_lpm").toDouble()); 69 ui->chiller_lpmEdit->setValue(query.value("chiller_lpm").toDouble());
70 ui->HLT_volumeEdit->setValue(query.value("HLT_volume").toDouble());
71 ui->HLT_deadspaceEdit->setValue(query.value("HLT_deadspace").toDouble());
70 /* 72 /*
71 * Now we have loaded this record, check if this equipment is 73 * Now we have loaded this record, check if this equipment is
72 * being used by a product. If so, make the name field read-only. 74 * being used by a product. If so, make the name field read-only.
73 */ 75 */
74 query2.prepare("SELECT eq_name FROM products WHERE eq_name=:name"); 76 query2.prepare("SELECT eq_name FROM products WHERE eq_name=:name");
99 ui->chiller_typeEdit->setCurrentIndex(1); 101 ui->chiller_typeEdit->setCurrentIndex(1);
100 ui->chiller_to79Edit->setValue(10); 102 ui->chiller_to79Edit->setValue(10);
101 ui->chiller_lossEdit->setValue(0); 103 ui->chiller_lossEdit->setValue(0);
102 ui->chiller_volumeEdit->setValue(0.5); 104 ui->chiller_volumeEdit->setValue(0.5);
103 ui->chiller_lpmEdit->setValue(0); 105 ui->chiller_lpmEdit->setValue(0);
106 ui->HLT_volumeEdit->setValue(20);
107 ui->HLT_deadspaceEdit->setValue(2);
104 inuse = 0; 108 inuse = 0;
105 } 109 }
106 /* Block select no chiller used */ 110 /* Block select no chiller used */
107 qobject_cast<QStandardItemModel*>(ui->chiller_typeEdit->model())->item(CHILLER_TYPE_NONE)->setEnabled(false); 111 qobject_cast<QStandardItemModel*>(ui->chiller_typeEdit->model())->item(CHILLER_TYPE_NONE)->setEnabled(false);
108 chiller_setup(ui->chiller_typeEdit->currentIndex()); 112 chiller_setup(ui->chiller_typeEdit->currentIndex());
129 connect(ui->chiller_typeEdit, &QComboBox::currentTextChanged, this, &EditEquipment::chiller_changed); 133 connect(ui->chiller_typeEdit, &QComboBox::currentTextChanged, this, &EditEquipment::chiller_changed);
130 connect(ui->chiller_to79Edit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); 134 connect(ui->chiller_to79Edit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
131 connect(ui->chiller_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); 135 connect(ui->chiller_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
132 connect(ui->chiller_lpmEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); 136 connect(ui->chiller_lpmEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
133 connect(ui->chiller_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); 137 connect(ui->chiller_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
138 connect(ui->HLT_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
139 connect(ui->HLT_deadspaceEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
134 140
135 calcBatchVolume(); 141 calcBatchVolume();
136 ui->saveButton->setEnabled(false); 142 ui->saveButton->setEnabled(false);
137 ui->deleteButton->setEnabled((inuse == 0 && id >= 0) ? true:false); 143 ui->deleteButton->setEnabled((inuse == 0 && id >= 0) ? true:false);
138 } 144 }
188 "top_up_water=:top_up_water, trub_loss=:trub_loss, evap_rate=:evap_rate, " 194 "top_up_water=:top_up_water, trub_loss=:trub_loss, evap_rate=:evap_rate, "
189 "boil_time=:boil_time, top_up_kettle=:top_up_kettle, " 195 "boil_time=:boil_time, top_up_kettle=:top_up_kettle, "
190 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " 196 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, "
191 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " 197 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, "
192 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, " 198 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, "
193 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss"); 199 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss, "
200 "HLT_volume=:HLT_volume, HLT_deadspace=:HLT_deadspace");
194 if (this->recno == -1) { 201 if (this->recno == -1) {
195 sql.append(", uuid=:uuid"); 202 sql.append(", uuid=:uuid");
196 } else { 203 } else {
197 sql.append(" WHERE record = :recno"); 204 sql.append(" WHERE record = :recno");
198 } 205 }
220 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex()); 227 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex());
221 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0')); 228 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0'));
222 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0')); 229 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0'));
223 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0')); 230 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0'));
224 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0')); 231 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0'));
232 query.bindValue(":HLT_volume", QString("%1").arg(ui->HLT_volumeEdit->value(), 2, 'f', 1, '0'));
233 query.bindValue(":HLT_deadspace", QString("%1").arg(ui->HLT_deadspaceEdit->value(), 2, 'f', 1, '0'));
225 234
226 if (this->recno == -1) { 235 if (this->recno == -1) {
227 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); 236 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
228 } else { 237 } else {
229 query.bindValue(":recno", this->recno); 238 query.bindValue(":recno", this->recno);
257 "top_up_water=:top_up_water, trub_loss=:trub_loss, evap_rate=:evap_rate, " 266 "top_up_water=:top_up_water, trub_loss=:trub_loss, evap_rate=:evap_rate, "
258 "boil_time=:boil_time, top_up_kettle=:top_up_kettle, " 267 "boil_time=:boil_time, top_up_kettle=:top_up_kettle, "
259 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " 268 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, "
260 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " 269 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, "
261 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, " 270 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, "
262 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss, uuid=:uuid"); 271 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss, "
272 "HLT_volume=:HLT_volume, HLT_deadspace=:HLT_deadspace, uuid=:uuid");
263 273
264 query.bindValue(":name", ui->nameEdit->text() + " [copy]"); 274 query.bindValue(":name", ui->nameEdit->text() + " [copy]");
265 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); 275 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0'));
266 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0')); 276 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0'));
267 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0')); 277 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0'));
285 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex()); 295 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex());
286 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0')); 296 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0'));
287 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0')); 297 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0'));
288 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0')); 298 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0'));
289 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0')); 299 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0'));
300 query.bindValue(":HLT_volume", QString("%1").arg(ui->HLT_volumeEdit->value(), 2, 'f', 1, '0'));
301 query.bindValue(":HLT_deadspace", QString("%1").arg(ui->HLT_deadspaceEdit->value(), 2, 'f', 1, '0'));
290 query.exec(); 302 query.exec();
291 if (query.lastError().isValid()) { 303 if (query.lastError().isValid()) {
292 qWarning() << "EditEquipment" << query.lastError(); 304 qWarning() << "EditEquipment" << query.lastError();
293 QMessageBox::warning(this, tr("Database error"), 305 QMessageBox::warning(this, tr("Database error"),
294 tr("MySQL error: %1\n%2\n%3") 306 tr("MySQL error: %1\n%2\n%3")

mercurial