Question about Datatable
c00012
741
Reputation points
Hello,
I want to show payment schedule on datatable like this;
so I wrote a code for handling data like this;
for (int i = 0; i < Convert.ToInt32(Terms) * 12; i++)
{
DataRow dataRow = amortable.NewRow();
dataRow["Terms"] = i + 1;
if(i==Convert.ToInt32(Terms)*12-1)
dataRow["Payment"] = Math.Round(Convert.ToDouble(Payment)+Convert.ToDouble(Residualvalue), 4);
dataRow["Payment"] = Math.Round(Convert.ToDouble(Payment), 4);
dataRow["Interest"] = Math.Round(APR / 12 * Convert.ToDouble(amortable.Rows[i].Field<double>("Balance")), 4);
dataRow["Principal"] = Math.Round(Convert.ToDouble(dataRow["Payment"]) - Convert.ToDouble(dataRow["Interest"]), 4);
dataRow["Balance"] = Math.Round(Convert.ToDouble(amortable.Rows[i].Field<double>("Balance")) - Convert.ToDouble(dataRow["Principal"]), 4);
if (Convert.ToDouble(dataRow["Balance"]) < 0.0)
dataRow["Balance"] = 0.0;
amortable.Rows.Add(dataRow);
}
However, When I run the code I realized this code didn't work.
Full source code: https://github.com/c00012/WpfApp2
please give me an advice to fix an error.
thanks,
c00012
Sign in to answer