以文本方式查看主题

-  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=94928)

--  作者:sywgb168
--  发布时间:2017/1/5 15:32:00
--  取表中多个列的数值进自动编号怎么弄

要取表中的:电压列、容量列、膜厚列、相别列、外壳直径列的数据后来自动编号,怎么写代码?
此主题相关图片如下:qq截图20170105152233.png
按此在新窗口浏览图片


此主题相关图片如下:qq截图20170105152849.png
按此在新窗口浏览图片

--  作者:有点色
--  发布时间:2017/1/5 15:34:00
--  

 

Dim lb As string = e.DataRow("电压") & e.DataRow("容量") & e.DataRow("膜厚") & e.DataRow("相别")

 


--  作者:有点色
--  发布时间:2017/1/5 15:36:00
--  
max = e.DataTable.Compute("max(产品编号)", "产品编号 like \'" & lb & "%\' and _Identify <> " & e.DataRow("_Identify"))
--  作者:sywgb168
--  发布时间:2017/1/5 16:01:00
--  
以下是引用有点色在2017/1/5 15:34:00的发言:

 

Dim lb As string = e.DataRow("电压") & e.DataRow("容量") & e.DataRow("膜厚") & e.DataRow("相别")

 

能帮我写完整段代码吗?谢谢

 

试过了,也不知什么原因,有时可以,有时不行,有时按重置列又可以,有时也不行

[此贴子已经被作者于2017/1/5 16:41:57编辑过]

--  作者:有点色
--  发布时间:2017/1/5 16:02:00
--  
贴出你写的代码
--  作者:sywgb168
--  发布时间:2017/1/5 17:19:00
--  

Select e.DataCol.Name
    Case "容量"
          If e.DataRow.IsNull("外壳直径") Then
            e.DataRow("产品编号") = Nothing
        Else
           Dim lb As String = e.DataRow("电压") & e.DataRow("容量") & e.DataRow("膜厚") & e.DataRow("相别") & e.DataRow("外壳直径")
            If e.DataRow("产品编号").StartsWith(lb) = False \'如果单据编号前缀不符
                Dim max As String
                Dim idx As Integer
                max = e.DataTable.Compute("max(产品编号)", "产品编号 like \'" & lb & "%\' and _Identify <> " & e.DataRow("_Identify"))  \'取得该类别的最大编号
                If max > "" Then \'如果存在最大编号
                    idx = CInt(max.Substring(2,3)) + 1 \'获得最大编号的后三位顺序号,并加1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("产品编号") = lb & Format(idx,"000")
            End If
        End If
End Select

这意思是不是填完“容量”和“外壳直径”后再执行代码


--  作者:sywgb168
--  发布时间:2017/1/5 17:24:00
--  
 
以下是引用sywgb168在2017/1/5 17:19:00的发言:

Select e.DataCol.Name
    Case "容量"
          If e.DataRow.IsNull("外壳直径") Then
            e.DataRow("产品编号") = Nothing
        Else
           Dim lb As String = e.DataRow("电压") & e.DataRow("容量") & e.DataRow("膜厚") & e.DataRow("相别") & e.DataRow("外壳直径")
            If e.DataRow("产品编号").StartsWith(lb) = False \'如果单据编号前缀不符
                Dim max As String
                Dim idx As Integer
                max = e.DataTable.Compute("max(产品编号)", "产品编号 like \'" & lb & "%\' and _Identify <> " & e.DataRow("_Identify"))  \'取得该类别的最大编号
                If max > "" Then \'如果存在最大编号
                    idx = CInt(max.Substring(2,3)) + 1 \'获得最大编号的后三位顺序号,并加1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("产品编号") = lb & Format(idx,"000")
            End If
        End If
End Select

这意思是不是填完“容量”和“外壳直径”后再执行代码

看图输完后又不执行了


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

--  作者:有点色
--  发布时间:2017/1/5 17:24:00
--  
Select e.DataCol.Name
    Case "容量","电压","外壳直径","膜厚","相别"
          If e.DataRow.IsNull("外壳直径") orelse e.datarow.isnull("电压") orelse e.datarow.isnull("外壳直径") orelse e.datarow.isnull("膜厚") orelse e.datarow.isnull("相别") Then
            e.DataRow("产品编号") = Nothing
        Else
           Dim lb As String = e.DataRow("电压") & e.DataRow("容量") & e.DataRow("膜厚") & e.DataRow("相别") & e.DataRow("外壳直径")
            If e.DataRow("产品编号").StartsWith(lb) = False \'如果单据编号前缀不符
                Dim max As String
                Dim idx As Integer
                max = e.DataTable.Compute("max(产品编号)", "产品编号 like \'" & lb & "%\' and _Identify <> " & e.DataRow("_Identify"))  \'取得该类别的最大编号
                If max > "" Then \'如果存在最大编号
                    idx = CInt(max.Substring(lb.length,3)) + 1 \'获得最大编号的后三位顺序号,并加1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("产品编号") = lb & Format(idx,"000")
            End If
        End If
End Select

--  作者:sywgb168
--  发布时间:2017/1/5 17:30:00
--  

问题解决了,谢谢