Traspasdo de datos en un Jtable
Publicado por Hector (63 intervenciones) el 22/11/2019 14:58:26
Hola amigos del foro he aquí nuevamente molestando, tengo una tabla de datos en el cual se ingresa máximo tres proveedores con sus respectivos precios, lo que quiero con el presente código que compare los tres proveedores y los traslade a la columna de compra, he aquí lo que tengo hecho hasta el momento, y el error que me manda un error:
he aquí el error que me manda, estuve averiguando por internet es por los espacios pero los precios son enteros, por lo cual no poseen espacios.
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "Punit_Repuestos"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at Archivos_Consorcio.Frmanalisis.actualizarActionPerformed(Frmanalisis.java:1627)
ojala que me puedan ayudar con este problema, desde ya muchas gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
private void actualizarActionPerformed(java.awt.event.ActionEvent evt) {
mostrardatos(txtsiniestro.getText());
DefaultTableModel dtm = (DefaultTableModel) tblDatos.getModel();
String valor, valor1, valor2;
if (dtm.getRowCount() > 0) {
for (int i = 0; i < dtm.getRowCount(); i++) {
String[] params = new String[dtm.getColumnCount()];
valor = ("Nombre_Proveedor"); // estos son los nombres de las columnas de los proveedores
valor1 = ("Nombre_Proveedor1");
valor2 = ("Nombre_Proveedor2");
//Double val = Double.parseDouble("Punit_Repuestos");
int val = Integer.parseInt("Punit_Repuestos"); // estos son los nombres de las columnas de los precios de los proveedores
Double val1 = Double.parseDouble("Punit_Repuestos1");
Double val2 = Double.parseDouble("Punit_Repuestos2");
if (val1.toString() == "0" && val2.toString() == "0") {
if (val > val1 && val > val2) {
String a = String.valueOf(val);
txtprecio3.setText(a);
txtproveedor3.setText(valor);
Double val4 = Double.parseDouble(txtprecio3.getText());
Double val5 = Double.parseDouble(txtcantidad.getText());
Long val6 = Math.round(val4 * val5);
txttotal3.setText(val6.toString());
try {
PreparedStatement pst = cn.prepareStatement("UPDATE analizacion_consorcio1 SET Nombre_Proveedor3='" + txtproveedor3.getText() + "',Punit_Repuestos3=" + txtprecio3.getText() + ",Ptotal_Repuestos3=" + txttotal3.getText() + " WHERE ID=" + txtid.getText() + "");
pst.executeUpdate();
mostrardatos1(txtsiniestro.getText());
} catch (SQLException ex) {
Logger.getLogger(Frmanalisis.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
if (val < val1 && val < val2) {
String a = String.valueOf(val);
txtprecio3.setText(a);
txtproveedor3.setText(valor);
Double val4 = Double.parseDouble(txtprecio3.getText());
Double val5 = Double.parseDouble(txtcantidad.getText());
Long val6 = Math.round(val4 * val5);
txttotal3.setText(val6.toString());
try {
PreparedStatement pst = cn.prepareStatement("UPDATE analizacion_consorcio1 SET Nombre_Proveedor3='" + txtproveedor3.getText() + "',Punit_Repuestos3=" + txtprecio3.getText() + ",Ptotal_Repuestos3=" + txttotal3.getText() + " WHERE ID=" + txtid.getText() + "");
pst.executeUpdate();
mostrardatos1(txtsiniestro.getText());
} catch (SQLException ex) {
Logger.getLogger(Frmanalisis.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
}
sumacolumna.setEnabled(true);
sumacolumna.requestFocus();
}
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "Punit_Repuestos"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at Archivos_Consorcio.Frmanalisis.actualizarActionPerformed(Frmanalisis.java:1627)
ojala que me puedan ayudar con este problema, desde ya muchas gracias
Valora esta pregunta


0