private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        try {
            
            String empleado = JOptionPane.showInputDialog("Confirmar");
            String sql = "INSERT INTO ventas(Empleados_idEmpleados, precio_total) VALUES( ?, ? )";
            String sql1 = "INSERT INTO productos_has_ventas(productos_idproductos, ventas_idventas, cantidad_venta) VALUES(?, ?, ?) ";
            
            String sql3 = "UPDATE productos "
                    + "SET cantidad = cantidad - ? "
                    + "WHERE idproductos = ? ";
            String sql4 = "SELECT idempleados FROM empleados WHERE idempleados = ?";

            Connection conn = Conexion.GetConnection();
            conn.setAutoCommit(false);
            PreparedStatement ps = conn.prepareStatement(sql);
            PreparedStatement ps1 = conn.prepareStatement(sql1);
            
            PreparedStatement ps3 = conn.prepareStatement(sql3);
            PreparedStatement ps4 = conn.prepareStatement(sql4);
            
            ps4.setString(1, empleado);
            ResultSet rs = ps4.executeQuery();
            

            if (rs.next()) {
                
                ps.setString(1, empleado);
                ps.setString(2, jLblPrecio.getText());
                ps.execute();
                conn.commit();
                
                String sqlLast = "SELECT `AUTO_INCREMENT` - 1 "
                        + " FROM  INFORMATION_SCHEMA.TABLES "
                        + " WHERE TABLE_SCHEMA = 'gamecrush' "
                        + " AND   TABLE_NAME   = 'ventas' ";
                Connection connLast = Conexion.GetConnection();
                PreparedStatement psLast = connLast.prepareStatement(sqlLast);
                lastId = psLast.executeQuery();
                lastId.next();
                String lastIdPed = lastId.getString(1);
                
                System.out.println(lastIdPed);
                int rows2 = jTableVentas.getRowCount();

                for (int j = 0; j < rows2; j++) {
                    ps3.setInt(1, (int) tmVent.getValueAt(j, 2));
                    ps3.setString(2, (String) tmVent.getValueAt(j, 0));

                    ps3.executeUpdate();
                    conn.commit();
                }

                for (int j = 0; j < rows2; j++) {
                    ps1.setString(1, (String) tmVent.getValueAt(j, 0));
                    ps1.setString(2, lastIdPed);
                    ps1.setInt(3, (int) tmVent.getValueAt(j, 2));
                    
                    ps1.execute();
                    conn.commit();
                }
                
                cancelVenta();
                clearVenta();
            } else {
                JOptionPane.showMessageDialog(this, "Empleado no valido");
            }

            ps.setString(1, sql);

        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }//GEN-LAST:event_jButton1ActionPerformed