if (dialog == null){
dialog = new DialogProduct(SwingUtil.getParentJFrame(this), true);
}
int id = (Integer) TableProduct.getValueAt(TableProduct.getSelectedRow(), 0);
Product product = null;
try {
product = productDAO.findById(id);
} catch (SQLException ex) {
Logger.getLogger(InternalFrameProduct.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(this, ex.getMessage(),"Sql Exception", JOptionPane.ERROR_MESSAGE);
return ;
}
dialog.setProduct(product);
dialog.setVisible(true);
if(dialog.getMode() == DialogProduct.SAVE_MODE){
product = dialog.getProduct();
try {
productDAO.update(product.getId(), product );
} catch (SQLException ex) {
Logger.getLogger(InternalFrameProduct.class.getName()).log(Level.SEVERE, null, ex);
}
}