If e.DataCol.Name = "品牌" Then
Dim dr As DataRow
Dim Filter As String
dr = DataTables("表A").Find("品牌 = '" &e.newValue & "'")
If dr IsNot Nothing Then '如果找到的话
Tables("表A").Filter = "品牌 = '" & e.NewValue & "'"
Dim r As Integer = CurrentTable.Rows.Count
Dim Result As DialogResult
Result = MessageBox.Show("表里相同的品牌记录" & "'" & e.NewValue & "'" & "共有" & r & "条,是否复制当前行", "提示",MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim dr1 As DataRow = e.DataTable.DataRows(e.DataTable.DataRows.Count - 1) '获得最后一行
For Each dc As DataCol In e.DataTable.DataCols
e.DataRow(dc.Name) = dr(dc.Name) '将最后一行的内容复制到新增行中.
Next
Else
MessageBox.Show("此品牌没有记录!")
Tables("表A").AddNew()
end if
If e.DataCol.Name = "品牌" Then
If e.NewValue > "" Then
Dim s1 As String = GetPy(e.NewValue,True)
Dim s2 As String
Dim cs() As String = New String() {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
Dim ns() As String = new String(){15,52,54,13,33,12,11,21,43,22,23,24,25,51,44,45,35,32,14,31,42,53,34,55,41,26}
For i As Integer = 0 To s1.length -1
Dim s3 As String = s1.Chars(i)
If Char.IsNumber(s3) = False Then
For n As Integer =0 To cs.Length -1
If cs(n) = s3 Then
s3 = ns(n)
Exit For
End If
Next
End If
s2 = s2 & s3
Next
s2 = s2.PadRight(4,"0")
s2 = s2.SubString(0,4)
Dim drs As List(of DataRow) = e.DataTable.Select("编号 Like '" & s2 & "*' And [_Identify] < " & e.DataRow("_Identify"))
If drs.Count = 0
e.DataRow("编号") = s2 & "01"
Else
e.DataRow("编号") = s2 & Format(drs.count + 1,"00")
End If
Else
e.DataRow("编号") = Nothing
End If
End If
End If
重发一下,修改了一下