Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
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
Ejemplo n.º 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 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 "));
    }
  }
Ejemplo n.º 6
0
  /** Esta función asocia un medio de publicación existente o nuevo a una acción de mercadeo. */
  protected String doIt() throws Exception {

    X_XX_VMA_MediaType medio = new X_XX_VMA_MediaType(Env.getCtx(), 0, null);
    // X_XX_VMA_MarketingActivity accion = new
    // X_XX_VMA_MarketingActivity(getCtx(),p_XX_VMA_MarketingActivity_ID,null);
    // X_C_Channel canal = new X_C_Channel(getCtx(),Medio,null);
    boolean bool = false;
    // String lista = accion.getXX_VMA_MediaList();
    // System.out.println("el medio es el número "+Medio);
    medio.setXX_VMA_MarketingActivity_ID(p_XX_VMA_MarketingActivity_ID);
    // si no se eligió un medio existente o se introdujo uno nuevo, fracasa el proceso
    // de asociación
    if (Medio == 0 && MedioValue == null) {
      ADialog.error(Env.WINDOW_INFO, null, "Error", Msg.translate(Env.getCtx(), "XX_Media"));
      throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
    } // si se eligió un medio existente se asocia a la acción de mercadeo
    else if (Medio != 0 && MedioValue == null) {
      medio.setC_Channel_ID(Medio);
      bool = medio.save();
      if (bool) {
        return Msg.translate(Env.getCtx(), "XX_PubliMedia");
      } else {
        ADialog.error(Env.WINDOW_INFO, null, Msg.translate(Env.getCtx(), "XX_MediaActivity"));
        throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
      }
      // si no se eligió un medio existente y se coloco uno nuevo, este se crea
      // primero como un canal de publicación y luego se asocia a la acción de mercadeo
    } else if (Medio == 0 && MedioValue != null) {
      // creación del nuevo medio de publicación
      X_C_Channel canal = new X_C_Channel(Env.getCtx(), 0, null);
      canal.setName(MedioValue);
      canal.save();
      // se asocia el medio de publicación a la acción de mercadeo
      medio.setC_Channel_ID(canal.getC_Channel_ID());
      bool = medio.save();
      if (bool) return Msg.translate(Env.getCtx(), "XX_PubliMedia");
      else {
        ADialog.error(
            Env.WINDOW_INFO, null, "Error", Msg.translate(Env.getCtx(), "XX_MediaActivity"));
        throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
      }
    } else {
      ADialog.error(
          Env.WINDOW_INFO, null, "Error", Msg.translate(Env.getCtx(), "XX_ChooseChannel"));
      throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
    }
  } // Fin doIt
  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();
    }
  }
Ejemplo n.º 8
0
  /** Call back from key panel */
  public void keyReturned(MPOSKey key) {
    // processed order
    if (p_posPanel.m_order != null && p_posPanel.m_order.isProcessed()) return;

    // new line
    p_posPanel.f_curLine.setM_Product_ID(key.getM_Product_ID());
    p_posPanel.f_curLine.setPrice();
    p_posPanel.f_curLine.setQty(key.getQty());
    if (!p_posPanel.f_curLine.saveLine()) {
      ADialog.error(0, this, "Could not save order line");
    }
    p_posPanel.updateInfo();
    return;
  }
