Ejemplo n.º 1
0
 private void calculate_button_Click(object sender, EventArgs e)
 {
     try
     {
         List <Debt> credit_list = new List <Debt>();
         Credit      credit      = new Credit(Convert.ToDouble(credit_amount_box.Text),
                                              Convert.ToInt32(credit_term_box.Value),
                                              Convert.ToDouble(interest_rate_box.Text),
                                              Credit.PaymentType(payment_type_box.Text),
                                              Credit.ToDate(month_box.Text, year_box.Text));
         int  m    = month_box.SelectedIndex;
         int  y    = year_box.SelectedIndex;
         Debt debt = new Debt(credit);
         for (int i = 0; i < credit.Credit_term * 12; i++)
         {
             debt = new Debt(credit);
             string month = month_collection[m];
             string year  = year_collection[y];
             debt.Date = month + " " + year;
             debt.Calculate_main_debt(credit);
             debt.Calculate_interest_changes(credit);
             debt.Calculate_monthly_payment(credit);
             credit_list.Add(debt);
             if (m == 11)
             {
                 m = 0;
                 y++;
             }
             else
             {
                 m++;
             }
             credit.Credit_amount -= debt.Debt_balance;
         }
         credit_table.DataSource = credit_list;
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }