以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 变量 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=185249) |
-- 作者:朱女士 -- 发布时间: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("选员工工时日记表") |
-- 作者:有点蓝 -- 发布时间:2023/2/13 10:34:00 -- Dim tjs As Double = DataTables("实时工序计算表").Compute("Sum(" & nr1 & ")", " |