以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  重复条件只在一条上显示结果  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=142020)

--  作者:有点蓝
--  发布时间:2019/10/16 17:00:00
--  

If e.DataCol.Name = "材料编码"  Then
dim dr as datarow = e.datatable.find("材料编码=\'" & e.newvalue & "\'","[_Identify]")
Dim b45 As Integer = Date.Today.Year
Dim c45 As Integer = Date.Today.Month
Dim dc01 As New Date(b45, c45, 1)
Dim dc02 As New Date(b45, c45, Date.DaysInMonth(b45, c45)) \'获取本月的最后一天
Dim y01 As Integer = Date.Today.Year
Dim m01 As Integer = Date.Today.Month
Dim dt01 As New Date(y01, m01, 1)
Dim dt02 As New Date(y01, m01, Date.DaysInMonth(y01, m01)) \'获取本月的最后一天
Dim dr02 As DataRow = e.DataRow
Dim dt03 As DataTable =DataTables("出入库明细")
    dr("进仓数量_毛坯来料") = dt03.SQLCompute("sum(入库数量)", "单据日期 >= \'" & dt01  & "\' and 单据日期 <= \'" & dt02 & "\' and 成品编码 = \'" & e.newvalue & "\'  And 单据类型= \'入库\'")
End If

--  作者:有点蓝
--  发布时间:2019/10/16 17:31:00
--  
可以去掉

If e.DataCol.Name = "材料编码"  Then

dim dr as datarow = e.datatable.find("材料编码=\'" & e.newvalue & "\'","[_Identify]")
if dr isnot nothing then
Dim b45 As Integer = Date.Today.Year
Dim c45 As Integer = Date.Today.Month
Dim dc01 As New Date(b45, c45, 1)
Dim dc02 As New Date(b45, c45, Date.DaysInMonth(b45, c45)) \'获取本月的最后一天
Dim y01 As Integer = Date.Today.Year
Dim m01 As Integer = Date.Today.Month
Dim dt01 As New Date(y01, m01, 1)
Dim dt02 As New Date(y01, m01, Date.DaysInMonth(y01, m01)) \'获取本月的最后一天
Dim dr02 As DataRow = e.DataRow
Dim dt03 As DataTable =DataTables("出入库明细")
    dr("进仓数量_毛坯来料") = dt03.SQLCompute("sum(入库数量)", "单据日期 >= \'" & dt01  & "\' and 单据日期 <= \'" & dt02 & "\' and 成品编码 = \'" & e.newvalue & "\'  And 单据类型= \'入库\'")
endif
End If

--  作者:有点蓝
--  发布时间:2019/10/17 10:15:00
--  
上传具体实例说明
--  作者:有点蓝
--  发布时间:2019/10/17 13:57:00
--  
我测试没有问题。按什么步骤测试?
--  作者:有点蓝
--  发布时间:2019/10/17 14:04:00
--  
我测试没有问题

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2019/10/17 14:03:53编辑过]

--  作者:有点蓝
--  发布时间:2019/10/17 14:24:00
--  
这个错误和您上面的问题完全一点关系都没有。是一个非常非常基础的问题:http://www.foxtable.com/webhelp/topics/2343.htm