private void Btn_Res_Click(object sender, RoutedEventArgs e) { try { string s = TBx_DepositSum.Text; double DepositSum = Convert.ToDouble(s); s = TBx_DepositDays.Text; int DepositDays = Convert.ToInt32(s); s = TBx_DepositPercents.Text; double DepositPercents = Convert.ToDouble(s); ClassFormula f = new ClassFormula(DepositDays, DepositSum, DepositPercents); // f.Month_and_JN_Calc(); f = f.Calculate(); TBx_CapitalOpeationCount.Text = f.List_ForMonths[f.List_ForMonths.Count - 1].Month; TBx_CapitalDaysCount.Text = f.List_ForMonths[0].days; List <ClassForDataGrid> tst = new List <ClassForDataGrid>(f.List_ForMonths.Count); for (int i = 0; i < f.List_ForMonths.Count; i++) { ClassForDataGrid cfdg = new ClassForDataGrid("0", "0", "0", "0", "0", "0") { Month = f.List_ForMonths[i].Month, DepSum = f.List_ForMonths[i].DepSum, DepPcnt = f.List_ForMonths[i].DepPercent, DepDay = f.List_ForMonths[i].days, Sp = f.List_ForMonths[i].Sp, S = f.List_ForMonths[i].S }; tst.Add(cfdg); } Percents.ItemsSource = tst; } catch (Exception ex) { } }
public ClassFormula Calculate() { bool ok = true; int TempJ = 0; ClassFormula NewF = this; n = 0; NewF.S = NewF.P; while (ok is true) { if ((days - 30) > 0) { j = TempJ = 30; n = n + 1; ok = true; NewF.S = NewF.S * (1 + ((NewF.I * NewF.j) / (365 * 100))); NewF.Sp = NewF.S - NewF.P; ForDataGrid fdg = new ForDataGrid(); fdg.Month = n.ToString(); fdg.DepSum = P.ToString(); fdg.DepPercent = I.ToString(); fdg.days = j.ToString(); fdg.Sp = Sp.ToString(); fdg.S = S.ToString(); List_ForMonths.Add(fdg); days = days - 30; } else { j = days; n = n + 1; ok = false; NewF.S = NewF.S * (1 + ((NewF.I * NewF.j) / (365 * 100))); NewF.Sp = NewF.S - NewF.P; ForDataGrid fdg = new ForDataGrid(); fdg.Month = n.ToString(); fdg.DepSum = P.ToString(); fdg.DepPercent = I.ToString(); fdg.days = j.ToString(); fdg.Sp = Sp.ToString(); fdg.S = S.ToString(); List_ForMonths.Add(fdg); } } if (TempJ != 0) { days = TempJ; } return(NewF); //недоделаные допы...................... /* * ClassFormula NewF = this; * * NewF.S = NewF.P * (1 + ((NewF.I * NewF.j) / (365 * 100))); * NewF.Sp = NewF.S - NewF.P; * * ForDataGrid fdg = new ForDataGrid(); * fdg.Month = "1"; * fdg.DepSum = P.ToString(); * fdg.DepPercent = I.ToString(); * fdg.days = j.ToString(); * fdg.Sp = Sp.ToString(); * fdg.S = S.ToString(); * * List_ForMonths.Add(fdg); * * ForDataGrid fdgN = new ForDataGrid(); * for (int i = 1; i < n; i++) * { * NewF.S = NewF.S * (1 + ((NewF.I * NewF.j) / (365 * 100))); * NewF.Sp = NewF.S - NewF.P; * * fdgN.Month = (i+1).ToString(); * fdgN.DepSum = P.ToString(); * fdgN.DepPercent = I.ToString(); * fdgN.days = j.ToString(); * fdgN.Sp = Sp.ToString(); * fdgN.S = S.ToString(); * * List_ForMonths.Add(fdgN); * } * * return NewF; */ }