-- 作者:wei0769
-- 发布时间:2020/7/21 14:43:00
--
\'先检查送货明细有多少条记录,如果超过60条,就提示不能大于60.处理好后打印
Dim Rowsh As Row = Tables("送货主表").Current
Dim shdh As String = Rowsh("送货单号") \'取得送货单号
\' 取得客户产品地址 Dim dress As String Dim cmd As New SQLCommand cmd.C cmd.CommandText = "s elect {产品}.地址 from {送货主表} inner join {产品} on {送货主表}.款号={产品}.款号 where {送货主表}.送货单号=\'" & shdh & "\'" dress = cmd.ExecuteScalar() \'MessageBox.show("地址是 " & dress)
Dim tb As Table = Tables("送货主表.送货明细") Dim xl As Integer = Tb.Rows.count If xl > 60 Then MessageBox.show("送货单不能打印大于60行的送货明细,请把送货单分几单处理再打印") \'Return Else Dim doc As New PrintDoc() \'定义一个报表 doc.PageSetting.Width = 130 \'纸张宽度为100毫米 doc.PageSetting.Height = 190 \'纸张高度为191毫米 Doc.PageSetting.LeftMargin = 5 \'设置左边距 Doc.PageSetting.RightMargin = 5 \'设置右边距 Doc.PageSetting.TopMargin = 5 \'设置上边距 Doc.PageSetting.BottomMargin = 5 \'设置下边距 \'页眉,按需要增加\' \'Dim rtx As prt.rendertext \'定义页眉的文本对象 \'rtx = New prt.RenderText \'设置文本对象的内容 \'rtx.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 \'rtx.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右对齐 \'rtx.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) \'设置底边框 \'rtx.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米 \'rtx.Style.FontSize = 8 \'字体大小为8磅 \'Doc.PageHeader = rtx \'作为页眉使用 Dim rt As New prt.RenderTable() \'定义一个表格对象 doc.Body.Children.Add(rt) \'将表格对象加入到报表中 rt.Style.GridLines.All = New prt.LineDef \'将网格线类型设为默认类型 rt.Width = 120 \'表宽为150毫米 rt.Height = 170 \'表高为150毫米 rt.Rows.Count = 25 \'设置行数 rt.Cols.Count = 8 \'设置列数 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.Rows(0).Height = 12 \'标题行高 rt.Cells(0,0).SpanCols = 8 \'合拼表头 rt.cells(0,0).text = "胸围制衣厂送货单" rt.cells(0,0).Style.Font = New Font("宋体", 18, FontStyle.Bold) \'设置字体 rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第一行表格线 rt.Rows(0).Style.Borders.Bottom = New prt.Linedef \'增加第一行底线 \'Dim Rowsh As Row = Tables("送货主表").Current 在最上面声明 rt.Rows(6).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Rows(6).Style.TextAlignVert = prt.AlignVertEnum.Center rt.Cells(1,1).SpanCols = 4 rt.Cells(1,6).SpanCols = 2 rt.cells(1,0).text = "地 址" rt.cells(1,1).text = "大道26号三楼" rt.cells(1,5).text = "单号" rt.cells(1,6).text = Rowsh("送货单号") rt.Cells(2,1).SpanCols = 4 rt.Cells(2,6).SpanCols = 2 rt.cells(2,0).text = "手 机" rt.cells(2,1).text = "34938" rt.cells(2,5).text = "合同号" rt.cells(2,6).text = Rowsh("合同号") rt.Cells(3,1).SpanCols = 4 rt.Cells(3,6).SpanCols = 2 rt.cells(3,0).text = "收货单位" rt.cells(3,1).text = rowsh("客户") rt.cells(3,5).text = "款号" rt.cells(3,6).text = rowsh("款号") rt.Cells(4,1).SpanCols = 4 rt.Cells(4,6).SpanCols = 2 rt.cells(4,0).text = "收货地址" rt.cells(4,1).text = dress rt.cells(4,5).text = "颜色" rt.cells(4,6).text = rowsh("颜色") rt.Cells(5,1).SpanCols = 4 rt.Cells(5,6).SpanCols = 2 rt.cells(5,5).text = "日期" rt.cells(5,6).text = rowsh("送货日期") rt.Cells(6,0).text = "尺码" rt.Cells(6,1).text = "件数" rt.Cells(6,2).text = "尺码" rt.Cells(6,3).text = "件数" rt.Cells(6,4).text = "尺码" rt.Cells(6,5).text = "件数" rt.Cells(6,6).text = "尺码" rt.Cells(6,7).text = "件数" \'Dim tb As Table = Tables("送货主表.送货明细") \'Dim xl As Integer = Tb.Rows.count For c As Integer = 0 To 3 For r As Integer = 7 To 21 If c*15+r-7 >= xl Then Exit For End If \'rt.cells(c*15+j-7,c*2).text = tb.rows(c*15+j-7)("款号") \'rt.cells(c*15+j-7,c*2+1).text = tb.rows(c*15+j-7)("送货数量") rt.cells(r,C * 2).text = tb.rows(c*15+r-7)("款号") rt.cells(r,c*2).Style.TextAlignHorz = prt.AlignHorzEnum.Right rt.cells(r,c * 2 + 1).text = tb.rows(C*15+r-7)("送货数量") Next Next rt.Rows(23).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第23行表格线 Dim i As Integer For i = 0 To 7 rt.cells(23,i).Style.Borders.All = New prt.LineDef("0mm", Color.white) Next rt.Rows(23).Style.Borders.Top = New prt.Linedef rt.Rows(24).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第23行表格线 For i = 0 To 7 rt.cells(24,i).Style.Borders.All = New prt.LineDef("0mm", Color.white) Next rt.Rows(22).Height = 20 \'标题行高 rt.cells(22,0).text = "备注" rt.Cells(22,1).SpanCols = 7 Dim ss As Integer ss = tb.Compute("sum(送货数量)") \'MessageBox.show(ss) \'rt.cells(22,1).text = "合计 " & ss & " 件" rt.cells(22,1).text = "合计 " & Rowsh("包数") & " 包" & "--共计 " & ss & " 件 -- " & Rowsh("备注") rt.cells(22,1).Style.TextAlignHorz = prt.AlignHorzEnum.Left rt.cells(22,1).Style.TextAlignVert = prt.AlignVertEnum.Top rt.cells(23,0).text = "收货单位" rt.cells(24,0).text = "及经手人" rt.Cells(23,1).SpanCols = 3 rt.cells(23,1).SpanRows = 2 rt.cells(23,1).text = "(盖章)" rt.cells(23,4).text = "送货单位" rt.cells(24,4).text = "及经手人" rt.Cells(23,5).SpanCols = 3 rt.cells(23,5).SpanRows = 2 rt.cells(23,5).text = "(盖章)" Doc.PrinterName = "EPSON LQ-615KII ESC/P2"
doc.Preview() \'预览 End If
|