Foxtable(狐表)用户栏目专家坐堂 → [求助]查询之后 在统计不正确


  共有10734人关注过本帖树形打印复制链接

主题:[求助]查询之后 在统计不正确

帅哥哟,离线,有人找我吗?
czy
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章 三级勋章 二级勋章
等级:超级版主 帖子:6318 积分:33963 威望:0 精华:10 注册:2008/8/31 20:56:00
  发帖心情 Post By:2012/11/11 23:53:00 [显示全部帖子]

Dim d As Date = Forms("窗口1").Controls("DateTimePicker1").value
Dim d1 As Date = Forms("窗口1").Controls("DateTimePicker2").value
If d = Nothing Or d1 = Nothing
    MessageBox.Show("请选择起始时间")
    Return
End If

Dim nt As New DataTableBuilder("统计表")
nt.AddDef("序号", Gettype(String),255)
nt.AddDef("姓名", Gettype(String),255)
nt.AddDef("值班时间", Gettype(String),256)
nt.AddDef("值班种类", Gettype(String),255)
nt.AddDef("金额", Gettype(Double),255)
nt.AddDef("领款人", Gettype(String),255)
nt.AddDef("备注", Gettype(String),255)
nt.Build()
Tables("统计表").Cols("值班时间").OpenWindow()

Dim f As New Filler
f.SourceTable = DataTables("机关值班记录表")
f.SourceCols = "值班员"
f.DataTable = DataTables("统计表")
f.DataCols = "姓名"
f.Filter = "[值班时间] >= #" & d & "# And [值班时间] <= #" & d1 & "#"
f.Fill()

Dim s,s1,s2,s3 As String
For Each dr As DataRow In DataTables("统计表").DataRows
    s = ""
    s1 = ""
    s2 = ""
    s3 = "值班员 = '" & dr("姓名") & "' And [值班时间] >= #" & d & "# And [值班时间] <= #" & d1 & "#"
    s = DataTables("机关值班记录表").GetComboListString("值班时间",s3 & " And 值班种类 = '白班'")
    If s <> ""
        s = "白班" & vbcrlf & s.Replace(" 0:00:00|",vbcrlf).Replace(" 0:00:00","")
    End If
    s1 = DataTables("机关值班记录表").GetComboListString("值班时间",s3 & " And 值班种类 = '夜班'")
    If s1 <> ""
        s1 = "夜班" & vbcrlf & s1.Replace(" 0:00:00|",vbcrlf).Replace(" 0:00:00","")
    End If
    s2 = DataTables("机关值班记录表").GetComboListString("值班时间",s3 & " And 值班种类 = '节假日'")
    If s2 <> ""
        s2 = "节假日" & vbcrlf & s2.Replace(" 0:00:00|",vbcrlf).Replace(" 0:00:00","")
    End If
    dr("值班时间") = s & iif(s <> "" , vbcrlf & s1 ,s1) & iif(s1 <> "" , vbcrlf & s2 ,s2)
    dr("值班种类") = Iif(s <> "" ,"白班","") & iif(s1 <> "" , ",夜班" ,"") & iif(s2 <> "" , ",节假日" ,"").Trim(",")
    dr("金额") = DataTables("机关值班记录表").Compute("sum(价格)",s3)
Next
MainTable = Tables("统计表")


 回到顶部