以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 填充数据时有相同的不填充 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=184935) |
-- 作者:青丘狐 -- 发布时间:2023/1/18 11:22:00 -- 填充数据时有相同的不填充 Dim f As New Filler f.SourceTable = DataTables("初始库存明细") \'指定数据来源 f.SourceCols = "仓库名称,品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号,计量方式,机构,部门,日期" \'指定数据来源列 f.DataTable = DataTables("现货库存明细") \'指定数据接收表 f.DataCols = "仓库名称,品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号,入库计量方式,机构,部门,进货日期" \'指定数据接收列 f.Fill() \'填充数据 填充数据时现货库存明细里有 品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号有和初始库存明细相同的值就不填充,请问要怎么改代码
[此贴子已经被作者于2023/1/18 11:23:23编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/1/18 11:27:00 -- 换种方式填充:http://www.foxtable.com/webhelp/topics/1533.htm 先使用find查询一下,有相同数据的就不填充 Dim Cols1() As String = {"来源列一","来源列二","来源列三"} Dim Cols2() As String = {"接收列一","接收列二","接收列三"} For Each dr1 As DataRow In DataTables("表A").Select("[金额] > 100") Dim dr2 As DataRow = DataTables("表B").find("接收列一=\'" & dr1("来源列一") & "\' and 接收列二=\'" & dr1("来源列二") & "\'") if dr2 isnothing then dr2 = DataTables("表B").AddNew() For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr1(Cols1(i)) Next end if Next |
-- 作者:青丘狐 -- 发布时间:2023/1/18 13:51:00 -- Dim Cols1() As String = {"仓库名称,品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号,计量方式,机构,部门,日期"} Dim Cols2() As String = {"仓库名称,品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号,入库计量方式,机构,部门,进货日期"} For Each dr1 As DataRow In DataTables("初始库存明细").Select("") Dim dr2 As DataRow = DataTables("现货库存明细").find("品名=\'" & dr1("品名") & "\' and 材质=\'" & dr1("材质") & "\'and 规格=\'" & dr1("规格") & "\' and 产地=\'" & dr1("产地") & "\' and 库存数量=\'" & dr1("库存数量") & "\' and 库存重量=\'" & dr1("库存重量") & "\' and 车船号=\'" & dr1("车船号") & "\' and 货位号=\'" & dr1("货位号") & "\' and 入库计量方式=\'" & dr1("计量方式") & "\' and 机构=\'" & dr1("机构") & "\' and 部门=\'" & dr1("部门") & "\' and 进货日期=\'" & dr1("日期")) If dr2 Is Nothing Then dr2 = DataTables("现货库存明细").AddNew() For i As Integer = 0 To Cols1.Length - 1 dr2(Cols2(i)) = dr1(Cols1(i)) Next End If Next .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2022.8.1.1 错误所在事件:窗口,初始库存明细,Button1,Click 详细错误信息: 表达式包含无效的字符串常量: \'2020-11-11。 是不是日期复制出错?日期时间型 [此贴子已经被作者于2023/1/18 13:51:41编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/1/18 14:00:00 -- and 进货日期=#" & dr1("日期") & “#”)
|
-- 作者:青丘狐 -- 发布时间:2023/1/18 14:18:00 -- .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2022.8.1.1 错误所在事件:窗口,初始库存明细,Button1,Click 详细错误信息: 列“仓库名称,品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号,计量方式,机构,部门,日期”不属于表 初始库存明细。 数据复制不了现货库存明细增加空行 Dim Cols1() As String = {"仓库名称,品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号,计量方式,机构,部门,日期"} Dim Cols2() As String = {"仓库名称,品名,材质,规格,产地,长度,库存数量,库存重量,车船号,货位号,入库计量方式,机构,部门,进货日期"} For Each dr1 As DataRow In DataTables("初始库存明细").Select("") Dim dr2 As DataRow = DataTables("现货库存明细").find("品名=\'" & dr1("品名") & "\' and 材质=\'" & dr1("材质") & "\'and 规格=\'" & dr1("规格") & "\' and 产地=\'" & dr1("产地") & "\' and 库存数量=\'" & dr1("库存数量") & "\' and 库存重量=\'" & dr1("库存重量") & "\' and 车船号=\'" & dr1("车船号") & "\' and 货位号=\'" & dr1("货位号") & "\' and 入库计量方式=\'" & dr1("计量方式") & "\' and 机构=\'" & dr1("机构") & "\' and 部门=\'" & dr1("部门") & "\' and 进货日期=#" & dr1("日期") & "#") If dr2 Is Nothing Then dr2 = DataTables("现货库存明细").AddNew() For i As Integer = 0 To Cols1.Length - 1 dr2(Cols2(i)) = dr1(Cols1(i)) Next End If Next [此贴子已经被作者于2023/1/18 14:18:27编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/1/18 14:29:00 -- 此主题相关图片如下:1.png |
-- 作者:青丘狐 -- 发布时间:2023/1/18 14:30:00 -- Dim dr2 As DataRow = DataTables("现货库存明细").find("品名=\'" & dr1("品名") & "\' and 材质=\'" & dr1("材质") & "\'and 规格=\'" & dr1("规格") & "\' and 产地=\'" & dr1("产地") & "\' and 库存数量=" & dr1("库存数量") & " and 库存重量=" & dr1("库存重量") & " and 车船号=\'" & dr1("车船号") & "\' and 货位号=\'" & dr1("货位号") & "\' and 入库计量方式=\'" & dr1("计量方式") & "\' and 机构=\'" & dr1("机构") & "\' and 部门=\'" & dr1("部门") & "\' and 进货日期=#" & dr1("日期") & "#") 如果是数值,则不需要括起来,直接使用即可,数值写法对吧? |
-- 作者:有点蓝 -- 发布时间:2023/1/18 14:32:00 -- 对的 |
-- 作者:青丘狐 -- 发布时间:2023/1/18 14:56:00 -- Dim Cols1() As String = {"仓库名称", "品名", "材质", "规格", "产地", "长度", "库存数量", "库存重量", "车船号", "货位号", "计量方式", "机构", "部门", "日期"} Dim Cols2() As String = {"仓库名称","品名","材质","规格","产地","长度","库存数量","库存重量","车船号","货位号","入库计量方式","机构","部门","进货日期"} For Each dr1 As DataRow In DataTables("初始库存明细").Select("") Dim dr2 As DataRow = DataTables("现货库存明细").find("品名=\'" & dr1("品名") & "\' and 材质=\'" & dr1("材质") & "\'and 规格=\'" & dr1("规格") & "\' and 产地=\'" & dr1("产地") & "\' and 库存数量=" & dr1("库存数量") & " and 库存重量=" & dr1("库存重量") & " and 车船号=\'" & dr1("车船号") & "\' and 货位号=\'" & dr1("货位号") & "\' and 入库计量方式=\'" & dr1("计量方式") & "\' and 机构=\'" & dr1("机构") & "\' and 部门=\'" & dr1("部门") & "\' and 进货日期=#" & dr1("日期") & "#") If dr2 Is Nothing Then dr2 = DataTables("现货库存明细").AddNew() For i As Integer = 0 To Cols1.Length - 1 dr2(Cols2(i)) = dr1(Cols1(i)) Next End If Next 可以复制了,有缺点是在初始库存明细里有空行是会把空行也复制了,请问怎样禁止空行复制的代码
|
-- 作者:有点蓝 -- 发布时间:2023/1/18 15:04:00 -- For Each dr1 As DataRow In DataTables("初始库存明细").Select("仓库名称 is not null") |