以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求关联表增行时的明细号代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=77250)

--  作者:liuyixin662
--  发布时间:2015/11/13 19:47:00
--  求关联表增行时的明细号代码

主表与明细表建立关联的是入库单号,入库单号为0001,关联表在增加行时生成如下的入库明细号:0001-01,0001-02,0001-03,0001-04,0001-05,求代码


--  作者:大红袍
--  发布时间:2015/11/13 20:19:00
--  

datacolchanged事件

 

If e.DataCol.name = "第一列" Then
   
    Dim bh As String = e.DataRow("第一列")
    Dim max As String
    Dim idx As Integer
    max = e.DataTable.Compute("Max(第二列)","第二列 like \'" & bh & "-%\' and [_Identify] <> " & e.DataRow("_Identify"))
    If max > "" Then \'如果存在最大编号
        idx = CInt(max.Substring(bh.length+1)) + 1 \'获得最大编号的后三位顺序号,并加1
    Else
        idx = 1 \'否则顺序号等于1
    End If
    e.DataRow("第二列") = bh & Format(idx,"-000")
   
End If


--  作者:liuyixin662
--  发布时间:2015/11/13 21:15:00
--  

谢谢!!!