Пример #1
0
 /** Create new Account and Charge */
 private void createNew() {
   log.info("");
   //  Get Input
   String value = valueField.getText();
   if (value.length() == 0) {
     valueField.setBackground(AdempierePLAF.getFieldBackground_Error());
     return;
   }
   String name = nameField.getText();
   if (name.length() == 0) {
     nameField.setBackground(AdempierePLAF.getFieldBackground_Error());
     return;
   }
   //  Create Element
   int C_ElementValue_ID = createElementValue(value, name, isExpense.isSelected());
   if (C_ElementValue_ID == 0) {
     ADialog.error(m_WindowNo, panel, "ChargeNotCreated", name);
     return;
   }
   //  Create Charge
   int C_Charge_ID = createCharge(name, C_ElementValue_ID);
   if (C_Charge_ID == 0) {
     ADialog.error(m_WindowNo, panel, "ChargeNotCreated", name);
     return;
   }
   ADialog.info(m_WindowNo, panel, "ChargeCreated", name);
 } //  createNew
Пример #2
0
  @Override
  protected void afterAction() {

    super.afterAction();

    if (isIgnoreChange()) {

      SwingTool.setCursorsFromParent(window, false);
      return;
    }

    if (successful()) {

      ADialog.info(
          Env.getWindowNo(getWindow()),
          getWindow(),
          Msg.translate(Env.getCtx(), "Success"),
          getSuccessMsg());
    } else {

      ADialog.error(
          Env.getWindowNo(getWindow()),
          getWindow(),
          Msg.translate(Env.getCtx(), "Error"),
          getErrorMsg());
    }

    SwingTool.setCursorsFromParent(window, false);
  }
Пример #3
0
  /** Create Charges from Accounts */
  private void createAccount() {
    createAccount(dataTable);

    if (listCreated.length() > 0)
      ADialog.info(m_WindowNo, panel, "ChargeCreated", listCreated.toString());
    if (listRejected.length() > 0)
      ADialog.error(m_WindowNo, panel, "ChargeNotCreated", listRejected.toString());
  } //  createAccount
  public void generateLabels() {

    Cursor hourglassCursor = new Cursor(Cursor.WAIT_CURSOR);
    xProductTable.stopEditor(true);
    m_frame.setCursor(hourglassCursor);
    PrintService psZebra_glued = null;
    PrintService psZebra_flat = null;
    PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);

    int id_label_glued = Env.getCtx().getContextAsInt("#XX_L_TYPELABELENGOMADA_ID");
    int id_label_flat = Env.getCtx().getContextAsInt("#XX_L_TYPELABELCOLGANTE_ID");

    int glued = 0, flats = 0;
    for (int row = 0; row < xProductTable.getRowCount(); row++) {
      IDColumn idcol = (IDColumn) xProductTable.getValueAt(row, 0);
      if (idcol != null && idcol.isSelected()) {
        KeyNamePair product_kp = (KeyNamePair) xProductTable.getValueAt(row, 3);
        MProduct product = new MProduct(Env.getCtx(), product_kp.getKey(), null);

        if (product.getXX_VMR_TypeLabel_ID() == id_label_glued) {
          glued++;
        } else if (product.getXX_VMR_TypeLabel_ID() == id_label_flat) {
          flats++;
        } else {
          X_XX_VMR_TypeLabel label_type =
              new X_XX_VMR_TypeLabel(Env.getCtx(), product.getXX_VMR_TypeLabel_ID(), null);

          String mss =
              Msg.getMsg(
                  Env.getCtx(),
                  "XX_WrongLabelType",
                  new String[] {label_type.getValue(), label_type.getName()});
          ADialog.error(m_WindowNo, m_frame, mss);
          dispose();
          return;
        }
      }
    }
    psZebra_glued = services[printer_glued];
    psZebra_flat = services[printer_flat];
    for (int row = 0; row < xProductTable.getRowCount(); row++) {
      IDColumn idcol = (IDColumn) xProductTable.getValueAt(row, 0);
      if (idcol != null && idcol.isSelected()) {
        KeyNamePair product_kp = (KeyNamePair) xProductTable.getValueAt(row, 3);
        MProduct product = new MProduct(Env.getCtx(), product_kp.getKey(), null);

        if (product.getXX_VMR_TypeLabel_ID() == id_label_glued) {
          print_labels(psZebra_glued, row, true);
        } else {
          print_labels(psZebra_flat, row, false);
        }
      }
    }
    if (flats + glued > 0) {
      ADialog.info(m_WindowNo, m_frame, "XX_PrintedLabels");
    }
    dispose();
  }
  private void fullAssociated() {

    boolean associated = true;

    String SQL =
        "Select * "
            + "from XX_VMR_REFERENCEMATRIX "
            + "where M_product IS NULL AND XX_VMR_PO_LINEREFPROV_ID="
            + LineRefProv.get_ID();

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL, null);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        associated = false;
      }

      rs.close();
      pstmt.close();

    } catch (Exception a) {
      log.log(Level.SEVERE, SQL, a);
    }

    if (associated == true) {
      String SQL10 =
          "UPDATE XX_VMR_PO_LineRefProv "
              + " SET XX_ReferenceIsAssociated='Y'"
              + " WHERE XX_VMR_PO_LineRefProv_ID="
              + LineRefProv.getXX_VMR_PO_LineRefProv_ID();

      DB.executeUpdate(null, SQL10);

      //			LineRefProv.setXX_ReferenceIsAssociated(true);
      //			LineRefProv.save();

      int dialog = Env.getCtx().getContextAsInt("#Dialog_Associate_Aux");

      if (dialog == 1) {
        ADialog.info(m_WindowNo, m_frame, "MustRefresh");
        Env.getCtx().remove("#Dialog_Associate_Aux");
      }

    } else {
      String SQL10 =
          "UPDATE XX_VMR_PO_LineRefProv "
              + " SET XX_ReferenceIsAssociated='N'"
              + " WHERE XX_VMR_PO_LineRefProv_ID="
              + LineRefProv.getXX_VMR_PO_LineRefProv_ID();

      DB.executeUpdate(null, SQL10);
      //			LineRefProv.setXX_ReferenceIsAssociated(false);
      //			LineRefProv.save();
    }
  }
  private void install() {
    ArrayList<IUnitModel> iunits = new ArrayList<IUnitModel>();
    for (int i = 0; i < repoAppsList.size(); i++) {
      IUnitModel iunit = repoAppsList.get(i);
      if (iunit.isSelected()) {
        iunits.add(iunit);
      }
    }

    if (P2.get().install(iunits)) {
      ADialog.info(0, this, Msg.getMsg(Env.getAD_Language(ctx), "OK"));
    } else {
      ADialog.error(
          0, this, Msg.getMsg(Env.getAD_Language(ctx), "Updates are not correctly installed "));
    }
  }
  @Override
  protected String doIt() throws Exception {
    Utilities calcularPuntuacion = new Utilities();
    Double avg = new Double(0);
    avg = calcularPuntuacion.calculateVendorRating(getRecord_ID());

    BigDecimal bigAvg = new BigDecimal(avg);
    bigAvg = bigAvg.setScale(2, RoundingMode.HALF_UP);

    calcularPuntuacion = null;

    log.saveInfo(
        "Vendor Rating", Msg.getMsg(getCtx(), "XX_VendorRating", new String[] {bigAvg.toString()}));
    ADialog.info(
        1,
        new Container(),
        Msg.getMsg(getCtx(), "XX_VendorRating", new String[] {bigAvg.toString()}));

    return Msg.getMsg(getCtx(), "XX_VendorRating", new String[] {bigAvg.toString()});
  }
