Пример #1
0
        override public Debt CloneDebt()
        {
            Debt clone = new Amortized();

            clone.order          = order;
            clone.interestPaid   = interestPaid;
            clone.maxPayment     = maxPayment;
            clone.apr            = apr;
            clone.interestFactor = interestFactor;
            clone.period         = period;
            clone.months         = months;
            clone.annualFees     = annualFees;
            clone.feesMonth      = feesMonth;
            clone.feesPaid       = feesPaid;
            clone.paidOff        = paidOff;
            clone.payment        = payment;
            clone.principalLeft  = principalLeft;
            clone.resultsPanel   = resultsPanel;
            return(clone);
        }
Пример #2
0
        // parse active main panel data to create a list of debt objects
        private DebtManager CreateDebtList(List <Panel> activePanels)
        {
            DebtManager debtManager = new DebtManager();

            foreach (Panel p in activePanels)
            {
                List <Control> controls         = GetControls(p);
                List <Control> matchingControls = GetControls(GetPanel(p, 1));
                ListBox        type             = controls[2] as ListBox;
                ListBox        structure        = controls[3] as ListBox;
                NumericUpDown  order            = controls[10] as NumericUpDown;

                if (type.Text == "Amortized Loan")
                {
                    Amortized debt = new Amortized();
                    // extract info from input boxes
                    debt.payment = Convert.ToDouble(controls[4].Text);
                    if (rollover.Checked)
                    {
                        debt.maxPayment = Convert.ToDouble(controls[5].Text);
                    }

                    debt.order = (int)order.Value;

                    debt.principalLeft = Convert.ToDouble(matchingControls[0].Text);
                    debt.apr           = Convert.ToDouble(matchingControls[1].Text) / 100;
                    debt.annualFees    = Convert.ToDouble(matchingControls[2].Text);
                    NumericUpDown feesMonthUpDown = matchingControls[3] as NumericUpDown;
                    debt.feesMonth = (int)feesMonthUpDown.Value;

                    debt.resultsPanel = GetPanel(p, 2);

                    // set compounding period and interestFactor
                    if (structure.Text == "Daily")
                    {
                        debt.period = 365.25;
                    }
                    else if (structure.Text == "Monthly")
                    {
                        debt.period = 12;
                    }
                    debt.CalculateInterestFactor();

                    // add completed debt object to list
                    debtManager.Add(debt);
                }
                else if (type.Text == "Credit Card/Line")
                {
                    CreditCard debt = new CreditCard();

                    // extract info from text boxes
                    debt.payment = Convert.ToDouble(controls[4].Text);
                    if (rollover.Checked)
                    {
                        debt.maxPayment = Convert.ToDouble(controls[5].Text);
                    }

                    debt.order = (int)order.Value;

                    debt.principalLeft = Convert.ToDouble(matchingControls[0].Text);
                    debt.apr           = Convert.ToDouble(matchingControls[1].Text) / 100;
                    debt.annualFees    = Convert.ToDouble(matchingControls[2].Text);
                    NumericUpDown feesMonthUpDown = matchingControls[3] as NumericUpDown;
                    debt.feesMonth = Convert.ToInt16(feesMonthUpDown.Value);

                    debt.resultsPanel = GetPanel(p, 2);

                    // set compounding period and interestFactor
                    if (structure.Text == "Daily")
                    {
                        debt.period = 365.25;
                    }
                    else if (structure.Text == "Monthly")
                    {
                        debt.period = 12;
                    }
                    debt.CalculateInterestFactor();

                    // add completed debt object to list
                    debtManager.Add(debt);
                }
                else if (type.Text == "Add-on Loan")
                {
                    AddOn debt = new AddOn();

                    // extract info from text boxes
                    debt.payment = Convert.ToDouble(controls[4].Text);
                    if (rollover.Checked)
                    {
                        debt.maxPayment = Convert.ToDouble(controls[5].Text);
                    }

                    debt.order = (int)order.Value;

                    debt.principalLeft = Convert.ToDouble(matchingControls[0].Text);
                    debt.annualFees    = Convert.ToDouble(matchingControls[1].Text);
                    NumericUpDown feesMonthUpDown = matchingControls[2] as NumericUpDown;
                    debt.feesMonth = Convert.ToInt16(feesMonthUpDown.Value);

                    debt.resultsPanel = GetPanel(p, 2);

                    // add completed debt object to list
                    debtManager.Add(debt);
                }
            }
            debtManager.Sort((d1, d2) => d1.order.CompareTo(d2.order));
            return(debtManager);
        }