コード例 #1
0
        }   //  getClientAcctSchema

        // by amit 23-12-2015
        public static MAcctSchema[] GetClientAcctSchemas(Ctx ctx, int AD_Client_ID, Trx trxName)
        {
            //  Check Cache
            int key = AD_Client_ID;

            if (_schema.ContainsKey(key))
            {
                return((MAcctSchema[])_schema[key]);
            }

            //  Create New
            List <MAcctSchema> list = new List <MAcctSchema>();
            MClientInfo        info = MClientInfo.Get(ctx, AD_Client_ID, trxName);
            MAcctSchema        ass  = MAcctSchema.Get(ctx, info.GetC_AcctSchema1_ID(), trxName);

            if (ass.Get_ID() != 0 && trxName == null)
            {
                list.Add(ass);
            }

            //	Other
            String sql = "SELECT C_AcctSchema_ID FROM C_AcctSchema acs "
                         + "WHERE IsActive='Y'";

            if (AD_Client_ID != 0)
            {
                sql += " AND AD_Client_ID=" + AD_Client_ID;
            }
            sql += " ORDER BY C_AcctSchema_ID";

            IDataReader dr = null;

            try
            {
                dr = DataBase.DB.ExecuteReader(sql, null, trxName);
                while (dr.Read())
                {
                    int id = Utility.Util.GetValueOfInt(dr[0].ToString());
                    if (id != info.GetC_AcctSchema1_ID())       //	already in list
                    {
                        ass = MAcctSchema.Get(ctx, id, trxName);
                        if (ass.Get_ID() != 0 && trxName == null)
                        {
                            list.Add(ass);
                        }
                    }
                }
                dr.Close();
                dr = null;
            }
            catch (System.Data.Common.DbException e)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
            }
            //  Save
            MAcctSchema[] retValue = new MAcctSchema[list.Count];
            retValue = list.ToArray();
            if (trxName == null)
            {
                _schema.Add(key, retValue);
            }
            return(retValue);
        }   //  getClientAcctSchema