/// <summary>
        /// CreatedBy:Piyumi
        /// CreatedDate:2016/2/5
        /// insert details of interest which related to a loan
        /// </summary>
        /// <returns>countval</returns>
        public int insertInterestDetails(Interest interest)
        {
            DataHandler dataHandler = new DataHandler();
            List<object[]> paramertList = new List<object[]>();            

            paramertList.Add(new object[] { "@interest_rate", interest.InterestRate });
            paramertList.Add(new object[] { "@paid_date", interest.PaidDate });
            paramertList.Add(new object[] { "@payment_period", interest.PaymentPeriod });
            paramertList.Add(new object[] { "@auto_remind_email", interest.AutoRemindEmail });
            paramertList.Add(new object[] { "@auto_remind_period", interest.RemindPeriod });
            paramertList.Add(new object[] { "@loan_id", interest.LoanId });
            paramertList.Add(new object[] { "@accrual_method_id", interest.AccrualMethodId });           

            try
            {
                return dataHandler.ExecuteSQLReturn("spInsertInterestDetails", paramertList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// CreatedBy:Piyumi
        /// CreatedDate:2016/2/7
        /// Get details of interest related to given loanId
        /// </summary>
        /// <param name="loanId"></param>
        /// <returns>InterestObject</returns>
        public Interest getInterestDetails(int loanId)
        {
            DataHandler dataHandler = new DataHandler();
            List<object[]> paramertList = new List<object[]>();
            paramertList.Add(new object[] { "@loan_id", loanId });

            DataSet dataSet = dataHandler.GetDataSet("spGetInterestDetailsByLoanId", paramertList);
            if (dataSet != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows.Count != 0)
            {
                Interest interest = new Interest();
                DataRow dataRow = dataSet.Tables[0].Rows[0];

                interest.InterestRate = decimal.Parse(dataRow["interest_rate"].ToString());
                if ((dataRow["paid_date"].ToString().Contains("d"))||(dataRow["paid_date"].ToString().Contains("m")))
                {
                    interest.option = "payoff";
                    interest.PaidDate = "payoff";
                }
                else
                {
                    interest.option = "once a month";
                    interest.PaidDate = dataRow["paid_date"].ToString();
                }
                interest.PaymentPeriod = dataRow["payment_period"].ToString();
                interest.AccrualMethodId = int.Parse(dataRow["accrual_method_id"].ToString());
                interest.AutoRemindEmail = dataRow["auto_remind_email"].ToString();
                if ((interest.AutoRemindEmail != null) && (interest.AutoRemindEmail != ""))
                {
                    interest.NeedReminder = true;
                }
                interest.RemindPeriod = int.Parse(dataRow["auto_remind_period"].ToString());
                interest.LoanId = int.Parse(dataRow["loan_id"].ToString());
                return interest;
            }
            else
            {
                return null;
            }           
        }