private void jbotgrabarActionPerformed(java.awt.event.ActionEvent evt) {                                           
        int[] matchScore = new int[1];
         boolean[] matched = new boolean[1];
         long iError;
         long secuLevel = 1;
         matched[0] = true;
         
         iError = fplib.MatchTemplate(regMin1,regMin2, secuLevel, matched); 
            System.out.println("resultado comparacion " + matched[0]);
         if (matched[0] == true)
         {
    
           if (matched[0]){
                     conexion fbc = new conexion();
                     // primero consulta con la base de datos si existe huella
                       v_where = " where id_contrato = ";
                       v_idcontrato = this.txt_idcontrato.getText();
                       
                       v_where = v_where + "'" + v_idcontrato + "' and ubicacion = " + v_dedo;
                        // se arma el resultado
                          fbc.consulta("*","vw_huellas","",v_where);
                try {
                    if (fbc.vresultSet.next()){
                    v_idhuella = fbc.vresultSet.getInt("id_huella");
                }
                } catch (SQLException ex) {
                    v_idhuella = 0;
           
                }
                
                if (v_idhuella == 0){ 
                    v_campo = "id_contrato,huella_dedo,ubicacion";
                    v_variables = v_idcontrato + ",'" + regMin1 + "'," + v_dedo;
                    this.jlb_mensaje.setText(v_variables);
                    fbc.insertar(v_campo, v_variables,"Huellas");
                }
                else{
                    v_where = " where id_huella = ";
                    v_where = v_where +  v_idhuella ;
                     v_campo = " huella_dedo = '" + regMin1 + "'"; 
                     fbc.modificar(v_campo,"Huellas",v_where);
                     this.jlb_mensaje.setText(v_campo);
                }
                
                fbc.desconectar();
                int resp=JOptionPane.showConfirmDialog(null,"Desea Grabar Otra Huella al mismo Personal?");
                
                if (JOptionPane.OK_OPTION == resp){
                  this.jlbl_dedo.setIcon(new ImageIcon("")); 
                  this.jbotgrabar.setEnabled(false);
                  this.jbot_capturar.grabFocus();
                }
                else {
                    this.txt_idcontrato.setText("");
                    this.lbl_foto1.setIcon(new ImageIcon(""));
                    this.jlbl_dedo.setIcon(new ImageIcon(""));
                    this.jbotgrabar.setEnabled(false);
                    this.jbot_capturar.setEnabled(false);
                    this.jlb_mensaje.setText("");
                    this.txt_nombre.setText("");
                    this.txt_nrocontrato.setText("");
                    this.txt_nrocontrato.grabFocus();
                }
            }
                 else
                     this.jlb_mensaje.setText( "Error en Grabacin : " + matchScore[0]);
                     
             
         }
             else
                this.jlb_mensaje.setText( "Error en Grabacin : " + iError);      
         
         
          
      
    }                                          
