以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于日期的代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=159643)

--  作者:爱相随
--  发布时间:2021/1/2 21:46:00
--  关于日期的代码

老师,下面代码是关日期的地方不对,不知道怎么做了,请指导,谢谢!!

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


--  作者:有点蓝
--  发布时间:2021/1/3 11:14:00
--  
      If e.DataRow("日期") < dt1 Then
         e.DataRow("本月折旧") = dr("月折旧额") 
      ElseIf dt1 <= e.DataRow("日期") andalso e.DataRow("日期") <= dt2  Then
         e.DataRow("本月折旧") = dr("资产净值") - dr("净残值") 
      Else
         e.DataRow("本月折旧") = 0 
      End If  
--  作者:爱相随
--  发布时间:2021/1/3 14:20:00
--  

谢谢老师