以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  代码错误  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=171327)

--  作者:cjl333333333
--  发布时间:2021/8/26 15:10:00
--  代码错误
     
    Case "磅码单"
        
        Dim Doc As new PrintDoc
        Dim rt As New prt.RenderTable \'定义一个新表格
        doc.PageSetting.PaperKind = 9
        Doc.PageSetting.LeftMargin = 10 \'设置左边距
        Doc.PageSetting.RightMargin = 10 \'设置右边距
        Doc.PageSetting.TopMargin = 15 \'设置上边距
        Doc.PageSetting.BottomMargin = 20 \'设置下边距
        rt.Style.GridLines.All = New prt.Linedef
        
        
        For i As Integer = 0  To Tables("库存表主表.库存表").Rows.Count - 1
            Dim jb As New SQLJoinTableBuilder("磅码单查询","磅码单")
            jb.C
            jb.AddCols( "{磅码单}.*")
            jb.Build()
            
            Tables("磅码单查询").Filter = "编号= \'"& Tables("库存表主表.库存表").Rows(I)("_Identify")& "\'"
            Dim DT As  DataTable = DataTables("磅码单查询")
            Dim rx3 As New prt.RenderTable
            rx3.Cells(0,0).Text =  "产品名称: " & Tables("库存表主表.库存表").Rows(I)("产品名称")
            rx3.Cells(1,0).Text =  "生产批号: " & Tables("库存表主表.库存表").Rows(I)("生产单号")
            rX3.Cells(0,0).Style.Font = New Font("宋体", 12, FontStyle.Bold) \'设置主标题字体
            rX3.Cells(1,0).Style.Font = New Font("宋体", 12, FontStyle.Bold) \'设置主标题字体
            doc.Body.Children.Add(rx3) \'加入到报表中
            
            Dim ColNames As String() = New String(){"序号","数量"}
            Dim idx As Integer = 0
            rt.Style.FontSize = 12
            For r As Integer = 0 To DT.DATARows.Count -1 Step 10 \'开始填入该列内容
                
                
                rt.Cells(idx,0).Text = "序号"
                rt.Cells(idx,0).Style.FontSize = 14
                rt.Cells(idx+1,0).Text = "数量"
                rt.Cells(idx+1,0).Style.FontSize = 14
                Dim k As Integer = 1
                For j As Integer = r To Math.Min(r+9,DT.DATARows.Count -1)
                    rt.Cells(idx,k).Text = DT.DATARows(j)("序号")
                    rt.Cells(idx,k).Style.FontSize = 12
                    rt.Cells(idx,k).Style.TextAlignHorz = prt.AlignHorzEnum.Center
                    rt.Cells(idx+1,k).Text = DT.DATARows(j)("数量")
                    rt.Cells(idx+1,k).Style.FontSize = 14
                    
                    k = k + 1
                Next
                idx  = idx + 2
            Next
            
            rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'禁止被垂直分割
            
            Dim k1 As Integer = rt.rows.count
            rt.Cells(k1, 0).Text = "合计"
            rt.Cells(k1, 8).Text = DT.compute("sum(数量)") & Tables("库存表主表.库存表").Current("单位")
            
            rt.Cells(k1, 9).Text = DT.compute("sum(件数)") &"件"
            doc.Body.Children.Add(rt)
        Next
        Dim rx4 As New prt.RenderTable
        rx4.Cells(0,0).Text =  "制单:" & Tables("库存表主表.库存表").Current("创建人") & "     复核:                          承运人:                    " & "制单日期:" & Date.Today
        rX4.Cells(0,0).Style.Font = New Font("宋体", 12, FontStyle.Bold) \'设置主标题字体
        Doc.PageFooter  = rx4 \'作为页眉使用
        
        
        Dim rx1 As New prt.RenderTable
        rx1.Cells(0,0).Text = "汕头市雅图包装印刷有限公司磅码单"
        rx1.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rX1.Cells(0,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) \'设置主标题字体
        Doc.PageHeader = rx1 \'作为页眉使用
        
        
        
        doc.Preview() \'预览


--  作者:cjl333333333
--  发布时间:2021/8/26 15:12:00
--  
老师,帮我看一下,这段代码里,前面第一节循环老出错,一条记录可以显示,两条记录会出现错误


--  作者:有点蓝
--  发布时间:2021/8/26 15:18:00
--  
出现什么错误?调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm,看哪一句代码出错
[此贴子已经被作者于2021/8/26 15:17:52编辑过]

--  作者:cjl333333333
--  发布时间:2021/8/26 15:19:00
--  
.NET Framework 版本:2.0.50727.4927
Foxtable 版本:2018.3.9.1
错误所在事件:窗口,出入库,TopicBar1,TopicLinkClick
详细错误信息:
添加的项目已经有所有者了。


--  作者:cjl333333333
--  发布时间:2021/8/26 15:21:00
--  
For i As Integer = 0  To Tables("库存表主表.库存表").Rows.Count - 1
            Dim jb As New SQLJoinTableBuilder("磅码单查询","磅码单")
            jb.C
            jb.AddCols( "{磅码单}.*")
            jb.Build()
            
            Tables("磅码单查询").Filter = "编号= \'"& Tables("库存表主表.库存表").Rows(I)("_Identify")& "\'"
            Dim DT As  DataTable = DataTables("磅码单查询")

就是错这段循环,如果我打单独一条记录就没问题如果打库存表中多条记录对应多个磅码单就会错。
出错就是:添加的项目已经有所有者了。  我把查询表拿到循环外还不行。

--  作者:有点蓝
--  发布时间:2021/8/26 15:23:00
--  
        For i As Integer = 0  To Tables("库存表主表.库存表").Rows.Count - 1
rt = New prt.RenderTable
            Dim jb As New SQLJoinTableBuilder("磅码单查询","磅码单")