Foxtable(狐表)用户栏目专家坐堂 → 执行“=”操作报错原因


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

主题:执行“=”操作报错原因

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


加好友 发短信
等级:幼狐 帖子:136 积分:1427 威望:0 精华:0 注册:2013/8/7 18:14:00
执行“=”操作报错原因  发帖心情 Post By:2021/11/22 18:34:00 [只看该作者]

'采购入库的产品净银重
Dim jb1 As New SQLJoinTableBuilder("应付初数据1","R03_InboundProducts_Detail")
Jb1.C
Jb1.AddTable("R03_InboundProducts_Detail","smartID","R03_InboundProducts","smartID")
Jb1.AddTable("R03_InboundProducts_Detail","itemID","R02_SilverStyle","itemID")
Jb1.AddExp("单据类型","'产品净银重'")
Jb1.AddExp("供应商代码","customerCode",True)
Jb1.AddExp("供应商名称","customerName",True)
Jb1.AddExp("本单日期","R03_InboundProducts.smartDate",True)
Jb1.AddExp("系统单号","R03_InboundProducts_Detail.smartID",True)
Jb1.AddExp("工费单号","R03_InboundProducts_Detail.smartID",True)
Jb1.AddExp("领料单号","case when sourceID is null then '无' ELSE sourceID end",True)
Jb1.AddExp("产品成色","R02_SilverStyle.materialName",True)
Jb1.AddExp("比较成色","R02_SilverStyle.materialName",True)
Jb1.AddExp("产品净银重","sum(isnull(weight,0)-isnull(stoneWeight,0))")
Jb1.AddExp("实领料成色","''")
Jb1.AddExp("实领料银重","'0'")
Jb1.AddExp("实工费","''")
Jb1.Filter = "convert(nvarchar(10),R03_InboundProducts.smartDate,121)>='"& StartDate &"' And convert(nvarchar(10),R03_InboundProducts.smartDate,121)<='"& EndDate &"'"


'半成品入库的产品净银重
Dim jb3 As New SQLJoinTableBuilder("应付初数据1","R03_SemiWarehousing_Detail")
Jb3.C
Jb3.AddTable("R03_SemiWarehousing_Detail","smartID","R03_SemiWarehousing","smartID")
Jb3.AddTable("R03_SemiWarehousing_Detail","itemID","R02_SilverStyle","itemID")
Jb3.AddExp("单据类型","'产品净银重'")
Jb3.AddExp("供应商代码","customerCode",True)
Jb3.AddExp("供应商名称","customerName",True)
Jb3.AddExp("本单日期","R03_SemiWarehousing.smartDate",True)
Jb3.AddExp("系统单号","R03_SemiWarehousing.smartID",True)
Jb3.AddExp("工费单号","R03_SemiWarehousing.smartID",True)
Jb3.AddExp("领料单号","sourceID",True)
Jb3.AddExp("产品成色","R02_SilverStyle.materialName",True)
Jb3.AddExp("比较成色","R02_SilverStyle.materialName",True)
Jb3.AddExp("产品净银重","sum(isnull(weight,0)-isnull(stoneWeight,0))")
Jb3.AddExp("实领料成色","''")
Jb3.AddExp("实领料银重","''")
Jb3.AddExp("实工费","''")
Jb3.Filter = "convert(nvarchar(10),R03_SemiWarehousing.smartDate,121)>='"& StartDate &"' And convert(nvarchar(10),R03_SemiWarehousing.smartDate,121)<='"& EndDate &"'"



'报废退货单的产品净银重
Dim jb4 As New SQLJoinTableBuilder("应付初数据1","R03_DelegationScrap_Detail")
Jb4.C
Jb4.AddTable("R03_DelegationScrap_Detail","smartID","R03_DelegationScrap","smartID")
Jb4.AddTable("R03_DelegationScrap_Detail","itemID","R02_SilverStyle","itemID")
Jb4.AddExp("单据类型","'产品净银重'")
Jb4.AddExp("供应商代码","customerCode",True)
Jb4.AddExp("供应商名称","customerName",True)
Jb4.AddExp("本单日期","R03_DelegationScrap.smartDate",True)
Jb4.AddExp("系统单号","R03_DelegationScrap.smartID",True)
Jb4.AddExp("工费单号","R03_DelegationScrap.smartID",True)
Jb4.AddExp("领料单号","'无'")
Jb4.AddExp("产品成色","R02_SilverStyle.materialName",True)
Jb4.AddExp("比较成色","R02_SilverStyle.materialName",True)
Jb4.AddExp("产品净银重","-(sum(isnull(weight,0)-isnull(stoneWeight,0)))")
Jb4.AddExp("实领料成色","''")
Jb4.AddExp("实领料银重","''")
Jb4.AddExp("实工费","''")
Jb4.Filter = "convert(nvarchar(10),R03_DelegationScrap.smartDate,121)>='"& StartDate &"' And convert(nvarchar(10),R03_DelegationScrap.smartDate,121)<='"& EndDate &"' and materialTypeCode='02'"


