Foxtable(狐表)用户栏目专家坐堂 → [求助]下面的代码有错吗?


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

主题:[求助]下面的代码有错吗?

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


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
[求助]下面的代码有错吗?  发帖心情 Post By:2016/6/27 11:40: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").SQLFind("deviceCode = '" & e.DataRow("SN") & "' or productno = '" & e.DataRow("SN") & "'")
        If dr1 IsNot Nothing Then
            Dim dr2 As DataRow = DataTables("assemblySubWorkOrder").SQLFind("SID = '" & dr1("subWorkOrder") & "'")
            If dr2 IsNot Nothing Then
                e.DataRow("工单行号") = dr2("LineFlag")
                Dim dr3 As DataRow = DataTables("assemblyWorkOrder").SQLFind("Id = '" & dr2("workOrder") & "'")
                If dr3 IsNot Nothing Then
                    e.DataRow("生产订单号码") = dr3("WorkOrderNo")
                    Dim dr4 As DataRow = DataTables("计划表").SQLFind("生产订单号码 = '" & 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 shry As WinForm.TextBox = forms("非插卡收货扫描").Controls("TextBox2")
                        e.DataRow("入库收货人员") = shry.text
                        msgbox(8)
                        e.DataRow.Save
                        Dim dr As DataRow = DataTables("U8物料编码入库单收货统计").SQLFind("入库单号 = '" & Vars("fckrkdh") & "' And 物料编码 = '" & e.DataRow("物料编码") & "'")
                        If dr IsNot Nothing Then
                            msgbox(10)
                            Dim fdr As DataRow = DataTables("非插卡收货扫描").SQLFind("SN = '" &  e.DataRow("SN") & "' And _Identify <> '" & e.DataRow("_Identify") & "'")
                            msgbox(dr("实扫到数量"))
                            msgbox(dr("总数量"))
                            If fdr IsNot Nothing Then
                                If  fdr("状态") = "收货重复扫描"  Or fdr("状态") = "收货完成" Then
                                    e.DataRow("数量") = 0
                                    e.DataRow("状态") = "收货重复扫描"
                                    e.DataRow.Save
                                    e.DataRow.locked = True
                                    msgbox(0)
                                End If
                            ElseIf fdr Is Nothing Then
                                msgbox(11)
                                msgbox(dr("实扫到数量"))
                                msgbox(dr("总数量"))

                                If (dr("实扫到数量") - dr("总数量") < 0) Then
                                    msgbox(1)
                                    e.DataRow("库位类别") = dr("库位类别")
                                    e.DataRow("入库单号") = Vars("fckrkdh")
                                    e.DataRow("数量") = 1
                                    dr("实扫到数量") = dr("实扫到数量") + 1
                                    dr("比较结果") = dr("实扫到数量") - dr("总数量")
                                    dr.save
                                    Forms("非插卡收货扫描").StopRedraw() '停止绘制窗口
                                    DataTables("U8物料编码入库单收货统计").StopRedraw()
                                    DataTables("U8物料编码入库单收货统计").RemoveFor("入库单号 = '" & Vars("fckrkdh") & "' And 物料编码 = '" & e.DataRow("物料编码") & "'")
                                    DataTables("U8物料编码入库单收货统计").AppendLoad("入库单号 = '" & Vars("fckrkdh") & "' And 物料编码 = '" & e.DataRow("物料编码") & "'")
                                    DataTables("U8物料编码入库单收货统计").ResumeRedraw()
                                    Forms("非插卡收货扫描").ResumeRedraw() '停止绘制窗口
                                    e.DataRow("状态") = "收货完成"
                                    e.DataRow("收货完成时间") = Date.now
                                    e.DataRow.Save
                                    e.DataRow.locked = True
                                ElseIf (dr("实扫到数量") - dr("总数量") = 0) Then
                                    e.DataRow("数量") = 0
                                    e.DataRow("状态") = "收货已满"
                                    e.DataRow.Save
                                    e.DataRow.locked = True
                                End If
                            End If
                        Else
                            e.DataRow("数量") = 0
                            e.DataRow("状态") = "非本入库单物料"
                            e.DataRow.Save
                            e.DataRow.locked = True
                        End If
                        msgbox(9)
                    End If
                End If
            End If
        Else
            e.DataRow("状态") = "序列号不存在"
            e.DataRow.Save
            e.DataRow.locked = True
        End If
    End If
End If

 

重复扫描的都对,就是有些SN,并没有执行红色的msgbox。怎么会不去执行呢?而其他的SN都是正常执行,结果也对。


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


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

每层if判断,加入一个msgbox调试啊,不执行,说明没有满足条件啊

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


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

Dim fdr As DataRow = DataTables("非插卡收货扫描").SQLFind("SN = '" &  e.DataRow("SN") & "' And _Identify <> '" & e.DataRow("_Identify") & "'")
                            msgbox(0)------所有的都会执行到它。
                            If fdr IsNot Nothing Then
                                If  fdr("状态") = "收货重复扫描"  Or fdr("状态") = "收货完成" Then
                                    e.DataRow("数量") = 0
                                    e.DataRow("状态") = "收货重复扫描"
                                    e.DataRow.Save
                                    e.DataRow.locked = True
                                End If
                            ElseIf fdr Is Nothing Then
                                msgbox(dr("实扫到数量"))
                                msgbox(dr("总数量"))--------不是所有都会执行到它,有写就执行不到。但条件都是满足的。很少奇怪。

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


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

 说明If判断的条件不满足啊,fdr不是空值啊。


 回到顶部