以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  为什么在SQLTable的DataColChanged没反应  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=144825)

--  作者:hongyefor
--  发布时间:2019/12/30 22:54:00
--  为什么在SQLTable的DataColChanged没反应
Select e.DataCol.Name
    Case "面料名称","面料类别"
        If e.DataRow.IsNull("面料名称") OrElse e.DataRow.IsNull("面料类别") Then
            e.DataRow("面料编号") = Nothing
        Else
            Dim bfry As String = e.DataRow("面料类别")
            If e.DataRow("面料类别") = "梭织面料" Then
                bfry = "SZ"
            ElseIf e.DataRow("面料类别") = "针织面料" Then
                bfry = "ZZ"
            ElseIf e.DataRow("面料类别") = "花边面料" Then
                bfry = "HB"
            ElseIf e.DataRow("面料类别") = "无纺面料" Then
                bfry = "WF"
            End If
    
            Dim bflx As String = GetPy(e.DataRow("面料名称").substring(0,2) ,True)
                      
            Dim bf As String = "ML"
            Dim d As Date = Date.Today()
            Dim bh As String = bf & Format(d,"yy") & bflx & Format(d,"MM") & bfry & Format(d,"yy") & "-"
           
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(面料编号)","面料编号 like \'" & bh & "%\'")
            If max > "" Then \'如果存在最大编号
                idx = CInt(max.Substring(bh.Length,3)) + 1 \'获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 \'否则顺序号等于1
            End If
            e.DataRow("面料编号") = bh & Format(idx,"000")
        End If
End Select

--  作者:有点蓝
--  发布时间:2019/12/30 23:03:00
--  
SQLTable的DataColChanged在窗口表事件里。如果后面使用了fill,DataSource,那么需要在全局表事件DataColChanged处理