Ejemplo n.º 9
0
  // DESDE AQUI AGREGADO POR GHUCHET
  private void completarMovimiento(MMovement move) {
    // Preparar el movimiento
    move.setDocAction(X_M_Movement.DOCACTION_Prepare);
    DocumentEngine.processIt(move, X_M_Movement.DOCACTION_Prepare);
    move.save();
    commit();
    move.load(get_TrxName());
    if (move.getDocStatus().equals("IN")) {
      ADialog.error(EnvConstants.WINDOW_INFO, new Container(), "NoLines");
    } else {

      // Aca debo actualizar las cantidades aprobadas
      String sql =
          "SELECT QtyRequired, XX_ApprovedQty FROM M_MOVEMENTLINE WHERE M_MOVEMENT_ID = "
              + move.getM_Movement_ID();
      PreparedStatement ps_1 =
          DB.prepareStatement(
              sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, null);
      ResultSet rs_1 = null;
      // System.out.println(sql);
      int qty_required = 0;
      try {
        rs_1 = ps_1.executeQuery();
        while (rs_1.next()) {
          qty_required = rs_1.getInt("QtyRequired");
          rs_1.updateInt("XX_ApprovedQty", qty_required);
          rs_1.updateRow();
        }
      } catch (Exception e) {
        e.printStackTrace();

      } finally {
        try {
          rs_1.close();
          ps_1.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }

      move.setXX_Status("PE");
      move.setXX_RequestDate(move.getUpdated());
      move.save();

      // Se envian correos dependiendo del tipo de documento
      enviarCorreoATienda(move, Env.getCtx().getContextAsInt("#XX_L_MT_PTRANSFERAPPROVAL_ID"));
    }
  }
  @Override
  protected String doIt() throws Exception {
    // TODO Auto-generated method stub

    X_XX_VMR_SizeCurve curve = new X_XX_VMR_SizeCurve(getCtx(), getRecord_ID(), get_TrxName());
    int header_id = curve.getXX_VMR_DistributionHeader_ID();
    int curve_id = curve.get_ID();

    String SQL_query =
        " SELECT D.M_ATTRIBUTEVALUE_ID, R.XX_VMR_VENDORPRODREF_ID "
            + " FROM XX_VMR_SIZECURVE S JOIN XX_VMR_SIZECURVEDETAIL D "
            + " ON ( S.XX_VMR_SIZECURVE_ID = D.XX_VMR_SIZECURVE_ID) JOIN "
            + " XX_VMR_SIZECURVEREFERENCE R ON "
            + "(R.XX_VMR_SIZECURVE_ID = D.XX_VMR_SIZECURVE_ID)"
            + " WHERE S.XX_VMR_DISTRIBUTIONHEADER_ID = "
            + header_id
            + " AND S.XX_VMR_SIZECURVE_ID = "
            + curve_id;
    try {
      PreparedStatement pstmt_b = DB.prepareStatement(SQL_query, null);
      ResultSet rs_b = pstmt_b.executeQuery();
      while (rs_b.next()) {
        X_XX_VMR_SizeCurveRefDetail ref_size_detail =
            new X_XX_VMR_SizeCurveRefDetail(getCtx(), 0, get_TrxName());
        ref_size_detail.setXX_VMR_VendorProdRef_ID(rs_b.getInt("XX_VMR_VENDORPRODREF_ID"));
        ref_size_detail.setXX_VMR_SIZECURVE_ID(curve_id);
        ref_size_detail.setM_AttributeValue_ID(rs_b.getInt("M_ATTRIBUTEVALUE_ID"));
        ref_size_detail.save();
      }
      pstmt_b.close();
      rs_b.close();
      String SQL_delete =
          "DELETE FROM XX_VMR_SIZECURVEDETAIL " + "WHERE XX_VMR_SIZECURVE_ID = " + curve_id;

      DB.executeUpdate(null, SQL_delete);

    } catch (SQLException e) {
      ADialog.error(1, new Container(), "XX_DatabaseAccessError");
      e.printStackTrace();
      return "XX_DatabaseAccessError";
    }
    curve.setXX_CalculatedSizeCurveRef(true);
    curve.save();

    return "";
  }
Ejemplo n.º 11
0
  private void payOrder() {

    // Check if order is completed, if so, print and open drawer, create an empty order and set
    // cashGiven to zero

    if (p_posPanel.m_order != null) {
      if (!p_posPanel.m_order.isProcessed() && !p_posPanel.m_order.processOrder()) {
        ADialog.warn(0, p_posPanel, "PosOrderProcessFailed");
        return;
      }

      if (PosPayment.pay(p_posPanel)) {
        printTicket();
        p_posPanel.setOrder(0);
      }
    }
  }
  @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()});
  }
 /** @param success */
 protected boolean afterDelete(boolean success) {
   if (success) {
     try {
       MPayment[] pays = getPayments(get_TrxName());
       for (int i = 0; i < pays.length; i++) {
         if (!pays[i].delete(false, get_TrxName())) {
           String msg =
               "No se pudo eliminar alguno de los pagos vinculados al documento que"
                   + "se está eliminando. Se cancelará la operación";
           s_log.severe(msg);
           ADialog.error(0, null, msg);
           return false;
         }
       }
     } catch (SQLException e) {
       s_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
       return false;
     }
   }
   return success;
 }
