Пример #1
0
 private void txtPrincipal_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         FormControlMethods.FormatTextBox((TextBox)sender);
     }
 }
Пример #2
0
        // Calculates the fraction that is being saved.
        private void txtIncome_Leave(object sender, EventArgs e)
        {
            FormControlMethods.FormatTextBox((TextBox)sender);

            decimal income   = decimal.Parse(txtIncome.Text, NumberStyles.Currency);
            decimal spending = decimal.Parse(txtSpending.Text, NumberStyles.Currency);
            decimal savings  = income - spending;

            txtSavings.Text = savings.ToString("C2") + " (" + (savings / income * 100).ToString("0.0") + "%)";
        }
Пример #3
0
        private void txtStockFraction_Leave(object sender, EventArgs e)
        {
            FormControlMethods.FormatTextBox((TextBox)sender);

            double stockFraction = double.Parse(txtStockFraction.Text);
            double bondFraction  = double.Parse(txtBondFraction.Text);

            if (sender.Equals(txtStockFraction))
            {
                bondFraction         = 100f - stockFraction;
                txtBondFraction.Text = bondFraction.ToString("0.0");
            }
            else
            {
                stockFraction         = 100f - bondFraction;
                txtStockFraction.Text = stockFraction.ToString("0.0");
            }
        }
Пример #4
0
        private void txtSpendingFractionGrowth_Leave(object sender, EventArgs e)
        {
            FormControlMethods.FormatTextBox((TextBox)sender);

            double savingsFraction  = double.Parse(txtSavingFractionGrowth.Text);
            double spendingFraction = double.Parse(txtSpendingFractionGrowth.Text);

            if (sender.Equals(txtSavingFractionGrowth))
            {
                spendingFraction = 100f - savingsFraction;
                txtSpendingFractionGrowth.Text = spendingFraction.ToString("0.0");
            }
            else
            {
                savingsFraction = 100f - spendingFraction;
                txtSavingFractionGrowth.Text = savingsFraction.ToString("0.0");
            }
        }
Пример #5
0
 private void txtAge_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         FormControlMethods.FormatTextBox((TextBox)sender);
         if (sender.Equals(txtIncome) || sender.Equals(txtSpending))
         {
             txtIncome_Leave(sender, e);
         }
         else if (sender.Equals(txtSpendingFractionGrowth) || sender.Equals(txtSavingFractionGrowth))
         {
             txtSpendingFractionGrowth_Leave(sender, e);
         }
         else if (sender.Equals(txtStockFraction) || sender.Equals(txtBondFraction))
         {
             txtStockFraction_Leave(sender, e);
         }
     }
 }
Пример #6
0
 private void txtPrincipal_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
 {
     FormControlMethods.FixTextBoxCursor((TextBox)sender, e);
 }
Пример #7
0
 private void txtPrincipal_Leave(object sender, EventArgs e)
 {
     FormControlMethods.FormatTextBox((TextBox)sender);
 }
Пример #8
0
 private void txtPrincipal_KeyPress(object sender, KeyPressEventArgs e)
 {
     FormControlMethods.GarbageNonText(sender, e);
 }
Пример #9
0
 private void txtAge_Leave(object sender, EventArgs e)
 {
     FormControlMethods.FormatTextBox((TextBox)sender);
     txtSavingsGoal.Text = GetGoal();
 }