Esempio n. 1
0
 /**
  *  Set default PriceList
  */
 public void SetM_PriceList_ID()
 {
     try
     {
         MPriceList defaultPL = MPriceList.GetDefault(GetCtx(), false);
         if (defaultPL == null)
         {
             defaultPL = MPriceList.GetDefault(GetCtx(), true);
         }
         if (defaultPL != null)
         {
             SetM_PriceList_ID(defaultPL.GetM_PriceList_ID());
         }
     }
     catch (Exception ex)
     {
         // MessageBox.Show("MRequisition--SetM_PriceList_ID");
         log.Severe(ex.ToString());
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Get Default Price List for Client (cached)
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="IsSOPriceList">SO or PO</param>
        /// <returns>PriceList or null</returns>
        public static MPriceList GetDefault(Ctx ctx, bool IsSOPriceList)
        {
            int        AD_Client_ID = ctx.GetAD_Client_ID();
            MPriceList retValue     = null;
            //	Search for it in cache
            //Iterator<MPriceList> it = _cache.values().iterator();
            IEnumerator <MPriceList> it = _cache.Values.GetEnumerator();

            while (it.MoveNext())
            {
                retValue = (MPriceList)it.Current;
                if (retValue.IsDefault() && retValue.GetAD_Client_ID() == AD_Client_ID)
                {
                    return(retValue);
                }
            }

            //Get from DB
            retValue = null;
            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM M_PriceList "
                       + "WHERE AD_Client_ID=" + AD_Client_ID + " AND IsDefault='Y'");
            if (IsSOPriceList)
            {
                //pstmt.setString(2, "Y");
                sql.Append(" AND IsSOPriceList='Y'"); // YS: Changed from hard code to Parameter
            }
            else
            {
                //pstmt.setString(2, "N");
                sql.Append(" AND IsSOPriceList='N'"); // YS: Changed from hard code to Parameter
            }
            sql.Append("ORDER BY M_PriceList_ID");

            //String sql = "SELECT * FROM M_PriceList "
            //    + "WHERE AD_Client_ID=" + AD_Client_ID
            //    + " AND IsDefault='Y'"
            //    + " AND IsSOPriceList=?" // YS: Changed from hard code to Parameter
            //    + "ORDER BY M_PriceList_ID";
            DataSet ds = null;

            try
            {
                ds = ExecuteQuery.ExecuteDataset(sql.ToString(), null);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    retValue = new MPriceList(ctx, dr, null);
                }
            }
            catch (Exception e)
            {
                ds = null;
                _log.Log(Level.SEVERE, sql.ToString(), e);
            }
            //	Return value
            if (retValue != null)
            {
                int key = retValue.GetM_PriceList_ID();
                _cache.Add(key, retValue);
            }
            return(retValue);
        }
Esempio n. 3
0
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="pl">parent</param>
 public MPriceListVersion(MPriceList pl)
     : this(pl.GetCtx(), 0, pl.Get_TrxName())
 {
     SetClientOrg(pl);
     SetM_PriceList_ID(pl.GetM_PriceList_ID());
 }