private void button_percent_do_dialogActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_button_percent_do_dialogActionPerformed // TODO add your handling code here: if (operationIndex == 1) { try { out.writeObject("CREATE_PERCENT"); out.flush(); Percent temp = new Percent(); PercentPK tempPK = new PercentPK(); tempPK.setValue(Double.parseDouble(jTextField1.getText())); tempPK.setCurrencyId(Integer.parseInt(jTextField2.getText())); tempPK.setDepositTypeId(Integer.parseInt(jTextField3.getText())); temp.setPercentPK(tempPK); out.writeObject(temp); out.flush(); boolean isDone = (boolean) in.readObject(); if (isDone) { this.dispose(); } } catch (IOException ex) { Logger.getLogger(CurrencyDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(CurrencyDialog.class.getName()).log(Level.SEVERE, null, ex); } } if (operationIndex == 2) { try { out.writeObject("UPDATE_PERCENT"); out.flush(); Percent temp = new Percent(); PercentPK tempPK = new PercentPK(); tempPK.setId(Integer.parseInt(jLabel5.getText())); tempPK.setValue(Double.parseDouble(jTextField1.getText())); tempPK.setCurrencyId(Integer.parseInt(jTextField2.getText())); tempPK.setDepositTypeId(Integer.parseInt(jTextField3.getText())); temp.setPercentPK(tempPK); out.writeObject(temp); out.flush(); boolean isDone = (boolean) in.readObject(); if (isDone) { this.dispose(); } } catch (IOException ex) { Logger.getLogger(CurrencyDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(CurrencyDialog.class.getName()).log(Level.SEVERE, null, ex); } } } // GEN-LAST:event_button_percent_do_dialogActionPerformed
/** Creates new form PercentDialog */ public PercentDialog(MainFrame mf, Percent temp, ObjectInputStream in, ObjectOutputStream out) { super(mf, true); initComponents(); this.operationIndex = mf.getOperationIndex(); System.out.println(operationIndex); this.in = in; this.out = out; if (operationIndex == 1) { this.setTitle("Добавление"); button_percent_do_dialog.setText("Добавить"); } if (operationIndex == 2) { this.setTitle("Редактирование"); button_percent_do_dialog.setText("Редактировать"); jLabel5.setText(temp.getPercentPK().getId() + ""); jTextField1.setText(temp.getPercentPK().getValue() + ""); jTextField2.setText(temp.getPercentPK().getCurrencyId() + ""); jTextField3.setText(temp.getPercentPK().getDepositTypeId() + ""); } }