老师,下面代码是关日期的地方不对,不知道怎么做了,请指导,谢谢!!
If e.DataCol.Name = "资产编码" Then '发生变化的是产品编号吗?
'在产品表找出该产品
Dim dr As DataRow
dr = DataTables("固定资产卡片").Find("资产编码 = '" & e.DataRow("资产编码") & "'" )
If dr IsNot Nothing '如果找到, 则设置各列内容
Dim y As Integer = Year(e.DataRow("结束计提折旧日期"))
Dim m As Integer = Month(e.DataRow("结束计提折旧日期"))'指定月份
Dim dt1 As New Date(y, m, 1)
Dim dt2 As New Date(y, m, Date.DaysInMonth(y,m)) '获取该月的最后一天
If e.DataRow("日期") < #" & dt1 & "# Then
e.DataRow("本月折旧") = dr("月折旧额")
ElseIf #" & dt1 <= e.DataRow("日期") <= #" & dt2 & "# Then
e.DataRow("本月折旧") = dr("资产净值") - dr("净残值")
Else
e.DataRow("本月折旧") = 0
End If
End If
End If