Dim sa As String = e.Form.Controls("荒料编号").value
If sa > "" Then
Dim Parts() As String = sa.Split("-")
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim cmb As WinForm.ComboBox
cmd.C
cmd.CommandText = "SELECT DISTINCT 流水编号 Fro m {质检} where 打包 = 0 And 荒料编号 Like '%" & Parts(1).SubString(0,3) & "%'"
dt = cmd.ExecuteReader()
cmb = e.Form.Controls("流水编号")
If cmd.ExecuteScalar > "" Then
cmb.ComboList= dt.GetComboListString("流水编号")
Else
'以下这段代码,如何改成,从后台获取存在的最大编号并且赋予编号
Dim idx As Integer
Dim max As String
max = DataTables("质检").Compute("Max(流水编号)","[荒料编号] = '" & sa & "'") '取得该天的最大编号
If max > "" Then
idx = CInt(max.Substring(13,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1
End If
e.form.Controls("流水编号").value = sa & "-" & Format(idx,"000")
End If
End If