Sei sulla pagina 1di 2

/*

String msj = "Agregado";


int nc = tablaventa.getRowCount();
if (nc>0){
JOptionPane.showMessageDialog(this,"tabla llena"+nc);
int x = tablaventa.getRowCount();
for (int i=1;i<=x;i++){
JOptionPane.showMessageDialog(this,"items : "+x);
String b = (String) tablaventa.getValueAt(i, 5);
String c = (String) tablaventa.getValueAt(i, 2);
String d = (String) tablaventa.getValueAt(i, 3);
String e = (String) tablaventa.getValueAt(i, 1);
String f = (String) tablaventa.getValueAt(i, 4);
JOptionPane.showMessageDialog(this,"Hea1 :
"+b+"\n"+c+"\n"+d+"\n"+e+"\n"+f);
String a = txtnventa.getText();
String b = (String) tablaventa.getValueAt(i, 5);
String c = (String) tablaventa.getValueAt(i, 2);
String d = (String) tablaventa.getValueAt(i, 3);
String e = (String) tablaventa.getValueAt(i, 1);
String f = (String) tablaventa.getValueAt(i, 4);

//JOptionPane.showMessageDialog(this,"Hea2 :
"+a+"\n"+b+"\n"+c+"\n"+d+"\n"+e+"\n"+f);
try {
ConexionBD conn = new ConexionBD();
Connection cn = conn.Conectar();
PreparedStatement ps = cn.prepareStatement("INSERT INTO
ventadetalle (NVenta, TipoPago, Producto, PrecioUnitario, Cantidad, SubTotal) "
+ "values (a,b,c,d,e,f)");
ps.executeUpdate();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,"error : "+e);
}
}
}
else{
JOptionPane.showMessageDialog(this,"tabla vacia");
}
*/

/*
ConexionBD conn = new ConexionBD();
Connection cn = conn.Conectar();

String sql = "INSERT INTO ventadetalle (NVenta, TipoPago, Producto,


PrecioUnitario, Cantidad, SubTotal)"
+ "values (?,?,?,?,?,?)";
String msj = "Agregado";

for (int i=0;i<tablaventa.getRowCount();i++){


try {
PreparedStatement ps = cn.prepareStatement(sql);
ps.setString(1, txtnventa.getText());
ps.setString(2, tablaventa.getValueAt(i, 5).toString());
ps.setString(3, tablaventa.getValueAt(i, 2).toString());
ps.setString(4, tablaventa.getValueAt(i, 3).toString());
ps.setString(5, tablaventa.getValueAt(i, 1).toString());
ps.setString(6, tablaventa.getValueAt(i, 4).toString());
int n = ps.executeUpdate();
if (n>0){
JOptionPane.showMessageDialog(this, n);
}
else{
JOptionPane.showMessageDialog(this, n);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this,"error : "+e);

}
}
*/

/*
String cantidad = spincantidad.getValue().toString();
String precio = txtpreciounitario.getText();
float c = Float.valueOf(cantidad);
float p = Float.valueOf(precio);
float sub = c * p;
ps.setFloat(6, sub);*/

/*PreparedStatement ps = cn.prepareStatement(sql);
ps.setString(1, txtnventa.getText());
ps.setString(2, pago);
ps.setString(3, ComboProducto.getSelectedItem().toString());
ps.setString(4, txtpreciounitario.getText());
ps.setString(5, spincantidad.getValue().toString());

String cantidad = spincantidad.getValue().toString();


String precio = txtpreciounitario.getText();
float c = Float.valueOf(cantidad);
float p = Float.valueOf(precio);
float sub = c * p;
ps.setFloat(6, sub);*/

/*
for (int i=0;i<tablaventa.getRowCount();i++){
PreparedStatement ps = cn.prepareStatement(sql);
ps.setString(1, txtnventa.getText());
ps.setString(2, tablaventa.getValueAt(i, 5).toString());
ps.setString(3, ComboProducto.getSelectedItem().toString());
ps.executeUpdate();
}
*/

//ps.setString(2, txtfecha.getText());

/*int n = ps.executeUpdate();
if (n>0){
JOptionPane.showMessageDialog(null, msj);
}
*/

Potrebbero piacerti anche