Foxtable(狐表)用户栏目专家坐堂 → 专业报表:关联表分组打印(新增2个问题)


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

主题:专业报表:关联表分组打印(新增2个问题)

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


加好友 发短信
等级:婴狐 帖子:28 积分:291 威望:0 精华:0 注册:2011/12/16 17:00:00
专业报表:关联表分组打印(新增2个问题)  发帖心情 Post By:2013/2/28 14:12:00 [只看该作者]

有订单表(订单号,客户两列)和订单明细表(订单号,产品号,规格,数量四列),通过订单号做了关联,

现在希望打印订单表当前行的订单号和客户列

 

然后再按照产品号分组打印相关联的订单明细表的 规格列 和数量列

 

得到

 

订单号      客户

  011          A

产品号:2012

规格      数量

1/2         3

3/4         5

产品号:2013

规格      数量

5/8        3

3/4        5

 

 

这样的效果,要怎么设置啊

[此贴子已经被作者于2013-3-1 13:05:20编辑过]

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


加好友 发短信
等级:管理员 帖子:47448 积分:251048 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/2/28 14:14:00 [只看该作者]


 回到顶部
美女呀,离线,留言给我吧!
annliu
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:28 积分:291 威望:0 精华:0 注册:2011/12/16 17:00:00
  发帖心情 Post By:2013/2/28 14:23:00 [只看该作者]

谢谢狐爸,但是我想用专业报表打印。

 回到顶部
美女呀,离线,留言给我吧!
annliu
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:28 积分:291 威望:0 精华:0 注册:2011/12/16 17:00:00
  发帖心情 Post By:2013/3/1 8:36:00 [只看该作者]

狐爸图片点击可在新窗口打开查看

 回到顶部
美女呀,离线,留言给我吧!
annliu
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:28 积分:291 威望:0 精华:0 注册:2011/12/16 17:00:00
  发帖心情 Post By:2013/3/1 8:56:00 [只看该作者]

Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
Dim rte As prt.RenderText '定义一个文本对象
rte = New prt.RenderText
rte.Text = "生产计划通知单" '设置文本对象的内容
rte.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rte.Style.Spacing.Bottom = 5 '设置下间隔为3毫米
rte.Style.Font = New Font("宋体", 16, FontStyle.Bold)
doc.Body.Children.Add(rte) '将文本对象加入到报表

'设置水印
rte = New prt.RenderText '设置文本对象的内容
rte.Text = "海盐三马标准件有限公司生产计划通知单" '设置文本内容
rte.Width = "Parent.Width" '宽度等于页面宽度
rte.Height = "Parent.Height" '高度等于页面高度
rte.Style.TextAngle = 45 '旋转45度
rte.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中对齐
rte.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中对齐
rte.Style.FontSize = 27 '字体大小为8磅
rte.Style.TextColor = Color.Gray '文本颜色为灰色
Doc.WaterMark = rte '作为页眉使用

Dim rta As New prt.RenderTable

rte = New prt.RenderText

rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "合同编号: " & Tables("订单表").Current("编号")
doc.Body.Children.Add(rte)

rte = New prt.RenderText
rte.y = "Prev.Bottom - 8"
rte.x = "Prev.Bottom + 70"
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "原合同号: " & Tables("订单表").Current("合同号")
doc.Body.Children.Add(rte)

rte = New prt.RenderText
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "客户编号: " & Tables("订单表").Current("客户编号")
doc.Body.Children.Add(rte)

rte = New prt.RenderText
rte.y = "Prev.Bottom - 8"
rte.x = "Prev.Bottom + 63"
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "客户简称: " & Tables("订单表").Current("客户简称")
doc.Body.Children.Add(rte)


rte = New prt.RenderText
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "交期: " & Tables("订单表").Current("交期")
doc.Body.Children.Add(rte)


rte = New prt.RenderText
rte.y = "Prev.Bottom - 8"
rte.x = "Prev.Bottom + 55"
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "总金额: " & Tables("订单表").Current("金额")
doc.Body.Children.Add(rte)

