Example #1
0
  public List<String> completeCode(String query) {
    List _result = null;
    String var = null;

    ArticlesInTO in = new ArticlesInTO();
    in.setItemCode(query);
    in.setItemName(var);

    try {
      _result = AdminEJBService.getArticles(in);

    } catch (Exception e) {
    }

    List<String> results = new ArrayList<String>();

    Iterator<ArticlesTO> iterator = _result.iterator();

    while (iterator.hasNext()) {
      ArticlesTO articulo = (ArticlesTO) iterator.next();
      results.add(articulo.getItemCode());
    }
    return results;
  }
Example #2
0
  // <editor-fold defaultstate="collapsed" desc="Evento al seleccionar del autocomplete" >
  public void findArticle(SelectEvent event) {
    List articulos = new Vector();
    String var = null;

    // Partir codigo, y quitar el codigo viejo
    newNomArt =
        StringUtils.isBlank(newNomArt)
            ? newNomArt
            : newNomArt.substring(0, newNomArt.lastIndexOf("ยป") - 1);

    ArticlesInTO in = new ArticlesInTO();
    in.setItemCode(newCod);
    in.setItemName(newNomArt);

    if (event.getObject().toString() != var) {
      List _result = null;

      try {
        _result = AdminEJBService.getArticles(in);

      } catch (Exception e) {
        faceMessage(e.getMessage() + " -- " + e.getCause());
        newCod = null;
        newNomArt = null;
      }
      if (_result.isEmpty()) {
        this.newCod = null;
        this.newNomArt = null;

      } else {
        Iterator<ArticlesTO> iterator = _result.iterator();
        while (iterator.hasNext()) {
          ArticlesTO articulo = (ArticlesTO) iterator.next();
          articulos.add(articulo);
        }
        if (articulos.size() == 1) {
          try {
            System.out.println("articulo unico, llenar campos en pantalla");
            ArticlesTO art = (ArticlesTO) articulos.get(0);
            newNomArt = art.getItemName();
            newCod = art.getItemCode();
            newUnidad = art.getBuyUnitMsr();
            newExistencia = art.getOnHand();
            newCostoPromedio = art.getAvgPrice();
            art = AdminEJBService.getArticlesByKey(newCod);
            if (almDest != "-1") {
              List alm = art.getBranchArticles();
              Iterator<BranchArticlesTO> iter = alm.iterator();
              while (iter.hasNext()) {
                BranchArticlesTO branch = (BranchArticlesTO) iter.next();
                if (branch.getWhscode().equals(almDest)) {
                  newExistencia = branch.getOnhand();
                  break;
                }
              }
            }
          } catch (Exception ex) {
            Logger.getLogger(GoodsIssuesBean.class.getName()).log(Level.SEVERE, null, ex);
          }
        } else {

          for (Object artt : articulos) {
            ArticlesTO art = (ArticlesTO) artt;
            if (newNomArt.equals(art.getItemName())) {
              newNomArt = art.getItemName();
              newCod = art.getItemCode();
              newUnidad = art.getBuyUnitMsr();
            }
          } // cierre for
        } // cierre else
      }
    }
  }