以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  是否代码有误  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=54759)

--  作者:hcx0522
--  发布时间:2014/8/4 11:37:00
--  是否代码有误


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

 

Select Case e.DataCol.name
    Case "数量","单价","存货名称","数量","金额"
        If e.DataRow.Isnull("数量") Then
            e.DataRow("金额") = Nothing
        Else
            e.DataRow("金额") = e.DataRow("单价") * e.DataRow("数量")
        End If
       
        For Each dr As DataRow In DataTables("盘点表").DataRows
        \' dr("本月入库数量") = 0
        Next
        Dim fdr As DataRow = DataTables("盘点表").Find("存货名称 =\'" & e.DataRow("存货名称") & "\'")
       \' MessageBox.show(fdr Is Nothing)
        If fdr IsNot Nothing Then
           Dim d As Date = new Date(Date.Today.Year,Date.Today.Month,1)
         \' MessageBox.show(DataTables("进仓").Compute("sum(数量)","存货名称 =\'" & e.DataRow("存货名称")  & "\' And 日期 >= #" & d & "# and 日期 < #" & d.AddMonths(1) & "#"))
            fdr("本月入库数量") = DataTables("进仓").Compute("sum(数量)","存货名称 =\'" & e.DataRow("存货名称")  & "\' And 日期 >= #" & d & "# and 日期 < #" & d.AddMonths(1) & "#")
        End If
    Case "日期"
        e.DataRow("年月")= Format(e.DataRow("日期"),"yyyyMM")
End Select

请问我的代码错在哪了,为什么不能统计呢?


--  作者:有点甜
--  发布时间:2014/8/4 11:46:00
--  

 现在是8月,统计的肯定是8月的数据啊。

 

fdr("本月入库数量") = DataTables("进仓").Compute("sum(数量)","存货名称 =\'" & e.DataRow("存货名称")  & "\' And 日期 >= #" & d & "# and 日期 < #" & d.AddMonths(1) & "#")

 

 如果要统计全部,就把日期去掉

 

fdr("本月入库数量") = DataTables("进仓").Compute("sum(数量)","存货名称 =\'" & e.DataRow("存货名称")  & "\'")