以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]查询语句  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=86472)

--  作者:syjylyq
--  发布时间:2016/6/18 8:50:00
--  [求助]查询语句

想建立一个查询语句,请问一下代码哪里出错了?

 


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

 

 

 

Dim sd As WinForm.DateTimePicker = e.Form.Controls("StartDate")
Dim ed As WinForm.DateTimePicker = e.Form.Controls("EndDate")
If sd.Value Is Nothing OrElse ed.Value Is Nothing Then
    MessageBox.Show("请输入起始日期和终止日期!","提示", MessageBoxButtons.OK ,MessageBoxIcon.Information)
    e.Cancel = True
ElseIf sd.Value > ed.Value Then
    MessageBox.Show("起始日期大于终止日期!","提示", MessageBoxButtons.OK ,MessageBoxIcon.Information)
    e.Cancel = True
Else
    Tables("产能统计_产能查询").Filter = "[生产交期] >= #" & sd.Value & "# And [生产交期] <= #" & ed.Value & "#"
    Dim t As TimeSpan = ed.Value - sd.Value
    Dim nms() As String = {"横机","半圆机","一","二","三","定型","四","五","手缝","整烫","四包","五包","六","七"}
    Dim c As Single
    Dim str As String = ""
    For Each n As String In nms
        c = DataTables("产能查询").Compute("Sum(e.DataRow(n))", "生产交期 >= #" & sd.Value & "# And 生产交期 <= #" & ed.Value & "#")
        str = n & "产能为:" & c & ","
    Next
    e.form.Controls("查询结果").Text = t.Days & "天各车间产能如下:" & str.trim(",")
End If




--  作者:Hyphen
--  发布时间:2016/6/18 9:37:00
--  
c = DataTables("产能查询").Compute("Sum(" & n & ")", "生产交期 >= #" & sd.Value & "# And 生产交期 <= #" & ed.Value & "#")
--  作者:syjylyq
--  发布时间:2016/6/18 10:01:00
--  

只显示最后一个车间的产能,我这个for each 语句不对吗?

是不是这样:str &= n & "车间产能为:" & c & ","

[此贴子已经被作者于2016/6/18 10:04:47编辑过]

--  作者:Hyphen
--  发布时间:2016/6/18 10:07:00
--  
嗯,str &= n & "车间产能为:" & c & ","
--  作者:syjylyq
--  发布时间:2016/6/18 10:22:00
--  
OK了,谢谢。