以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]流水账代码运行 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=161124) |
-- 作者:sjf0823 -- 发布时间:2021/3/7 10:32:00 -- [求助]流水账代码运行 \'剩余加班时长 Select Case e.DataCol.Name Case "姓名","计算_加班","计算_调休" Dim dr As DataRow Dim mr As DataRow = e.DataRow Dim drs As List(of DataRow) Dim jk As Integer Dim ck As Integer dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [姓名] = \'" & mr("姓名") & "\'", "[_SortKey] Desc") If dr Is Nothing Then \'如果是第一行,计算结存 jk = DataTables("请假调休表").SQLCompute("Sum(计算_加班)","[_SortKey] < " & mr("_SortKey") & " And 姓名 = \'" & mr("姓名") & "\'") ck = DataTables("请假调休表").SQLCompute("Sum(计算_调休)","[_SortKey] < " & mr("_SortKey") & " And 姓名 = \'" & mr("姓名") & "\'") mr("计算_剩余加班时长") = e.DataRow("计算_加班") - e.DataRow("计算_调休") + jk - ck dr = mr End If drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [姓名] = \'" & dr("姓名") & "\'","[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("计算_剩余加班时长") = drs(i-1)("计算_剩余加班时长") + drs(i)("计算_加班") - drs(i)("计算_调休") Next If e.DataCol.Name = "姓名" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then \'如果修改的是姓名列 dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [姓名] = \'" & e.OldValue & "\'", "[_SortKey] Desc") \'找出旧姓名的上一行 If dr Is Nothing Then \'如果不存在上一行,那么本行就是旧姓名的第一行,由于已经被修改为新姓名,需要找出旧姓名现在的第一行 dr = e.DataTable.Find("[姓名] = \'" & e.OldValue & "\'", "[_SortKey]") \'找出旧姓名现在的第一行 If dr IsNot Nothing Then \'如果找到,计算计算_剩余加班时长 jk = DataTables("请假调休表").SQLCompute("Sum(计算_加班)","[_SortKey] < " & mr("_SortKey") & " And 姓名 = \'" & e.OldValue & "\'") ck = DataTables("请假调休表").SQLCompute("Sum(计算_调休)","[_SortKey] < " & mr("_SortKey") & " And 姓名 = \'" & e.OldValue & "\'") dr("计算_剩余加班时长") = dr("计算_加班") - dr("计算_调休") + jk - ck End If End If If dr IsNot Nothing Then drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [姓名] = \'" & dr("姓名") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("计算_剩余加班时长") = drs(i-1)("计算_剩余加班时长") + drs(i)("计算_加班") - drs(i)("计算_调休") Next End If End If End Select 老师,求助下我参照流水账代码计算加班和调休后结余,输入姓名后就报错 错误显示如下: “.NET Framework 版本:4.0.30319.42000 Foxtable 版本:2020.5.29.8 错误所在事件:表,请假调休表,DataColChanged 详细错误信息: Exception has been thrown by the target of an invocation. Column \'_SortKey\' does not belong to table 请假调休表.” |
-- 作者:有点蓝 -- 发布时间:2021/3/7 20:40:00 -- 这个表没有开启插入行功能:http://www.foxtable.com/webhelp/topics/1791.htm 方法1、开启插入行功能 2、改为使用_Identify列
|