private void btnInsertarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInsertarActionPerformed
        try{
            int numero = Integer.parseInt(txt1.getText());
            if(numero>0){
                Insertar insertar = new Insertar();
                Statement consulta = conexion();
                try{
                ResultSet resultado = consulta.executeQuery("SELECT * FROM tblproductos "
                                 + "WHERE Codigo="+numero);
                    if(resultado.next()==false){
                        insertar.txt1.setText(txt1.getText());
                        insertar.setVisible(rootPaneCheckingEnabled);
                    }else{
                        JOptionPane.showMessageDialog(null, "El Codigo "+numero+" ya exite");
                    }
                }catch(Exception e){}
            }else{
                JOptionPane.showMessageDialog(null, "El numero debe ser mayor que cero");
            }
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(null, "Debe escribir un numero");
        }
        
    }//GEN-LAST:event_btnInsertarActionPerformed