/// <summary> /// Get Parent /// </summary> /// <returns>Returns the parent.</returns> public MDistribution GetParent() { if (_parent == null) { _parent = new MDistribution(GetCtx(), GetGL_Distribution_ID(), Get_TrxName()); } return(_parent); } // getParent
} // get /// <summary> /// Get Distributions for Account /// </summary> /// <param name="ctx">context</param> /// <param name="Account_ID">id</param> /// <returns>array of distributions</returns> public static MDistribution[] Get(Ctx ctx, int Account_ID) { //Integer key = new Integer (Account_ID); int key = Account_ID; //MDistribution[] retValue = (MDistribution[])s_accounts.get(key); MDistribution[] retValue = (MDistribution[])s_accounts[key]; if (retValue != null) { return(retValue); } String sql = "SELECT * FROM GL_Distribution " + "WHERE Account_ID=@Param1"; //ArrayList<MDistribution> list = new ArrayList<MDistribution>(); List <MDistribution> list = new List <MDistribution>(); SqlParameter[] Param = new SqlParameter[1]; IDataReader idr = null; DataTable dt = null; //PreparedStatement pstmt = null; try { //pstmt = DataBase.prepareStatement (sql, null); //pstmt.setInt (1, Account_ID); Param[0] = new SqlParameter("@Param1", Account_ID); //ResultSet rs = pstmt.executeQuery (); idr = DataBase.DB.ExecuteReader(sql, Param, null); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { list.Add(new MDistribution(ctx, dr, null)); } } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); } finally { dt = null; } // retValue = new MDistribution[list.Count]; //list.toArray (retValue); retValue = list.ToArray(); //s_accounts.put(key, retValue); s_accounts.Add(key, retValue); return(retValue); } // get
} // getParent /// <summary> /// Set Parent /// </summary> /// <param name="parent">The parent to set.</param> public void SetParent(MDistribution parent) { _parent = parent; } // setParent
} // get /// <summary> /// Get Distributions for combination /// </summary> /// <param name="ctx">context</param> /// <param name="C_AcctSchema_ID">schema</param> /// <param name="PostingType">posting type</param> /// <param name="C_DocType_ID">document type</param> /// <param name="AD_Org_ID">org</param> /// <param name="Account_ID">account</param> /// <param name="M_Product_ID">product</param> /// <param name="C_BPartner_ID">partner</param> /// <param name="C_Project_ID">project</param> /// <param name="C_Campaign_ID">campaign</param> /// <param name="C_Activity_ID">activity</param> /// <param name="AD_OrgTrx_ID">trx org</param> /// <param name="C_SalesRegion_ID">C_SalesRegion_ID</param> /// <param name="C_LocTo_ID">location to</param> /// <param name="C_LocFrom_ID">from</param> /// <param name="User1_ID">user 1</param> /// <param name="User2_ID">user 2</param> /// <returns>array of distributions or null</returns> public static MDistribution[] Get(Ctx ctx, int C_AcctSchema_ID, String PostingType, int C_DocType_ID, int AD_Org_ID, int Account_ID, int M_Product_ID, int C_BPartner_ID, int C_Project_ID, int C_Campaign_ID, int C_Activity_ID, int AD_OrgTrx_ID, int C_SalesRegion_ID, int C_LocTo_ID, int C_LocFrom_ID, int User1_ID, int User2_ID) { MDistribution[] acctList = Get(ctx, Account_ID); if (acctList == null || acctList.Length == 0) { return(null); } // //ArrayList<MDistribution> list = new ArrayList<MDistribution>(); List <MDistribution> list = new List <MDistribution>(); for (int i = 0; i < acctList.Length; i++) { MDistribution distribution = acctList[i]; if (!distribution.IsActive() || !distribution.IsValid()) { continue; } // Mandatory Acct Schema if (distribution.GetC_AcctSchema_ID() != C_AcctSchema_ID) { continue; } // Only Posting Type / DocType if (distribution.GetPostingType() != null && !distribution.GetPostingType().Equals(PostingType)) { continue; } if (distribution.GetC_DocType_ID() != 0 && distribution.GetC_DocType_ID() != C_DocType_ID) { continue; } // Optional Elements - "non-Any" if (!distribution.IsAnyOrg() && distribution.GetAD_Org_ID() != AD_Org_ID) { continue; } if (!distribution.IsAnyAcct() && distribution.GetAccount_ID() != Account_ID) { continue; } if (!distribution.IsAnyProduct() && distribution.GetM_Product_ID() != M_Product_ID) { continue; } if (!distribution.IsAnyBPartner() && distribution.GetC_BPartner_ID() != C_BPartner_ID) { continue; } if (!distribution.IsAnyProject() && distribution.GetC_Project_ID() != C_Project_ID) { continue; } if (!distribution.IsAnyCampaign() && distribution.GetC_Campaign_ID() != C_Campaign_ID) { continue; } if (!distribution.IsAnyActivity() && distribution.GetC_Activity_ID() != C_Activity_ID) { continue; } if (!distribution.IsAnyOrgTrx() && distribution.GetAD_OrgTrx_ID() != AD_OrgTrx_ID) { continue; } if (!distribution.IsAnySalesRegion() && distribution.GetC_SalesRegion_ID() != C_SalesRegion_ID) { continue; } if (!distribution.IsAnyLocTo() && distribution.GetC_LocTo_ID() != C_LocTo_ID) { continue; } if (!distribution.IsAnyLocFrom() && distribution.GetC_LocFrom_ID() != C_LocFrom_ID) { continue; } if (!distribution.IsAnyUser1() && distribution.GetUser1_ID() != User1_ID) { continue; } if (!distribution.IsAnyUser2() && distribution.GetUser2_ID() != User2_ID) { continue; } // list.Add(distribution); } // for all distributions with acct // MDistribution[] retValue = new MDistribution[list.Count]; //list.toArray (retValue); retValue = list.ToArray(); return(retValue); } // get