List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java
private void btnWallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWallActionPerformed Boolean isSave = false;/*from w w w. j a v a 2s. c o m*/ String staff = ""; String pass = "NO"; String checker = ""; if (this.currentEntry != null) { if (AppHelper.CheckTwoDigit(this.txtWallBase.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleBung.getText()) && AppHelper.CheckTwoDigit(this.txtWallClosure.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleLeft.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleRight.getText()) && AppHelper.CheckTwoDigit(this.txtWallUnderHandle.getText())) { if (recordValidationService.Validate(currentEntry, RecordKey.WALL_BASE, Float.parseFloat(this.txtWallBase.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_CLOSURE, Float.parseFloat(this.txtWallClosure.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_BUNG, Float.parseFloat(this.txtWallHandleBung.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_LEFT, Float.parseFloat(this.txtWallHandleLeft.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_RIGHT, Float.parseFloat(this.txtWallHandleRight.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_UNDER_HANDLE, Float.parseFloat(this.txtWallUnderHandle.getText()))) { isSave = true; } else { checker = JOptionPane.showInputDialog(this, "the value is not within the range, please entry technician name.", "Warning", JOptionPane.OK_OPTION); if (!checker.equals("")) { isSave = true; } } staff = this.txtWallStaff.getText(); this.txtWallStaff.setText(""); } else { JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning", JOptionPane.OK_OPTION); } if (isSave) { DefaultTableModel model = (DefaultTableModel) this.tblWall.getModel(); Date now = new Date(); String time = new SimpleDateFormat("HH:mm").format(now); Float valueUnderHandle = Float.parseFloat(this.txtWallUnderHandle.getText()); Float valueBase = Float.parseFloat(this.txtWallBase.getText()); Float valueClosure = Float.parseFloat(this.txtWallClosure.getText()); Float valueHandleBung = Float.parseFloat(this.txtWallHandleBung.getText()); Float valueHandleLeft = Float.parseFloat(this.txtWallHandleLeft.getText()); Float valueHandleRight = Float.parseFloat(this.txtWallHandleRight.getText()); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_UNDER_HANDLE, Float.parseFloat(this.txtWallUnderHandle.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_UNDER_HANDLE, valueUnderHandle, pass, staff }); UpdateEntryData(now, valueUnderHandle, RecordKey.WALL_UNDER_HANDLE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_BASE, Float.parseFloat(this.txtWallBase.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_BASE, valueBase, "YES", staff }); UpdateEntryData(now, valueBase, RecordKey.WALL_BASE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_CLOSURE, Float.parseFloat(this.txtWallClosure.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_CLOSURE, valueClosure, pass, staff }); UpdateEntryData(now, valueClosure, RecordKey.WALL_CLOSURE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_BUNG, Float.parseFloat(this.txtWallHandleBung.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_BUNG, valueHandleBung, pass, staff }); UpdateEntryData(now, valueHandleBung, RecordKey.WALL_HANDLE_BUNG, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_LEFT, Float.parseFloat(this.txtWallHandleLeft.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_LEFT, valueHandleLeft, pass, staff }); UpdateEntryData(now, valueHandleLeft, RecordKey.WALL_HANDLE_LEFT, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_RIGHT, Float.parseFloat(this.txtWallHandleRight.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_RIGHT, valueHandleRight, pass, staff }); UpdateEntryData(now, valueHandleRight, RecordKey.WALL_HANDLE_RIGHT, staff, pass, ""); ((AbstractTableModel) this.tblWall.getModel()).fireTableDataChanged(); this.txtWallUnderHandle.setText(""); this.txtWallBase.setText(""); this.txtWallClosure.setText(""); this.txtWallHandleBung.setText(""); this.txtWallHandleLeft.setText(""); this.txtWallHandleRight.setText(""); } } }
From source file:interfazGrafica.loginInterface.java
private void vehiculosDispCrearCotItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_vehiculosDispCrearCotItemStateChanged // TODO add your handling code here: panelConsultas.removeAll();/*from w w w . ja va 2 s. c o m*/ panelContenedor.setVisible(true); String consultaSQL = "SELECT id_vehiculo, marca_vehiculo, modelo_vehiculo, color_vehiculo, " + "nuevo_vehiculo, valor_vehiculo, id_sede FROM vehiculos WHERE marca_vehiculo = '" + (String) vehiculosDispCrearCot.getSelectedItem() + "' AND cantidad_disponible_vehiculo = 1;"; ResultSet tabla = new OperacionesBD().consultas(consultaSQL); DefaultTableModel dtm = new DefaultTableModel(0, 0); try { int count = 0; while (tabla.next()) { count++; } String[][] data = new String[count][7]; int i = 0; tabla = new OperacionesBD().consultas(consultaSQL); while (tabla.next()) { data[i][0] = "" + tabla.getInt("id_vehiculo"); data[i][1] = tabla.getString("marca_vehiculo"); data[i][2] = tabla.getString("modelo_vehiculo"); data[i][3] = tabla.getString("color_vehiculo"); data[i][4] = tabla.getString("nuevo_vehiculo"); data[i][5] = tabla.getString("valor_vehiculo"); data[i][6] = tabla.getString("id_sede"); i++; } String[] nombreColumnas = { "Codigo", "Marca", "Modelo", "Color", "Nuevo", "Valor", "Sede" }; dtm.setColumnIdentifiers(nombreColumnas); tableCrearCot.setModel(dtm); for (int j = 0; j < count; j++) { dtm.addRow(data[j]); } } catch (SQLException exc) { JOptionPane.showMessageDialog(null, "Error al acceder a la base de datos"); exc.printStackTrace(); } }
From source file:interfazGrafica.loginInterface.java
private void vehiculosDispVenderItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_vehiculosDispVenderItemStateChanged // TODO add your handling code here: panelConsultas.removeAll();//from w w w . j av a2 s . c o m panelContenedor.setVisible(true); String consultaSQL = "SELECT id_vehiculo, marca_vehiculo, modelo_vehiculo, color_vehiculo, " + "nuevo_vehiculo, valor_vehiculo, id_sede FROM vehiculos WHERE marca_vehiculo = '" + (String) vehiculosDispVender.getSelectedItem() + "' AND cantidad_disponible_vehiculo = 1;"; ResultSet tabla = new OperacionesBD().consultas(consultaSQL); DefaultTableModel dtm = new DefaultTableModel(0, 0); try { int count = 0; while (tabla.next()) { count++; } String[][] data = new String[count][7]; int i = 0; tabla = new OperacionesBD().consultas(consultaSQL); while (tabla.next()) { data[i][0] = "" + tabla.getInt("id_vehiculo"); data[i][1] = tabla.getString("marca_vehiculo"); data[i][2] = tabla.getString("modelo_vehiculo"); data[i][3] = tabla.getString("color_vehiculo"); data[i][4] = tabla.getString("nuevo_vehiculo"); data[i][5] = tabla.getString("valor_vehiculo"); data[i][6] = tabla.getString("id_sede"); i++; } String[] nombreColumnas = { "Codigo", "Marca", "Modelo", "Color", "Nuevo", "Valor", "Sede" }; dtm.setColumnIdentifiers(nombreColumnas); tableCrearCot1.setModel(dtm); for (int j = 0; j < count; j++) { dtm.addRow(data[j]); } } catch (SQLException exc) { JOptionPane.showMessageDialog(null, "Error al acceder a la base de datos"); exc.printStackTrace(); } }
From source file:interfaces.InterfazPrincipal.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: String identificacion = jTextFieldNitProveedores.getText(); String nombre = jTextFieldNombreProveedores.getText(); int identificacionClienteInt = 0; try {/*from ww w .j a v a 2 s . c om*/ ControladorProveedores controladorProveedores = new ControladorProveedores(); ArrayList<Proveedores> listaDeProveedores = controladorProveedores.obtenerProveedores(identificacion, nombre); //Agregar filas DefaultTableModel modelo = (DefaultTableModel) TablaDeProveedores.getModel(); for (int i = 0; i < modelo.getRowCount(); i++) { modelo.removeRow(i); } modelo.setRowCount(0); for (int i = 0; i < listaDeProveedores.size(); i++) { Proveedores proveedor = listaDeProveedores.get(i); Object[] fila = new Object[4]; fila[0] = proveedor.getIdentificacion(); fila[1] = proveedor.getNombre(); //button.setText("<HTML>Click the <FONT color=\"#000099\"><U>link "+i+"</U></FONT>"+ " to go to the Java website.</HTML>"); fila[3] = "Editar"; modelo.addRow(fila); } TablaDeProveedores.setModel(modelo); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Buscar con campos validos", "Error", JOptionPane.ERROR_MESSAGE); } //TablaDeProveedores }
From source file:interfaces.InterfazPrincipal.java
private void BotonBuscarClienteSaldoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonBuscarClienteSaldoActionPerformed String nombreCliente = nombreClienteBusquedaSaldo.getText(); //08-11-2014 listar clientes por nombre ControladorCliente controladorCliente = new ControladorCliente(); ArrayList<Cliente> listaClientes = new ArrayList<>(); if (nombreCliente.equals("")) { listaClientes = controladorCliente.obtenerClientes(); } else {//from w w w . jav a 2 s . c o m listaClientes = controladorCliente.obtenerClientes(nombreCliente, 0); } //08-11-2014 Crear dialogo de bsqueda final JDialog dialogoEditar = new JDialog(this); dialogoEditar.setTitle("Buscar clientes"); dialogoEditar.setSize(300, 300); dialogoEditar.setResizable(false); JPanel panelDialogo = new JPanel(); panelDialogo.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; JLabel ediitarTextoPrincipalDialogo = new JLabel("Buscar cliente"); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.insets = new Insets(10, 60, 10, 10); Font textoGrande = new Font("Arial", 1, 16); ediitarTextoPrincipalDialogo.setFont(textoGrande); panelDialogo.add(ediitarTextoPrincipalDialogo, c); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.insets = new Insets(10, 10, 10, 10); final JTable tablaDialogo = new JTable(); DefaultTableModel modeloTabla = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //all cells false return false; } }; ; modeloTabla.addColumn("Identificacin"); modeloTabla.addColumn("Nombre"); //LLenar tabla for (int i = 0; i < listaClientes.size(); i++) { Object[] data = { "1", "2" }; data[0] = listaClientes.get(i).getCliente_id(); data[1] = listaClientes.get(i).getNombre(); modeloTabla.addRow(data); } tablaDialogo.setModel(modeloTabla); tablaDialogo.getColumn("Identificacin").setMinWidth(110); tablaDialogo.getColumn("Nombre").setMinWidth(110); tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll = new JScrollPane(tablaDialogo); scroll.setPreferredSize(new Dimension(220, 150)); panelDialogo.add(scroll, c); c.insets = new Insets(0, 0, 0, 10); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; JButton botonGuardarClienteDialogo = new JButton("Elegir"); panelDialogo.add(botonGuardarClienteDialogo, c); c.gridx = 1; c.gridy = 2; c.gridwidth = 1; JButton botonCerrarClienteDialogo = new JButton("Cancelar"); panelDialogo.add(botonCerrarClienteDialogo, c); dialogoEditar.add(panelDialogo); dialogoEditar.setVisible(true); botonCerrarClienteDialogo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogoEditar.dispose(); } }); botonGuardarClienteDialogo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = tablaDialogo.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(dialogoEditar, "Por favor seleccione una fila"); } else { Object identificacionCliente = tablaDialogo.getValueAt(row, 0); mostrarIdentificacionCliente.setText(String.valueOf(identificacionCliente)); String nombreClientePago = String.valueOf(tablaDialogo.getValueAt(row, 1)); //Limitar a 15 caracteres if (nombreClientePago.length() >= 15) { nombreClientePago = nombreClientePago.substring(0, 12); } textoPersonaSaldo.setText(nombreClientePago); DefaultTableModel modeloClientes = (DefaultTableModel) TablaDeSaldoClientes.getModel(); for (int i = 0; i < modeloClientes.getRowCount(); i++) { modeloClientes.removeRow(i); } modeloClientes.setRowCount(0); ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura(); //SELECT * FROM Flujo_Factura where factura_id in (select factura_id from Factura where cliente_id = 1130614506); ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura( " where factura_id in (select factura_id from Factura where cliente_id = " + String.valueOf(identificacionCliente) + " and estado=\"fiado\") order by factura_id"); double pago = 0.0; for (int i = 0; i < flujosCliente.size(); i++) { String[] datos = flujosCliente.get(i); TablaDeSaldoClientes.setModel(modeloClientes); NumberFormat formatter = new DecimalFormat("#0"); String valorMovimiento = String.valueOf(formatter.format(Double.parseDouble(datos[4]))); Object[] rowData = { datos[1], datos[2], datos[3], valorMovimiento }; if (datos[2].equals("deuda")) { pago += Double.parseDouble(datos[4]); } else { pago -= Double.parseDouble(datos[4]); } modeloClientes.addRow(rowData); } TablaDeSaldoClientes.setModel(modeloClientes); NumberFormat formatter = new DecimalFormat("#0"); textoTotalDebe.setText(String.valueOf(formatter.format(pago))); dialogoEditar.dispose(); //Mostrar en table de clientes los datos botonRegistrarAbono.setEnabled(true); } } }); }
From source file:interfaces.InterfazPrincipal.java
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed String nombreCliente = nombreClienteReporteCliente.getText(); String identificacion = identificacionClienteCliente.getText(); try {//from w w w .java2 s . c o m //08-11-2014 listar clientes por nombre ControladorCliente controladorCliente = new ControladorCliente(); ArrayList<Cliente> listaClientes = new ArrayList<Cliente>(); if (nombreCliente.equals("") && identificacion.equals("")) { listaClientes = controladorCliente.obtenerClientes(); } else { int identificacionNumerico = 0; if (!identificacion.equals("")) { identificacionNumerico = Integer.parseInt(identificacion); } listaClientes = controladorCliente.obtenerClientes(nombreCliente, identificacionNumerico); } //08-11-2014 Crear dialogo de bsqueda final JDialog dialogoEditar = new JDialog(this); dialogoEditar.setTitle("Buscar clientes"); dialogoEditar.setSize(300, 300); dialogoEditar.setResizable(false); JPanel panelDialogo = new JPanel(); panelDialogo.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; JLabel ediitarTextoPrincipalDialogo = new JLabel("Buscar cliente"); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.insets = new Insets(10, 60, 10, 10); Font textoGrande = new Font("Arial", 1, 16); ediitarTextoPrincipalDialogo.setFont(textoGrande); panelDialogo.add(ediitarTextoPrincipalDialogo, c); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.insets = new Insets(10, 10, 10, 10); final JTable tablaDialogo = new JTable(); DefaultTableModel modeloTabla = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //all cells false return false; } }; ; modeloTabla.addColumn("Identificacin"); modeloTabla.addColumn("Nombre"); //LLenar tabla for (int i = 0; i < listaClientes.size(); i++) { Object[] data = { "1", "2" }; data[0] = listaClientes.get(i).getCliente_id(); data[1] = listaClientes.get(i).getNombre(); modeloTabla.addRow(data); } tablaDialogo.setModel(modeloTabla); tablaDialogo.getColumn("Identificacin").setMinWidth(110); tablaDialogo.getColumn("Nombre").setMinWidth(110); tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll = new JScrollPane(tablaDialogo); scroll.setPreferredSize(new Dimension(220, 150)); panelDialogo.add(scroll, c); c.insets = new Insets(0, 0, 0, 10); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; JButton botonGuardarClienteDialogo = new JButton("Elegir"); panelDialogo.add(botonGuardarClienteDialogo, c); c.gridx = 1; c.gridy = 2; c.gridwidth = 1; JButton botonCerrarClienteDialogo = new JButton("Cancelar"); panelDialogo.add(botonCerrarClienteDialogo, c); dialogoEditar.add(panelDialogo); dialogoEditar.setVisible(true); botonCerrarClienteDialogo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogoEditar.dispose(); } }); botonGuardarClienteDialogo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = tablaDialogo.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(dialogoEditar, "Por favor seleccione una fila"); } else { Object identificacionCliente = tablaDialogo.getValueAt(row, 0); jTextFieldIdentificacionClienteReporte.setText(String.valueOf(identificacionCliente)); botonGenerarReporteCliente.setEnabled(true); dialogoEditar.dispose(); } } }); // TODO add your handling code here: } catch (Exception e) { JOptionPane.showMessageDialog(this, "El valor de la identificacin de ser numrico"); } }
From source file:interfaces.InterfazPrincipal.java
public void generarTablaUsuarios() { //tablaUsuariosDelSistema ControladorUsuarios controladorUsuarios = new ControladorUsuarios(); ArrayList<Usuarios> listaUsuarios = controladorUsuarios.obtenerTodosUsuarios(); DefaultTableModel modeloTabla = (DefaultTableModel) tablaUsuariosDelSistema.getModel(); for (int i = 0; i < modeloTabla.getRowCount(); i++) { modeloTabla.removeRow(i);/*from www. ja va 2 s.co m*/ } modeloTabla.setRowCount(0); for (int i = 0; i < listaUsuarios.size(); i++) { Usuarios usuarioActual = listaUsuarios.get(i); Object[] rowData = new Object[3]; rowData[0] = usuarioActual.getLogin(); rowData[1] = usuarioActual.getCreation_data(); char habilitado = usuarioActual.getStatus(); if (habilitado == 'e') { rowData[2] = "Habilitado"; } else { rowData[2] = "Inhablitado"; } modeloTabla.addRow(rowData); } tablaUsuariosDelSistema.setModel(modeloTabla); }
From source file:interfaces.InterfazPrincipal.java
private void BotonBuscarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonBuscarClienteActionPerformed // TODO add your handling code here: String nombreCliente = nombreClienteBusqueda.getText(); String identificacionCliente = identificacionClienteBusqueda.getText(); int identificacionClienteInt = 0; try {/* w w w. ja va 2s. co m*/ if (!identificacionCliente.equals("")) { identificacionClienteInt = Integer.parseInt(identificacionCliente); } ControladorCliente controladorCliente = new ControladorCliente(); ArrayList<Cliente> listaDeClientes = controladorCliente.obtenerClientes(nombreCliente, identificacionClienteInt); //Agregar filas DefaultTableModel modelo = (DefaultTableModel) TablaDeClientes.getModel(); for (int i = 0; i < modelo.getRowCount(); i++) { modelo.removeRow(i); } modelo.setRowCount(0); for (int i = 0; i < listaDeClientes.size(); i++) { Cliente cliente = listaDeClientes.get(i); Object[] fila = new Object[4]; fila[0] = cliente.getCliente_id(); fila[1] = cliente.getNombre(); Double montoAPrestar = cliente.getMonto_prestamo(); NumberFormat formatter = new DecimalFormat("#0"); fila[2] = formatter.format(montoAPrestar); fila[3] = "Editar"; modelo.addRow(fila); } TablaDeClientes.setModel(modelo); } catch (Exception e) { JOptionPane.showMessageDialog(this, "La identificacin debe ser numrica, por favor ingrese correctamente el dato", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:com.cch.aj.entryrecorder.frame.SettingsJFrame.java
private void UpdateProductUI(Product currentProduct) { txtProductCode.setText(currentProduct.getCode() == null || currentProduct.getCode() == "- Select -" ? "" : currentProduct.getCode().toString()); ;/*w ww. ja v a 2s.c o m*/ txtProductDesc .setText(currentProduct.getDescription() == null ? "" : currentProduct.getDescription().toString()); ; txtProductPerc1.setText(currentProduct.getAdditiveAPercentage() == null ? "" : currentProduct.getAdditiveAPercentage().toString()); ; txtProductPerc2.setText(currentProduct.getAdditiveBPercentage() == null ? "" : currentProduct.getAdditiveBPercentage().toString()); ; txtProductPerc3.setText(currentProduct.getAdditiveCPercentage() == null ? "" : currentProduct.getAdditiveCPercentage().toString()); txtProductWeightMax .setText(currentProduct.getWeightMax() == null ? "" : currentProduct.getWeightMax().toString()); txtProductWeightMin .setText(currentProduct.getWeightMin() == null ? "" : currentProduct.getWeightMin().toString()); //combobox this.FillMouldComboBox(this.cbProductMould, currentProduct.getMouldId() != null ? currentProduct.getMouldId().getId() : 0); this.FillPolymerComboBox(this.cbProductPolymer, currentProduct.getPolymerId() != null ? currentProduct.getPolymerId().getId() : 0); this.FillAdditiveComboBox(this.cbProductAdditive1, currentProduct.getAdditiveAId() != null ? currentProduct.getAdditiveAId().getId() : 0); this.FillAdditiveComboBox(this.cbProductAdditive2, currentProduct.getAdditiveBId() != null ? currentProduct.getAdditiveBId().getId() : 0); this.FillAdditiveComboBox(this.cbProductAdditive3, currentProduct.getAdditiveCId() != null ? currentProduct.getAdditiveCId().getId() : 0); FillEmbossingComboBox(this.cbProductInsert, currentProduct.getInsertId() != null ? currentProduct.getInsertId().getId() : 0, "INSERT"); FillEmbossingComboBox(this.cbProductEmbossing, currentProduct.getEmbossingId() != null ? currentProduct.getEmbossingId().getId() : 0, "EMBOSSING"); List<String> threadBoresA = new ArrayList<String>(); threadBoresA.add("- Select -"); if (settingMould.getThreadBoreASize1() != null && !settingMould.getThreadBoreASize1().equals("")) { threadBoresA.add(settingMould.getThreadBoreASize1()); } if (settingMould.getThreadBoreASize2() != null && !settingMould.getThreadBoreASize2().equals("")) { threadBoresA.add(settingMould.getThreadBoreASize2()); } if (settingMould.getThreadBoreASize3() != null && !settingMould.getThreadBoreASize3().equals("")) { threadBoresA.add(settingMould.getThreadBoreASize3()); } this.cbProductBoreA.setModel(new DefaultComboBoxModel(threadBoresA.toArray())); this.cbProductBoreA1.setModel(new DefaultComboBoxModel(threadBoresA.toArray())); List<String> threadBoresB = new ArrayList<String>(); threadBoresB.add("- Select -"); if (settingMould.getThreadBoreBSize1() != null && !settingMould.getThreadBoreBSize1().equals("")) { threadBoresB.add(settingMould.getThreadBoreBSize1()); } if (settingMould.getThreadBoreBSize2() != null && !settingMould.getThreadBoreBSize2().equals("")) { threadBoresB.add(settingMould.getThreadBoreBSize2()); } if (settingMould.getThreadBoreBSize3() != null && !settingMould.getThreadBoreBSize3().equals("")) { threadBoresB.add(settingMould.getThreadBoreBSize3()); } this.cbProductBoreB.setModel(new DefaultComboBoxModel(threadBoresB.toArray())); this.cbProductBoreB1.setModel(new DefaultComboBoxModel(threadBoresB.toArray())); List<String> threadNecks = new ArrayList<String>(); threadNecks.add("- Select -"); if (settingMould.getThreadNeckSize1() != null && !settingMould.getThreadNeckSize1().equals("")) { threadNecks.add(settingMould.getThreadNeckSize1()); } if (settingMould.getThreadNeckSize2() != null && !settingMould.getThreadNeckSize2().equals("")) { threadNecks.add(settingMould.getThreadNeckSize2()); } if (settingMould.getThreadNeckSize3() != null && !settingMould.getThreadNeckSize3().equals("")) { threadNecks.add(settingMould.getThreadNeckSize3()); } this.cbProductNeck.setModel(new DefaultComboBoxModel(threadNecks.toArray())); this.cbProductNeck1.setModel(new DefaultComboBoxModel(threadNecks.toArray())); if (currentProduct.getBung() != null && !currentProduct.getBung().equals("")) { this.cbProductBung.setSelectedItem(currentProduct.getBung().toString()); } if (currentProduct.getPierced() != null && !currentProduct.getPierced().equals("")) { this.cbProductPierced.setSelectedItem(currentProduct.getPierced().toString()); } if (currentProduct.getViewLine() != null && !currentProduct.getViewLine().equals("")) { this.cbProductViewLine.setSelectedItem(currentProduct.getViewLine().toString()); } if (currentProduct.getDgnondg() != null) { this.cbProductDg.setSelectedIndex(currentProduct.getDgnondg()); } if (currentProduct.getThreadBoreA() != null) { this.cbProductBoreA.setSelectedIndex(currentProduct.getThreadBoreA()); } if (currentProduct.getThreadBoreB() != null) { this.cbProductBoreB.setSelectedIndex(currentProduct.getThreadBoreB()); } if (currentProduct.getThreadNeck() != null) { this.cbProductNeck.setSelectedIndex(currentProduct.getThreadNeck()); } if (currentProduct.getThreadBoreA1() != null) { this.cbProductBoreA1.setSelectedIndex(currentProduct.getThreadBoreA1()); } if (currentProduct.getThreadBoreB1() != null) { this.cbProductBoreB1.setSelectedIndex(currentProduct.getThreadBoreB1()); } if (currentProduct.getThreadNeck1() != null) { this.cbProductNeck1.setSelectedIndex(currentProduct.getThreadNeck1()); } if (currentProduct.getClosureType() != null) { this.cbProductClosureType.setSelectedItem(currentProduct.getClosureType()); } // DefaultTableModel model = (DefaultTableModel) this.tblCheck.getModel(); model.setRowCount(0); model.fireTableDataChanged(); List<Checkitem> checks = this.checkitemService.GetAllEntities(); List<Checkitem> list = new ArrayList<Checkitem>(); for (Checkitem ci : checks) { if (ci.getProductCollection().contains(this.settingProduct)) { list.add(ci); } } if (list != null) { for (Checkitem item : list) { model.addRow(new Object[] { item.getId(), item.getDescription() }); } } this.txtCheckDesc.setText(""); // if (this.settingProduct.getWeightMin() == null && this.settingProduct.getWeightMax() == null) { this.txtProductWeightMin.setText( this.settingMould.getWeightDgMin() != null ? this.settingMould.getWeightDgMin().toString() : ""); this.txtProductWeightMax.setText( this.settingMould.getWeightDgMax() != null ? this.settingMould.getWeightDgMax().toString() : ""); } else { this.txtProductWeightMin.setText( this.settingProduct.getWeightMin() != null ? this.settingProduct.getWeightMin().toString() : ""); this.txtProductWeightMax.setText( this.settingProduct.getWeightMax() != null ? this.settingProduct.getWeightMax().toString() : ""); } if (currentProduct.getProductImage() != null) { this.labDrawingImage1.setText(currentProduct.getProductImage().toString()); AppHelper.DisplayImage(currentProduct.getProductImage().toString(), this.pnlDrawingImage1); } else { this.labDrawingImage1.setText("Image File Path"); this.pnlDrawingImage1.removeAll(); } if (currentProduct.getClosureType() != null && currentProduct.getClosureType().equals("TWIN")) { this.cbProductBoreA1.setVisible(true); this.cbProductBoreB1.setVisible(true); this.cbProductNeck1.setVisible(true); } else { this.cbProductBoreA1.setVisible(false); this.cbProductBoreB1.setVisible(false); this.cbProductNeck1.setVisible(false); } }
From source file:interfaces.InterfazPrincipal.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String nombre = jTextField_Producto_Con_Nombre.getText(); String descripcion = jTextField_Producto_Con_Descripcion.getText(); String unidades_string = jTextField_Producto_Con_Unidades.getText(); String precio_string = jTextField4.getText(); int unidades = 0; double precio = 0; try {//from w w w. j av a2s . c om if (!unidades_string.equals("")) { unidades = Integer.parseInt(unidades_string); } if (!precio_string.equals("")) { precio = Double.parseDouble(precio_string); } ControladorProducto controladorPro = new ControladorProducto(); String restriccion = ""; boolean encounter = true; if (!nombre.equals("")) { if (encounter) { encounter = false; restriccion = " where "; } else { restriccion += " OR "; } restriccion += " nombre like '%" + nombre + "%'"; } if (!descripcion.equals("")) { if (encounter) { encounter = false; restriccion = " where "; } else { restriccion += " OR "; } restriccion += " descripcion like '%" + descripcion + "%'"; } if (!unidades_string.equals("")) { if (encounter) { encounter = false; restriccion = " where "; } else { restriccion += " OR "; } restriccion += " unidades =" + unidades; } if (!precio_string.equals("")) { if (encounter) { encounter = false; restriccion = " where "; } else { restriccion += " OR "; } restriccion += " precio =" + precio; } ArrayList<Productos> listaDeProductos = controladorPro.getProducto(restriccion); //Agregar filas DefaultTableModel modelo = (DefaultTableModel) TablaDeProductos.getModel(); if (modelo.getRowCount() > 0) { for (int i = modelo.getRowCount() - 1; i > -1; i--) { modelo.removeRow(i); } } for (int i = 0; i < listaDeProductos.size(); i++) { Productos producto = listaDeProductos.get(i); Object[] fila = new Object[7]; fila[0] = (i + 1); fila[1] = producto.getProductoId(); fila[2] = producto.getNombre(); fila[3] = producto.getDescripcion(); fila[4] = producto.getUnidadesDisponibles(); fila[5] = producto.getPrecio(); fila[6] = producto.getCodigoBarras(); modelo.addRow(fila); } TablaDeProductos.setModel(modelo); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error al consultar los productos\nInformacin tcnica\n" + e.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }