以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  自动生成工序号问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=194936)

--  作者:lgz518
--  发布时间:2025/2/7 19:41:00
--  自动生成工序号问题
主表与明细表关联,下面代码如何改?

if e.datacol.name = "工序" then
dim idx as integer = tables("明细表").finrow(e.datarow)
if idx = 0 then
e.datarow("工序号") = 1
else
dim r as row = tables("明细表").rows(idx- 1)
if r("工序") = e.datarow("工序") then
e.datarow("工序号") = r("工序号")
else
e.datarow("工序号") = r("工序号") + 1
end if
end if
end if

--  作者:有点蓝
--  发布时间:2025/2/8 8:54:00
--  
数据是怎么样的?要实现什么功能?代码在哪个表的什么事件?执行有什么问题?
[此贴子已经被作者于2025/2/8 8:54:32编辑过]

--  作者:lgz518
--  发布时间:2025/2/8 10:04:00
--  
代码在明细表,需求的功能,主表新增后,明细表新增后生成序号,类似狐表的表序号
--  作者:有点蓝
--  发布时间:2025/2/8 10:23:00
--  
代码执行有什么问题?
--  作者:lgz518
--  发布时间:2025/2/8 10:47:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:工序号.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2025/2/8 10:58:00
--  
If e.DataCol.name = "工序" Then
    Dim dr As DataRow = e.DataTable.find("编号=\'" & e.DataRow("编号") & "\' and 工序=\'" & e.DataRow("工序") & "\' and _identiify<>" & e.DataRow("_identiify"))
    If dr IsNot Nothing Then
        e.DataRow("工序号") = dr("工序号")
    Else
        Dim max As Integer = e.DataTable.compute("max(工序号)", "编号=\'" & e.DataRow("编号") & "\' and _identiify<>" & e.DataRow("_identiify"))
        e.DataRow("工序号") = max + 1
    End If
End If

--  作者:lgz518
--  发布时间:2025/2/8 11:34:00
--  
执行报错:列“_identiify”不属于表 明细表
--  作者:有点蓝
--  发布时间:2025/2/8 11:38:00
--  
多个字母,自行改改