Foxtable(狐表)用户栏目专家坐堂 → [求助]datacolchanged


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

主题:[求助]datacolchanged

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


加好友 发短信
等级:五尾狐 帖子:1165 积分:8129 威望:0 精华:0 注册:2015/3/30 10:44:00
[求助]datacolchanged  发帖心情 Post By:2016/1/20 17:29:00 [只看该作者]

SN:20013040150 MAC:84:79:73:06:9e:40 H/W:MFRP0640080330BD00
希望把上面的字符串输入到e.datarow("SN"),能自动截取出SN,MAC,H/W。然后SN触发datacolchanged,然后去各字段的值。
是不是红色的代码不应该写入到datacolchange里面?
好像截取的也不对。
Dim str As String = e.DataRow("SN")
If str.Contains("SN:") And str.Contains("MAC:") And str.Contains("H/W:") Then
    If str.IndexOf("MAC:") > 0 Then
        e.DataRow("SN") = str.SubString(3,str.IndexOf("MAC:")-2)
    ElseIf str.IndexOf("MAC:") > 0 Then
        e.DataRow("MAC") = str.SubString(str.IndexOf("MAC:") + 4, str.IndexOf("H/W:")-2)
    ElseIf str.IndexOf("H/W:") > 0 Then
        e.DataRow("H/W") = str.SubString(str.IndexOf("H/W:")+3)
    End If
End If

If e.DataCol.name = "SN" Then
    Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","提示"}
    If e.NewValue Is Nothing Then
        For Each nm As String In nms
            e.DataRow(nm) = Nothing
        Next
    Else
        Dim dr1 As DataRow = DataTables("assemblyProduct").Find("deviceCode = '" & e.DataRow("SN") & "'")
        If dr1 IsNot Nothing Then
            Dim dr2 As DataRow = DataTables("assemblySubWorkOrder").Find("SID = '" & dr1("subWorkOrder") & "'")
            If dr2 IsNot Nothing Then
                e.DataRow("工单行号") = dr2("LineFlag")
                Dim dr3 As DataRow = DataTables("assemblyWorkOrder").Find("Id = '" & dr2("workOrder") & "'")
                If dr3 IsNot Nothing Then
                    e.DataRow("生产订单号码") = dr3("WorkOrderNo")
                    Dim dr4 As DataRow = DataTables("批量").Find("生产订单号码 = '" & e.DataRow("生产订单号码") & "' and 工单行号 = '" & e.DataRow("工单行号") & "'")
                    If dr4 IsNot Nothing Then
                        e.DataRow("物料编码") = dr4("物料编码")
                        e.DataRow("物料名称") = dr4("物料名称")
                        e.DataRow("类别说明") = dr4("类别说明")
                        e.DataRow("产品批次") = dr4("产品批次")
                        e.DataRow("订单号") = dr4("订单号")
                        e.DataRow("订单行号") = dr4("订单行号")
                        e.DataRow("客户") = dr4("客户")
                        e.DataRow("备注") = dr4("备注")
                        e.DataRow("软件版本") = dr4("软件版本")
                        e.DataRow("数量") = 1
                        Dim drksl As WinForm.Button = Forms("盘库扫描").Controls("Button2")
                        Dim sum As Integer =  DataTables("盘货扫描").Compute("SUM(数量)")
                        drksl.text = "待入库数量" & "(" & sum & ")"
                    End If
                End If
            End If
        Else
            e.DataRow("提示") = "序列号不存在"
        End If
    End If
End If
[此贴子已经被作者于2016/1/20 17:37:04编辑过]

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


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

没看到你什么意思,参考代码

 

Dim str As String = "SN:20013040150 MAC:84:79:73:06:9e:40 H/W:MFRP0640080330BD00"
If str.Contains("SN:") And str.Contains("MAC:") And str.Contains("H/W:") Then
    Dim idx1 As Integer = str.IndexOf("MAC:")
    Dim idx2 As Integer = str.IndexOf("H/W:")
    msgbox(str.SubString(3, idx1-3))
    msgbox(str.substring(idx1+4, idx2-idx1-5))
    msgbox(str.substring(idx2+5))
End If


 回到顶部