Ejemplo n.º 1
0
 public static void InsertMoneyParam(string pParamName, SqlCommand pCommand, OCurrency? pVal)
 {
     if (!pVal.HasValue)
     {
         pCommand.Parameters.AddWithValue(pParamName, SqlMoney.Null);
     }
     else
     {
         pCommand.Parameters.Add(pParamName, SqlDbType.Money);
         pCommand.Parameters[pParamName].Value = pVal.Value;
     }
 }
Ejemplo n.º 2
0
 public static int Compare(OCurrency o1, OCurrency o2, int installmentNumber)
 {
     if (o1 - o2 > (OcurrencyDelta*(double)installmentNumber) )return 1;
     else if (o2 - o1 > (OcurrencyDelta * (double)installmentNumber)) return -1;
     else return 0;
 }
Ejemplo n.º 3
0
 public OCurrency(OCurrency obj)
 {
     _currency = obj._currency;
 }
Ejemplo n.º 4
0
 public static bool Equals(OCurrency a1, OCurrency a2)
 {
     return Math.Abs(a1.Value - a2.Value) < OcurrencyDelta.Value ? true : false;
 }
Ejemplo n.º 5
0
 public static int Compare(OCurrency o1, OCurrency o2)
 {
     if (o1 - o2 > OcurrencyDelta) return 1;
     else if (o2 - o1 > OcurrencyDelta) return -1;
     else return 0;
 }
Ejemplo n.º 6
0
 //add a function to convert string to OCurrency
 public static OCurrency ConvertStringToDecimal(string text, OCurrency defaultValue, bool useCents)
 {
     if (!string.IsNullOrEmpty(text))
     {
         try
         {
             return new OCurrency(Math.Round(Convert.ToDecimal(text), useCents ? 2 : 0, MidpointRounding.AwayFromZero));
         }
         catch
         {
             throw new OctopusRepayException(OctopusRepayExceptionsEnum.AmountIsNull);
         }
     }
     return defaultValue;
 }
Ejemplo n.º 7
0
 // a function to convert string to OCurrency
 public static OCurrency? ConvertStringToNullableDecimal(string text, OCurrency defaultValue)
 {
     if (!string.IsNullOrEmpty(text))
     {
         try
         {
             return  new OCurrency( Convert.ToDecimal(text));
         }
         catch
         {
             return defaultValue;
         }
     }
     return null;
 }
Ejemplo n.º 8
0
 //convert OCurrency to string
 public static string ConvertNullableDecimalToString(OCurrency  number)
 {
     if (number.HasValue)
     {
         try
         {
             return number.GetFormatedValue(true);
         }
         catch
         {
             return String.Empty;
         }
     }
     return String.Empty;
 }
Ejemplo n.º 9
0
 // add a function to convert OCurrency to nullable int32
 public static int? ConvertDecimalToNullableInt32(OCurrency number)
 {
     try
     {
         return Convert.ToInt32(number.Value);
     }
     catch
     {
         return null;
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Check If Min Max And Value correctly Filled
        /// </summary>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="fixedValue"></param>
        /// <returns>true/false</returns>
        public static bool CheckMinMaxAndValueCorrectlyFilled(OCurrency min, OCurrency max, OCurrency fixedValue)
        {
            bool returned = false;

            if (min.HasValue && max.HasValue&& !fixedValue.HasValue)
                returned = CheckIfMinLowerThanMax(min, max);

            else if (!min.HasValue && !max.HasValue && fixedValue.HasValue)
                returned = true;

            return returned;
        }
Ejemplo n.º 11
0
 public static bool CheckIfValueBetweenMinAndMax(OCurrency  min, OCurrency max, OCurrency number)
 {
     bool result = false;
     if (number <= max && number >= min) result = true;
     return result;
 }
Ejemplo n.º 12
0
        ///<summary>
        ///this methode check if first param lower than second param
        ///</summary>
        ///<param name="a">first param</param>
        ///<param name="b">second param</param>
        ///<returns>true if first param lower than second</returns>
        ///<returns>false if second param lower than first</returns>
        public static bool CheckIfMinLowerThanMax( OCurrency? a, OCurrency? b)
        {
            bool result = false;
            if (a < b)
                result=true;

            return result;
        }