Beruflich Dokumente
Kultur Dokumente
Gracias
a todos.
import java.awt.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import java.sql.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.ListSelectionEvent;
public sqlbase1()
{
modelo.addColumn("Cod");
modelo.addColumn("Cant");
modelo.addColumn("Detalle");
modelo.addColumn("V/u");
modelo.addColumn("Subt");
modelo.addColumn("iva(16%)");
modelo.addColumn("Total");
this.tbproductos.setModel(modelo);
JScrollPane1.setViewportView(tbproductos);
bconsultar.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
bconsultarActionPerformed(evt);
}
});;
baceptar.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
baceptarActionPerformed(evt);
}
});;
/* JMenuItem1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
JMenuItem1ActionPerformed(evt);
}
});;
beliminartodos.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
beliminartodosActionPerformed(evt);
}
});;*/
bgrabar.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
bgrabarActionPerformed(evt);
}
});;
tbproductos.setComponentPopupMenu(JPopupMenu1);
JScrollPane1.setViewportView(tbproductos);
} // de contructor
//************ ************ ************
if(rs.next())
{
txtproducto.setText(rs.getString(2));
txtvunitario.setText(rs.getString(3));
}
else
{
labelresultado.setText("No existe un registro con dicho codigo");
}
//conexion.close();
}//de try
catch(SQLException ex)
{
Logger.getLogger(sqlbase1.class.getName()).log(Level.SEVERE,null,ex);
}
}
txtsubtotal.setText(String.valueOf(subt)); //t1.setText(String.valueOf(res));
txtiva.setText(String.valueOf(iva));
txttotal.setText(String.valueOf(total));
datos[0] = txtcodigo.getText();
txtcodigo.setText(null);
datos[1] = txtcantidad.getText();
txtcantidad.setText(null);
datos[2] = txtproducto.getText();
txtproducto.setText(null);
datos[3] = txtvunitario.getText();
txtvunitario.setText(null);
datos[4] = txtsubtotal.getText();
txtsubtotal.setText(null);
datos[5] = txtiva.getText();
txtiva.setText(null);
datos[6] = txttotal.getText();
txttotal.setText(null);
modelo.addRow(datos);
//*** *** ***
txtgrantotal.setText(String.valueOf(gtotal));
}
}
}
hacercalculos(i);
enviardatos();
} //de for
totalventas();
txtcodigo.setText("");
txtcantidad.setText("");
txttotal.setText("");
txtgrantotal.setText("");
}
//****** ***** *****
txtcantidad.setText(String.valueOf(gcant));
txttotal.setText(String.valueOf(gtotal));
}
ps.executeUpdate();
//conexion.close();
}//de try
catch(Exception e)
{
System.out.print(e.getMessage());
}
}
if(rs.next())
{
txttotalventas.setText(rs.getString(2));
}
//conexion.close();
}//de try
catch(SQLException ex)
{
Logger.getLogger(sqlbase1.class.getName()).log(Level.SEVERE,null,ex);
}
//*** ***
String cad1 = txtgrantotal.getText();
String cad2 = txttotalventas.getText();
double gtotal = Double.parseDouble(cad1);
double totalv = Double.parseDouble(cad2);
totalv = (gtotal + totalv);
txttotalventas.setText(String.valueOf(totalv));
try
{
String sql = " Update totalventas set totalv = ?";
Connection conexion = conn2.getConnction();
PreparedStatement ps = conexion.prepareStatement(sql);
ps.setString(1,txttotalventas.getText());
ps.executeUpdate();
//conexion.close();
}
catch(Exception e)
{
System.out.print(e.getMessage());
}
labelresultado.setText("se grabaron los datos");
} //de void totalventas
}//de clase principal