SelectedIndexChanged代码:
Dim scdd As WinForm.ComboBox = e.Form.Controls("ComboBox2")
If e.Sender.text = "松江" Then
scdd.text = "SJ"
ElseIf e.Sender.text = "金山" Then
scdd.text = "JS"
End If
click代码:
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"
Dim str1 As String = scdd.text
Dim str2 As String = kcbh.text
Dim max As String
Dim idx As Integer
max = DataTables("仓库管理").SQLCompute("Max(库位编码)","库位编码 like '" & bh & "%'")
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(4, 5)) + 1 '获得最大编号的后五位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
r.save
r("库位编码") = bh & str1 & str2 & Format(idx,"00000")
End If
编码都是1,而不是自动增加。我要的效果是KWSJ100001,KWSJ100002,KWJS100001,KWJS00002......
此主题相关图片如下:编码.png