Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------- haciendo la consulta-------------------//
- private void Consulta() {
- try {
- //----variables del metodo----//
- SimpleDateFormat dFormato = new SimpleDateFormat("yyyy-MM-dd");
- String intervaloInicio = dFormato.format(jDCInicial.getDate());
- String intervaloFinal = dFormato.format(jDCFechaFinal.getDate());
- int fila = jTEmpleados.getSelectedRow();
- String numEmpleado = jTEmpleados.getValueAt(fila, 0).toString();
- //----terminan variables ----//
- DefaultTableModel model = new DefaultTableModel();
- jTRerporte.setModel(model);
- PreparedStatement ps = null;
- ResultSet rs = null;
- Connection conn = MySQLConection.getConnection();
- String SQL = "SELECT empleados.numEmpleado, empleados.user, empleados.puntoDeVenta, "
- + "count(pedidosempleado.idPedidoEmpleado) As conteo, "
- + "sum(pedidosempleado.tiempoTotal) AS tiempo, "
- + "sum(pedidosempleado.comision1)AS comision, "
- + "empleados.comision from empleados inner join pedidosempleado on empleados.numEmpleado=pedidosempleado.numeroEmpleado"
- + " where pedidosempleado.fechaFin between '" + intervaloInicio + "' AND '" + intervaloFinal + "' and empleados.numEmpleado='" + numEmpleado + "'";
- ps = conn.prepareStatement(SQL);
- rs = ps.executeQuery();
- ResultSetMetaData rsm = rs.getMetaData();
- int columnas = rsm.getColumnCount();
- model.addColumn("idEmpleado");
- model.addColumn("Usuario");
- model.addColumn("Sucursal");
- model.addColumn("Trabajos Realizados");
- model.addColumn("Tiempo Trabajado");
- model.addColumn("Comisiones");
- model.addColumn("Comision");
- int[] anchos = {2, 10, 20, 5, 10, 10, 10};
- for (int x = 0; x < columnas; x++) {
- jTRerporte.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