Dim tbl As Table = Tables("订单表.订单明细表")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetUniqueValues("","名称")
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rte= New prt.RenderText
    rte.Style.FontSize = 14
    rte.Style.FontBold = True
    rte.Style.Spacing.Bottom = 2
    rte.Text = "名称: " & Region
    doc.Body.Children.Add(rte)
   
    rta  = New prt.RenderTable
    rta.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rta.Style.TextAlignVert = prt.AlignVertEnum.Center
    rta.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
    rta.CellStyle.Spacing.All = 1
    rta.Cols.Count = 4
    rta.Cells(0,0).Text = "规格"
    rta.Cells(0,1).Text = "数量"
    rta.Cells(0,2).Text = "单位"
    rta.Cells(0,3).Text = "业务科录入_头标"
    rta.Cells(0,4).Text = "凹凸"
    rta.Cells(0,5).Text = "对边对角"
    rta.Cells(0,6).Text = "要求材质"
    rta.Cells(0,7).Text = "线径"
    rta.Cells(0,8).Text = "线材所需"
    rta.rows(0).Style.Borders.Top = New prt.LineDef(1,Color.LightGray)
    rta.rows(0).Style.Borders.Bottom = New prt.LineDef(1,Color.LightGray)
    Rows = tbl.DataTable.Select("[名称] = '" & Region & "'")
    With Tables("订单表.订单明细表")
        For r As Integer = 0 To .Rows.Count - 1 '遍历关联表每一行
            rta.Cells(r+1,0).Text = .rows(r)("规格")
            rta.Cells(r+1,1).Text = .rows(r)("数量")
            rta.Cells(r+1,2).Text = .rows(r)("单位")
            rta.Cells(r+1,3).Text = .rows(r)("业务科录入_头标")
            rta.Cells(r+1,6).Text = .rows(r)("要求材质")
            rta.Cells(r+1,7).Text = .rows(r)("线径")
            rta.Cells(r+1,8).Text = .rows(r)("线材所需")
            If .rows(r)("凹凸") = True Then
                rte = New prt.RenderText
                rte.text = "凹"
                rta.Cells(r+1,5).RenderObject = rte
            Else
                rte = New prt.RenderText
                rte.text = "凸"
                rta.Cells(r+1,5).RenderObject = rte
            End If
        Next
    End With
    doc.Body.Children.Add(rta)
 Next  
    rte= New prt.RenderText
    rte.Style.FontBold = True
    rte.Style.Spacing.Top = 3
    rte.Text = "产品数目: " & Tables("订单表.订单明细表").Rows.Count
    rte.Style.TextAlignHorz = prt.AlignHorzEnum.Right
    doc.Body.Children.Add(rte)
   
    doc.Preview

 

这段代码的结果不对,应该怎么改啊


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251048 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/3/1 9:02:00 [只看该作者]

最好做个简单的例子,设计好这两个表,输入几行测试数据,然后发上来,并说明问题,方便别人测试分析调试。

例子尽量简单,抓住关键点就行。


 回到顶部
美女呀,离线,留言给我吧!
annliu
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:28 积分:291 威望:0 精华:0 注册:2011/12/16 17:00:00
  发帖心情 Post By:2013/3/1 9:24:00 [只看该作者]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目x.foxdb


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251048 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/3/1 9:37:00 [只看该作者]

你的问题不知一点点,你学了很多,但是有些概念还是模糊,我建议您按顺序系统学习帮助文件,这样才能理解,理解了才能灵活运用。

 

稍微改了一下:

 

Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
Dim rte As prt.RenderText '定义一个文本对象
rte = New prt.RenderText
rte.Text = "生产计划通知单" '设置文本对象的内容
rte.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rte.Style.Spacing.Bottom = 5 '设置下间隔为3毫米
rte.Style.Font = New Font("宋体", 16, FontStyle.Bold)
doc.Body.Children.Add(rte) '将文本对象加入到报表

'设置水印
rte = New prt.RenderText '设置文本对象的内容
rte.Text = "海盐三马标准件有限公司生产计划通知单" '设置文本内容
rte.Width = "Parent.Width" '宽度等于页面宽度
rte.Height = "Parent.Height" '高度等于页面高度
rte.Style.TextAngle = 45 '旋转45度
rte.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中对齐
rte.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中对齐
rte.Style.FontSize = 27 '字体大小为8磅
rte.Style.TextColor = Color.Gray '文本颜色为灰色
Doc.WaterMark = rte '作为页眉使用

Dim rta As New prt.RenderTable

rte = New prt.RenderText

rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "合同编号: " & Tables("订单表").Current("编号")
doc.Body.Children.Add(rte)

rte = New prt.RenderText
rte.y = "Prev.Bottom - 8"
rte.x = "Prev.Bottom + 70"
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "原合同号: " & Tables("订单表").Current("合同号")
doc.Body.Children.Add(rte)

rte = New prt.RenderText
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "客户编号: " & Tables("订单表").Current("客户编号")
doc.Body.Children.Add(rte)

