Dim scdd As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim kcbh As WinForm.ComboBox = e.Form.Controls("ComboBox3")
If scdd.text = "" Or kcbh.text = "" Then
MessageBox.show("不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Error)
Else
Tables("仓库管理").filter = ""
Dim r As DataRow = DataTables("仓库管理").AddNew()
Dim bh As String = "KW" & scdd.text & kcbh.text
Dim max As String
Dim idx As Integer
max = DataTables("仓库管理").SQLCompute("Max(库位编码)","库位编码 like '" & bh & "%'")
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(bh.length)) + 1 '获得最大编号的后五位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
r("库位编码") = bh & Format(idx,"00000")
r.save
End If