以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 请问老师如何在筛选后仍能找到未筛选前的最大值?发现新问题:同时提交会有重复编号问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=161023) |
-- 作者:i4whylg -- 发布时间:2021/3/3 9:32:00 -- 请问老师如何在筛选后仍能找到未筛选前的最大值?发现新问题:同时提交会有重复编号问题 我在项目事件的LoadUserSetting里面加了过滤条件 If User.Group = "管理人员" Then DataTables("项目表").LoadFilter = "" Else DataTables("项目表").LoadFilter = "录入人员 = \'" & User.Name & "\'" End If DataTables("项目表").Load() 然后表“项目表”的表事件DataColChanged里面根据年度找到该年度的最大值,然后加1,但因为筛选过了,只能找到该录入人员名下最大的 Select e.DataCol.Name Case "年度批号" If e.DataRow.IsNull("年度批号") Then e.DataRow("产品批号") = Nothing Else Dim lb As String = e.DataRow("年度批号") If e.DataRow("产品批号").StartsWith(lb) = False \'如果单据产品批号前缀不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(产品批号)","年度批号 = \'" & lb & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该年度批号的最大产品批号 If max > "" Then \'如果存在最大产品批号 idx = CInt(max.Substring(6,5)) + 1 \'获得最大产品批号并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("产品批号") = lb & Format(idx,"00000") End If End If End Select [此贴子已经被作者于2021/3/3 10:32:37编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/3/3 9:34:00 -- Select e.DataCol.Name Case "年度批号" If e.DataRow.IsNull("年度批号") Then e.DataRow("产品批号") = Nothing Else Dim lb As String = e.DataRow("年度批号") If e.DataRow("产品批号").StartsWith(lb) = False \'如果单据产品批号前缀不符 Dim max As String Dim idx As Integer max = e.DataTable.SQLCompute("Max(产品批号)","年度批号 = \'" & lb & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该年度批号的最大产品批号 If max > "" Then \'如果存在最大产品批号 idx = CInt(max.Substring(6,5)) + 1 \'获得最大产品批号并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("产品批号") = lb & Format(idx,"00000") e.DataRow.save End If End If End Select
|
-- 作者:i4whylg -- 发布时间:2021/3/3 9:37:00 -- 感谢老师,完美运行 |
-- 作者:i4whylg -- 发布时间:2021/3/3 10:26:00 -- 还要请教有点蓝老师,我用两个用户同时输入,如果时间间隔有五秒中,可以按顺序生成最大序列号,如果同时提交,则会产生重复的最大序列号,这种情况怎么办呢? |
-- 作者:有点蓝 -- 发布时间:2021/3/3 10:35:00 -- 需要借助服务端控制:http://www.foxtable.com/webhelp/topics/3008.htm |
-- 作者:i4whylg -- 发布时间:2021/3/3 10:37:00 -- 好的,我仔细看看帮助 |