以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教编码的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=61319)

--  作者:jswjyjf
--  发布时间:2014/12/10 20:50:00
--  请教编码的问题

收款 付款 费用 都放在一个表,以单据号区别 如收款sk000001 以此类推 ,同样费用 FY000001 以此类推,付款Fk000001 。。。。

 

 

如果新开收款单 新号码是SK000002 , 如新开付款单 新号码FK000002  代码如何写 


--  作者:有点甜
--  发布时间:2014/12/10 20:56:00
--  

 一样那样写,判断开什么但,先用compute得到最大的编号,然后加1即可。

 

 http://www.foxtable.com/help/topics/2403.htm

 

 

 


--  作者:jswjyjf
--  发布时间:2014/12/10 21:03:00
--  

 \'Dim bh As String = "SK" &  Format(DataTables("资金收付").sqlCompute("Max(单据号)") + 1, "000000")
Dim bh As String="SK"
  Dim max As String
    Dim idx As Integer
    max = DataTables("资金收付").sqlCompute("Max(单据号)","单据号 like \'" & bh & "-%\'")
msgbox(max)
    If max > "" Then \'如果存在最大销售单号
        idx = CInt(max.Substring(9,3)) + 1 \'获得最大销售单号的后三位顺序号,并加1
    Else
        idx = 1 \'否则顺序号等于1
    End If
    msgbox(bh & "-" & Format(idx,"000000"))

假如开收款单 这段代码对吗

 

 


--  作者:有点甜
--  发布时间:2014/12/10 21:06:00
--  
Dim bh As String="SK"
Dim max As String
Dim idx As Integer
max = DataTables("资金收付").sqlCompute("Max(单据号)","单据号 like \'" & bh & "-%\'")
msgbox(max)
If max > "" Then \'如果存在最大销售单号
    idx = CInt(max.Substring(bh.Length+1)) + 1 \'获得最大销售单号的后三位顺序号,并加1
Else
    idx = 1 \'否则顺序号等于1
End If
msgbox(bh & "-" & Format(idx,"000000"))