以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  自动生成编号语局错误  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=49703)

--  作者:阆子天涯
--  发布时间:2014/4/22 22:52:00
--  自动生成编号语局错误

Dim rq As WinForm.DateTimePicker = e.Form.Controls("日期")
Dim djlx As WinForm.ComboBox = e.Form.Controls("单据类型")
Dim pp As WinForm.ComboBox = e.Form.Controls("品牌")
Dim md As WinForm.ComboBox = e.Form.Controls("门店")
Dim djbh As WinForm.TextBox = e.Form.Controls("单据编号")

If rq.Value = Nothing   Then
    djbh.Text =""
 Else
        Dim bh As String = Format(rq.value,"yyyyMMdd") \'取得编号的8位前缀
        If   DataTables("库调明细表_主表").DataRow("业务单号").StartsWith(bh) = False 
            Dim max As String
            Dim idx As Integer
            max = e.DataTables("库调明细表_主表").Compute("Max("业务单号")","单据日期 = #" & rq.Value & "# And [_Identify] <> " & DataTables("库调明细表_主表").DataRow("_Identify") And ) 
            If max > "" Then \'如果存在最大编号
                idx = CInt(max.Substring(9,3)) + 1             Else
                idx = 1 
            End If
            djbh.text = bh & "-" & Format(idx,"000")
        End If
    End If
End If


--  作者:有点甜
--  发布时间:2014/4/22 23:00:00
--  

 试试这样改。

 

Dim rq As WinForm.DateTimePicker = e.Form.Controls("日期")
Dim djlx As WinForm.ComboBox = e.Form.Controls("单据类型")
Dim pp As WinForm.ComboBox = e.Form.Controls("品牌")
Dim md As WinForm.ComboBox = e.Form.Controls("门店")
Dim djbh As WinForm.TextBox = e.Form.Controls("单据编号")

If rq.Value = Nothing   Then
    djbh.Text =""
Else
    Dim bh As String = Format(rq.value,"yyyyMMdd") \'取得编号的8位前缀
    If   Tables("库调明细表_主表").Current("业务单号").StartsWith(bh) = False
        Dim max As String
        Dim idx As Integer
        max = DataTables("库调明细表_主表").Compute("Max(业务单号)","单据日期 = #" & rq.Value & "# And [_Identify] <> " & Tables("库调明细表_主表").current("_Identify"))
        If max > "" Then \'如果存在最大编号
            idx = CInt(max.Substring(9,3)) + 1
        Else
            idx = 1
        End If
        djbh.text = bh & "-" & Format(idx,"000")
    End If
End If


--  作者:阆子天涯
--  发布时间:2014/4/23 15:16:00
--  
还是不行,唉!
--  作者:Bin
--  发布时间:2014/4/23 15:22:00
--  
出现什么问题? 编号不正常还是报错? 
--  作者:阆子天涯
--  发布时间:2014/4/23 21:14:00
--  

  请帮忙看下以下代码哪儿错了,

max = DataTables("库调明细表_主表").Compute("Max(业务单号)","[单据日期] = #" & rq.Value & "#  And [_Identify] <> " & Tables("库调明细表_主表").current("_Identify") And "品牌" = "pp.text" And "门店" = "md.text"),执行后提示为

<!--StartFragment -->

       


--  作者:阆子天涯
--  发布时间:2014/4/23 21:19:00
--  
 请帮忙看下以下代码哪儿错了,

max = DataTables("库调明细表_主表").Compute("Max(业务单号)","[单据日期] = #" & rq.Value & "#  And [_Identify] <> " & Tables("库调明细表_主表").current("_Identify") And "品牌" = "pp.text" And "门店" = "md.text"),执行后错误提示请看附件图片


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20140423211532.jpg
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2014/4/23 21:32:00
--  

 这样改一下

 

max = DataTables("库调明细表_主表").Compute("Max(业务单号)","[单据日期] = #" & rq.Value & "#  And [_Identify] <> " & Tables("库调明细表_主表").current("_Identify") & " And 品牌 = \'" & pp.text & "\' And 门店 = \'" & md.text & "\'")

[此贴子已经被作者于2014-4-23 21:34:04编辑过]

--  作者:阆子天涯
--  发布时间:2014/4/23 22:01:00
--  
版主真厉害,我就没想到,谢谢啦!