Ayuda en Jtable
Publicado por Hector (63 intervenciones) el 04/03/2020 01:29:27
Hola amigos del foro mi consulta estoy realizando un proyecto en el cual ingreso datos para comparar datos (distintos proveedores) y que me escoga el menor por cada fila, es decir como muestro en la pantalla que se adjunta, el código que realice no me muestra error pero no realiza tal situación, aqui se los dejo para que me indiquen en que estoy fallando.
ojala que me puedan ayudar ya que no puedo salir de esto, creo que puede hacerse de mover datos de una columna a otra columna con su valores y 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
55
56
57
58
private void actualizarActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel dtm = (DefaultTableModel) tblDatos.getModel();
if (dtm.getRowCount() > 0) {
for (int i = 1; i < dtm.getRowCount(); i++) {
String clave = (String) tblDatos.getValueAt(i, 0);
Double ID1 = Double.parseDouble(clave);
String valor = (String) tblDatos.getValueAt(i, 7);
String valor1 = (String) tblDatos.getValueAt(i, 10);
String valor2 = (String) tblDatos.getValueAt(i, 13);
String valor3 = (String) tblDatos.getValueAt(i, 8);
Double val = Double.parseDouble(valor3);
String valor4 = (String) tblDatos.getValueAt(i, 11);
Double val1 = Double.parseDouble(valor4);
String valor5 = (String) tblDatos.getValueAt(i, 14);
Double val2 = Double.parseDouble(valor4);
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());
String valor6 = (String) tblDatos.getValueAt(i, 4);
Double val3 = Double.parseDouble(valor6);
Long val6 = Math.round(val4 * val3);
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=" + ID1.toString() + "");
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());
String valor6 = (String) tblDatos.getValueAt(i, 4);
Double val3 = Double.parseDouble(valor6);
Long val6 = Math.round(val4 * val3);
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=" + ID1.toString() + "");
pst.executeUpdate();
mostrardatos1(txtsiniestro.getText());
} catch (SQLException ex) {
Logger.getLogger(Frmanalisis.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
}
actualizar.setVisible(false);
sumacolumna.setEnabled(true);
sumacolumna.requestFocus();
}
- Pantalla-de-Analisis.rar(237,0 KB)
Valora esta pregunta


0