@Override public void initialize(URL location, ResourceBundle resources) { try { initGrains(); initProviders(); } catch (DataBaseException e) { Utils.showErrorDialog("Ошибка базы данных!", e); } }
public void HandlerCalcPriceButton(ActionEvent event) { try { grain = getGrain(selectGrainCb.getValue()); System.out.println("> " + grain.getName()); try { grain.setWeight(Double.parseDouble(weightTf.getText())); } catch (NumberFormatException e) { weightTf.requestFocus(); throw new NumberFormatException("Вес партии зерна"); } for (Entry<String, TextField> entry : propertiesTf.entrySet()) { TextField tf = entry.getValue(); String propertyName = entry.getKey(); System.out.println("\t> " + propertyName); if (!tf.isDisable()) { try { grain.getProperty(propertyName).setValue(Double.parseDouble(tf.getText())); } catch (NumberFormatException e) { tf.requestFocus(); throw new NumberFormatException(grain.getProperty(propertyName).getDescription()); } grain.getProperty(propertyName).setEnabled(true); } else { grain.getProperty(propertyName).setEnabled(false); } } System.out.println("> before calculator"); PriceCalculator calculator = new PriceCalculator(grain, dao); calculator.calculatePrice(); infoTa.setText(calculator.toString()); Supply supply = new Supply(); supply.setProvider(selectProviderCb.getValue()); supply.setDate(new Date(Calendar.getInstance().getTimeInMillis())); // supply.setGrain(grain.getName()); supply.setGrain(grain.getDescription()); supply.setWeight(grain.getWeight()); supply.setPrice(calculator.getPrice()); dao.saveSupply(supply); } catch (RestrictiveConditionException e) { Utils.showErrorDialog("Ограшичительные кондиции!", e); infoTa.clear(); } catch (DataBaseException e) { Utils.showErrorDialog("Обшибка базы данных!", e); infoTa.clear(); } catch (NumberFormatException e) { Utils.showErrorDialog("Неверный ввод!", e); infoTa.clear(); } catch (Exception ex) { Utils.showErrorDialog("Ошибка!", ex); infoTa.clear(); } }