'领料出库领料重
Dim Jb2 As New SQLJoinTableBuilder("应付初数据1","R04_OutboundMaterial_Detail")
Jb2.C
Jb2.AddTable("R04_OutboundMaterial_Detail","smartID","R04_OutboundMaterial","smartID")
Jb2.AddTable("R04_OutboundMaterial_Detail","itemID","R02_SilverStyle","itemID")
Jb2.AddExp("单据类型","'领料重'")
Jb2.AddExp("供应商代码","customerCode",True)
Jb2.AddExp("供应商名称","customerName",True)
Jb2.AddExp("本单日期","R04_OutboundMaterial.smartDate",True)
Jb2.AddExp("系统单号","R04_OutboundMaterial.smartID",True)
Jb2.AddExp("工费单号","factoryID",True)
Jb2.AddExp("领料单号","R04_OutboundMaterial.smartID",True)
Jb2.AddExp("产品成色","''")
Jb2.AddExp("比较成色","itemName",True)
Jb2.AddExp("产品净银重","null")
Jb2.AddExp("实领料成色","itemName",True)
Jb2.AddExp("实领料银重","-sum(isnull(weight,0))")
Jb2.AddExp("实工费","''")
Jb2.Filter = "convert(nvarchar(10),R04_OutboundMaterial.smartDate,121)>='"& StartDate &"' And convert(nvarchar(10),R04_OutboundMaterial.smartDate,121)<='"& EndDate &"'"


'报废退货单的领料重
Dim jb5 As New SQLJoinTableBuilder("应付初数据1","R03_DelegationScrap_Detail")
Jb5.C
Jb5.AddTable("R03_DelegationScrap_Detail","smartID","R03_DelegationScrap","smartID")
Jb5.AddTable("R03_DelegationScrap_Detail","itemID","R02_SilverStyle","itemID")
Jb5.AddExp("单据类型","'领料重'")
Jb5.AddExp("供应商代码","customerCode",True)
Jb5.AddExp("供应商名称","customerName",True)
Jb5.AddExp("本单日期","R03_DelegationScrap.smartDate",True)
Jb5.AddExp("系统单号","R03_DelegationScrap.smartID",True)
Jb5.AddExp("工费单号","'无'")
Jb5.AddExp("领料单号","R03_DelegationScrap.smartID",True)
Jb5.AddExp("产品成色","''")
Jb5.AddExp("比较成色","R02_SilverStyle.materialName",True)
Jb5.AddExp("产品净银重","null")
Jb5.AddExp("实领料成色","R02_SilverStyle.materialName",True)
Jb5.AddExp("实领料银重","-(sum(isnull(weight,0)-isnull(stoneWeight,0)))")
Jb5.AddExp("实工费","''")
Jb5.Filter = "convert(nvarchar(10),R03_DelegationScrap.smartDate,121)>='"& StartDate &"' And convert(nvarchar(10),R03_DelegationScrap.smartDate,121)<='"& EndDate &"' and materialTypeCode='01'"


'半成品入库的实工费
Dim jb6 As New SQLJoinTableBuilder("应付初数据1","R03_SemiWarehousing")
Jb6.C
Jb6.AddExp("单据类型","'实工费'")
Jb6.AddExp("供应商代码","customerCode")
Jb6.AddExp("供应商名称","customerName")
Jb6.AddExp("本单日期","smartDate")
Jb6.AddExp("系统单号","smartID")
Jb6.AddExp("工费单号","smartID")
Jb6.AddExp("领料单号","sourceID")
Jb6.AddExp("产品成色","''")
Jb6.AddExp("比较成色","''")
Jb6.AddExp("产品净银重","null")
Jb6.AddExp("实领料成色","''")
Jb6.AddExp("实领料银重","''")
Jb6.AddExp("实工费","actualAmount")
Jb6.Filter = "" & TimeRange & ""

'委外入库的实工费
Dim jb7 As New SQLJoinTableBuilder("应付初数据1","R03_DelegationInbound")
Jb7.C
Jb7.AddExp("单据类型","'实工费'")
Jb7.AddExp("供应商代码","customerCode")
Jb7.AddExp("供应商名称","customerName")
Jb7.AddExp("本单日期","smartDate")
Jb7.AddExp("系统单号","smartID")
Jb7.AddExp("工费单号","smartID")
Jb7.AddExp("领料单号","''")
Jb7.AddExp("产品成色","''")
Jb7.AddExp("比较成色","''")
Jb7.AddExp("产品净银重","null")
Jb7.AddExp("实领料成色","''")
Jb7.AddExp("实领料银重","''")
Jb7.AddExp("实工费","actualAmount")
Jb7.Filter = "" & TimeRange & ""

