以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  提示索引和长度错误提示  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=28327)

--  作者:yankunhao
--  发布时间:2013/1/25 15:54:00
--  提示索引和长度错误提示


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

DataColChanged代码如下,原本是没这个提示的,今天增加了红色部份的代码后提示了,不知道是什么原因引起的.

 

 

Select e.DataCol.Name
    Case "sheet_no"
        If e.DataRow.IsNull("sheet_no") Then
            e.DataRow("sheet_lot") = Nothing
        Else
            Dim lb As String = e.DataRow("sheet_no")
            If e.DataRow("sheet_lot").StartsWith(lb) = False \'如果单据编号前缀不符
                Dim max As String
                Dim idx As Integer
                max = e.DataTable.Compute("Max(sheet_lot)","sheet_no = \'" & lb & "\'") \'取得该类别的最大编号
                If max > "" Then \'如果存在最大编号
                    Dim n As Integer
                    n =max.IndexOf("_")
                    If n <>-1 Then
                        idx = CInt(max.Substring(n+1,3)) + 1 \'获得最大编号的后三位顺序号,并加1
                    End If
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("sheet_lot") = lb & "_" & Format(idx,"000")
            End If
        End If
    Case "part_no"
        Dim cmd As New SQLCommand
        Dim cmd1 As new SQLCommand
        Dim dt As DataTable
        Dim dt1 As DataTable
        cmd.C
        cmd.CommandText = "SELECT part_no,wf_cp_gz,wf_cp_ggrem,cu_part_no,wf_bz_fs,wf_edino,cu_part_no,wf_jsbkd,wf_bomkd,wf_scbkd,sheet_sta From {obas_part_spec} where [part_no] = \'" & e.DataRow("part_no") &"\'"
        cmd1.C
        cmd1.CommandText = "SELECT part_no,sal_unit_no From {obas_part1} where part_no = \'" & e.DataRow("part_no") &"\'"
        dt = cmd.ExecuteReader()
        dt1 = cmd1.ExecuteReader()
        Dim dr As DataRow
        dr = dt.Find("part_no = \'" & e.DataRow("part_no") & "\'")
        If dr IsNot Nothing \'如果找到, 则设置各列内容
            e.DataRow("国家")= dr("wf_cp_gz")
            e.DataRow("客户编码")= dr("cu_part_no")
            e.DataRow("rem")= dr("wf_cp_ggrem") & "/ 电脑纹No." & dr("wf_edino") & "/ ABUS NO." & dr("cu_part_no")
            e.DataRow("define1")= dr("wf_bz_fs")
            e.DataRow("wf_jsbkd")= dr("wf_jsbkd")
            e.DataRow("wf_bomkd")= dr("wf_bomkd")
            e.DataRow("wf_scbkd")= dr("wf_scbkd")
            e.DataRow("wf_guigesheet_sta")= dr("sheet_sta")


        Else
            e.DataRow("国家")= Nothing
            e.DataRow("客户编码")= Nothing
            e.DataRow("wf_jsbkd")= Nothing
            e.DataRow("wf_bomkd")= Nothing
            e.DataRow("wf_scbkd")= Nothing
            e.DataRow("wf_guigesheet_sta")= Nothing
        End If
       
        Dim dr1 As DataRow =dt1.DataRows(0)
        e.DataRow("sal_unit")= dr1("sal_unit_no")
        Dim dr2 As DataRow=DataTables("料品资料查询表").Find("part_no = \'" & e.DataRow("part_no") & "\'")
        If dr2 IsNot Nothing Then
           Return
        Else
            Dim s As String =e.DataRow("part_no")
           If s ="1" Then
                Return
            Else
                \'Dim Filter As String = "[part_no] = \'" & s & "\'"
                DataTables("料品资料查询表").Load()
                End If
        End If
End Select


--  作者:lin_hailun
--  发布时间:2013/1/25 16:02:00
--  
 这句代码错了。看看你对应的数据msgbox(max)看看

idx = CInt(max.Substring(n+1,3)) + 1 \'获得最大编号的后三位顺序号,并加1