在Datacolchanging事件,加入代码
If e.DataCol.Name <> "编辑者" Then
If e.DataRow("编辑者") = User.Name Then '如果编辑者是当前用户
Return
End If
Dim cmd As New SQLCommand
Dim exp As String = "编辑者 Is Null And [_Identify] = " & e.DataRow("_Identify")
cmd.CommandText = "U pdate {内供} Set 编辑者 = '" & User.Name & "' Where " & exp
If cmd.ExecuteNonQuery = 1 Then
e.DataRow("编辑者") = User.Name
Else
cmd.CommandText = "S elect 编辑者 From {内供} Where [_Identify] = " & e.DataRow("_Identify")
Dim nm As String = cmd.ExecuteScalar
If nm > "" Then
MessageBox.show(nm & "正在编辑此行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
MessageBox.show("此行可能已经被删除,无法编辑!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
e.Cancel = True '取消编辑
End If
End If