rte = New prt.RenderText
rte.y = "Prev.Bottom - 8"
rte.x = "Prev.Bottom + 63"
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "客户简称: " & Tables("订单表").Current("客户简称")
doc.Body.Children.Add(rte)


rte = New prt.RenderText
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "交期: " & Tables("订单表").Current("交期")
doc.Body.Children.Add(rte)


rte = New prt.RenderText
rte.y = "Prev.Bottom - 8"
rte.x = "Prev.Bottom + 55"
rte.Style.FontSize = 14
rte.Style.FontBold = True
rte.Style.Spacing.Bottom = 2
rte.Text = "总金额: " & Tables("订单表").Current("金额")
doc.Body.Children.Add(rte)

Dim tbl As Table = Tables("订单表.订单明细表")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetUniqueValues("编号 = '" & Tables("订单表").Current("编号") & "'","名称")
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rte= New prt.RenderText
    rte.Style.FontSize = 14
    rte.Style.FontBold = True
    rte.Style.Spacing.Bottom = 2
    rte.Text = "名称: " & Region
    doc.Body.Children.Add(rte)
   
    rta  = New prt.RenderTable
    rta.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rta.Style.TextAlignVert = prt.AlignVertEnum.Center
    rta.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
    rta.CellStyle.Spacing.All = 1
    rta.Cols.Count = 4
    rta.Cells(0,0).Text = "规格"
    rta.Cells(0,1).Text = "数量"
    rta.Cells(0,2).Text = "单位"
    rta.Cells(0,3).Text = "业务科录入_头标"
    rta.Cells(0,4).Text = "凹凸"
    rta.Cells(0,5).Text = "对边对角"
    rta.Cells(0,6).Text = "要求材质"
    rta.Cells(0,7).Text = "线径"
    rta.Cells(0,8).Text = "线材所需"
    rta.rows(0).Style.Borders.Top = New prt.LineDef(1,Color.LightGray)
    rta.rows(0).Style.Borders.Bottom = New prt.LineDef(1,Color.LightGray)
    Rows = tbl.DataTable.Select("[名称] = '" & Region & "' And 编号 = '" & Tables("订单表").Current("编号") & "'")
    For r As Integer = 0 To Rows.Count - 1 '遍历关联表每一行
        rta.Cells(r+1,0).Text = rows(r)("规格")
        rta.Cells(r+1,1).Text = rows(r)("数量")
        rta.Cells(r+1,2).Text = rows(r)("单位")
        rta.Cells(r+1,3).Text = rows(r)("业务科录入_头标")
        rta.Cells(r+1,6).Text = rows(r)("要求材质")
        rta.Cells(r+1,7).Text = rows(r)("线径")
        rta.Cells(r+1,8).Text = rows(r)("线材所需")
        If rows(r)("凹凸") = True Then
            rte = New prt.RenderText
            rte.text = "凹"
            rta.Cells(r+1,5).RenderObject = rte
        Else
            rte = New prt.RenderText
            rte.text = "凸"
            rta.Cells(r+1,5).RenderObject = rte
        End If
    Next
   
    doc.Body.Children.Add(rta)
Next
rte= New prt.RenderText
rte.Style.FontBold = True
rte.Style.Spacing.Top = 3
rte.Text = "产品数目: " & Tables("订单表.订单明细表").Rows.Count
rte.Style.TextAlignHorz = prt.AlignHorzEnum.Right
doc.Body.Children.Add(rte)

doc.Preview

 

[此贴子已经被作者于2013-3-1 9:41:55编辑过]

 回到顶部
美女呀,离线,留言给我吧!
annliu
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:28 积分:291 威望:0 精华:0 注册:2011/12/16 17:00:00
  发帖心情 Post By:2013/3/1 13:04:00 [只看该作者]

狐爸,谢谢你,我会继续学习的 ,目前还有2个问题

 

1、如果 想把名称放在以下这个位置,该怎么弄

 

规格      数量      单位       头标       

       名称 :六角重型螺母

1/2       30        千件        shs 2h

 

2、 业务科录入_头标     怎样才能改为  头标  。

 


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251048 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/3/1 14:01:00 [只看该作者]

1、


rte.Text = "名称: " & Region

 

改为:

 

rte.Text = "            名称: " & Region

 

 

2、

 

rta.Cells(0,3).Text = "业务科录入_头标"

改为:

 

rta.Cells(0,3).Text = "头标"


 回到顶部
总数 12 1 2 下一页