Пример #8
0
  /**
   * After Save
   *
   * @param newRecord new
   * @param success success
   * @return true if can be saved
   */
  protected boolean afterSave(boolean newRecord, boolean success) {
    boolean save = super.afterSave(newRecord, success);

    if (save) {
      if (get_ValueAsBigDecimal("XX_L_VCN_StorageCharge")
              .compareTo((BigDecimal) get_ValueOld("XX_L_VCN_StorageCharge"))
          != 0) {
        String msg =
            "¿Está seguro que quiere actualizar el porcentaje de gasto de almacenaje?. "
                + "\nEste cambio actualizará el factor de reposición de las tasas de cambio de periodo igual o posterior al actual.";
        Boolean ask = ADialog.ask(1, new Container(), msg);
        if (ask) {
          BigDecimal percentageIncreaseOld = (BigDecimal) get_ValueOld("XX_L_VCN_StorageCharge");
          BigDecimal percentageIncrease = get_ValueAsBigDecimal("XX_L_VCN_StorageCharge");
          Date time = Utilities.currentServerDate();
          Calendar date = Calendar.getInstance();
          date.setTime(time);
          date.set(Calendar.HOUR, 0);
          date.set(Calendar.MINUTE, 0);
          date.set(Calendar.SECOND, 0);
          date.set(Calendar.MILLISECOND, 0);
          BigDecimal multiplyRate = new BigDecimal(0);
          BigDecimal replacementFactor_aux = new BigDecimal(0);
          BigDecimal replacementFactor = new BigDecimal(0);
          int conversionRateID = 0;

          DateFormat formatter = new SimpleDateFormat("yyyy-MM");
          // Calendar to Date Conversion
          int year = date.get(Calendar.YEAR);
          int month = date.get(Calendar.MONTH);
          int day = date.get(Calendar.DATE);
          Date auxDate = new Date((year - 1900), month, day);
          String fecha = formatter.format(auxDate);

          String SQL =
              "Select C.XX_REPLACEMENTFACTOR, C.MULTIPLYRATE, C.C_CONVERSION_RATE_ID, C.XX_PERIOD_ID, P.STARTDATE "
                  + "\nFROM C_CONVERSION_RATE C, C_PERIOD P WHERE C.XX_PERIOD_ID =  P.C_PERIOD_ID AND "
                  + "\nP.ISACTIVE='Y' AND P.AD_CLIENT_ID = 1000012 AND P.STARTDATE >=  TO_DATE('"
                  + fecha
                  + "','YYYY-MM')";
          System.out.println(SQL);
          PreparedStatement pstmt = null;
          ResultSet rs = null;
          try {
            pstmt = DB.prepareStatement(SQL, null);
            rs = pstmt.executeQuery();

            int i = 0;
            while (rs.next()) {
              multiplyRate = rs.getBigDecimal("MultiplyRate");
              replacementFactor_aux = rs.getBigDecimal("XX_ReplacementFactor");
              conversionRateID = rs.getInt("C_CONVERSION_RATE_ID");

              // Si se esta en medio de un período se agrega a la tabla X_XX_VCN_ReplacementFactor
              // el factor de reposición anterior.
              Calendar start = Calendar.getInstance();
              start.setTime(rs.getDate("STARTDATE"));
              if (start.compareTo(date) <= 0) {
                X_XX_VCN_ReplacementFactor replacementFactorOld =
                    new X_XX_VCN_ReplacementFactor(Env.getCtx(), 0, null);
                replacementFactorOld.setC_Conversion_Rate_ID(conversionRateID);
                replacementFactorOld.setXX_ReplacementFactor(replacementFactor_aux);
                replacementFactorOld.setMultiplyRate(multiplyRate);
                replacementFactorOld.setXX_PercentageIncrease(percentageIncreaseOld);
                replacementFactorOld.save();
                replacementFactorOld.setValidTo(replacementFactorOld.getCreated());
                replacementFactorOld.save();
              }
              // Set Replacement Factor
              X_C_Conversion_Rate convertionRate =
                  new X_C_Conversion_Rate(Env.getCtx(), rs.getInt("C_CONVERSION_RATE_ID"), null);
              replacementFactor = multiplyRate.add((multiplyRate.multiply(percentageIncrease)));
              convertionRate.set_Value("XX_ReplacementFactor", replacementFactor);
              convertionRate.save();
              i++;
            }

            if (i > 0) {
              msg =
                  "Se actualizó el Factor de Reposición de las Tasas de Cambio de periodo igual o posterior al actual.";
              ADialog.info(1, new Container(), msg);
            }

          } catch (Exception e) {
            e.printStackTrace();
          } finally {
            DB.closeResultSet(rs);
            DB.closeStatement(pstmt);
          }
        } else {
          return false;
        }
      }
    }
    return save;
  }
 private void update() {
   P2Updater.startupUpdater();
   ADialog.info(0, this, Msg.getMsg(Env.getAD_Language(ctx), "OK"));
 }
