Dim cmd As New SQLCommand cmd.C Dim datenow As String = Functions.Execute("systime") Dim pt As String = Functions.Execute("打印机选择","标签打印") Dim doc As New PrintDoc() '定义一个报表 doc.PageSetting.Width = 90 '纸张宽度为90毫米 doc.PageSetting.Height = 50 Doc.PageSetting.LeftMargin = 5 '设置左边距 Doc.PageSetting.RightMargin = 1 '设置右边距 Doc.PageSetting.TopMargin = 1 '设置上边距 Doc.PageSetting.BottomMargin = 1 '设置下边距 Dim Bar As New BarCodeBuilder Bar.Symbology = Barpro.Symbology.Code128 Bar.BarHeight = 15 Bar.QuietZoneWidth = 2 Bar.BarWidth = 0.32 Bar.CodeAlignment = Barpro.Alignment.AboveCenter Bar.TextAlignment = Barpro.Alignment.BelowCenter Bar.Font = New Font("宋体",10.5) Dim s1,s2,s3,s4,s5,s6,s7 As String Dim tt As String = Vars("活动窗口") & "_Table1" Dim r As Row = Tables(tt).current s1 = r("条码单号") s2 = r("订单号") s3 = r("货物件数") s4 = r("客户简称") s5 = r("商场名称") cmd.commandtext = "select 库位 from {托运配送点} where 简称 = '"& s5 &"'" s6 = cmd.ExecuteScalar() If r IsNot Nothing Then For i As Integer = 0 To s3 -1 Doc.PageSetting.Landscape = True '横向打印 Dim ra As New prt.RenderArea '定义一个容器 Dim rt2 As New prt.RenderTable() '定义一个表格对象 rt2.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米 rt2.Style.Spacing.Bottom = 0 '和下一个工资条的距离是3毫米 rt2.Rows.Count = 1 '设置总行数 rt2.Cols.Count = 2 '设置总列数 rt2.Height = 19 '设置表格的高度 ' rt2.Width = 86 rt2.Rows(0).Height = 73 rt2.Cols(0).Width = 76 rt2.Cols(1).Width = 380 Dim ra1 As New prt.RenderArea '定义一个容器 ra1 = rt2.Cells(0,0).Area Dim ra2 As New prt.RenderArea '定义一个容器 ra2 = rt2.Cells(0,1).Area Bar.Code = s1 & "-" & i +1 Dim img1 As prt.RenderImage img1 = new prt.RenderImage img1.Image = GetImage("双得力.png") img1.Width = 15 img1.Height = 18 Dim img2 As prt.RenderImage img2 = new prt.RenderImage img2.Image = bar.GetImage(400) img2.Height = 18 img2.Width = "Auto" Dim rt1 As New prt.RenderTable() '定义一个表格对象 rt1.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米 rt1.Style.Spacing.Bottom = 1 '和下一个工资条的距离是3毫米 rt1.Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中 rt1.Style.TextAlignHorz = prt.AlignHorzEnum.Center rt1.Style.Font = New Font("宋体",11,FontStyle.Bold) rt1.Rows.Count = 3 '设置总行数 rt1.Cols.Count = 4 '设置总列数 rt1.Height = 28 '设置表格的高度 rt1.Width = 86 rt1.Cols(0).Width = 49 rt1.Cols(1).Width = 131 rt1.Cols(2).Width = 49 rt1.Cols(3).Width = 100 rt1.Rows(0).Height = 27 rt1.Rows(1).Height = 37 rt1.Rows(2).Height = 37 rt1.Cells(0,0).Text= s5 rt1.Cells(0,3).Text= s6 rt1.Cells(1,0).Text = "订单号" rt1.Cells(1,1).Text = s2 rt1.Cells(2,0).Text= "厂商名称" rt1.Cells(2,1).Text = s4 rt1.Cells(2,2).Text= "箱数编号" rt1.Cells(2,3).Text = s3 & "-" & i +1 & "#" rt1.Cells(0,0).SpanCols = 2 rt1.Cells(1,1).SpanCols = 3 rt1.Cells(0,0).Style.Font = New Font("宋体",12) rt1.Cells(0,3).Style.Font = New Font("宋体",14,FontStyle.Bold) rt1.Cells(1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Left rt1.Cells(2,1).Style.Font = New Font("宋体",12) rt1.Cells(2,3).Style.Font = New Font("宋体",12,FontStyle.Bold) ra1.Children.Add(img1) '加入图片到RenderArea中 ra2.Children.Add(img2) '加入图片到RenderArea中 ra.Children.Add(rt2) '加入到容器中 ra.Children.Add(rt1) '加入到容器中 Doc.Body.ChildRen.Add(ra) '将容器加入到报表中 Next ' Doc.Preview() cmd.CommandText = "Insert Into [打印记录] (打印者,打印名称,打印时间,单据号) Values('" & Vars("用户") & "','条码标签','"& datenow &"','"& s1 &"')" cmd.ExecuteNonQuery() Doc.PrinterName = pt doc.Print() End If
|