Foxtable(狐表)用户栏目专家坐堂 → 筛选一个时间段到统计表1


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

主题:筛选一个时间段到统计表1

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/10/26 14:42:00 [显示全部帖子]

Dim Filter As String

Dim a = e.Form.Controls("TextBox1").Text
Dim b = e.Form.Controls("TextBox2").Text


With e.Form.Controls("TextBox1")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "[" & a & "] Like '%" & .text & "%'"
    End If
End With

With e.Form.Controls("TextBox2")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "[" & b & "] Like '%" & .text & "%'"
    End If
End With

With e.Form.Controls("DateTimePicker1")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "记录填写时间 >= #" & .text & "#"
    End If
End With

With e.Form.Controls("DateTimePicker2")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "记录填写时间 <= #" & .text & "#"
    End If
End With

If Filter > "" Then
    Tables("工时").Filter = Filter
End If

Dim t As Table = Tables("工时")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
'g.GroupOn = "姓名"
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
t.Subtotal()

Dim r As Row
For i As Integer = 0 To t.Rows.Count(True) - 1
    r = t.Rows(i,True)
    If r.IsGroup '如果是分组行
        Dim f As String = "[" & a & "] = '" & r("[" & a & "]") & "'"
        Dim v As String = " [" & b & "]:" & t.Compute("Sum([" & b & "])",f)
        r("[" & a & "]") = "[" & a & "]:" & r("[" & a & "]") & v
    End If
Next

Dim b1 As New GroupTableBuilder("统计表1",DataTables("工时"))
b1.Groups.AddDef("[" & a & "]","" & a & "") '添加日期列用于分组,并用"月"代替原名称
b1.Totals.AddDef("[" & b & "]") '添加数量列用于统计
b1.Subtotal = True '生成汇总模式
b1.Filter = Filter
b1.Build '生成统计表
MainTable = Tables("统计表1") '打开生成的统计表

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/10/26 16:07:00 [显示全部帖子]

修改

 

With e.Form.Controls("TextBox1")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(" & a & ",'System.String') Like '%" & .text & "%'"
    End If
End With

With e.Form.Controls("TextBox2")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(" & b & ",'System.String') Like '%" & .text & "%'"
    End If
End With

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/10/26 17:34:00 [显示全部帖子]

Dim Filter As String

Dim a = e.Form.Controls("TextBox1").Text
Dim b = e.Form.Controls("TextBox2").Text


With e.Form.Controls("TextBox1")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(" & a & ",'System.String') Like '%" & .text & "%'"
    End If
End With

With e.Form.Controls("TextBox2")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(" & b & ",'System.String') Like '%" & .text & "%'"
    End If
End With

With e.Form.Controls("DateTimePicker1")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "工作日期 >= #" & .text & "#"
    End If
End With

With e.Form.Controls("DateTimePicker2")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "工作日期 <= #" & .text & "#"
    End If
End With

If Filter > "" Then
    Tables("工时").Filter = Filter
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/10/26 18:42:00 [显示全部帖子]

开发者密码贴出来。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/10/27 8:51:00 [显示全部帖子]

红色代码删掉

 

Dim Filter As String

Dim a = e.Form.Controls("TextBox1").Text
Dim b = e.Form.Controls("TextBox2").Text


With e.Form.Controls("TextBox1")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(" & a & ",'System.String') Like '%" & .text & "%'"
    End If
End With

With e.Form.Controls("TextBox2")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(" & b & ",'System.String') Like '%" & .text & "%'"
    End If
End With

With e.Form.Controls("DateTimePicker1")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "工作日期 >= #" & .text & "#"
    End If
End With

With e.Form.Controls("DateTimePicker2")
    If .value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "工作日期 <= #" & .text & "#"
    End If
End With


 回到顶部