Пример #10
0
  @SuppressWarnings("unchecked")
  public void executeUpdate(String query) {
    erroSQL.setText(null);

    /*
       int linhas=table.getRowCount();
    if(linhas>0){
    	for(int conta=0;conta<linhas;conta++){
    		table.remove(conta);
    	}
    }
    */

    boolean jaExiste = false;
    if (query.substring(0, 6).toLowerCase().equals("delete")
        || query.substring(0, 6).toLowerCase().equals("update")) {
      if (!query.contains("where")) {
        ADialog.info(m_WindowNo, this, "Obrigatório Clausula WHERE");
        return;
      }
    }
    Date data1 = new Date();
    int retornoDB = DB.executeUpdate(query, null);
    Date data2 = new Date();

    table.removeAll();
    table.repaint();
    if (retornoDB == -1) {

      erroSQL.setText(CLogger.retrieveError().toString());
      return;
    }
    String texto = null;
    if (caixaLista.getItemCount() > 0) {

      for (int a = 0; a < caixaLista.getItemCount(); a++) {
        String selecao = comandoSQL.getSelectedText();
        if (selecao != null) {
          texto = comandoSQL.getSelectedText();
        } else {
          texto = comandoSQL.getText();
        }

        if (caixaLista.getItemAt(a).equals(texto.toLowerCase())) {
          jaExiste = true;
          return;
        }
      }
    }
    if (jaExiste == false) {
      String selecao = comandoSQL.getSelectedText();
      if (selecao != null) {
        caixaLista.addItem(comandoSQL.getSelectedText());
      } else {
        caixaLista.addItem(comandoSQL.getText());
      }
      caixaLista.setPreferredSize(new Dimension(300, 20));
    }
    Object tempo = data2.getTime() - data1.getTime();
    erroSQL.setText(
        "Query returned successfully:"
            + retornoDB
            + " rows affected, "
            + tempo
            + " ms execution time.");
    table.removeAll();
  }