src/EditYeastPack.cpp

Tue, 31 Jan 2023 11:10:14 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 31 Jan 2023 11:10:14 +0100
changeset 481
8a25dbe682eb
parent 480
94b3def5d778
permissions
-rw-r--r--

Added valid flag to the inventory_yeastpack table. Initial false and after record edit set to true. This should prevent the use possible wrong values.

480
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditYeastPack.cpp is part of bmsapp.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "EditYeastPack.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "../ui/ui_EditYeastPack.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "MainWindow.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "global.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 EditYeastPack::EditYeastPack(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditYeastPack)
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 QSqlQuery query;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 qDebug() << "EditYeastPack record:" << id;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 ui->setupUi(this);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 this->recno = id;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 WindowTitle();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 ui->formEdit->addItem(tr("Liquid"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 ui->formEdit->addItem(tr("Dry"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 ui->formEdit->addItem(tr("Slant"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 ui->formEdit->addItem(tr("Culture"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 ui->formEdit->addItem(tr("Frozen"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 ui->formEdit->addItem(tr("Bottle"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 ui->formEdit->addItem(tr("Dried"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 if (id >= 0) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 query.prepare("SELECT * FROM inventory_yeastpack WHERE record = :recno");
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 query.bindValue(":recno", id);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 query.exec();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 query.next();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 ui->laboratoryEdit->setText(query.value("laboratory").toString());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 ui->packageEdit->setText(query.value("package").toString());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 ui->formEdit->setCurrentIndex(query.value("form").toInt());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 ui->notesEdit->setPlainText(query.value("notes").toString());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 ui->cellsEdit->setValue(query.value("cells").toDouble() / 1000000000);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 ui->viabilityEdit->setValue(query.value("viability").toDouble());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 ui->maxEdit->setValue(query.value("max").toInt());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 ui->sizeEdit->setValue(query.value("size").toDouble() * 1000);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 ui->usedEdit->setValue(query.value("used").toInt());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 /* Set some defaults */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 ui->formEdit->setCurrentIndex(YEAST_FORMS_DRY);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 ui->viabilityEdit->setValue(0.99);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 ui->maxEdit->setValue(100);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 ui->usedEdit->setValue(0);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 PackSet();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 Viability();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 connect(ui->laboratoryEdit, &QLineEdit::textChanged, this, &EditYeastPack::is_changed);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 connect(ui->formEdit, &QComboBox::currentTextChanged, this, &EditYeastPack::form_changed);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 connect(ui->packageEdit, &QLineEdit::textChanged, this, &EditYeastPack::is_changed);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 connect(ui->cellsEdit, &QDoubleSpinBox::textChanged, this, &EditYeastPack::is_changed);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 connect(ui->viabilityEdit, &QDoubleSpinBox::textChanged, this, &EditYeastPack::viability_changed);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 connect(ui->maxEdit, &QSpinBox::textChanged, this, &EditYeastPack::viability_changed);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 connect(ui->sizeEdit, &QDoubleSpinBox::textChanged, this, &EditYeastPack::is_changed);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 ui->saveButton->setEnabled(false);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 EditYeastPack::~EditYeastPack()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 delete ui;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 emit entry_changed();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 /*
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 * Window header, mark any change with '**'
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 void EditYeastPack::WindowTitle()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 QString txt;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 if (this->recno < 0) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 txt = QString(tr("BMSapp - Add new yeast package"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 txt = QString(tr("BMSapp - Edit yeast package %1").arg(this->recno));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 if (this->textIsChanged) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 txt.append((QString(" **")));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 setWindowTitle(txt);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 void EditYeastPack::on_saveButton_clicked()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 QSqlQuery query;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 /* If there are errors in the form, show a message and do "return;" */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 if (ui->laboratoryEdit->text().length() < 2) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 QMessageBox::warning(this, tr("Edit Yeast Package"), tr("Laboratory name empty or too short."));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 return;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 if (ui->packageEdit->text().length() < 2) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 QMessageBox::warning(this, tr("Edit Yeast Package"), tr("Package name empty or too short."));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 return;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 if (this->textIsChanged) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 if (this->recno == -1) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 query.prepare("INSERT INTO inventory_yeastpack SET laboratory=:laboratory, form=:form, "
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 "package=:package, notes=:notes, cells=:cells, viability=:viability, max=:max, "
481
8a25dbe682eb Added valid flag to the inventory_yeastpack table. Initial false and after record edit set to true. This should prevent the use possible wrong values.
Michiel Broek <mbroek@mbse.eu>
parents: 480
diff changeset
125 "size=:size, used='0', valid='1', uuid = :uuid");
480
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 query.prepare("UPDATE inventory_yeastpack SET laboratory=:laboratory, form=:form, "
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 "package=:package, notes=:notes, cells=:cells, viability=:viability, max=:max, "
481
8a25dbe682eb Added valid flag to the inventory_yeastpack table. Initial false and after record edit set to true. This should prevent the use possible wrong values.
Michiel Broek <mbroek@mbse.eu>
parents: 480
diff changeset
129 "size=:size, valid='1' WHERE record = :recno");
480
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 query.bindValue(":laboratory", ui->laboratoryEdit->text());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 query.bindValue(":form", ui->formEdit->currentIndex());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 query.bindValue(":package", ui->packageEdit->text());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 query.bindValue(":notes", ui->notesEdit->toPlainText());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 query.bindValue(":cells", QString("%1").arg(ui->cellsEdit->value() * 1000000000, 1, 'f', 0, '0'));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 query.bindValue(":viability", QString("%1").arg(ui->viabilityEdit->value(), 5, 'f', 4, '0'));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 query.bindValue(":max", ui->maxEdit->value());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 query.bindValue(":size", QString("%1").arg(ui->sizeEdit->value() / 1000, 5, 'f', 4, '0'));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 if (this->recno == -1) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 query.bindValue(":recno", this->recno);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 query.exec();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 if (query.lastError().isValid()) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 qWarning() << "EditYeastPack" << query.lastError();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 QMessageBox::warning(this, tr("Database error"),
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 tr("MySQL error: %1\n%2\n%3")
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 .arg(query.lastError().nativeErrorCode())
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 .arg(query.lastError().driverText())
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 .arg(query.lastError().databaseText()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 qDebug() << "EditYeastPack Saved";
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 ui->saveButton->setEnabled(false);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 this->textIsChanged = false;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 WindowTitle();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 void EditYeastPack::on_cloneButton_clicked()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 QSqlQuery query;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 query.prepare("INSERT INTO inventory_yeastpack SET laboratory=:laboratory, form=:form, "
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 "package=:package, notes=:notes, cells=:cells, viability=:viability, max=:max, "
481
8a25dbe682eb Added valid flag to the inventory_yeastpack table. Initial false and after record edit set to true. This should prevent the use possible wrong values.
Michiel Broek <mbroek@mbse.eu>
parents: 480
diff changeset
168 "size=:size, used=:used, valid='0', uuid=:uuid");
480
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 query.bindValue(":laboratory", ui->laboratoryEdit->text());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 query.bindValue(":form", ui->formEdit->currentIndex());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 query.bindValue(":package", ui->packageEdit->text() + " [copy]");
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 query.bindValue(":notes", ui->notesEdit->toPlainText());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 query.bindValue(":cells", QString("%1").arg(ui->cellsEdit->value() * 1000000000, 1, 'f', 0, '0'));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 query.bindValue(":viability", QString("%1").arg(ui->viabilityEdit->value(), 5, 'f', 4, '0'));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 query.bindValue(":max", ui->maxEdit->value());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 query.bindValue(":size", QString("%1").arg(ui->sizeEdit->value() / 1000, 5, 'f', 4, '0'));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 query.bindValue(":used", ui->usedEdit->value());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 query.exec();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 if (query.lastError().isValid()) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 qWarning() << "EditYeastPack" << query.lastError();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 QMessageBox::warning(this, tr("Database error"),
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 tr("MySQL error: %1\n%2\n%3")
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 .arg(query.lastError().nativeErrorCode())
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 .arg(query.lastError().driverText())
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 .arg(query.lastError().databaseText()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 qDebug() << "EditYeastPack Clone saved";
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 void EditYeastPack::on_deleteButton_clicked()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 QSqlQuery query;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 int rc = QMessageBox::warning(this, tr("Delete yeast pack"), tr("Delete %1").arg(ui->packageEdit->text()),
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 if (rc == QMessageBox::No)
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 return;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 query.prepare("DELETE FROM inventory_yeastpack WHERE record = :recno");
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 query.bindValue(":recno", this->recno);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 query.exec();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 if (query.lastError().isValid()) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 qWarning() << "EditYeastPack" << query.lastError();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 QMessageBox::warning(this, tr("Database error"),
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 tr("MySQL error: %1\n%2\n%3")
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 .arg(query.lastError().nativeErrorCode())
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 .arg(query.lastError().driverText())
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 .arg(query.lastError().databaseText()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 qDebug() << "EditYeastPack Deleted" << this->recno;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 this->close();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 this->setResult(1);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 void EditYeastPack::Viability()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 double vpm = ui->viabilityEdit->value();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 double max = ui->maxEdit->value();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 double degrade = 1 - ((1 - vpm) / 30.41); /* viability degradation per day. */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 double base = max;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 for (int i = 0; i < 182; i++) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 base = base * degrade;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 if (base > max)
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 base = max;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 ui->resultEdit->setValue(base);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 qDebug() << "Viability()" << vpm << max << degrade << base;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 void EditYeastPack::PackSet()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 if (ui->formEdit->currentIndex() == YEAST_FORMS_DRY || ui->formEdit->currentIndex() == YEAST_FORMS_DRIED) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 ui->sizeEdit->setSuffix(tr(" gr"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 ui->sizeEdit->setSuffix(tr(" ml"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 /*
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 * TODO: The delete button may be enabled for records with used > 0 if
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 * there are more records with the same laboratory and form.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 * There should always be at least one record, the rest is allowed to
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 * be deleted. So, we need to count.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 if (ui->usedEdit->value() > 0) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 ui->laboratoryEdit->setReadOnly(true);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 ui->formEdit->setDisabled(true);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 ui->deleteButton->setEnabled(false);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 qDebug() << "PackSet blocked";
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 ui->laboratoryEdit->setReadOnly(false);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 ui->formEdit->setDisabled(false);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 ui->deleteButton->setEnabled(true);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 void EditYeastPack::is_changed()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 ui->saveButton->setEnabled(true);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 this->textIsChanged = true;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 WindowTitle();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 void EditYeastPack::form_changed()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 PackSet();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 is_changed();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 void EditYeastPack::viability_changed()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 Viability();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 is_changed();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 void EditYeastPack::on_quitButton_clicked()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 if (this->textIsChanged) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 int rc = QMessageBox::warning(this, tr("Yeast package changed"), tr("The yeast package has been modified. Save changes?"),
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 switch (rc) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 case QMessageBox::Save:
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 on_saveButton_clicked();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 break; /* Saved and then Quit */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 case QMessageBox::Discard:
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 break; /* Quit without Save */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 case QMessageBox::Cancel:
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 return; /* Return to the editor page */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 this->close();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 this->setResult(1);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308

mercurial