Ejemplo n.º 14
0
  /** Create/Save Account */
  private void action_Save() {
    log.info("");
    /** Check completeness (mandatory fields) ... and for duplicates */
    StringBuffer sb = new StringBuffer();
    StringBuffer sql =
        new StringBuffer("SELECT C_ValidCombination_ID, Alias FROM C_ValidCombination WHERE ");
    Object value = null;
    if (s_AcctSchema.isHasAlias()) {
      value = f_Alias.getValue().toString();
      if (value == null) sb.append(Msg.translate(Env.getCtx(), "Alias")).append(", ");
    }
    MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length; i++) {
      MAcctSchemaElement ase = elements[i];
      String type = ase.getElementType();
      //
      if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
        value = f_AD_Org_ID.getValue();
        sql.append("AD_Org_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
        value = f_Account_ID.getValue();
        sql.append("Account_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
        value = f_SubAcct_ID.getValue();
        sql.append("C_SubAcct_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
        value = f_M_Product_ID.getValue();
        sql.append("M_Product_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
        value = f_C_BPartner_ID.getValue();
        sql.append("C_BPartner_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
        value = f_C_Campaign_ID.getValue();
        sql.append("C_Campaign_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
        value = f_C_LocFrom_ID.getValue();
        sql.append("C_LocFrom_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
        value = f_C_LocTo_ID.getValue();
        sql.append("C_LocTo_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
        value = f_C_Project_ID.getValue();
        sql.append("C_Project_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
        value = f_C_SalesRegion_ID.getValue();
        sql.append("C_SalesRegion_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
        value = f_AD_OrgTrx_ID.getValue();
        sql.append("AD_OrgTrx_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
        value = f_C_Activity_ID.getValue();
        sql.append("C_Activity_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
        value = f_User1_ID.getValue();
        sql.append("User1_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
        value = f_User2_ID.getValue();
        sql.append("User2_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      }
      //
      if (ase.isMandatory() && value == null) sb.append(ase.getName()).append(", ");
    } //	Fields in Element Order

    if (sb.length() != 0) {
      ADialog.error(m_WindowNo, this, "FillMandatory", sb.substring(0, sb.length() - 2));
      return;
    }
    if (f_AD_Org_ID == null || f_AD_Org_ID.getValue() == null) {
      ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "AD_Org_ID"));
      return;
    }
    if (f_Account_ID == null || f_Account_ID.getValue() == null) {
      ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "Account_ID"));
      return;
    }

    /** Check if already exists */
    sql.append("AD_Client_ID=? AND C_AcctSchema_ID=?");
    log.fine("Check = " + sql.toString());
    int IDvalue = 0;
    String Alias = null;
    try {
      PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
      pstmt.setInt(1, m_AD_Client_ID);
      pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID());
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        IDvalue = rs.getInt(1);
        Alias = rs.getString(2);
      }
      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql.toString(), e);
      IDvalue = 0;
    }
    log.fine("ID=" + IDvalue + ", Alias=" + Alias);

    if (Alias == null) Alias = "";

    //	We have an account like this already - check alias
    if (IDvalue != 0 && s_AcctSchema.isHasAlias() && !f_Alias.getValue().toString().equals(Alias)) {
      sql = new StringBuffer("UPDATE C_ValidCombination SET Alias=");
      if (f_Alias.getValue().toString().length() == 0) sql.append("NULL");
      else sql.append("'").append(f_Alias.getValue()).append("'");
      sql.append(" WHERE C_ValidCombination_ID=").append(IDvalue);
      int i = 0;
      try {
        java.sql.PreparedStatement stmt =
            DB.prepareStatement(
                sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null);
        i = stmt.executeUpdate();
        stmt.close();
      } catch (SQLException e) {
        log.log(Level.SEVERE, sql.toString(), e);
      }
      if (i == 0) ADialog.error(m_WindowNo, this, "AccountNotUpdated");
    }

    //	load and display
    if (IDvalue != 0) {
      loadInfo(IDvalue, s_AcctSchema.getC_AcctSchema_ID());
      action_Find(false);
      return;
    }

    log.config("New");
    Alias = null;
    if (f_Alias != null) Alias = f_Alias.getValue().toString();
    int C_SubAcct_ID = 0;
    if (f_SubAcct_ID != null && f_SubAcct_ID.getValue() != null)
      C_SubAcct_ID = ((Integer) f_SubAcct_ID.getValue()).intValue();
    int M_Product_ID = 0;
    if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null)
      M_Product_ID = ((Integer) f_M_Product_ID.getValue()).intValue();
    int C_BPartner_ID = 0;
    if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null)
      C_BPartner_ID = ((Integer) f_C_BPartner_ID.getValue()).intValue();
    int AD_OrgTrx_ID = 0;
    if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null)
      AD_OrgTrx_ID = ((Integer) f_AD_OrgTrx_ID.getValue()).intValue();
    int C_LocFrom_ID = 0;
    if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null)
      C_LocFrom_ID = ((Integer) f_C_LocFrom_ID.getValue()).intValue();
    int C_LocTo_ID = 0;
    if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null)
      C_LocTo_ID = ((Integer) f_C_LocTo_ID.getValue()).intValue();
    int C_SRegion_ID = 0;
    if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null)
      C_SRegion_ID = ((Integer) f_C_SalesRegion_ID.getValue()).intValue();
    int C_Project_ID = 0;
    if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null)
      C_Project_ID = ((Integer) f_C_Project_ID.getValue()).intValue();
    int C_Campaign_ID = 0;
    if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null)
      C_Campaign_ID = ((Integer) f_C_Campaign_ID.getValue()).intValue();
    int C_Activity_ID = 0;
    if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null)
      C_Activity_ID = ((Integer) f_C_Activity_ID.getValue()).intValue();
    int User1_ID = 0;
    if (f_User1_ID != null && f_User1_ID.getValue() != null)
      User1_ID = ((Integer) f_User1_ID.getValue()).intValue();
    int User2_ID = 0;
    if (f_User2_ID != null && f_User2_ID.getValue() != null)
      User2_ID = ((Integer) f_User2_ID.getValue()).intValue();

    MAccount acct =
        MAccount.get(
            Env.getCtx(),
            m_AD_Client_ID,
            ((Integer) f_AD_Org_ID.getValue()).intValue(),
            s_AcctSchema.getC_AcctSchema_ID(),
            ((Integer) f_Account_ID.getValue()).intValue(),
            C_SubAcct_ID,
            M_Product_ID,
            C_BPartner_ID,
            AD_OrgTrx_ID,
            C_LocFrom_ID,
            C_LocTo_ID,
            C_SRegion_ID,
            C_Project_ID,
            C_Campaign_ID,
            C_Activity_ID,
            User1_ID,
            User2_ID,
            0,
            0);
    if (acct != null && acct.get_ID() == 0) acct.save();

    //  Show Info
    if (acct == null || acct.get_ID() == 0) loadInfo(0, 0);
    else {
      //	Update Account with optional Alias
      if (Alias != null && Alias.length() > 0) {
        acct.setAlias(Alias);
        acct.save();
      }
      loadInfo(acct.get_ID(), s_AcctSchema.getC_AcctSchema_ID());
    }
    action_Find(false);
  } //	action_Save
