Metziop

Untitled

Sep 3rd, 2020 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1.     private void btnGuardarInvActionPerformed(java.awt.event.ActionEvent evt) {                                              
  2.         Connection con = null;
  3.         try {
  4.             con = getConnection();
  5.             ps = con.prepareStatement("INSERT INTO inventario (articulo, sucursal, existencia, marca)VALUES(?,?,?,?)");
  6.             ps.setString(1, txtArticuloInv.getText());
  7.             ps.setString(2, txtSucursalInv.getText());
  8.             ps.setInt(3, Integer.parseInt(txtExistenciaInv.getText()));
  9.             ps.setString(4, txtMarcaInv.getText());
  10.             int res = ps.executeUpdate();
  11.             if (res > 0) {
  12.                 borrarDatos();
  13.             } else {
  14.                 JOptionPane.showMessageDialog(null, "Error al guardar");
  15.                 borrarDatos();
  16.             }
  17.             con.close();
  18.  
  19.         } catch (Exception e) {
  20.             System.err.println("Error de conexion");
  21.         }
  22.  
  23.     }        
Add Comment
Please, Sign In to add comment