Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -------------- Metodo para calcular las comisiones -------------///
- private void actualizarTabla2(String user) {
- try {
- DefaultTableModel model = new DefaultTableModel();
- jtComisiones.setModel(model);
- jtComisiones.setAutoCreateRowSorter(true);
- PreparedStatement ps = null;
- ResultSet rs = null;
- Connection conn;
- conn = MySQLConection.getConnection();
- String sql = "SELECT user, SUM(comision1) FROM pedidosempleado Where sucursal1='Matriz'";
- ps = conn.prepareStatement(sql);
- rs = ps.executeQuery();
- ResultSetMetaData rsm = rs.getMetaData();
- int columnas = rsm.getColumnCount();
- model.addColumn("Nombre");
- model.addColumn("Comision");
- int[] anchos = {20, 20};
- for (int x = 0; x < columnas; x++) {
- jtComisiones.getColumnModel().getColumn(x).setPreferredWidth(anchos[x]);
- }
- while (rs.next()) {
- Object[] filas = new Object[columnas];
- for (int i = 0; i < columnas; i++) {
- filas[i] = rs.getObject(i + 1);
- }
- model.addRow(filas);
- }
- } catch (Exception e) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement