765 /* |
766 /* |
766 * Search the yeast pointed by the index and instock flag. |
767 * Search the yeast pointed by the index and instock flag. |
767 */ |
768 */ |
768 QString sql = "SELECT name,laboratory,product_id,type,form,min_temperature,max_temperature,flocculation,attenuation," |
769 QString sql = "SELECT name,laboratory,product_id,type,form,min_temperature,max_temperature,flocculation,attenuation," |
769 "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide," |
770 "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide," |
770 "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost FROM inventory_yeasts "; |
771 "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost,inventory FROM inventory_yeasts "; |
771 if (instock) |
772 if (instock) |
772 sql.append("WHERE inventory > 0 "); |
773 sql.append("WHERE inventory > 0 "); |
773 sql.append("ORDER BY laboratory,product_id,name"); |
774 sql.append("ORDER BY laboratory,product_id,name"); |
774 query.prepare(sql); |
775 query.prepare(sql); |
775 query.exec(); |
776 query.exec(); |
803 product->yeasts[product->yeasts_row].y_gr_hl_lo = query.value(18).toInt(); |
804 product->yeasts[product->yeasts_row].y_gr_hl_lo = query.value(18).toInt(); |
804 product->yeasts[product->yeasts_row].y_sg_lo = query.value(19).toDouble(); |
805 product->yeasts[product->yeasts_row].y_sg_lo = query.value(19).toDouble(); |
805 product->yeasts[product->yeasts_row].y_gr_hl_hi = query.value(20).toInt(); |
806 product->yeasts[product->yeasts_row].y_gr_hl_hi = query.value(20).toInt(); |
806 product->yeasts[product->yeasts_row].y_sg_hi = query.value(21).toDouble(); |
807 product->yeasts[product->yeasts_row].y_sg_hi = query.value(21).toDouble(); |
807 product->yeasts[product->yeasts_row].y_cost = query.value(22).toDouble(); |
808 product->yeasts[product->yeasts_row].y_cost = query.value(22).toDouble(); |
|
809 product->yeasts[product->yeasts_row].y_inventory = query.value(23).toDouble(); |
808 |
810 |
809 /* |
811 /* |
810 * Update the visible fields |
812 * Update the visible fields |
811 */ |
813 */ |
|
814 const QSignalBlocker blocker1(yamountEdit); |
812 ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name); |
815 ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name); |
813 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory); |
816 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory); |
814 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id); |
817 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id); |
815 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { |
818 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { |
|
819 if (oldform != YEAST_FORMS_LIQUID) |
|
820 product->yeasts[product->yeasts_row].y_amount = 1; |
|
821 yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount); |
816 yamountEdit->setDecimals(0); |
822 yamountEdit->setDecimals(0); |
817 yamountEdit->setSingleStep(1.0); |
823 yamountEdit->setSingleStep(1.0); |
818 yamountLabel->setText(tr("Total packs:")); |
824 yamountLabel->setText(tr("Total packs:")); |
819 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { |
825 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { |
|
826 if (oldform == YEAST_FORMS_LIQUID) |
|
827 product->yeasts[product->yeasts_row].y_amount = 0.01; |
|
828 yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount * 1000.0); |
820 yamountEdit->setDecimals(1); |
829 yamountEdit->setDecimals(1); |
821 yamountEdit->setSingleStep(0.5); |
830 yamountEdit->setSingleStep(0.5); |
822 yamountLabel->setText(tr("Amount in gr:")); |
831 yamountLabel->setText(tr("Amount in gr:")); |
823 } else { |
832 } else { |
|
833 if (oldform == YEAST_FORMS_LIQUID) |
|
834 product->yeasts[product->yeasts_row].y_amount = 0.01; |
|
835 yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount * 1000.0); |
824 yamountEdit->setDecimals(1); |
836 yamountEdit->setDecimals(1); |
825 yamountEdit->setSingleStep(0.5); |
837 yamountEdit->setSingleStep(0.5); |
826 yamountLabel->setText(tr("Amount in ml:")); |
838 yamountLabel->setText(tr("Amount in ml:")); |
827 } |
839 } |
828 |
840 |
848 |
860 |
849 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).y_attenuation, 2, 'f', 1, '0')); |
861 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).y_attenuation, 2, 'f', 1, '0')); |
850 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
862 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
851 ui->yeastsTable->setItem(product->yeasts_row, 8, item); |
863 ui->yeastsTable->setItem(product->yeasts_row, 8, item); |
852 |
864 |
853 calcYeast(); |
865 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) |
|
866 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(product->yeasts_row).y_amount, 1, 'f', 0, '0')); |
|
867 else if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY || product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED) |
|
868 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(product->yeasts_row).y_amount * 1000.0, 3, 'f', 2, '0')); |
|
869 else |
|
870 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(product->yeasts_row).y_amount * 1000.0, 3, 'f', 2, '0')); |
|
871 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
872 ui->yeastsTable->setItem(product->yeasts_row, 9, item); |
|
873 |
|
874 //calcYeast(); |
854 is_changed(); |
875 is_changed(); |
|
876 emit refreshAll(); |
855 } |
877 } |
856 |
878 |
857 |
879 |
858 void EditProduct::yeast_instock_changed(bool val) |
880 void EditProduct::yeast_instock_changed(bool val) |
859 { |
881 { |
980 yamountEdit = new QDoubleSpinBox(dialog); |
1002 yamountEdit = new QDoubleSpinBox(dialog); |
981 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit")); |
1003 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit")); |
982 yamountEdit->setGeometry(QRect(160, 130, 121, 24)); |
1004 yamountEdit->setGeometry(QRect(160, 130, 121, 24)); |
983 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1005 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
984 yamountEdit->setAccelerated(true); |
1006 yamountEdit->setAccelerated(true); |
|
1007 yamountEdit->setMaximum(10000.0); |
985 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { |
1008 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { |
986 yamountEdit->setDecimals(0); |
1009 yamountEdit->setDecimals(0); |
987 yamountEdit->setSingleStep(1.0); |
1010 yamountEdit->setSingleStep(1.0); |
988 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount); |
1011 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount); |
989 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { |
1012 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { |