コード例 #1
0
  private void TableProductoMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_TableProductoMouseClicked
    int filaselected = TableProducto.getSelectedRow();
    String codigo = " ", producto = " ", precio = " ", cantidad = " ";
    try {
      if (filaselected == -1) {
        JOptionPane.showMessageDialog(null, "Debe Seleccionar un producto");
      } else {
        TableProducto.getModel();
        //     codigo = TableProducto.getValueAt(filaselected, 0).toString();
        producto = TableProducto.getValueAt(filaselected, 1).toString();
        precio = TableProducto.getValueAt(filaselected, 2).toString();
        cantidad = TableProducto.getValueAt(filaselected, 3).toString();
        codigo = TableProducto.getValueAt(filaselected, 0).toString();
        NombreP.setText(producto);
        PrecioP.setText(precio);
        CantidadP.setText(cantidad);
        cod.setText(codigo);
      }

    } catch (HeadlessException e) {

    }

    // TODO add your handling code here:
  } // GEN-LAST:event_TableProductoMouseClicked
コード例 #2
0
  private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed

    boolean Tipo = false;
    if (Servicio.isSelected() == true) {
      Tipo = true;
    }
    try {
      Statement estatuto = conex.getCn().createStatement();
      estatuto.executeUpdate(
          "UPDATE producto set Producto = '"
              + NombreP.getText()
              + "',"
              + "Precio = '"
              + PrecioP.getText()
              + "',Cantidad = '"
              + CantidadP.getText()
              + "',Servicio = "
              + Tipo
              + ""
              + "  where idProducto = "
              + cod.getText()
              + "");
      JOptionPane.showMessageDialog(
          null,
          NombreP.getText() + " Actualizado Exitosamente",
          "StudentControl 1.2",
          JOptionPane.INFORMATION_MESSAGE);
    } catch (SQLException e) {
      JOptionPane.showMessageDialog(
          null,
          "No se Registro el Producto: " + e.getMessage(),
          "StudentControl 1.2",
          JOptionPane.INFORMATION_MESSAGE);
    }
    producto();
    // TODO add your handling code here:
  } // GEN-LAST:event_jButton3ActionPerformed
コード例 #3
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    CantidadP = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    TableProducto = new javax.swing.JTable();
    jLabel1 = new javax.swing.JLabel();
    NombreP = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    btnGuardar = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    PrecioP = new javax.swing.JTextField();
    jLabel3 = new javax.swing.JLabel();
    Servicio = new javax.swing.JCheckBox();
    jButton1 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    cod = new javax.swing.JLabel();

    setTitle("Ingreso de Productos");

    jPanel1.setBorder(
        new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
    jPanel1.setOpaque(false);
    jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
    jPanel1.add(CantidadP, new org.netbeans.lib.awtextra.AbsoluteConstraints(172, 85, 202, 28));

    TableProducto.setModel(
        new javax.swing.table.DefaultTableModel(
            new Object[][] {
              {null, null, null, null},
              {null, null, null, null},
              {null, null, null, null},
              {null, null, null, null}
            },
            new String[] {"Title 1", "Title 2", "Title 3", "Title 4"}));
    TableProducto.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            TableProductoMouseClicked(evt);
          }
        });
    jScrollPane1.setViewportView(TableProducto);

    jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(13, 140, 361, 208));

    jLabel1.setForeground(new java.awt.Color(255, 255, 255));
    jLabel1.setText("Producto:");
    jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(13, 14, 155, 31));

    NombreP.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyReleased(java.awt.event.KeyEvent evt) {
            NombrePKeyReleased(evt);
          }
        });
    jPanel1.add(NombreP, new org.netbeans.lib.awtextra.AbsoluteConstraints(172, 14, 202, 31));

    jLabel2.setForeground(new java.awt.Color(255, 255, 255));
    jLabel2.setText("Precio:");
    jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(13, 51, 155, 28));

    btnGuardar.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Recursos/guardar.png"))); // NOI18N
    btnGuardar.setText("Guardar");
    btnGuardar.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnGuardarActionPerformed(evt);
          }
        });
    jPanel1.add(btnGuardar, new org.netbeans.lib.awtextra.AbsoluteConstraints(13, 354, -1, 61));

    jButton2.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Recursos/delete.png"))); // NOI18N
    jButton2.setText("Salir");
    jButton2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
          }
        });
    jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(293, 354, -1, 61));
    jPanel1.add(PrecioP, new org.netbeans.lib.awtextra.AbsoluteConstraints(172, 51, 202, 28));

    jLabel3.setForeground(new java.awt.Color(255, 255, 255));
    jLabel3.setText("Cantidad:");
    jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(13, 85, 155, 28));

    Servicio.setText("Es Servicio?");
    Servicio.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            ServicioActionPerformed(evt);
          }
        });
    jPanel1.add(Servicio, new org.netbeans.lib.awtextra.AbsoluteConstraints(13, 115, -1, -1));

    jButton1.setText("jButton1");
    jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(156, 140, -1, -1));

    jButton3.setText("Actualizar");
    jButton3.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
          }
        });
    jPanel1.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(143, 360, 90, 50));

    cod.setText("codigo");
    cod.setEnabled(false);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
                    .addContainerGap())
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout
                    .createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cod)
                    .addGap(105, 105, 105)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jPanel1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addComponent(cod)
                    .addContainerGap()));

    pack();
  } // </editor-fold>//GEN-END:initComponents
