Foxtable(狐表)用户栏目专家坐堂 → 打印后台数据的排序问题


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

主题:打印后台数据的排序问题

帅哥哟,离线,有人找我吗?
1234567
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:821 积分:6422 威望:0 精华:0 注册:2013/2/18 17:46:00
打印后台数据的排序问题  发帖心情 Post By:2014/6/15 15:57:00 [显示全部帖子]

采用SQLCommand的ExecuteReader方法,生成一个临时表

不能用  Tables("XX").Sort = "XXX"方式进行排序号。

希望在打印是按序号列排序,该怎么改代码?


 

Dim doc As New PrintDoc
Dim
rt As New prt.RenderTable
Dim
cmd As New SQLCommand '定义一个SQL命令
Dim
dt As DataTable '定义一个数据表变量
Dim
Count As Integer = 0
cmd.CommandText =
"Select * From {订单} Where Year(日期) = 2009 And Month(日期) = 6"
dt = cmd.ExecuteReader()
'生成一个临时表
For
Each Col AS DataCol In Dt.DataCols
    rt.Cells(
0,Count).Text = Col.Name
    For
r As integer = 0 To dt.DataRows.Count - 1
        rt.Cells(r +
1,Count).Text = dt.DataRows(r)(Col.Name)
    Next

    Count = Count +
1
Next

rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
'灰色网格线
rt.CellStyle.Spacing.All =
1 '内容距离网格线1毫米
rt.Rows(
0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中

doc.Body.Children.Add(rt)
doc.Preview()


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


加好友 发短信
等级:四尾狐 帖子:821 积分:6422 威望:0 精华:0 注册:2013/2/18 17:46:00
  发帖心情 Post By:2014/6/15 16:16:00 [显示全部帖子]

谢谢


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


加好友 发短信
等级:四尾狐 帖子:821 积分:6422 威望:0 精华:0 注册:2013/2/18 17:46:00
  发帖心情 Post By:2014/6/17 9:17:00 [显示全部帖子]

为什么没有按序排列?

 

Dim doc As New PrintDoc
Doc.PageSetting.LeftMargin = 5 '设置左边距
Doc.PageSetting.RightMargin = 5 '设置右边距
Doc.PageSetting.TopMargin = 5 '设置上边距
Doc.PageSetting.BottomMargin = 5 '设置下边距
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim rx1 As prt.RenderText
Dim tbl As Table = Tables("施工计划_Table1")
tbl.Sort = "作业顺序"
Dim ColNames As String() = New String(){"作业顺序", "工艺单编号", "加工内容_序号", "加工内容_工序", "加工内容_加工",  "作业计划_作业人员",  "作业计划_要求完成日期", "作业计划_估工" , "加工_实工", "加工_加工人", "检验确认", "钳工确认"}
Dim filter As String = "当天作业计划 = true"
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String()) = tbl.DataTable.GetValues("加工内容_工序|作业计划_机床代号",tbl. filter)
doc.Pagesetting.LandScape = True
For Each Region As String() In Regions
Dim ra1 As New prt.RenderArea
ra1.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止被垂直分割
Dim ra2 As New prt.RenderArea
ra2.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止被垂直分割
ra2.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
rx = New prt.RenderText
rx.Width = 160 '宽度53毫米
rx.Height =8 '高度24毫米
rx.Style.FontSize = 12
        rx.Style.Spacing.Bottom = 2
    rx.Text = Region(0) & " / " & Region(1)
ra2.Children.Add(rx) '添加到容器中
 rx1 = New prt.RenderText
rx1.Width = 120 '宽度53毫米
rx1.Height = 8 '高度24毫米
    rx1.Style.FontSize = 10
       rx1.Style.Spacing.Bottom = 2
    rx1.Text = "日期: " & Today
rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Right
rx1.Style.TextAlignVert = prt.AlignVertEnum.Bottom '垂直居中
 
ra2.Children.Add(rx1) '添加到容器中
ra1.Children.Add(ra2)
rt = New prt.RenderTable
    rt.Style.Font = Tables("施工计划_Table1").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
 rt.Style.Font = tbl.Font
     Rows = tbl.DataTable.Select("[作业计划_机床代号] = '" &  Region(1) & "' and " & filter)
