public void interest_payment_dates(int AppID, int AccID, DateTime date, int duration) { LoanDSTableAdapters.InsertInterestDateTableAdapter intDates = new LoanDSTableAdapters.InsertInterestDateTableAdapter(); DateTime startDate = date; DateTime[] curentDate = new DateTime[duration]; string strDate; for (int i = 0; i < 12; i++) { if (i == 0) { curentDate[i] = startDate; strDate = startDate.Month.ToString() + "-" + startDate.Day.ToString(); intDates.InsertInterestDates(AccID, AppID, strDate); } else { DateTime dt = startDate.AddMonths(i); int prevMnths = curentDate[i - 1].Month; if (dt.Month > prevMnths + 1) { dt = lastDay(curentDate[i - 1].Month, curentDate[i - 1].Year); strDate = dt.Month.ToString() + "-" + dt.Day.ToString(); intDates.InsertInterestDates(AccID, AppID, strDate); } else { curentDate[i] = dt; strDate = dt.Month.ToString() + "-" + dt.Day.ToString(); intDates.InsertInterestDates(AccID, AppID, strDate); } } } }
public void interest_payment_dates(int AppID,int AccID,DateTime date,int duration) { LoanDSTableAdapters.InsertInterestDateTableAdapter intDates = new LoanDSTableAdapters.InsertInterestDateTableAdapter(); DateTime startDate=date; DateTime[] curentDate = new DateTime[duration]; string strDate; for (int i = 0; i<12; i++) { if (i == 0) { curentDate[i] = startDate; strDate = startDate.Month.ToString() + "-" + startDate.Day.ToString(); intDates.InsertInterestDates(AccID, AppID, strDate); } else { DateTime dt = startDate.AddMonths(i); int prevMnths = curentDate[i - 1].Month; if (dt.Month > prevMnths + 1) { dt = lastDay(curentDate[i - 1].Month, curentDate[i - 1].Year); strDate = dt.Month.ToString() + "-" + dt.Day.ToString(); intDates.InsertInterestDates(AccID, AppID, strDate); } else { curentDate[i] = dt; strDate = dt.Month.ToString() + "-" + dt.Day.ToString(); intDates.InsertInterestDates(AccID, AppID, strDate); } } } }