699 return; |
700 return; |
700 } |
701 } |
701 |
702 |
702 if (this->textIsChanged) { |
703 if (this->textIsChanged) { |
703 if (this->recno == -1) { |
704 if (this->recno == -1) { |
704 query.prepare("INSERT INTO recipes SET name=:name, " |
705 query.prepare("INSERT INTO recipes SET locked=:locked, st_name=:st_name, st_letter=:st_letter, " |
|
706 "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " |
|
707 "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " |
|
708 "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " |
|
709 "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " |
|
710 "name=:name, notes:=notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " |
|
711 "boil_time=:boil_time, efficiency=:efficiency, " |
705 "uuid = :uuid"); |
712 "uuid = :uuid"); |
706 } else { |
713 } else { |
707 query.prepare("UPDATE recipes SET name=:name " |
714 query.prepare("UPDATE recipes SET locked=:locked, st_name=:st_name, st_letter=:st_letter, " |
|
715 "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " |
|
716 "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " |
|
717 "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " |
|
718 "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " |
|
719 "name=:name, notes:=notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " |
|
720 "boil_time=:boil_time, efficiency=:efficiency " |
708 " WHERE record = :recno"); |
721 " WHERE record = :recno"); |
709 } |
722 } |
710 //query.bindValue(":name", ui->nameEdit->text()); |
723 query.bindValue(":locked", ui->lockedEdit->isChecked() ? 1:0); |
711 //query.bindValue(":notes", ui->notesEdit->toPlainText()); |
724 query.bindValue(":st_name", ui->st_nameEdit->text()); |
|
725 query.bindValue(":st_letter", ui->st_groupEdit->text()); |
|
726 query.bindValue(":st_guide", ui->st_guideEdit->text()); |
|
727 query.bindValue(":st_category", ui->st_catEdit->text()); |
|
728 query.bindValue(":st_catnr", st_type); |
|
729 query.bindValue(":st_og_min", QString("%1").arg(ui->est_ogShow->minval(), 4, 'f', 3, '0')); |
|
730 query.bindValue(":st_og_max", QString("%1").arg(ui->est_ogShow->maxval(), 4, 'f', 3, '0')); |
|
731 query.bindValue(":st_fg_min", QString("%1").arg(ui->est_fgShow->minval(), 4, 'f', 3, '0')); |
|
732 query.bindValue(":st_fg_max", QString("%1").arg(ui->est_fgShow->maxval(), 4, 'f', 3, '0')); |
|
733 query.bindValue(":st_ibu_min", QString("%1").arg(ui->est_ibuShow->minval(), 4, 'f', 3, '0')); |
|
734 query.bindValue(":st_ibu_max", QString("%1").arg(ui->est_ibuShow->maxval(), 4, 'f', 3, '0')); |
|
735 query.bindValue(":st_color_min", QString("%1").arg(ui->est_colorShow->minval(), 4, 'f', 3, '0')); |
|
736 query.bindValue(":st_color_max", QString("%1").arg(ui->est_colorShow->maxval(), 4, 'f', 3, '0')); |
|
737 query.bindValue(":st_carb_min", QString("%1").arg(ui->est_carbShow->minval(), 4, 'f', 3, '0')); |
|
738 query.bindValue(":st_carb_max", QString("%1").arg(ui->est_carbShow->maxval(), 4, 'f', 3, '0')); |
|
739 query.bindValue(":st_abv_min", QString("%1").arg(ui->est_abvShow->minval(), 4, 'f', 3, '0')); |
|
740 query.bindValue(":st_abv_max", QString("%1").arg(ui->est_abvShow->maxval(), 4, 'f', 3, '0')); |
|
741 query.bindValue(":name", ui->nameEdit->text()); |
|
742 query.bindValue(":notes", ui->notesEdit->toPlainText()); |
|
743 query.bindValue(":type", ui->typeEdit->currentIndex()); |
|
744 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 2, 'f', 1, '0')); |
|
745 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); |
|
746 query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 2, 'f', 1, '0')); |
|
747 query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0')); |
|
748 query.bindValue(":est_og", QString("%1").arg(ui->est_ogEdit->value(), 4, 'f', 3, '0')); |
|
749 query.bindValue(":est_fg", QString("%1").arg(ui->est_fgEdit->value(), 4, 'f', 3, '0')); |
|
750 query.bindValue(":est_abv", QString("%1").arg(ui->est_abvEdit->value(), 2, 'f', 1, '0')); |
|
751 query.bindValue(":est_color", QString("%1").arg(ui->est_colorEdit->value(), 1, 'f', 0, '0')); |
|
752 query.bindValue(":color_method", ui->color_methodEdit->currentIndex()); |
|
753 query.bindValue(":est_ibu", QString("%1").arg(ui->est_ibuEdit->value(), 1, 'f', 0, '0')); |
|
754 query.bindValue(":ibu_method", ui->ibu_methodEdit->currentIndex()); |
|
755 query.bindValue(":est_carb", QString("%1").arg(ui->est_carbEdit->value(), 2, 'f', 1, '0')); |
|
756 |
712 if (this->recno == -1) { |
757 if (this->recno == -1) { |
713 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
758 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
714 } else { |
759 } else { |
715 query.bindValue(":recno", this->recno); |
760 query.bindValue(":recno", this->recno); |
716 } |
761 } |
717 query.exec(); |
762 qDebug() << query.lastQuery(); |
|
763 // query.exec(); |
718 if (query.lastError().isValid()) { |
764 if (query.lastError().isValid()) { |
719 qDebug() << "EditRecipe" << query.lastError(); |
765 qDebug() << "EditRecipe" << query.lastError(); |
720 QMessageBox::warning(this, tr("Database error"), |
766 QMessageBox::warning(this, tr("Database error"), |
721 tr("MySQL error: %1\n%2\n%3") |
767 tr("MySQL error: %1\n%2\n%3") |
722 .arg(query.lastError().nativeErrorCode()) |
768 .arg(query.lastError().nativeErrorCode()) |