以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]循环打印  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=70627)

--  作者:新航程小何
--  发布时间:2015/6/25 12:05:00
--  [求助]循环打印
各位老师,我想实现的功能是每一个二维码对应一个文本说明,而文本说明是根据生成二维码的某一列的内容作为另一表的查询条件,去找到文本说明。也就是生成一个订单行的二维码,,通过订单中“用户编号”查找到用户表中对应的“用户姓名”,将“用户姓名”,作为二维码的说明文本。我写了如下代码,但是每次生成二维码的时候,都会生成多余的二维码。请老师指点,代码怎样修改?
Dim Result As DialogResult
Dim rs As List(of Row) = Tables("订单").GetCheckedRows()
If rs.Count > 0 Then
    Dim doc As New PrintDoc
    Dim rg As prt.RenderGraphics
    Dim Bar As New BarCodeBuilder
    Bar.Symbology = Barpro.Symbology.QRCode
    Doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
    For Each r As Row In rs
        Bar.Code = "【用户编号】" & r("用户编号") & vbcrlf & "【产品批次】" & r("产品批次") & vbcrlf & "【产品名称】" & r("产品名称") 
        Bar.TextFont = New Font("微软雅黑",10.5)
        Dim  b As String=r("用户编号")
        Dim ps As List( of String) =DataTables("用户").sqlgetvalues("用户姓名","","用户编号 = \'" & b & "\'")
        For Each  p As String In ps
            Bar.HumanReadableText="用户姓名:" &  dr("用户姓名")
        Next
        rg = new prt.RenderGraphics
        bar.DrawOnCanvas(rg.Graphics,0,0,1)
        rg.Style.Spacing.All = 1
        Doc.Body.Children.Add(rg)
    Next
    Doc.Preview()
Else
    messagebox.show("请选择打印二维码项?")
End If

--  作者:大红袍
--  发布时间:2015/6/25 12:11:00
--  
  代码没什么问题,例子发上来测试。
--  作者:新航程小何
--  发布时间:2015/6/25 14:58:00
--  
老师, 你帮忙看看
[此贴子已经被作者于2015/6/25 14:59:03编辑过]

--  作者:新航程小何
--  发布时间:2015/6/25 14:59:00
--  
我上传的附件怎么看不见?
--  作者:新航程小何
--  发布时间:2015/6/25 15:00:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.zip


--  作者:大红袍
--  发布时间:2015/6/25 15:16:00
--  

这句代码

 

Dim ps As List( of String) =DataTables("用户").sqlgetvalues("用户姓名","","用户编号 = \'" & b & "\'")

 

改成

 

Dim ps As List( of String) =DataTables("用户").SQLGetValues("用户姓名","用户编号 = \'" & b & "\'","")


--  作者:大红袍
--  发布时间:2015/6/25 15:17:00
--  

或者

 

Dim Result As DialogResult
Dim rs As List(of Row) = Tables("订单表").GetCheckedRows()
If rs.Count > 0 Then
    Dim doc As New PrintDoc
    Dim rg As prt.RenderGraphics
    Dim Bar As New BarCodeBuilder
    Bar.Symbology = Barpro.Symbology.QRCode
    Doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
    For Each r As Row In rs
        Bar.Code = "【用户编号】" & r("用户编号") & vbcrlf & "【产品批次】" & r("产品批次") & vbcrlf & "【产品名称】" & r("产品名称")
        Bar.TextFont = New Font("微软雅黑",10.5)
        Dim  b As String=r("用户编号")
        Dim fdr As DataRow = DataTables("用户").SQLFind("用户编号 = \'" & b & "\'")
        If fdr IsNot Nothing Then
            Bar.HumanReadableText="用户姓名:" &  fdr("用户姓名")
        End If
        rg = new prt.RenderGraphics
        bar.DrawOnCanvas(rg.Graphics,0,0,1)
        rg.Style.Spacing.All = 1
        Doc.Body.Children.Add(rg)
    Next
    Doc.Preview()
Else
    messagebox.show("请选择打印二维码项?")
End If


--  作者:新航程小何
--  发布时间:2015/6/25 15:23:00
--  
x谢谢老师,问题已解决