以下是引用裴保民在2018/2/13 9:58:00的发言:
甜老师:月有大小月,每年2月份天数都不一样,光月份+1能行吗?
起始日、结束日,没问题,只有到期还款日,需要重新计算,如
Dim dt_xyk As DataTable = DataTables("信用卡")
Dim dt_lsz As DataTable = DataTables("流水账")
Dim dt_yk As DataTable = DataTables("用卡")
dt_yk .DataRows.Clear
Dim d As Date = new Date(Date.Today.Year, Date.Today.Month, 1)
Dim ds() As Date = {d, d.AddMonths(1)}
d = d.AddMonths(-1)
For Each dr As DataRow In dt_xyk.DataRows
Dim ndr As DataRow = dt_yk .AddNew
ndr("卡号") = dr("卡号")
ndr("账户名称") = dr("账户名称")
ndr("信用额度") = dr("信用额度")
ndr("账单日") =dr("账单日")
ndr("还款日") =dr("还款日")
ndr("可用额度") = ndr("信用额度") -(dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 类别 = '转出'"))-(dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 类别 = '转入'"))
If dr("账单日")+1 <= Date.today.day Then
ndr("起始记账日") = d.AddDays(dr("账单日")).AddMonths(1)
ndr("结束记账日") = d.AddDays(dr("账单日")-1).AddMonths(2)
Else
ndr("起始记账日") = d.AddDays(dr("账单日")).AddMonths(0)
ndr("结束记账日") = d.AddDays(dr("账单日")-1).AddMonths(1)
End If
ndr("固定还款日") = dr("固定还款日")
If dr("固定还款日") = False Then
ndr("到期还款日") = cdate(ndr("结束记账日")).AddDays(dr("还款日"))
Else
ndr("到期还款日") = d.AddDays(dr("还款日")-1).AddMonths(2)
End If
Dim begin As Date
Dim enddate As Date
If dr("账单日")+1 <= Date.today.day Then
begin = d.AddDays(dr("账单日")).AddMonths(1)
enddate = d.AddDays(dr("账单日")-1).AddMonths(2)
Else
begin = d.AddDays(dr("账单日")).AddMonths(0)
enddate = d.AddDays(dr("账单日")-1).AddMonths(1)
End If
Dim dq As Date
If dr("固定还款日") = False Then
dq = enddate.AddDays(dr("还款日"))
Else
dq = d.AddDays(dr("还款日")-1).AddMonths(2)
End If
Dim jishu As Date
Dim zdts As Integer
jishu = ndr("结束记账日")
zdts =(jishu - Date.today).TotalDays
If zdts < = 5 Then
ndr = dt_yk .AddNew
ndr("卡号") = dr("卡号")
ndr("账户名称") = dr("账户名称")
ndr("信用额度") = dr("信用额度")
ndr("账单日") =dr("账单日")
ndr("还款日") =dr("还款日")
ndr("可用额度") = ndr("信用额度") -(dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 类别 = '转出'"))-(dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 类别 = '转入'"))
ndr("起始记账日") = begin.AddMonths(1)
ndr("结束记账日") = enddate.AddMonths(1)
If dr("固定还款日") = False Then
dq = enddate.addmonths(1).AddDays(dr("还款日"))
Else
dq = d.AddDays(dr("还款日")-1).AddMonths(3)
End If
ndr("到期还款日") =dq
ndr("固定还款日") = dr("固定还款日")
ndr("剩余免息天数") =-1*(enddate - Date.today).TotalDays-1
End If
Next
Tables("用卡").sort = "排序列,剩余免息天数 desc"