Foxtable(狐表)用户栏目专家坐堂 → [求助]编号计算不正确。


  共有2155人关注过本帖树形打印复制链接

主题:[求助]编号计算不正确。

帅哥哟,离线,有人找我吗?
huhu
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1165 积分:8129 威望:0 精华:0 注册:2015/3/30 10:44:00
[求助]编号计算不正确。  发帖心情 Post By: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......

图片点击可在新窗口打开查看此主题相关图片如下:编码.png
图片点击可在新窗口打开查看


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/1/17 11:30:00 [只看该作者]

 
[此贴子已经被作者于2016/1/17 11:30:07编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By: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

 回到顶部