Foxtable(狐表)用户栏目专家坐堂 → 变量


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

主题:变量

美女呀,离线,留言给我吧!
朱女士
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:513 积分:4073 威望:0 精华:0 注册:2020/2/8 11:14:00
变量  发帖心情 Post By:2023/2/13 10:32:00 [只看该作者]

老师您好!
我的代码,出现错误信息:找不到列[nr1]。其实数据表里有这列,这是变量调用问题?麻烦帮忙看看,谢谢!重点是我标的“绿颜色”部分。
Dim dtp1 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim dtp2 As WinForm.combobox = e.Form.Controls("combobox1")
Dim ygxm As String = dtp2.value
Dim y1 As Integer = year(dtp1.value)
Dim m1 As Integer = month(dtp1.value)
Dim dt1 As New Date(y1, m1, 1)
Dim dt2 As New Date(y1, m1, Date.DaysInMonth(y1, m1))
Dim dds As Integer = Date.DaysInMonth(y1, m1)
'生成表格

Dim dtb As New DataTableBuilder("选员工工时日记表")

dtb.AddDef("年月", GetType(String), 8)
dtb.AddDef("日期", GetType(String), 4)

dtb.AddDef("清单条码编码", GetType(String), 28)
dtb.AddDef("客户", GetType(String), 18)
dtb.AddDef("项目号", GetType(String), 58)
dtb.AddDef("产品类型", GetType(String), 28)
dtb.AddDef("产品图号", GetType(String), 58)
dtb.AddDef("产品名称", GetType(String), 28)
dtb.AddDef("内容", GetType(String), 8)
Dim gxs As New List(Of String)

For Each gx As String In DataTables("实时工序计算表").GetValues("工序名称", "员工姓名 like '" & ygxm & "'")
    gxs.Add(gx)
    dtb.AddDef(gx, GetType(String), 18)
Next
dtb.Build()
Dim arys() As String = gxs.ToArray()


Dim i, j As Integer
Dim s1() As String = {"实际耗时", "重量", "件数"}
Dim mm, nn As String
If m1 <= 9 Then
    mm = "0" & trim(str(m1))
Else
    mm = trim(Str(m1))
End If

Dim s As Integer
For i = 1 To dds
    If i <= 9 Then
        nn = "0" & trim(str(i))
    Else
        nn = trim (str(i))
    End If 
    For j = 1 To 3
        Dim v As String = trim(Str(j))
        Dim q As Integer = 0
        Dim rq As String = Str(y1) + Str(mm) + Str(nn)
        Dim da1 As Date = CDate(rq)
        
        For Each qdtm As String In DataTables("实时工序计算表").GetValues("清单条码编码", "员工姓名 like '" & ygxm & "'and 日期= #" & da1 & "#")
            Dim mr As DataRow = DataTables("实时工序计算表").find("清单条码编码='" & qdtm & "'and 员工姓名 like '" & ygxm & "'and 日期= #" & da1 & "#")
            If mr IsNot Nothing Then 
                q = q + 1 
                Dim dr As DataRow = DataTables("选员工工时日记表").AddNew() 
                dr("清单条码编码") = qdtm
                dr("年月") = str(y1) & mm
                dr("日期") = nn 
                dr("内容") = s1(j - 1)
                Dim nr1 As String = s1(j - 1)
             
                For Each gxm As String In gxs
                    'Dim tjs As Double = DataTables("实时工序计算表").Compute("Sum(sl(j-1))", "[日期]=#" & da1 & "# and [清单条码编码]='" & qdtm & "' and [员工姓名] like '" & ygxm & "'and [工序名称]='" & gxm & "'")
                   Dim tjs As Double = DataTables("实时工序计算表").Compute("Sum(nr1)", "[日期]=#" & da1 & "# and [清单条码编码]='" & qdtm & "' and [员工姓名] like '" & ygxm & "'and [工序名称]='" & gxm & "'")
                   ' dr(gxm) = tjs
                    
                Next 
            End If
        Next 
        
    Next 
    
Next
For Each wr1 As DataRow In DataTables("选员工工时日记表").DataRows
    Dim tm1 As String = wr1("清单条码编码")
    
    Dim qr As DataRow = DataTables("ddqdb").find("清单条码编码='" & tm1 & "'")
    If qr IsNot Nothing Then
        wr1("项目号") = qr("项目号") 
        wr1("产品类型") = qr("产品类型")
        wr1("客户") = qr("客户") 
        wr1("产品名称") = qr("产品名称")
        wr1("项目号") = qr("项目号") 
        wr1("产品图号") = qr("产品图号")
    End If
Next

MessageBox.Show("计算完毕!", "提示!")
MainTable = Tables("选员工工时日记表")





图片点击可在新窗口打开查看此主题相关图片如下:bb7eeacc64f29ae5542bfc87688dedb.jpg
图片点击可在新窗口打开查看


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


加好友 发短信
等级:超级版主 帖子:111381 积分:566969 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/2/13 10:34:00 [只看该作者]

Dim tjs As Double = DataTables("实时工序计算表").Compute("Sum(" & nr1 & ")", "

 回到顶部