Exemplo n.º 1
0
        }       //	Get

        /**
         *  Get BOMs Of Product
         *	@param ctx context
         *	@param M_Product_ID product
         *	@param trxName trx
         *	@param whereClause optional WHERE clause w/o AND
         *	@return array of BOMs
         */
        public static MBOM[] GetOfProduct(Ctx ctx, int M_Product_ID,
                                          Trx trxName, String whereClause)
        {
            List <MBOM> list = new List <MBOM>();
            String      sql  = "SELECT * FROM M_BOM WHERE M_Product_ID=" + M_Product_ID;

            if (whereClause != null && whereClause.Length > 0)
            {
                sql += " AND " + whereClause;
            }
            //PreparedStatement pstmt = null;
            DataTable   dt  = null;
            IDataReader idr = null;

            try
            {
                //pstmt = DataBase.prepareStatement (sql, trxName);
                //pstmt.SetInt (1, M_Product_ID);
                //ResultSet rs = pstmt.executeQuery ();
                idr = VAdvantage.DataBase.DB.ExecuteReader(sql, null, trxName);
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();

                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(new MBOM(ctx, dr, trxName));
                }
                //rs.close ();
                //pstmt.close ();
                //pstmt = null;
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                dt = null;
            }
            //try
            //{
            //    if (pstmt != null)
            //        pstmt.close ();
            //    pstmt = null;
            //}
            //catch (Exception e)
            //{
            //    pstmt = null;
            //}

            MBOM[] retValue = new MBOM[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }       //	GetOfProduct
Exemplo n.º 2
0
        /**
         *  Get BOM from Cache
         *	@param ctx context
         *	@param M_BOM_ID id
         *	@return MBOM
         */
        public static MBOM Get(Ctx ctx, int M_BOM_ID)
        {
            int  key      = M_BOM_ID;
            MBOM retValue = (MBOM)_cache[key];

            if (retValue != null)
            {
                return(retValue);
            }
            retValue = new MBOM(ctx, M_BOM_ID, null);
            if (retValue.Get_ID() != 0)
            {
                _cache.Add(key, retValue);
            }
            return(retValue);
        }       //	Get