'返修入库的实工费
Dim jb8 As New SQLJoinTableBuilder("应付初数据1","R03_RepairRetrieve")
Jb8.C
Jb8.AddExp("单据类型","'实工费'")
Jb8.AddExp("供应商代码","customerCode")
Jb8.AddExp("供应商名称","customerName")
Jb8.AddExp("本单日期","smartDate")
Jb8.AddExp("系统单号","smartID")
Jb8.AddExp("工费单号","smartID")
Jb8.AddExp("领料单号","''")
Jb8.AddExp("产品成色","''")
Jb8.AddExp("比较成色","''")
Jb8.AddExp("产品净银重","null")
Jb8.AddExp("实领料成色","''")
Jb8.AddExp("实领料银重","''")
Jb8.AddExp("实工费","actualAmount")
Jb8.Filter = "" & TimeRange & ""

'报废退货的实工费
Dim jb9 As New SQLJoinTableBuilder("应付初数据1","R03_DelegationScrap")
Jb9.C
Jb9.AddExp("单据类型","'实工费'")
Jb9.AddExp("供应商代码","customerCode")
Jb9.AddExp("供应商名称","customerName")
Jb9.AddExp("本单日期","smartDate")
Jb9.AddExp("系统单号","smartID")
Jb9.AddExp("工费单号","smartID")
Jb9.AddExp("领料单号","'无'")
Jb9.AddExp("产品成色","''")
Jb9.AddExp("比较成色","''")
Jb9.AddExp("产品净银重","null")
Jb9.AddExp("实领料成色","''")
Jb9.AddExp("实领料银重","''")
Jb9.AddExp("实工费","actualAmount")
Jb9.Filter = "" & TimeRange & ""

'付款单的实工费
Dim jb10 As New SQLJoinTableBuilder("应付初数据1","R06_PayMoney_Detail")
Jb10.C
Jb10.AddExp("单据类型","'实工费'")
Jb10.AddTable("R06_PayMoney_Detail","smartID","R06_PayMoney","smartID")
Jb10.AddExp("供应商代码","customerCode")
Jb10.AddExp("供应商名称","customerName")
Jb10.AddExp("本单日期","smartDate")
Jb10.AddExp("系统单号","R06_PayMoney_Detail.smartID")
Jb10.AddExp("工费单号","R06_PayMoney_Detail.smartID+'序'+cast(number as varchar)")
Jb10.AddExp("领料单号","''")
Jb10.AddExp("产品成色","''")
Jb10.AddExp("比较成色","''")
Jb10.AddExp("产品净银重","null")
Jb10.AddExp("实领料成色","''")
Jb10.AddExp("实领料银重","''")
Jb10.AddExp("实工费","-amount")
Jb10.Filter = "" & TimeRange & ""

'往来费用单的实工费
Dim jb11 As New SQLJoinTableBuilder("应付初数据1","R06_Account_Detail")
Jb11.C
Jb11.AddExp("单据类型","'实工费'")
Jb11.AddTable("R06_Account_Detail","smartID","R06_Account","smartID")
Jb11.AddExp("供应商代码","customerCode")
Jb11.AddExp("供应商名称","customerName")
Jb11.AddExp("本单日期","smartDate")
Jb11.AddExp("系统单号","R06_Account_Detail.smartID")
Jb11.AddExp("工费单号","R06_Account_Detail.smartID+'序'+cast(number as varchar)")
Jb11.AddExp("领料单号","''")
Jb11.AddExp("产品成色","''")
Jb11.AddExp("比较成色","''")
Jb11.AddExp("产品净银重","null")
Jb11.AddExp("实领料成色","''")
Jb11.AddExp("实领料银重","''")
Jb11.AddExp("实工费","amount")
Jb11.Filter = "" & TimeRange & ""

'材料入库的实工费
Dim jb12 As New SQLJoinTableBuilder("应付初数据1","R04_InboundMaterial")
Jb12.C
Jb12.AddExp("单据类型","'实工费'")
Jb12.AddExp("供应商代码","customerCode")
Jb12.AddExp("供应商名称","customerName")
Jb12.AddExp("本单日期","smartDate")
Jb12.AddExp("系统单号","smartID")
Jb12.AddExp("工费单号","smartID")
Jb12.AddExp("领料单号","''")
Jb12.AddExp("产品成色","''")
Jb12.AddExp("应领料成色","''")
Jb12.AddExp("产品净银重","null")
Jb12.AddExp("比较成色","''")
Jb12.AddExp("实领料银重","''")
Jb12.AddExp("实工费","actualAmount")
Jb12.Filter = "" & TimeRange & ""