コード例 #4
0
 private void NombrePKeyReleased(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_NombrePKeyReleased
   NombreP.setText(NombreP.getText().toUpperCase()); // TODO add your handling code here:
 } // GEN-LAST:event_NombrePKeyReleased
コード例 #5
0
 private void btnGuardarActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnGuardarActionPerformed
   boolean Tipo = false;
   if (Servicio.isSelected() == true) {
     Tipo = true;
   }
   if (("".equals(NombreP.getText()))
       || ("".equals(PrecioP.getText()))
       || ("".equals(CantidadP.getText()))) {
     JOptionPane.showMessageDialog(
         null,
         "No ha ingresado ningun Producto",
         "StudentControl 1.2",
         JOptionPane.INFORMATION_MESSAGE);
   } else {
     if (isNumeric(PrecioP.getText()) == true) {
       if (isNumeric(CantidadP.getText()) == true) {
         if (conex.Bitacora(Usuario, "Nuevo Producto: " + NombreP) == true) {
           try {
             Statement estatuto = conex.getCn().createStatement();
             estatuto.executeUpdate(
                 "INSERT INTO producto"
                     + "(Producto, Precio, Cantidad, Servicio)"
                     + "values('"
                     + NombreP.getText()
                     + "','"
                     + PrecioP.getText()
                     + "','"
                     + CantidadP.getText()
                     + "', "
                     + Tipo
                     + ")");
             JOptionPane.showMessageDialog(
                 null,
                 NombreP.getText() + " Agregado Exitosamente",
                 "StudentControl 1.2",
                 JOptionPane.INFORMATION_MESSAGE);
           } catch (SQLException e) {
             JOptionPane.showMessageDialog(
                 null,
                 "No se Registro el Producto: " + e.getMessage(),
                 "StudentControl 1.2",
                 JOptionPane.INFORMATION_MESSAGE);
           }
           NombreP.setText("");
           PrecioP.setText("");
           CantidadP.setText("");
           producto();
         }
       } else {
         JOptionPane.showMessageDialog(
             null,
             "Debe Ingresar una Cantidad Valida del Producto",
             "StudentControl 1.2",
             JOptionPane.INFORMATION_MESSAGE);
       }
     } else {
       JOptionPane.showMessageDialog(
           null,
           "Debe Ingresar un Valor Valido para el Precio",
           "StudentControl 1.2",
           JOptionPane.INFORMATION_MESSAGE);
     }
   }
   // TODO add your handling code here:
 } // GEN-LAST:event_btnGuardarActionPerformed