/// <summary>
        /// Compare based on net amount
        /// throws exception if the arguments' types prevent them from
        ///  being compared by this Comparator.
        /// </summary>
        /// <param name="o1">the first object to be compared.</param>
        /// <param name="o2">the second object to be compared.</param>
        /// <returns>a negative integer, zero, or a positive integer as the
        /// first argument is less than, equal to, or greater than the
        /// second. </returns>
        public new int Compare(PO o1, PO o2)
        {
            if (o1 == null)
            {
                throw new ArgumentException("o1 = null");
            }
            if (o2 == null)
            {
                throw new ArgumentException("o2 = null");
            }
            MRfQResponseLineQty q1 = null;
            MRfQResponseLineQty q2 = null;

            if (o1 is MRfQResponseLineQty)//instanceof
            {
                q1 = (MRfQResponseLineQty)o1;
            }
            else
            {
                throw new Exception("ClassCast--o1");
            }
            if (o2 is MRfQResponseLineQty)//instanceof
            {
                q2 = (MRfQResponseLineQty)o2;
            }
            else
            {
                throw new Exception("ClassCast--o2");
            }
            //
            if (!q1.IsValidAmt())
            {
                return(-99);
            }
            if (!q2.IsValidAmt())
            {
                return(+99);
            }
            Decimal?net1 = q1.GetNetAmt();

            if (net1 == null)
            {
                return(-9);
            }
            Decimal?net2 = q2.GetNetAmt();

            if (net2 == null)
            {
                return(+9);
            }
            return(net1.Value.CompareTo(net2.Value));
        }
Beispiel #2
0
        /// <summary>
        /// Get active Response Qtys of this RfQ Qty
        /// </summary>
        /// <param name="onlyValidAmounts">only valid amounts</param>
        /// <returns>array of response line qtys</returns>
        public MRfQResponseLineQty[] GetResponseQtys(bool onlyValidAmounts)
        {
            List <MRfQResponseLineQty> list = new List <MRfQResponseLineQty>();
            DataTable   dt  = null;
            String      sql = "SELECT * FROM C_RfQResponseLineQty WHERE C_RfQLineQty_ID=" + GetC_RfQLineQty_ID() + " AND IsActive='Y'";
            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, Get_TrxName());
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    MRfQResponseLineQty qty = new MRfQResponseLineQty(GetCtx(), dr, Get_TrxName());
                    if (onlyValidAmounts && !qty.IsValidAmt())
                    {
                        ;
                    }
                    else
                    {
                        list.Add(qty);
                    }
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
                dt = null;
            }

            MRfQResponseLineQty[] retValue = new MRfQResponseLineQty[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
 /// <summary>
 /// Is Net Amount equal ?
 /// </summary>
 /// <param name="obj">the reference object with which to compare.</param>
 /// <returns>true if Net Amount equal</returns>
 public override bool Equals(Object obj)
 {
     if (obj is MRfQResponseLineQty)
     {
         MRfQResponseLineQty cmp = (MRfQResponseLineQty)obj;
         if (!cmp.IsValidAmt() || !IsValidAmt())
         {
             return(false);
         }
         Decimal?cmpNet = cmp.GetNetAmt();
         if (cmpNet == null)
         {
             return(false);
         }
         Decimal?net = cmp.GetNetAmt();
         if (net == null)
         {
             return(false);
         }
         return(cmpNet.Value.CompareTo(net) == 0);
     }
     return(false);
 }