以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 甜甜,你好, 自动编号问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=116320) |
|
-- 作者:cyrollin -- 发布时间:2018/3/22 17:22:00 -- 甜甜,你好, 自动编号问题 设计了这样一组数据, 比如: 编号 次数 111
001 111
002 222
001 222
002 222
003 222
004 参考: http://www.foxtable.com/webhelp/scr/2403.htm 修改为: Select e.DataCol.Name Case "编号" If e.DataRow.IsNull("编号") Then e.DataRow("次数") = Nothing Else Dim bh As String = e.DataRow("编号") If e.DataRow("次数").StartsWith(bh) = False \'如果单据编号前缀不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(次数)","编号 = \'" & bh & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max) + 1 \'加1 Else idx = Nothing \'否则顺序号等于空 End If e.DataRow("次数") = Format(idx,"000") End If End If End Select 但没有实现 |
|
-- 作者:有点甜 -- 发布时间:2018/3/22 18:06:00 -- Select e.DataCol.Name Case "编号" If e.DataRow.IsNull("编号") Then e.DataRow("次数") = Nothing Else Dim bh As String = e.DataRow("编号") Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(次数)","编号 = \'" & bh & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max) + 1 \'加1 Else idx = 1\'否则顺序号等于空 End If e.DataRow("次数") = Format(idx,"000") End If End Select |
|
-- 作者:cyrollin -- 发布时间:2018/3/22 18:37:00 -- 甜甜太厉害了. 如果单独使用这段代码是完全可行的, 但是我把这段代码加到这个里面,就不行了, 要稍微改动一下哪里呢? ... ... ... For Each fdr As DataRow In DataTables("客户数据").Select("固定时间 = \'" & e.DataRow("星期") & "\'", "固定排序,时间") \'从客户数据里面加载数据到主表里面 If i = 0 Then dr = e.DataRow Else dr = e.DataTable.AddNew End If dr("日期") = e.DataRow("日期") dr("编号") = fdr("编号") dr("支付方式") = fdr("支付方式") Select e.DataCol.Name Case "编号" If e.DataRow.IsNull("编号") Then e.DataRow("次数") = Nothing Else Dim bh As String = e.DataRow("编号") Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(次数)","编号 = \'" & bh & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max) + 1 \'加1 Else idx = 1\'否则顺序号等于空 End If e.DataRow("次数") = Format(idx,"000") End If End Select i += 1 Next SystemReady = True Tables("主表").sort = "日期" End If |
|
-- 作者:有点甜 -- 发布时间:2018/3/22 20:20:00 -- For Each fdr As DataRow In DataTables("客户数据").Select("固定时间 = \'" & e.DataRow("星期") & "\'", "固定排序,时间") \'从客户数据里面加载数据到主表里面 If i = 0 Then dr = e.DataRow Else dr = e.DataTable.AddNew End If dr("日期") = e.DataRow("日期") dr("编号") = fdr("编号") dr("支付方式") = fdr("支付方式") If dr.IsNull("编号") Then dr("次数") = Nothing Else Dim bh As String = dr("编号") Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(次数)","编号 = \'" & bh & "\' And [_Identify] <> " & dr("_Identify")) \'取得该类别的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max) + 1 \'加1 Else idx = 1\'否则顺序号等于空 End If dr("次数") = Format(idx,"000") End If i += 1 Next |
|
-- 作者:cyrollin -- 发布时间:2018/3/26 15:28:00 -- 现在程序要这样设置了, 次数有时要人工修改一下. 然后下一条次数会自动按照上一条次数的数字+1, 而不是用最大次数+1 比如是这样: 编号 次数 111 001 111 002 222 001 222 002 222 003 222 004 222 008 (人工修改了次数) 222 009 (自动按上面的数字+1) 222 010 (同上) 再次谢谢甜甜帮忙:) |
|
-- 作者:有点甜 -- 发布时间:2018/3/26 15:58:00 -- 你需要加一个辅助列【人工修改】,如果手动修改,就勾选一下,然后查找数据,排除手动修改的列
max = e.DataTable.Compute("Max(次数)","(人工修改 = false or 人工修改 is null) and 编号 = \'" & bh & "\' And [_Identify] <> " & dr("_Identify")) \'取得该类别的最大编号 |
|
-- 作者:有点甜 -- 发布时间:2018/3/26 16:01:00 -- 如果你要计算次数,可以改成这样
max = e.DataTable.Compute("count(次数)","编号 = \'" & bh & "\' And [_Identify] <> " & dr("_Identify")) \'取得该类别的最大编号 |
|
-- 作者:cyrollin -- 发布时间:2018/3/26 16:27:00 -- "
" 这个代码还是查找数据记录中最大次数,然后再加1, 不是按照上一条数据里面手动改的次数记录数字加1.
|
|
-- 作者:有点甜 -- 发布时间:2018/3/26 16:36:00 -- 不明白你说的意思,请上传实例说明。说明操作哪一行数据,然后需要得到什么效果。 |
|
-- 作者:cyrollin -- 发布时间:2018/3/26 17:45:00 -- 帮我看下附件,谢谢1 |