'窗口 按钮单击事件
Dim val As Integer
val = DataTables("表").SQLCompute("max(ID)") + 1
'当前行最大值
Dim max As Integer = DataTables("表").Compute("max(ID)") + 1
Dim valmax As Integer
If val > max Then
valmax = val
Else
valmax = max
End If
Dim r As Row = Tables("表").Current
Dim dnew As Row = Tables("表").AddNew
Dim name As String = r("ID")
For Each c As Col In Tables("表").Cols
If c.Name = "ID" Then
' MessageBox.show(valmax)
dnew(c.Name) = valmax
ElseIf c.Name = "条件" Then
dnew(c.Name) = Nothing
ElseIf c.Name <> "_Identify" Then
dnew(c.Name) = r(c.Name)
End If
Next
'表DataColChanging事件
Select Case e.DataCol.Name
Case "ID"
If e.NewValue IsNot Nothing Then
Dim dr As DataRow = e.DataTable.Find("id = '" & e.NewValue & "' ")
If dr IsNot Nothing Then
StatusBar.Message1 = "此iD已经存在"
e.Cancel = True
End If
End If
End Select