以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  保存时自动生成编号  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=135233)

--  作者:Sunliangcai
--  发布时间:2019/5/21 13:39:00
--  保存时自动生成编号

窗口1有个Table1绑定“纯净水领用”,新增行时不生成“领水编号”,保存时生成“领水编号”,如果新增多行时才保存,求老师指教,谢谢!

Dim ary() As String = Functions.Execute("Xueqi")
Dim r As Row = Tables("纯净水领用").Current
If r.DataRow.RowState = DataRowState.Added Then
    Dim max As String
    max = DataTables("纯净水领用").SQLCompute("Max(领水编号)","领水编号 Like \'" & ary(1) & "-" & "%\'")
    If max = "" Then
        r("领水编号") = ary(1) & "-" & "001"
    Else
        Dim v As Integer = max.SubString(7,3)
        r("领水编号") = ary(1) & "-" & format(v +1,"000")
    End If
    DataTables("纯净水领用").Save()
End If


--  作者:有点甜
--  发布时间:2019/5/21 13:52:00
--  
Dim ary() As String = Functions.Execute("Xueqi")
For Each r As Row In Tables("纯净水领用").Rows
    If r.DataRow.RowState = DataRowState.Added Then
        Dim max As String
        max = DataTables("纯净水领用").SQLCompute("Max(领水编号)","领水编号 Like \'" & ary(1) & "-" & "%\'")
        If max = "" Then
            r("领水编号") = ary(1) & "-" & "001"
        Else
            Dim v As Integer = max.SubString(7,3)
            r("领水编号") = ary(1) & "-" & format(v +1,"000")
        End If
        r.save
    End If
Next

--  作者:Sunliangcai
--  发布时间:2019/5/21 15:33:00
--  

老师还想问个问题,如果有空值,鼠标进入空值行

Dim kjmc() As String = "日期,班级处室,领水桶数,退水桶数,还桶数,破桶数,领送人,收发人".Split(",")
For Each r As Row In Tables("纯净水领用").Rows
    For i As Integer = 0 To kjmc.Length - 1
        If r.IsNull(kjmc(i)) Then
            MessageBox.Show("【"& kjmc(i)&"】有空值,请检查")
             r(kjmc(i)).鼠标选中行

            Return
        End If
    Next
Next


--  作者:有点甜
--  发布时间:2019/5/21 17:23:00
--  
Tables("纯净水领用").select(r.index, Tables("纯净水领用").cols(kjmc(i)).index)