Ejemplo n.º 15
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;
  }
Ejemplo n.º 16
0
  private void deleteOrder() {
    if (p_posPanel != null && ADialog.ask(0, this, "Delete order?"))
      p_posPanel.m_order.deleteOrder();
    // p_posPanel.newOrder();

  }
Ejemplo n.º 17
0
  /**
   * ************************************************************************ Insert String
   *
   * @param origOffset
   * @param string
   * @param attr
   * @throws BadLocationException
   */
  @Override
  public void insertString(int origOffset, String string, AttributeSet attr)
      throws BadLocationException {
    log.finest("Offset=" + origOffset + " String=" + string + " Length=" + string.length());
    if (origOffset < 0 || string == null) throw new IllegalArgumentException("Invalid argument");

    int offset = origOffset;
    int length = string.length();
    //	From DataBinder (assuming correct format)
    if (length != 1) {
      super.insertString(offset, string, attr);
      return;
    }

    /** Manual Entry */
    String content = getText();
    //	remove all Thousands
    if (content.indexOf(m_groupingSeparator) != -1) {
      StringBuffer result = new StringBuffer();
      for (int i = 0; i < content.length(); i++) {
        if (content.charAt(i) == m_groupingSeparator) {
          if (i < offset) offset--;
        } else result.append(content.charAt(i));
      }
      super.remove(0, content.length());
      super.insertString(0, result.toString(), attr);
      //
      m_tc.setCaretPosition(offset);
      //	ADebug.trace(ADebug.l6_Database, "Clear Thousands (" + m_format.toPattern() + ")" + content
      // + " -> " + result.toString());
      content = result.toString();
    } //	remove Thousands

    /**
     * ******************************************************************** Check Character entered
     */
    char c = string.charAt(0);
    if (Character.isDigit(c)) // c >= '0' && c <= '9')
    {
      //	ADebug.trace(ADebug.l6_Database, "Digit=" + c);
      super.insertString(offset, string, attr);
      return;
    }

    //	Decimal - remove other decimals
    //	Thousand - treat as Decimal
    else if (c == m_decimalSeparator || c == m_groupingSeparator || c == '.' || c == ',') {
      //	log.info("Decimal=" + c + " (ds=" + m_decimalSeparator + "; gs=" + m_groupingSeparator +
      // ")");
      //  no decimals on integers
      if (m_displayType == DisplayType.Integer) return;
      int pos = content.indexOf(m_decimalSeparator);

      //	put decimal in
      String decimal = String.valueOf(m_decimalSeparator);
      super.insertString(offset, decimal, attr);

      //	remove other decimals
      if (pos != 0) {
        content = getText();
        StringBuffer result = new StringBuffer();
        int correction = 0;
        for (int i = 0; i < content.length(); i++) {
          if (content.charAt(i) == m_decimalSeparator) {
            if (i == offset) result.append(content.charAt(i));
            else if (i < offset) correction++;
          } else result.append(content.charAt(i));
        }
        super.remove(0, content.length());
        super.insertString(0, result.toString(), attr);
        m_tc.setCaretPosition(offset - correction + 1);
      } //	remove other decimals
    } //	decimal or thousand

    //	something else
    else if (VNumber.AUTO_POPUP || "=+-/*%".indexOf(c) > -1) {

      //	Minus - put minus on start of string
      if (c == m_minusSign && offset == 0) {
        //	no minus possible
        if (m_displayType == DisplayType.Integer) return;
        //	add at start of string
        else super.insertString(0, "-", attr);
      } else {
        log.fine("Input=" + c + " (" + (int) c + ")");

        if (c == m_percentSign && offset > 0) {
          // don't convert integers to percent. 1% = 0?
          if (m_displayType == DisplayType.Integer) return;
          // divide by 100
          else {
            String value = getText();
            BigDecimal percentValue = new BigDecimal(0.0);
            try {
              if (value != null && value.length() > 0) {
                Number number = m_format.parse(value);
                percentValue = new BigDecimal(number.toString());
                percentValue =
                    percentValue.divide(
                        new BigDecimal(100.0),
                        m_format.getMaximumFractionDigits(),
                        BigDecimal.ROUND_HALF_UP);
                m_tc.setText(m_format.format(percentValue));
              }
            } catch (ParseException pe) {
              log.info("InvalidEntry - " + pe.getMessage());
            }
          }
        } else {

          String result =
              VNumber.startCalculator(m_tc, getText(), m_format, m_displayType, m_title, c);
          super.remove(0, content.length());

          // insertString(0, result, attr);
          m_tc.setText(result);
        }
      }
    } else ADialog.beep();
  } //	insertString
