private void frmMain_Load(object sender, EventArgs e)
        {
            debtList = new DebtList();
            comboBox1.SelectedIndex = 0;

            path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\debtsnowball.xml";
            if (File.Exists(path))
            {
                debtList = DebtList.Load(path);
                RefreshData();
            }
        }
        public void RefreshData()
        {
            try
            {
                try
                {
                    txtExtraPayment.Text  = debtList.InitialSnowball.ToString();
                    dateTimePicker1.Value = debtList.InitialSnowballStart;
                }
                catch { }

                gvDebts.DataSource = null;
                gvDebts.DataSource = debtList.Debts;

                gvSnowball.DataSource = null;
                List <DebtPaymentDisplay> dpds = new List <DebtPaymentDisplay>();

                DebtList.SnowballApproaches sa = DebtList.SnowballApproaches.MyOrder;
                switch (comboBox1.SelectedIndex)
                {
                case 1: sa = DebtList.SnowballApproaches.LowestBalanceFirst;
                    break;

                case 2: sa = DebtList.SnowballApproaches.HighestInterestFirst;
                    break;
                }


                foreach (DebtPayment dp in debtList.ProcessPlan(true, sa, Convert.ToDouble(txtExtraPayment.Text), dateTimePicker1.Value))
                {
                    dpds.Add(new DebtPaymentDisplay(dp));
                }
                gvSnowball.DataSource = dpds;
                gvSnowball.FirstDisplayedScrollingRowIndex = gvSnowball.RowCount - 1;

                /* --------------------- */
                dgvNonSnowball.DataSource = null;
                List <DebtPaymentDisplay> dpds2 = new List <DebtPaymentDisplay>();
                foreach (DebtPayment dp in debtList.ProcessPlan(false, sa, Convert.ToDouble(txtExtraPayment.Text)))
                {
                    dpds2.Add(new DebtPaymentDisplay(dp));
                }
                dgvNonSnowball.DataSource = dpds2;
                dgvNonSnowball.FirstDisplayedScrollingRowIndex = dgvNonSnowball.RowCount - 1;
                /* -----------------------*/

                debtList           = DebtList.Load(path);
                gvDebts.DataSource = null;

                List <DebtDisplay> dds = new List <DebtDisplay>();
                foreach (Debt d in debtList.Debts)
                {
                    dds.Add(new DebtDisplay(d));
                }
                gvDebts.DataSource = dds;

                foreach (DataGridViewRow d in gvDebts.Rows)
                {
                    d.Selected = false;
                }

                dgvExtraPayments.DataSource = null;

                List <ExtraPaymentDisplay> epds = new List <ExtraPaymentDisplay>();
                foreach (ExtraPayment ep in debtList.ExtraPayments)
                {
                    epds.Add(new ExtraPaymentDisplay(ep));
                }

                dgvExtraPayments.DataSource = epds; //debtList.ExtraPayments;
                foreach (DataGridViewRow d in dgvExtraPayments.Rows)
                {
                    d.Selected = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }