以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 帮忙看看这个代码怎么修改? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=40170) |
-- 作者:blackzhu -- 发布时间:2013/9/11 11:17:00 -- 帮忙看看这个代码怎么修改? \'\'\'... Dim y As Integer = Date.Today.Year Dim m As Integer = Date.Today.Month Dim s_date As New Date(y, m-1,22) Dim e_date As New Date(y, m,21) Dim Filter As String Filter = "日期 >= \'" & s_date & "\' And 日期 <= \'" & e_date & "\'" DataTables("十监区管理").LoadFilter = Filter & "And 区分 =\'砂场生产数据录入\'" DataTables("十监区管理").Load Dim ls As New List(Of String) Do While s_date < e_date.AddDays(-7) ls.Add("日期>=\'" & s_date & "\' And 日期<=\'" & s_date.AddDays(6) & "\'") s_date = s_date.AddDays(7) Loop ls.Add("日期>=\'" & s_date & "\' And 日期<=\'" & e_date & "\'") Dim dtb As New DataTableBuilder("统计") dtb.AddDef("部门", Gettype(String), 50) dtb.AddDef("年", Gettype(String), 50) dtb.AddDef("月", Gettype(String), 50) dtb.AddDef("组别", Gettype(String), 50) dtb.AddDef("管组民警", Gettype(String), 50) dtb.AddDef("项目", Gettype(String), 50) Dim 周别 As Integer For Each l As String In ls 周别+=1 dtb.AddDef("第" & 周别 & "周", GetType(Double)) Next Tables(e.Form.Name & "_Table1").DataSource = dtb.BuildDataSource Dim i As Integer For Each v As String() In DataTables("十监区管理").GetUniqueValues("","部门","年","月","组别","管组民警") Dim s() As String ={"总产量(KG)","总废品(KG)","废品率(%)"} For i = 0 To s.Length -1 Dim dr1 As DataRow = Tables(e.form.Name & "_Table1").DataTable.AddNew() dr1("部门") = v(0) dr1("年") = v(1) dr1("月") = v(2) dr1("组别") = v(3) dr1("管组民警") = v(4) dr1("项目") = s(i) Next Next Dim Arys As List(Of String()) Dim Ar As DataRow Dim dt1 As Date Dim dt2 As Date Dim Filter1 As String Dim Val,Val1,Val2,Val3 As Double Arys = DataTables("十监区管理").GetUniqueValues("","部门","年","月","组别","管组民警") For Each Ary As String() In Arys Filter = "[部门] = \'" & Ary(0) & "\'And 年=\'" & Ary(1) & "\'And 月 = \'" & Ary(2) & "\'And 组别=\'" & Ary(3) & "\'And 管组民警=\'" & Ary(4) & "\' And 项目=\'总产量(KG)\'" If Filter > "" Then Ar = DataTables(e.form.Name & "_Table1").Find(Filter) If Ar IsNot Nothing Then For Each l As String In ls Filter1 = l & " And [部门] = \'" & Ary(0) & "\'And 年=\'" & Ary(1) & "\'And 月 = \'" & Ary(2) & "\'And 组别=\'" & Ary(3) & "\'And 管组民警=\'" & Ary(4) & "\' And 区分 =\'砂场生产数据录入\'" Val= DataTables("十监区管理").Compute("Sum(数值)",Filter1 & " And 数据统计项目=\'总成品(个)\'") Val1= DataTables("十监区管理").Compute("Sum(数值)",Filter1 & " And 数据统计项目=\'单重(公斤)\'") Val2 = Val * Val1 MessageBox.Show(Filter1 & " And 数据统计项目=\'总成品(个)\'") MessageBox.Show("总成品数:" & Val & "单重:" & Val1 & "总产量:" & Val2) If Val2 > 0 Then Ar("第" & 周别 & "周") = Val2 Else Ar("第" & 周别 & "周") = 0 End If Next End If End If Next e.Sender.Checked = False 这个代码应该怎么改? 先根据日期生成几个星期周列(例如 第一周,第二周),然后计算这个日期的时间段的数值,写入想对应的星期周的 总产量(KG) 的行中
|
-- 作者:Bin -- 发布时间:2013/9/11 11:19:00 -- 好歹有个例子才好测试吧. |
-- 作者:blackzhu -- 发布时间:2013/9/11 11:26:00 -- 那我做个吧 |
-- 作者:blackzhu -- 发布时间:2013/9/11 11:32:00 -- 例子来了: |
-- 作者:Bin -- 发布时间:2013/9/11 11:34:00 -- 那么多个窗口,哪个才是? |
-- 作者:blackzhu -- 发布时间:2013/9/11 11:41:00 -- 窗口4 |
-- 作者:程兴刚 -- 发布时间:2013/9/11 12:01:00 -- 老朱,日期单引号改引号"And处缺空格应为" And |
-- 作者:程兴刚 -- 发布时间:2013/9/11 12:08:00 -- 我手机不方便,其他的地方您再看看! |
-- 作者:blackzhu -- 发布时间:2013/9/11 12:17:00 -- 不是这个问题 你那个是我改例子的原因 |
-- 作者:blackzhu -- 发布时间:2013/9/11 12:59:00 -- BIN 有无做出来? |