Ejemplo n.º 18
0
  /**
   * ActionListener
   *
   * @param e ActionEvent
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
      if (fAddress1.isMandatory() && ((((String) fAddress1.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fAddress2.isMandatory() && ((((String) fAddress2.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fAddress3.isMandatory() && ((((String) fAddress3.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fPostal.isMandatory() && ((((String) fPostal.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else {
        action_OK();
        m_change = true;
        dispose();
      }
    } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
      m_change = false;
      dispose();
    } else if (e.getSource() == fCountry) {
      //	Country Changed - display in new Format
      //	Modifier for Mouse selection is 16  - for any key selection 0
      MCountry c = (MCountry) fCountry.getSelectedItem();
      m_location.setCountry(c);
      //	refrseh
      mainPanel.removeAll();
      initLocation();
      fCountry.requestFocus(); // 	allows to use Keybord selection
    }
    // Kenos
    else if (e.getSource() == fRegion) {
      //	Modifier for Mouse selection is 16  - for any key selection 0
      MRegion r = (MRegion) fRegion.getSelectedItem();
      m_location.setRegion(r);
      //	refrseh
      mainPanel.removeAll();
      initLocation();
      fRegion.requestFocus(); // 	allows to use Keybord selection
    }
    // Kenos
    else if (e.getSource() == toLink) {
      String urlString = GOOGLE_MAPS_URL_PREFIX + getGoogleMapsLocation(m_location);
      String message = null;

      try {
        new URL(urlString);
        Env.startBrowser(urlString);
      } catch (Exception ex) {
        message = ex.getMessage();
        ADialog.warn(0, this, "URLnotValid", message);
      }
    } else if (e.getSource() == toRoute) {
      int AD_Org_ID = Env.getAD_Org_ID(Env.getCtx());
      if (AD_Org_ID != 0) {
        MOrgInfo orgInfo = MOrgInfo.get(Env.getCtx(), AD_Org_ID, null);
        MLocation orgLocation = new MLocation(Env.getCtx(), orgInfo.getC_Location_ID(), null);

        String urlString =
            GOOGLE_MAPS_ROUTE_PREFIX
                + GOOGLE_SOURCE_ADDRESS
                + getGoogleMapsLocation(orgLocation)
                + // org
                GOOGLE_DESTINATION_ADDRESS
                + getGoogleMapsLocation(m_location); // partner
        String message = null;
        try {
          new URL(urlString);
          Env.startBrowser(urlString);
        } catch (Exception ex) {
          message = ex.getMessage();
          ADialog.warn(0, this, "URLnotValid", message);
        }
      }
    } else if (e.getSource() == getAddress) {
      if (fPostal != null && !fPostal.getText().equals("")) {
        if (!fAddress1.getText().equals("")
            || !fAddress2.getText().equals("")
            || !fAddress3.getText().equals("")
            || !fAddress4.getText().equals("")
            || fCity.getSelectedIndex() > 0) {
          String warningMsg = "O endereço atual será substituido. Deseja continuar?";
          String warningTitle = "Aviso";
          int response =
              JOptionPane.showConfirmDialog(
                  null, warningMsg, warningTitle, JOptionPane.YES_NO_OPTION);
          if (response == JOptionPane.NO_OPTION) return;
        }

        WebServiceCep cep = WebServiceCep.searchCep(fPostal.getText());
        if (cep.wasSuccessful()) {
          MRegion[] regions = MRegion.getRegions(Env.getCtx(), 139);
          for (MRegion r : regions)
            if (r.getName() != null && r.getName().equals(cep.getUf())) {
              fRegion.setSelectedItem(r);
              break;
            }
          fCity.setSelectedItem(cep.getCidade());
          fAddress1.setText(cep.getLogradouroType() + " " + cep.getLogradouro());
          fAddress3.setText(cep.getBairro());
          if (cep.getCep().length() == 8)
            fPostal.setText(cep.getCep().substring(0, 5) + "-" + cep.getCep().substring(5));
          else fPostal.setText(cep.getCep());
        } else if (cep.getResulCode() == 0)
          JOptionPane.showMessageDialog(null, "CEP não encontrado na base de dados.");
        else if (cep.getResulCode() == 14)
          JOptionPane.showMessageDialog(
              null, "Não foi possível fazer a busca. (Possível problema com a Internet).");
        else JOptionPane.showMessageDialog(null, "Erro ao fazer a busca.");
      } else JOptionPane.showMessageDialog(null, "Preencha o CEP.");
    }
  } //	actionPerformed
Ejemplo n.º 19
0
  /** Shows the searched order condition */
  private void showCreditNotificationCondition() {

    ADialog.warn(
        m_WindowNo, this.mainPanel, Msg.translate(Env.getCtx(), "XX_NoNotificationsForFilter"));
  }
 private void update() {
   P2Updater.startupUpdater();
   ADialog.info(0, this, Msg.getMsg(Env.getAD_Language(ctx), "OK"));
 }
