以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]未将对象引用设置到对象实例 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=80735) |
-- 作者:huhu -- 发布时间:2016/1/30 17:12: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 msgbox(0) Dim dr1 As DataRow = DataTables("assemblyProduct").Find("deviceCode = \'" & e.DataRow("SN") & "\'") If dr1 IsNot Nothing Then msgbox(1) Dim dr2 As DataRow = DataTables("assemblySubWorkOrder").Find("SID = \'" & dr1("subWorkOrder") & "\'") msgbox(2) If dr2 IsNot Nothing Then msgbox(3) e.DataRow("工单行号") = dr2("LineFlag") msgbox(4) Dim dr3 As DataRow = DataTables("assemblyWorkOrder").Find("Id = \'" & dr2("workOrder") & "\'") If dr3 IsNot Nothing Then msgbox(5) e.DataRow("生产订单号码") = dr3("WorkOrderNo") msgbox(6) 执行红色代码会报未将对象引用设置到对象实例。代码不应该有问题啊。这是怎么回事?
|
-- 作者:大红袍 -- 发布时间:2016/1/31 9:59:00 -- 这个表DataColChanged事件有问题。
执行红色代码会触发 工单行号 和 生产订单号码 的DataColChanged事件,那里的代码有问题。
否者,你就用SystemReady = False |
-- 作者:huhu -- 发布时间:2016/2/1 12:12:00 -- 这是全部代码。dr如果没找到,应该执行else代码,可是没弹出 msgbox(0)和msgbox(1) 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 SystemReady = False e.DataRow("工单行号") = dr2("LineFlag") SystemReady = True Dim dr3 As DataRow = DataTables("assemblyWorkOrder").Find("Id = \'" & dr2("workOrder") & "\'") If dr3 IsNot Nothing Then SystemReady = False e.DataRow("生产订单号码") = dr3("WorkOrderNo") SystemReady = True SystemReady = False msgbox(11) Dim dr4 As DataRow = DataTables("批量").Find("生产订单号码 = \'" & e.DataRow("生产订单号码") & "\' and 工单行号 = \'" & e.DataRow("工单行号") & "\'") msgbox(e.DataRow("生产订单号码")) SystemReady = True msgbox(e.DataRow("工单行号")) msgbox(dr4 IsNot Nothing) If dr4 IsNot Nothing Then msgbox(14) SystemReady = False 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("软件版本") SystemReady = True 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 SystemReady = False e.DataRow("数量") = 0 e.DataRow("状态") = "收货重复扫描" e.DataRow.locked = True SystemReady = True End If Else If dr("比较结果") < 0 Then SystemReady = False e.DataRow("库位类别") = dr("库位类别") e.DataRow("入库单号") = Vars("fckrkdh") e.DataRow("数量") = 1 e.DataRow("状态") = "收货完成" e.DataRow("收货完成时间") = Date.now e.DataRow.locked = True dr("实扫到数量") = dr("实扫到数量") + 1 SystemReady = True ElseIf dr("比较结果") = 0 Then SystemReady = False e.DataRow("数量") = 0 e.DataRow("状态") = "收货已满" e.DataRow.locked = True SystemReady = True End If End If Else msgbox(0) SystemReady = False e.DataRow("数量") = 0 e.DataRow("状态") = "非本入库单物料" e.DataRow.locked = True SystemReady = True msgbox(1) End If End If End If End If Else SystemReady = False e.DataRow("状态") = "序列号不存在" e.DataRow.locked = True SystemReady = True End If End If End If Dim tjrk As WinForm.Button = e.Form.Controls("Button3") Dim qxbcrk As WinForm.Button = e.Form.Controls("Button5") For Each ddr As DataRow In DataTables("U8物料数量汇总表").DataRows If ddr("比较结果") = 0 Then tjrk.Enabled = True qxbcrk.Enabled = False Else tjrk.Enabled = False qxbcrk.Enabled = True End If Next Dim drksl As WinForm.Button = Forms("非插卡收货扫描").Controls("Button2") Dim sum As Integer = DataTables("非插卡收货扫描").Compute("SUM(数量)") drksl.text = "实扫到数量" & "(" & sum & ")"
[此贴子已经被作者于2016/2/1 12:43:50编辑过]
|
-- 作者:大红袍 -- 发布时间:2016/2/1 12:18:00 -- 弹出
msgbox(dr IsNot Nothing) |
-- 作者:huhu -- 发布时间:2016/2/1 12:45:00 -- msgbox(dr4 IsNot Nothing)----返回false |
-- 作者:大红袍 -- 发布时间:2016/2/1 14:05:00 -- 看5楼啊,弹出dr啊。你的这个If Else是判断dr的。
条件不匹配肯定不执行代码啊。 |
-- 作者:huhu -- 发布时间:2016/2/1 14:31:00 -- 我上面标红标错了。是判断dr4的。反馈为false |
-- 作者:大红袍 -- 发布时间:2016/2/1 14:34:00 -- 要匹配if else啊
If e.DataCol.name = "SN" Then |