以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]帮忙分析一下代码,谢谢! (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=64902) |
-- 作者:rophy0952 -- 发布时间:2015/3/4 18:28:00 -- [求助]帮忙分析一下代码,谢谢! If e.DataCol.name = "每箱净重" Then Dim dr As DataRow = e.DataRow If dr("计价") = 1 AndAlso dr("等级") = "一等品" Then Dim dr1 As DataRow = DataTables("订单明细表").SQLfind("客户订单号 = \'" & e.DataRow("客户订单号") & "\'and 客户代号 = \'"& e.DataRow("客户代号") & "\'and 规格 = \'"& e.datarow("产品规格") & "\'and 厂商代号 = \'" & e.DataRow("厂商代号") & "\' and 作废 = 0") If dr1 IsNot Nothing Then dr("单价") = dr1("单价") End If End If If dr("计价") = 1 AndAlso dr("等级") <> "一等品"Then Dim dr2 As DataRow = DataTables("销售价格表").SQLfind("客户代号 = \'" & e.DataRow("客户代号") & "\'and 物料类型 = \'" & e.DataRow("物料类型") & "\' and 规格 = \'"& e.datarow("产品规格") & "\'and 型号 = \'"& e.datarow("产品型号") & "\'and 基材来源 = \'" & e.DataRow("基材来源") & "\' and 厂商代号 = \'" & e.DataRow("厂商代号") & "\'and 物料等级 = \'二等品\'") If dr2 IsNot Nothing Then dr("单价") = dr2("单价") End If End If If dr("计价") = 0 Then dr("单价") = 0 End If End If 以上代码用来生成单价,想实现以下功能: 1.当“计价”列为true时,“等级”列为一等品时,从“订单明细表”中提取单价; 2.当“计价”列为true时,“等级”列不等于一等品时,从“销售价格表”中提取单价; 2.当“计价”列为true时,单价为0; 在运行以上代码时,提示错误:“未将对象引用设置到对象的实例。”,请问是何原因?
|
-- 作者:yinyb36 -- 发布时间:2015/3/4 18:52:00 -- If e.DataCol.name = "每箱净重" Then Dim dr As DataRow = e.DataRow If dr("计价") = true If dr("等级") = "一等品" Then Dim dr1 As DataRow = DataTables("订单明细表").SQLfind("客户订单号 = \'" & e.DataRow("客户订单号") & "\'and 客户代号 = \'"& e.DataRow("客户代号") & "\'and 规格 = \'"& e.datarow("产品规格") & "\'and 厂商代号 = \'" & e.DataRow("厂商代号") & "\' and 作废 = 0") If dr1 IsNot Nothing Then dr("单价") = dr1("单价") End If Else Dim dr2 As DataRow = DataTables("销售价格表").SQLfind("客户代号 = \'" & e.DataRow("客户代号") & "\'and 物料类型 = \'" & e.DataRow("物料类型") & "\' and 规格 = \'"& e.datarow("产品规格") & "\'and 型号 = \'"& e.datarow("产品型号") & "\'and 基材来源 = \'" & e.DataRow("基材来源") & "\' and 厂商代号 = \'" & e.DataRow("厂商代号") & "\'and 物料等级 = \'二等品\'") If dr2 IsNot Nothing Then dr("单价") = dr2("单价") End If End If Else dr("单价") = 0 End If End If
|
-- 作者:有点甜 -- 发布时间:2015/3/4 19:11:00 -- 你的代码不会报这个错,肯定是别的代码影响了。
具体可以上传例子测试。 |
-- 作者:rophy0952 -- 发布时间:2015/3/5 17:24:00 -- 现在不出现提示,但也无法出现单价。烦请指导,谢谢! |
-- 作者:有点甜 -- 发布时间:2015/3/5 17:30:00 -- If e.DataCol.name = "每箱净重" Then Select Case e.DataCol.Name |