/** 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
@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); }
/** 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
/** 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(); }
/** 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; }
// 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")); } }
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 { // 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 ""; }
/** @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; }
/** 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