rt.Cells(0,0).Text = "序号"   
rt.Cells(0,1).Text = "任务单"
rt.Cells(0,2).Text = "模具编号"
rt.Cells(0,3).Text = "产品名称"
rt.Cells(0,4).Text = "零件名称"
rt.Cells(0,5).Text = "数量"
rt.Cells(0,6).Text = "工艺单编号"
rt.Cells(0,7).Text = "序号"
rt.Cells(0,8).Text = "工序"
rt.Cells(0,9).Text = "加工内容"
rt.Cells(0,10).Text = "作业人员"
rt.Cells(0,11).Text = "要求完成时间"
rt.Cells(0,12).Text = "估工"
rt.Cells(0,13).Text = "实工"
rt.Cells(0,14).Text = "作业确认"
rt.Cells(0,15).Text = "检验确认"
rt.Cells(0,16).Text = "钳工确认"
For r As Integer = 0 To Rows.Count -1 '开始填入该列内容
rt.Cols(0).Width = 20
rt.Cols(1).Width = 30    
rt.Cols(2).Width = 35
rt.Cols(3).Width = 60
rt.Cols(4).Width = 60
rt.Cols(5).Width = 20
rt.Cols(6).Width = 45
rt.Cols(7).Width = 20
rt.Cols(8).Width = 30
rt.Cols(9).Width = 120
rt.Cols(10).Width = 35
rt.Cols(11).Width = 40
rt.Cols(12).Width = 20
rt.Cols(13).Width = 20
rt.Cols(14).Width = 25
rt.Cols(15).Width = 35
rt.Cols(16).Width = 35
 Dim fdr As DataRow = DataTables("任务单").Find("任务单编号 = '" & Rows(r)("工艺单编号").split("-")(0) & "'")
        If fdr IsNot Nothing Then
            rt.Cells(r + 1, 1).Text = fdr("任务单编号")
            rt.Cells(r + 1, 2).Text = fdr("工装模具编号")
            rt.Cells(r + 1, 3).Text = fdr("产品名称")
       End If
       Dim fdr1 As DataRow = DataTables("工艺单").Find("工艺单编号 = '" & Rows(r)("工艺单编号") & "'")
       If fdr1 IsNot Nothing Then
        rt.Cells(r + 1, 4).Text = fdr1("零件名称")
        rt.Cells(r + 1, 5).Text = fdr1("零件数量")
      End If
Next
 For c As Integer = 1 To ColNames.Length - 1 '逐列设置和填入内容
              For r As Integer = 0 To Rows.Count -1 '开始填入该列内容
If tbl.Cols(ColNames(c)).IsNumeric AndAlso Rows(r)(ColNames(c)) = 0 Then
 rt.Cells(r + 1, c+5).Text = ""
            Else
                rt.Cells(r + 1, c+5).Text = Rows(r)(ColNames(c))
rt.Cells(r + 1, 0).Text = Rows(r)(ColNames(0))
            End If
Next
Next
 rt.RowGroups(0,6).Header = prt.TableHeaderEnum.All
ra1.Children.Add(rt)
 doc.Body.Children.Add(ra1)
Next
doc.preview()


图片点击可在新窗口打开查看此主题相关图片如下:1559.png
图片点击可在新窗口打开查看

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


加好友 发短信
等级:四尾狐 帖子:821 积分:6422 威望:0 精华:0 注册:2013/2/18 17:46:00
  发帖心情 Post By:2014/6/17 9:24:00 [显示全部帖子]

Dim doc As New PrintDoc
Doc.PageSetting.LeftMargin = 5 '设置左边距
Doc.PageSetting.RightMargin = 5 '设置右边距
Doc.PageSetting.TopMargin = 5 '设置上边距
Doc.PageSetting.BottomMargin = 5 '设置下边距
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim rx1 As prt.RenderText
Dim tbl As Table = Tables("施工计划_Table1")
tbl.Sort = "作业顺序"
我已经排序了呀?

 回到顶部