以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  调用函数错误  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=189357)

--  作者:朱女士
--  发布时间:2023/11/27 15:33:00
--  调用函数错误
老师您好!
   我有一个计算,调用了函数,出现了错误,以前是access数据源,现在是sql server数据源,烦请帮看看,谢谢!
错误信息:

图片点击可在新窗口打开查看此主题相关图片如下:计算函数错误.png
图片点击可在新窗口打开查看

代码:
im aa(50) As Object
Dim dtp1 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim dt1 As Date = dtp1.value
Dim dtp2 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2")
Dim dt2 As Date = dtp2.value

DataTables("实时工序计算表").LoadFilter = ""
DataTables("实时工序计算表").Load()

\'按客户与日期加载数据表
DataTables("实时工序计算表").LoadFilter = "发货日期>= \'" & dt1 & " \' and 发货日期<= \'" & dt2 & "\' and 清单条码编码 is not null"
DataTables("实时工序计算表").Load()
Dim tname As String = "选日期计算全员工时明细表"
aa(3) = tname
\'\'5、创建查询表
Dim dtb1 As New DataTableBuilder(tname)
aa(4) = dtb1
Functions.Execute("按员工姓名建表", aa)
Dim gxs As New List(Of String)
aa(5) = gxs
Functions.Execute("工序字段", aa)
dtb1.Build()
\'计算数据
\'Dim names As List(Of String)

For Each name As String() In DataTables("实时工序计算表").GetValues("员工姓名|清单条码编码", "发货日期 is not null")
aa(12) = name
Functions.Execute("全员工作量合计数据", aa)

Next 
MessageBox.Show("计算完毕!", "提示!")
e.form.close 
mainTable = Tables(tname)

自定义函数:全员工作量合计数据


Dim cp, kh As String
Dim tname As String = Args(3)
Dim tzl, tsl, jts, dwzl, dwsl As Double
Dim name As String() = Args(12)
dim jr as DataRow
Dim dr1 As DataRow = DataTables("实时工序计算表").find("员工姓名=\'" & name(0) & "\' and 清单条码编码=\'" & name(1) & "\'")
If dr1 IsNot Nothing Then
    Dim ur As DataRow = DataTables("ddqdb").find("清单条码编码=\'" & name(1) & "\'")
    
    If ur IsNot Nothing Then
        cp = ur("产品类型") 
        kh = ur("客户")
        tzl = ur("重量")
        tsl = ur("件每台") * ur("台数")
        jts = ur("件每台")
        jr = DataTables(tname).AddNew()
        
        jr("项目号") = ur("项目号")
        jr("员工姓名") = name(0)
        jr("清单条码编码") = name(1)
        jr("客户") = kh 
        jr("产品类型") = cp
        jr("台数") = ur("台数")
        If jts <> 0 Then
            jr("件每台") = jts
        Else
            jr("件每台") = Nothing
        End If
        jr("日期") = dr1("发货日期")
        jr("变压器型号") = ur("变压器型号")
        jr("所属装配") = ur("所属装配")
        jr("产品名称") = ur("产品名称")
        jr("产品图号") = ur("产品图号")
        jr("订单类别") = ur("订单类别")
        jr("重量") = tzl
        jr("数量") = tsl
    End If 
    
    Dim tzlhs As Double = DataTables("实时工序计算表").Compute("Sum(实际耗时)", "员工姓名=\'" & name(0) & "\' and 清单条码编码=\'" & name(1) & "\'and 结算单位=\'重量\'")
    Dim tslhs As Double = DataTables("实时工序计算表").Compute("Sum(实际耗时)", "员工姓名=\'" & name(0) & "\' and 清单条码编码=\'" & name(1) & "\'and 结算单位=\'数量\'")
    tzlhs = tzlhs / 60
    tslhs = tslhs / 60
    
    If tzlhs <> 0 Then
        jr("重量耗时h") = round2(tzlhs , 2)
        dwzl = round2(tzl / tzlhs, 2)
        jr("kg/小时") = dwzl
    Else
        jr("重量耗时h") = Nothing
        jr("kg/小时") = Nothing
    End If
    If tzlhs <> 0 Then
        jr("数量耗时h") = round2(tzlhs , 2)
        dwsl = round2(tsl / tslhs, 2)
        jr("数量/小时") = dwzl
    Else
        jr("数量耗时h") = Nothing
        jr("数量/小时") = Nothing
    End If
    jr("总耗时h") = round2((tzlhs + tslhs), 2)
End If

Dim gxs As List(Of String) = Args(5)


For Each gx As String In DataTables("实时工序计算表").GetValues("工序名称", "", "顺序号")
    gxs.Add(gx)
    
    Dim gxzl As Double = DataTables("实时工序计算表").Compute("Sum(重量)", "员工姓名=\'" & name(0) & "\' and [清单条码编码]=\'" & name(1) & "\' and 工序名称=\'" & gx & "\' and 结算单位=\'重量 \'")
    Dim gxzlhs As Double = DataTables("实时工序计算表").Compute("Sum(实际耗时)", "员工姓名=\'" & name(0) & "\' and [清单条码编码]=\'" & name(1) & "\' and 工序名称=\'" & gx & "\' and 结算单位=\'重量 \'")
    Dim gxsl As Double = DataTables("实时工序计算表").Compute("Sum(件数)", "员工姓名=\'" & name(0) & "\' and [清单条码编码]=\'" & name(1) & "\' and 工序名称=\'" & gx & "\' and 结算单位=\'数量 \'")
    Dim gxslhs As Double = DataTables("实时工序计算表").Compute("Sum(实际耗时)", "员工姓名=\'" & name(0) & "\' and [清单条码编码]=\'" & name(1) & "\' and 工序名称=\'" & gx & "\' and 结算单位=\'数量 \'")
    
    gxzlhs = gxzlhs / 60
    gxslhs = gxslhs / 60
    
    Dim gxx1 As String = gx & "_重量"
    Dim gxx2 As String = gx & "_重量耗时h"
    Dim gxx3 As String = gx & "_数量"
    Dim gxx4 As String = gx & "_数量耗时h" 
    If gxzlhs <> 0 Then
        jr(gxx1) = round2(gxzl, 2)
        jr(gxx2) = round2(gxzlhs, 2)
    Else
        jr(gxx1) = Nothing
        jr(gxx2) = Nothing
    End If
    If gxslhs <> 0 Then
        jr(gxx3) = round2(gxsl, 2)
        jr(gxx4) = round2(gxslhs, 2)
    Else
        jr(gxx3) = Nothing
        jr(gxx4) = Nothing
    End If
    
    
    Tables(tname).Cols(gxx1).GrandTotal = True
    Tables(tname).Cols(gxx2).GrandTotal = True
    Tables(tname).Cols(gxx3).GrandTotal = True
    Tables(tname).Cols(gxx4).GrandTotal = True
Next


--  作者:有点蓝
--  发布时间:2023/11/27 15:52:00
--  
调试看是哪一句代码出错