src/EditProductTab8.cpp

changeset 307
afd711e37f68
parent 283
242a68fa7186
child 349
f05aeee71a14
equal deleted inserted replaced
306:d45c502ce77f 307:afd711e37f68
633 */ 633 */
634 product->w2_amount = 0; 634 product->w2_amount = 0;
635 } 635 }
636 ui->w2_volEdit->setValue(product->w2_amount); 636 ui->w2_volEdit->setValue(product->w2_amount);
637 637
638 check_waters();
638 calcWater(); 639 calcWater();
639 is_changed(); 640 is_changed();
641 }
642
643
644 void EditProduct::check_waters()
645 {
646 QSqlQuery query;
647 product->waters_ok = true;
648
649 if (product->w1_name != "") {
650 qDebug() << "check_waters 1" << product->w1_name;
651 query.prepare("SELECT unlimited_stock,inventory FROM inventory_waters WHERE name=:name");
652 query.bindValue(":name", product->w1_name);
653 query.exec();
654 if (query.first()) {
655 if ((query.value("unlimited_stock").toInt() == 0) && (query.value("inventory").toDouble() < product->w1_amount)) {
656 product->waters_ok = false;
657 qDebug() << "w1_amount too low";
658 }
659 }
660 }
661
662 if ((product->w2_name != "") && (product->w2_amount > 0)) {
663 qDebug() << "check_waters 2" << product->w2_name;
664 query.prepare("SELECT unlimited_stock,inventory FROM inventory_waters WHERE name=:name");
665 query.bindValue(":name", product->w2_name);
666 query.exec();
667 if (query.first()) {
668 if ((query.value("unlimited_stock").toInt() == 0) && (query.value("inventory").toDouble() < product->w2_amount)) {
669 product->waters_ok = false;
670 qDebug() << "w2_amount too low";
671 }
672 }
673 }
640 } 674 }
641 675
642 676
643 void EditProduct::w1_name_changed(int val) 677 void EditProduct::w1_name_changed(int val)
644 { 678 {
658 query.exec(); 692 query.exec();
659 query.first(); 693 query.first();
660 for (int i = 0; i < (val - 1); i++) { 694 for (int i = 0; i < (val - 1); i++) {
661 query.next(); 695 query.next();
662 } 696 }
663 qDebug() << "set water" << query.value(1).toString(); 697 qDebug() << "set water" << query.value("name").toString();
664 698
665 product->w1_name = query.value(1).toString(); 699 product->w1_name = query.value("name").toString();
666 product->w1_calcium = query.value(3).toDouble(); 700 product->w1_calcium = query.value("calcium").toDouble();
667 product->w1_magnesium = query.value(8).toDouble(); 701 product->w1_magnesium = query.value("magnesium").toDouble();
668 product->w1_total_alkalinity = query.value(11).toDouble(); 702 product->w1_total_alkalinity = query.value("total_alkalinity").toDouble();
669 product->w1_sodium = query.value(7).toDouble(); 703 product->w1_sodium = query.value("sodium").toDouble();
670 product->w1_chloride = query.value(6).toDouble(); 704 product->w1_chloride = query.value("chloride").toDouble();
671 product->w1_sulfate = query.value(5).toDouble(); 705 product->w1_sulfate = query.value("sulfate").toDouble();
672 product->w1_ph = query.value(9).toDouble(); 706 product->w1_ph = query.value("ph").toDouble();
673 707
674 ui->w1_caEdit->setValue(product->w1_calcium); 708 ui->w1_caEdit->setValue(product->w1_calcium);
675 ui->w1_mgEdit->setValue(product->w1_magnesium); 709 ui->w1_mgEdit->setValue(product->w1_magnesium);
676 ui->w1_hco3Edit->setValue(product->w1_total_alkalinity * 1.22); 710 ui->w1_hco3Edit->setValue(product->w1_total_alkalinity * 1.22);
677 ui->w1_caco3Edit->setValue(product->w1_total_alkalinity); 711 ui->w1_caco3Edit->setValue(product->w1_total_alkalinity);
678 ui->w1_naEdit->setValue(product->w1_sodium); 712 ui->w1_naEdit->setValue(product->w1_sodium);
679 ui->w1_clEdit->setValue(product->w1_chloride); 713 ui->w1_clEdit->setValue(product->w1_chloride);
680 ui->w1_so4Edit->setValue(product->w1_sulfate); 714 ui->w1_so4Edit->setValue(product->w1_sulfate);
681 ui->w1_phEdit->setValue(product->w1_ph); 715 ui->w1_phEdit->setValue(product->w1_ph);
682 716
717 check_waters();
683 is_changed(); 718 is_changed();
684 calcWater(); 719 calcWater();
685 } 720 }
686 721
687 722
729 ui->w2_naEdit->setValue(product->w2_sodium); 764 ui->w2_naEdit->setValue(product->w2_sodium);
730 ui->w2_clEdit->setValue(product->w2_chloride); 765 ui->w2_clEdit->setValue(product->w2_chloride);
731 ui->w2_so4Edit->setValue(product->w2_sulfate); 766 ui->w2_so4Edit->setValue(product->w2_sulfate);
732 ui->w2_phEdit->setValue(product->w2_ph); 767 ui->w2_phEdit->setValue(product->w2_ph);
733 768
769 check_waters();
734 is_changed(); 770 is_changed();
735 calcWater(); 771 calcWater();
736 } 772 }
737 773
738 774

mercurial