以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]编号计算不正确。 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=80150) |
-- 作者:huhu -- 发布时间:2016/1/17 11:28:00 -- [求助]编号计算不正确。 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......
|
-- 作者:大红袍 -- 发布时间:2016/1/17 11:30:00 -- [此贴子已经被作者于2016/1/17 11:30:07编辑过]
|
-- 作者:大红袍 -- 发布时间:2016/1/17 11:34:00 -- 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
|