i'm on a college course and part of it is studying programming, my current assignment is to create a basic application for a user to view customer, accounts, products and transfer databases. We are using windows forms app in visual studio and sqlite. i have it set up so you can view each table in a datagridview. i am able to update,add,delete each one. Part of the accounts table includes ISA balance and the daily accrued amount and the product able includes the interest rate for each product. What i need to do now is be able to update the accrued column for each account when the table is loaded. I have created method for calculating the number of days passed since the start of financial year and store it into a variable. I need now to go through the accounts table to get the balance and product type they have and the go through the product table to find the interest rate of each product and then calculate the accrued and update the accrued table with the new value.
private void days()
{
year = DateTime.Now.Year - 1;
DateTime start = new DateTime(year, 03, 13);
DateTime end = DateTime.Today;
TimeSpan span = end - start;
difference = span.Days;
}
I have a variable setup to store the product i and a method ready to run make the calulations based on what the product id is.
if(Global.productID == "1")
{
interestRate = 0.03/365;
Global.accrued = (interestRate * double.Parse(Global.balance))* difference;
}
if (Global.productID == "2")
{
interestRate = 0.07/365;
Global.accrued = (interestRate * double.Parse(Global.balance)) * difference;
}
I'm at a loss as to where to go from here so any help or guidance would be appreciated
foreach (DataRow row in dt_Accounts.Rows)
{
Global.productID = row["prodid"].ToString();
Global.balance = row["balance"].ToString();
interest();
row["accrued"] = Global.accrued.ToString();
}
i have tried the code above but that didnt work