48 query.prepare("SELECT * FROM inventory_miscs WHERE record = :recno"); |
48 query.prepare("SELECT * FROM inventory_miscs WHERE record = :recno"); |
49 query.bindValue(":recno", id); |
49 query.bindValue(":recno", id); |
50 query.exec(); |
50 query.exec(); |
51 query.next(); |
51 query.next(); |
52 |
52 |
53 ui->nameEdit->setText(query.value(1).toString()); |
53 ui->nameEdit->setText(query.value("name").toString()); |
54 ui->typeEdit->setCurrentIndex(query.value(2).toInt()); |
54 ui->typeEdit->setCurrentIndex(query.value("type").toInt()); |
55 ui->useEdit->setCurrentIndex(query.value(3).toInt()); |
55 ui->useEdit->setCurrentIndex(query.value("use_use").toInt()); |
56 ui->timeEdit->setValue(query.value(4).toInt()); |
56 ui->timeEdit->setValue(query.value("time").toInt()); |
57 ui->isweightEdit->setChecked(query.value(5).toInt() ? true:false); |
57 ui->isweightEdit->setChecked(query.value("amount_is_weight").toInt() ? true:false); |
58 ui->useforEdit->setPlainText(query.value(6).toString()); |
58 ui->useforEdit->setPlainText(query.value("use_for").toString()); |
59 ui->notesEdit->setPlainText(query.value(7).toString()); |
59 ui->notesEdit->setPlainText(query.value("notes").toString()); |
60 ui->alwaysEdit->setChecked(query.value(8).toInt() ? true:false); |
60 ui->alwaysEdit->setChecked(query.value("always_on_stock").toInt() ? true:false); |
61 ui->inventoryEdit->setValue(query.value(9).toDouble()); |
61 ui->inventoryEdit->setValue(query.value("inventory").toDouble() * 1000.0); |
62 ui->costEdit->setValue(query.value(10).toDouble()); |
62 ui->costEdit->setValue(query.value("cost").toDouble()); |
63 ui->valueEdit->setValue(query.value(9).toDouble() * query.value(10).toDouble()); |
63 ui->valueEdit->setValue(query.value("inventory").toDouble() * query.value("cost").toDouble()); |
64 if (query.value(11).toString().length() == 10) { |
64 if (query.value("production_date").toString().length() == 10) { |
65 ui->prodEdit->setDate(query.value(11).toDate()); |
65 ui->prodEdit->setDate(query.value("production_date").toDate()); |
66 } else { |
66 } else { |
67 ui->prodEdit->clear(); |
67 ui->prodEdit->clear(); |
68 } |
68 } |
69 if (query.value(12).toString().length() == 10) { |
69 if (query.value("tht_date").toString().length() == 10) { |
70 ui->thtEdit->setDate(query.value(12).toDate()); |
70 ui->thtEdit->setDate(query.value("tht_date").toDate()); |
71 } else { |
71 } else { |
72 ui->thtEdit->clear(); |
72 ui->thtEdit->clear(); |
73 } |
73 } |
74 } else { |
74 } else { |
75 /* Set some defaults */ |
75 /* Set some defaults */ |
77 ui->useEdit->setCurrentIndex(0); |
77 ui->useEdit->setCurrentIndex(0); |
78 ui->timeEdit->setValue(0); |
78 ui->timeEdit->setValue(0); |
79 ui->prodEdit->clear(); |
79 ui->prodEdit->clear(); |
80 ui->thtEdit->clear(); |
80 ui->thtEdit->clear(); |
81 } |
81 } |
|
82 UnitSet(); |
82 TimeSet(); |
83 TimeSet(); |
83 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditMisc::is_changed); |
84 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditMisc::is_changed); |
84 connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); |
85 connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); |
85 connect(ui->useEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); |
86 connect(ui->useEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); |
86 connect(ui->timeEdit, &QSpinBox::textChanged, this, &EditMisc::time_changed); |
87 connect(ui->timeEdit, &QSpinBox::textChanged, this, &EditMisc::time_changed); |
87 connect(ui->isweightEdit, &QCheckBox::stateChanged, this, &EditMisc::is_changed); |
88 connect(ui->isweightEdit, &QCheckBox::stateChanged, this, &EditMisc::weight_changed); |
88 connect(ui->useforEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
89 connect(ui->useforEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
89 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
90 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
90 connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditMisc::is_changed); |
91 connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditMisc::is_changed); |
91 connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); |
92 connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); |
92 connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); |
93 connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); |
93 connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed); |
94 connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed); |
|
95 connect(ui->prodButton1, SIGNAL(clicked()), this, SLOT(prod_date_today())); |
|
96 connect(ui->prodButton2, SIGNAL(clicked()), this, SLOT(prod_date_clear())); |
94 connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed); |
97 connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed); |
|
98 connect(ui->thtButton1, SIGNAL(clicked()), this, SLOT(tht_date_today())); |
|
99 connect(ui->thtButton2, SIGNAL(clicked()), this, SLOT(tht_date_clear())); |
95 |
100 |
96 ui->saveButton->setEnabled(false); |
101 ui->saveButton->setEnabled(false); |
97 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false); |
102 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false); |
98 } |
103 } |
99 |
104 |