以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  考勤相同小时排除  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=113074)

--  作者:xietan417
--  发布时间:2018/1/8 16:52:00
--  考勤相同小时排除
如何将一个人在同一天里相同的小时内的多余考勤数据排除?举例:比如早上上班时间:同一个人打了两次卡,就形成两条记录,如何将多余的记录删除?
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目2.foxdb


[此贴子已经被作者于2018/1/8 16:52:47编辑过]

--  作者:有点甜
--  发布时间:2018/1/8 17:04:00
--  

参考代码

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列"
For Each dr As DataRow In DataTables("表A").Select("", cs)
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        If pdr("第一列") <> dr("第一列") OrElse format(pdr("第二列"),"yyyyMMddHH") <> format(dr("第二列"), "yyyyMMddHH")  Then
            flag = True
        End If
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

\'Tables("表A").filter = "_Identify in (" & idx.trim(",") & ")"
Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")"


--  作者:xietan417
--  发布时间:2018/1/9 15:22:00
--  
谢谢!如果间隔时间为5分钟以上就算是有效打卡?这个代码应该怎么改?

If pdr("第一列") <> dr("第一列") OrElse format(pdr("第二列"),"yyyyMMddHH") <> format(dr("第二列"), "yyyyMMddHH")  Then
把时间format到分吗?
[此贴子已经被作者于2018/1/9 15:23:59编辑过]

--  作者:有点甜
--  发布时间:2018/1/9 15:28:00
--  

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列"
For Each dr As DataRow In DataTables("表A").Select("", cs)
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        Dim sp As TimeSpan = dr("第二列") - pdr("第二列")
        If pdr("第一列") <> dr("第一列") OrElse sp.TotalMinutes >= 5  Then
            flag = True
        End If
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify in (" & idx.trim(",") & ")"
\'Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")"


--  作者:xietan417
--  发布时间:2018/1/9 15:45:00
--  
谢谢!居然忘记用时段来做判断!图片点击可在新窗口打开查看