Exemplo n.º 1
0
 /// <summary>
 /// checks to see if the user entered a valid currency amount
 /// ie) only 2 decimal places
 /// </summary>
 /// <returns>return true if the currency amount is valid</returns>
 private bool AmountCurrOK()
 {
     // ie) "2.21" => ["2","21"]
     string[] seperate = AmountCurr.Split('.');
     if (seperate.Length == 2 && IsNumeric(seperate[0]) && IsNumeric(seperate[1]))
     {
         string postDecimal = seperate[1];
         if (postDecimal.Length <= 2)
         {
             AmountCurrError = false;
             return true;
         }
         else
         {
             AmountCurrError = true;
             return false;
         }
     }
     // no decimal entered, just integer
     else if (seperate.Length == 1 && IsNumeric(seperate[0]))
     {
         AmountCurrError = false;
         return true;
     }
     else
     {
         AmountCurrError = true;
         return false;
     }
 }
Exemplo n.º 2
0
        private void UpdateTemps()
        {
            if (AmountBtc.Equals("0") || AmountCurr.Equals("0") || String.IsNullOrEmpty(AmountBtc) || String.IsNullOrEmpty(AmountCurr))
            {
                TempBalance = Balance;
                TempBalanceCurr = Math.Round(BalanceCurr,2);
                return;
            }

            decimal remainBtc = Balance.ToDecimal(MoneyUnit.BTC) - decimal.Parse(AmountBtc) - AmountFee.ToDecimal(MoneyUnit.BTC);
            if (remainBtc >= 0)
            {
                TempBalance = Money.FromUnit(remainBtc, MoneyUnit.BTC);
            }
            else
            {                
                TempBalance = 0;
            }

            decimal remainCurr = BalanceCurr - decimal.Parse(AmountCurr) - AmountFeeCurr;
            if (remainCurr >= 0)
            {
                TempBalanceCurr = Math.Round(remainCurr,2);
            }
            else
            {
                
                TempBalanceCurr = 0;
            }
        }