Foxtable(狐表)用户栏目专家坐堂 → [求助]如何改呢?


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

主题:[求助]如何改呢?

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


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

Dim dr As DataRow = DataTables("U8物料数量汇总表").Find("入库单号 = '" & Vars("fckrkdh") & "' And 物料编码 = '" & e.DataRow("物料编码") & "'")
                        If dr IsNot Nothing Then
                            Dim fdr As DataRow = DataTables("非插卡收货扫描").Find("SN = '" &  e.DataRow("SN") & "' And _Identify <> " & e.DataRow("_Identify"))
                            If fdr IsNot Nothing Then
                                If  fdr("提示") = "收货重复扫描"  Or fdr("提示") = "收货完成" Then
                                    e.DataRow("数量") = 0
                                    e.DataRow("提示") = "收货重复扫描"
                                    e.DataRow.locked = True
                                End If
                            Else
                                If dr("比较结果") < 0 Then
                                    msgbox(0)
                                    e.DataRow("库位类别") = dr("库位类别")
                                    e.DataRow("入库单号") = Vars("fckrkdh")
                                    e.DataRow("数量") = 1
                                    e.DataRow("提示") = "收货完成"
                                    e.DataRow("收货完成时间") = Date.now
                                    e.DataRow.locked = True
                                    dr("实扫到数量") = dr("实扫到数量") + 1
                                    msgbox(1)                                    
                                ElseIf dr("比较结果") = 0 Then
                                    msgbox(2)                                    
                                    e.DataRow("数量") = 0
                                    e.DataRow("提示") = "收货已满"
                                    e.DataRow.locked = True
                                    msgbox(3)                                    
                                End If
                            End If
                        Else
                            e.DataRow("数量") = 0
                            e.DataRow("提示") = "非本入库单物料"
                            e.DataRow.locked = True
                        End If
                    End If
红色代码执行可能会遇到执行完后正好dr("比较结果")=0了,那就又把蓝色的代码也给执行了,就会本应该是红色代码的值变为了蓝色代码的值。

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


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

前面要判断列名啊

 

If e.DataCol.Name = "比较结果" Then

 

 

End If

 


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


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

看来我没说清楚,下面是完整的代码。比较结果是另外一个表的。不是本表。
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("软件版本")
                        Dim dr As DataRow = DataTables("U8物料数量汇总表").Find("入库单号 = '" & Vars("fckrkdh") & "' And 物料编码 = '" & e.DataRow("物料编码") & "'")
                        If dr IsNot Nothing Then
                            Dim fdr As DataRow = DataTables("非插卡收货扫描").Find("SN = '" &  e.DataRow("SN") & "' And _Identify <> " & e.DataRow("_Identify"))
                            If fdr IsNot Nothing Then
                                If  fdr("提示") = "收货重复扫描"  Or fdr("提示") = "收货完成" Then
                                    e.DataRow("数量") = 0
                                    e.DataRow("提示") = "收货重复扫描"
                                    e.DataRow.locked = True
                                End If
                            Else
                                If dr("比较结果") < 0 Then
                                    msgbox(0)
                                    e.DataRow("库位类别") = dr("库位类别")
                                    e.DataRow("入库单号") = Vars("fckrkdh")
                                    e.DataRow("数量") = 1
                                    e.DataRow("提示") = "收货完成"
                                    e.DataRow("收货完成时间") = Date.now
                                    e.DataRow.locked = True
                                    dr("实扫到数量") = dr("实扫到数量") + 1
                                    msgbox(1)                                    
                                ElseIf dr("比较结果") = 0 Then
                                    msgbox(2)                                    
                                    e.DataRow("数量") = 0
                                    e.DataRow("提示") = "收货已满"
                                    e.DataRow.locked = True
                                    msgbox(3)                                    
                                End If
                            End If
                        Else
                            e.DataRow("数量") = 0
                            e.DataRow("提示") = "非本入库单物料"
                            e.DataRow.locked = True
                        End If
                    End If
                End If
            End If
        Else
            e.DataRow("提示") = "序列号不存在"
            e.DataRow.locked = True
        End If
    End If
End If

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


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

不存在你说的问题啊。不可能执行两次啊。

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


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

msgbox(0),
msgbox(1),
msgbox(2),
msgbox(3),
都弹出来了


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


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

一行,不可能触发多次。触发你修改了多行的SN值。

 

要不你就试试加入

 

SystemReady = False

 

'代码

 

SystemReady = True

 


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


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

o .
我还需要说一下,比较结果列是一个表达式。会不会和这有关系?

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


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

触发一次datacolchanged事件,不可能弹出多个msgbox。

 

你肯定触发多次SN的datacolchanged事件了。上传例子测试。


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


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

前面还有一段是对字符串SN:20013040150 MAC:84:79:73:06:9e:40 H/W:MFRP0640080330BD00
自动裁出来SN,MAC,HW。这个是不是相当于触发了2次。
第一次SN的值为SN:20013040150 MAC:84:79:73:06:9e:40 H/W:MFRP0640080330BD00
执行了下面代码后。SN变为了20013040150。
但我奇怪的是第一次SN是不可能找到结果的。
Dim str As String = e.DataRow("SN")
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:")
    e.DataRow("SN") = str.SubString(3, idx1-3)
    e.DataRow("MAC") = str.substring(idx1+4, idx2-idx1-5)
    e.DataRow("HW") = str.substring(idx2+5)
End If

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


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

这段代码写到datacolchanging事件

 

If e.DataCol.Name = "SN" Then

Dim str As String = e.NewValue
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:")
    e.DataRow("MAC") = str.substring(idx1+4, idx2-idx1-5)
    e.DataRow("HW") = str.substring(idx2+5)
    e.NewValue = str.SubString(3, idx1-3)
End If
End If

 回到顶部