'采购成品入库的实工费
Dim jb13 As New SQLJoinTableBuilder("应付初数据1","R03_InboundProducts")
Jb13.C
Jb13.AddExp("单据类型","'实工费'")
Jb13.AddExp("供应商代码","customerCode")
Jb13.AddExp("供应商名称","customerName")
Jb13.AddExp("本单日期","smartDate")
Jb13.AddExp("系统单号","smartID")
Jb13.AddExp("工费单号","smartID")
Jb13.AddExp("领料单号","sourceID")
Jb13.AddExp("产品成色","''")
Jb13.AddExp("比较成色","''")
Jb13.AddExp("产品净银重","null")
Jb13.AddExp("实领料成色","''")
Jb13.AddExp("实领料银重","''")
Jb13.AddExp("实工费","actualAmount")
Jb13.Filter = "" & TimeRange & ""




'组合jb1  '采购入库的产品净银重
jb1.Merge(jb2)  '组合jb2  '领料出库领料重
jb1.Merge(jb3)  '组合jb3  '半成品入库的产品净银重
jb1.Merge(jb4)  '组合jb4  '报废退货单的产品净银重
jb1.Merge(jb5)  '组合jb5  '报废退货单的领料重
jb1.Merge(jb6)  '组合jb6  '半成品入库的实工费
jb1.Merge(jb7)  '组合jb7  '委外入库的实工费
jb1.Merge(jb8)  '组合jb8  '返修入库的实工费
jb1.Merge(jb9)  '组合jb9  '报废退货的实工费
jb1.Merge(jb10) '组合jb10 '付款单的实工费
jb1.Merge(jb11) '组合jb11 '往来费用单的实工费
jb1.Merge(jb12) '组合jb12 '材料入库的实工费
jb1.Merge(jb13) '组合jb13 '采购成品入库的实工费
Dim dt As DataTable
dt=jb1.Build(True)
'MainTable = Tables("应付初数据1")
'Tables("应付初数据1").visible =True

MessageBox.Show(1233)




Dim sCols() As String = {"单据类型","供应商代码","供应商名称","本单日期","系统单号","工费单号","领料单号","产品成色","实工费","产品净银重","实领料成色","实领料银重","比较成色"}
Dim dCols() As String = {"tableName","customerCode","customerName","smartDate","ID","factoryID","sourceID","materialName","actualAmount","weight","actualmaterialName","actualweight","actualmaterial"}
MessageBox.Show(456) ’调试后在此后报错
For Each dr1 As DataRow In dt.DataRows
    If DataTables("R03_payable_Detail").Find("tableName = '" & dr1("单据类型") & "' and ID = '" & dr1("系统单号") & "'and factoryID = '" & dr1("工费单号") & "' and sourceID = '" & dr1("领料单号") & "' and materialName = '" & dr1("产品成色") & "' and actualAmount = '" & dr1("实工费") & "' and weight = '" & dr1("产品净银重") & "' and actualmaterialName = '" & dr1("实领料成色") & "' and actualweight = '" & dr1("实领料银重") & "'") Is Nothing  Then    
 Dim nr As DataRow = DataTables("R03_payable_Detail").AddNew()
        For i As Integer =0 To sCols.Length -1
            nr(dCols(i)) = dr1(sCols(i))
        Next
    End If
Next
MessageBox.Show(789)


以上代码执行后报错如下,求老师解答下
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2021.11.18.11
错误所在事件:窗口,主界面,Button51,Click
详细错误信息:
无法在 System.Double 和 System.String 上执行“=”操作。

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


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/11/22 20:14:00 [只看该作者]

关联的列,列类型必须一致,实领料银重应该不是字符串,那么就不能使用单引号引起来

Jb1.AddExp("实领料银重","0")

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


加好友 发短信
等级:幼狐 帖子:136 积分:1427 威望:0 精华:0 注册:2013/8/7 18:14:00
  发帖心情 Post By:2021/12/1 16:27:00 [只看该作者]

Jb1.AddExp("实领料银重","0"),改成这个以后,导致后面出来的数据都被取整,2935.5显示为2936了,有什么方法解决?对应列已设置为高精度小数

[此贴子已经被作者于2021/12/1 16:29:16编辑过]

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


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/12/1 16:35:00 [只看该作者]

试试

Jb1.AddExp("实领料银重","0 * 0.00001")

 回到顶部