Ejemplo n.º 21
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();
  }
Ejemplo n.º 22
0
  /**
   * Insert String
   *
   * @param offset offset
   * @param string string
   * @param attr attributes
   * @throws BadLocationException
   */
  @Override
  public void insertString(int offset, String string, AttributeSet attr)
      throws BadLocationException {
    log.finest(
        "Offset="
            + offset
            + ",String="
            + string
            + ",Attr="
            + attr
            + ",OldText="
            + getText()
            + ",OldLength="
            + getText().length());

    //	manual entry
    //	DBTextDataBinder.updateText sends stuff at once - length=8
    if (string != null && string.length() == 1) {
      //	ignore if too long
      if (offset >= m_mask.length()) return;

      //	is it an empty field?
      int length = getText().length();
      if (offset == 0 && length == 0) {
        Date today = new Date(System.currentTimeMillis());
        String dateStr = m_format.format(today);
        super.insertString(0, string + dateStr.substring(1), attr);
        m_tc.setCaretPosition(1);
        return;
      }

      //	is it a digit ?
      try {
        Integer.parseInt(string);
      } catch (Exception pe) {
        // hengsin, [ 1660175 ] Date field - anoying popup
        // startDateDialog();
        ADialog.beep();
        return;
      }

      //	try to get date in field, if invalid, get today's
      /*try
      {
      	char[] cc = getText().toCharArray();
      	cc[offset] = string.charAt(0);
      	m_format.parse(new String(cc));
      }
      catch (ParseException pe)
      {
      	startDateDialog();
      	return;
      }*/

      //	positioned before the delimiter - jump over delimiter
      if (offset != m_mask.length() - 1 && m_mask.charAt(offset + 1) == DELIMITER)
        m_tc.setCaretPosition(offset + 2);

      //	positioned at the delimiter
      if (m_mask.charAt(offset) == DELIMITER) {
        offset++;
        m_tc.setCaretPosition(offset + 1);
      }
      super.remove(offset, 1); // 	replace current position
    }

    //	Set new character
    super.insertString(offset, string, attr);
    //	New value set Cursor
    if (offset == 0 && string != null && string.length() > 1) m_tc.setCaretPosition(0);
  } //	insertString