Esempio n. 1
0
        void UpdateBorrowInterest()
        {
            float amount    = RoundBorrowAmount();
            int   months    = RoundBorrowMonths();
            bool  canBorrow = amount > 0 && months > 0;

            if (textBlockBorrowInterest != null)
            {
                if (canBorrow)
                {
                    float interest = MyBank.CalculateBorrowInterest(months, amount);
                    textBlockBorrowInterest.Text = interest.ToString("F2") + " % per year";
                }
                else
                {
                    if (amount > 0)
                    {
                        textBlockBorrowInterest.Text = "Select months";
                    }
                    else
                    {
                        textBlockBorrowInterest.Text = "Select amount";
                    }
                }
            }
            if (buttonBorrowMoney != null)
            {
                if (canBorrow)
                {
                    buttonBorrowMoney.IsEnabled = true;
                }
                else
                {
                    buttonBorrowMoney.IsEnabled = false;
                }
            }
        }