Examples of MAllocationHdr


Examples of org.compiere.model.MAllocationHdr

    m_trx = Trx.get(Trx.createTrxName("AllocReset"), true);
    int count = 0;

    if (p_C_AllocationHdr_ID != 0)
    {
      MAllocationHdr hdr = new MAllocationHdr(getCtx(), p_C_AllocationHdr_ID, m_trx.getTrxName());
      if (delete(hdr))
        count++;
      else
        errors .append(Env.getContext(getCtx(), 0, "resetAllocationError"));

      m_trx.close();
      if(errors.length() == 0)
        return "@Deleted@ #" + count;
      else
        return "@Deleted@ #" + count + "\n could not delete:" + errors.toString();
     
    }
   
    //  Selection
    StringBuffer sql = new StringBuffer("SELECT * FROM C_AllocationHdr ah "
      + "WHERE EXISTS (SELECT * FROM C_AllocationLine al "
        + "WHERE ah.C_AllocationHdr_ID=al.C_AllocationHdr_ID");
    if (p_C_BPartner_ID != 0)
      sql.append(" AND al.C_BPartner_ID=?");
    else if (p_C_BP_Group_ID != 0)
      sql.append(" AND EXISTS (SELECT * FROM C_BPartner bp "
          + "WHERE bp.C_BPartner_ID=al.C_BPartner_ID AND bp.C_BP_Group_ID=?)");
    else
      sql.append(" AND AD_Client_ID=?");
    if (p_DateAcct_From != null)
      sql.append(" AND TRIM(ah.DateAcct) >= ?");
    if (p_DateAcct_To != null)
      sql.append(" AND TRIM(ah.DateAcct) <= ?");
    //  Do not delete Cash Trx
    sql.append(" AND al.C_CashLine_ID IS NULL)");
    //  Open Period
    sql.append(" AND EXISTS (SELECT * FROM C_Period p"
      + " INNER JOIN C_PeriodControl pc ON (p.C_Period_ID=pc.C_Period_ID AND pc.DocBaseType='CMA') "
      + "WHERE ah.DateAcct BETWEEN p.StartDate AND p.EndDate)");
    //
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try
    {
      pstmt = DB.prepareStatement (sql.toString(), m_trx.getTrxName());
      int index = 1;
      if (p_C_BPartner_ID != 0)
        pstmt.setInt(index++, p_C_BPartner_ID);
      else if (p_C_BP_Group_ID != 0)
        pstmt.setInt(index++, p_C_BP_Group_ID);
      else
        pstmt.setInt(index++, Env.getAD_Client_ID(getCtx()));
      if (p_DateAcct_From != null)
        pstmt.setTimestamp(index++, p_DateAcct_From);
      if (p_DateAcct_To != null)
        pstmt.setTimestamp(index++, p_DateAcct_To);
      rs = pstmt.executeQuery ();
      while (rs.next ())
      {
        MAllocationHdr hdr = new MAllocationHdr(getCtx(), rs, m_trx.getTrxName());
        /*CHANGES START HERE DOMINIC TARR 20081021*/
//        if (delete(hdr))
  //        count++;
       
        allocations.add(hdr);
        /*CHANGES END HERE DOMINIC TARR 20081021*/

      }
     }
    catch (Exception e)
    {
      log.log(Level.SEVERE, sql.toString(), e);
      m_trx.rollback();
    }
    finally
    {
      /*CHANGES START HERE DOMINIC TARR 20081021*/
      Iterator i = allocations.iterator();
      if(ADialog.ask(0, Env.getWindow(0), "this will delete " + allocations.size() + " allocations, are you sure?"))
        {
        while(i.hasNext()){
          MAllocationHdr hdr = (MAllocationHdr)(i.next());
          if (delete(hdr))//deletes it here
            count++;
          else
            errors .append(Env.getContext(getCtx(), 0, "resetAllocationError"));

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.