Example #1
0
  private void jbtAgreagarActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jbtAgreagarActionPerformed
    try {
      rs =
          con.Listar(
              "Id_Categoria",
              "categoria_mdo",
              "where Nombre_Categoria='" + jtfCategoria.getText() + "'");
      while (rs.next()) {
        this.id = rs.getString("Id_Categoria");
      }

      if (con.Altas(
          "mano_de_obra",
          "",
          "('"
              + jtfCodigo.getText()
              + "','"
              + id
              + "','"
              + jtfPrecio.getText()
              + "', '"
              + jtfItem.getText()
              + "','"
              + jtfDetalles.getText()
              + "', '"
              + jtfMinutos.getText()
              + "')")) {
        JOptionPane.showMessageDialog(
            rootPane, "Se ha registrado la mano de obra", "Éxito", JOptionPane.INFORMATION_MESSAGE);
        this.dispose();
      } else {
        JOptionPane.showMessageDialog(
            rootPane,
            "No se ha podido registrar la mano de obra",
            "Error",
            JOptionPane.ERROR_MESSAGE);
      }
    } catch (SQLException ex) {
      Logger.getLogger(JDNMDO.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jbtAgreagarActionPerformed
Example #2
0
  private void jbtAgregarActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jbtAgregarActionPerformed
    try {
      rs =
          con.Listar(
              "Id_proveedor", "proveedor", "where Nom_proveedor='" + jtfProveedor.getText() + "'");
      while (rs.next()) {
        this.prov = rs.getString("Id_proveedor");
      }

      if (prov.equalsIgnoreCase("")) {
        JOptionPane.showMessageDialog(
            rootPane, "No existe tal proveedor", "Error", JOptionPane.ERROR_MESSAGE);
        jtfProveedor.requestFocus();
      }

      rs =
          con.Listar(
              "Id_categoria_Insumo",
              "categoria_insumo",
              "where Nombre_categoria='" + jcbCategoria.getSelectedItem() + "'");
      while (rs.next()) {
        this.id = rs.getString("Id_categoria_Insumo");
      }

      if (id.equalsIgnoreCase("")) {
        JOptionPane.showMessageDialog(
            rootPane, "No existe tal insumo", "Error", JOptionPane.ERROR_MESSAGE);
        jcbCategoria.requestFocus();
      }

      if (con.Altas(
          "insumos",
          "",
          "('"
              + jtfCodigo.getText()
              + "','"
              + prov
              + "','"
              + id
              + "','"
              + jtfNombre.getText()
              + "','"
              + jtfDescripcion.getText()
              + "','"
              + jtfCantidad.getText()
              + "','"
              + jtfPago.getText()
              + "','"
              + jtfPrecio.getText()
              + "')")) {
        JOptionPane.showMessageDialog(
            rootPane, "Se ha registrado el insumo", "Éxito", JOptionPane.INFORMATION_MESSAGE);
        this.dispose();
      } else {
        JOptionPane.showMessageDialog(
            rootPane, "No se ha podido registrar el insumo", "Error", JOptionPane.ERROR_MESSAGE);
      }
      // Traer id proveedor e id categoria
    } catch (SQLException ex) {
      Logger.getLogger(JDNInsumo.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jbtAgregarActionPerformed