资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:52k
源码类别:
企业管理
开发平台:
Visual Basic
- Attribute VB_Name = "DyjbModule"
- '**********************************************
- '* 模 块 名 称 :打印基本模块
- '* 功 能 描 述 :
- '* 程序员姓名 : 张建忠
- '* 最后修改人 : 张建忠
- '* 最后修改时间:2001/07/25
- '* 备 注:
- '**********************************************
- Public XtReportCode As String '传递打印报表编码
- Public Sub Scdybb(Dyymctbl As Form, Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer, Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer, bbylte As Boolean, Optional PrintMessageNotShow As Boolean) '生 成 打 印 报 表
- '函数参数为:打印页面设置窗体变量,报表主标题,报表小标题数组,报表小标题组织形式,报表小标题个数,报表表尾行数组,报表表尾行组织形式,报表表尾行行数,是预览还是直接打印(选择项),打印时打印选择项窗体是否显示(主要为了支持连续打印)
- '程 序 运 行 临 时 变 量
- Dim Bbbtkd$, Bbbody$, Bbydx#, Bbydy#, Bbqsx# '报表标题宽度,表体,移动X,移动Y,报表左边界(报表起始X坐标)
- Dim Rowjsq%, Coljsq%, Byhjsq% '网格行列计数器,本页行计数器
- Dim Bbzkd#, Btzgd#, Bwzgd#, Btkdte#, Btsjhgd#, MaxColwidth# '报表总宽度,标题总高度,报表表尾行高度,标题宽度,表头+n行数据行高度,报表最大列宽
- Dim Bbhsjsq&, Bbhsjsqte&, Byzzh&, Bybbhs& '报表数据行数计数器,报表数据行数计数保存,报表终止行,本页报表行数
- Dim Ztkd1#, Ztkd2#, Ztgd1#, Ztgd2# '不同字体高与宽
- Dim Bbsjhgd#, Bbgdhgd#, Kdfdbl#, Gdfdbl# '报表数据行高度,固定行高度,表宽放大比例,表高放大比例
- Dim Lszbj#, Bbpage$, Bbynfyh& '临时左边界,报表页号,报表页内分页号
- Dim jsqte% '临时计数器
- Dim bbQslz&, bbzzlz& '本页报表输出起始列值,本页报表输出终止列值
- Dim Yxbbkd# '本页有效报表宽度
- Dim Tsxx As String '系统提示信息
- Dim Papername(1 To 70) As String '纸张大小对应描述
- Dim Bbzys As Integer
- Dim Sfdyfyh As Boolean '是否打印分页号
- Dim Xbtmaxlen As Double '小标题最大长度
- Dim Bwhmaxlen As Double '表尾行最大长度
- '设计人员自定义变量(不让用户定义是为了保持系统打印一致性)
- Dim Sckd#, Xhsjg#, Xbthjg#, zdxgd# '标题下划线缩进,下划线间隔,小标题表尾行间隔,装订线高度
- Dim Zdxsjg#, Zdxzjg# '装订线上间隔,装订线左间隔
- Dim Xbths%, Bwhs% '小标题行数,表尾行数
- Dim Bbfzbl As String '报表分组输出条件
- Dim Bwzb$, Bwbzdw$ '表尾制表人,报表编制单位
- '用 户 自 定 义 变 量
- Dim Bbgdscqsl&, Bbgdsczzl&, bbscQslz&, bbsczzlz& '报表固定输出起始列,报表固定输出终止列,报表输出起始列,报表输出终止列(报表起始列>报表固定输出终止列)
- Dim Btfontsize&, Sjfontsize&, Btfontname$, Sjfontname$ '报表标题字体大小,数据区字体大小
- Dim Pagecount%, Mybbhs&, Zdbbhs& '报表页数计数器,每页满页报表行数,用户指定报表行数
- Dim Dyxsbz As Boolean, Sfmy As Boolean, Zdhs As Boolean '是否输出单元标志,表格满页控制,指定每页报表行数
- Dim Bwdyrq$, Bwrjmc$ '打印日期,软件制作版本
- Dim Bbalign$ '报表组织形式(1-居左,2-居中)
- Dim zdxwz% '报表装订线位置
- Dim sfsckb As Boolean '是否输出空表
- Dim sfscgdl As Boolean '页内分页时是否输出固定列
- Dim Sflxdy As Boolean '报表是否连续打印
- Dim Sftdfssc As Boolean '是否套打方式输出
- Dim Bjjghs As Integer '报表之间间隔
- Dim Bbmcte As String '报 表 名 称
- Dim Bbbxjg As Long '报表表线打印间隔
- Papername(1) = "Letter, 8 1/2 x 11 英寸"
- Papername(2) = "Letter Small, 8?x 11 英寸"
- Papername(3) = "Tabloid, 11 x 17 英寸"
- Papername(4) = "Ledger, 17 x 11 英寸"
- Papername(5) = "Legal, 8 x 14 英寸"
- Papername(6) = "Statement, 5 1/2 x 8 1/2 英寸"
- Papername(7) = "Executive, 7 1/2 x 10 1/2 英寸"
- Papername(8) = "A3 297 x 420 毫米"
- Papername(9) = "A4 210 x 297 毫米"
- Papername(10) = "A4 Small, 210 x 297 毫米"
- Papername(11) = "A5, 148 x 210 毫米"
- Papername(12) = "B4, 250 x 354 毫米"
- Papername(13) = "B5, 182 x 257 毫米"
- Papername(14) = "Folio, 8 x 13 英寸"
- Papername(15) = "Quarto, 215 x 275 毫米"
- Papername(16) = "10 x 14 英寸"
- Papername(17) = "11x17 英寸"
- Papername(18) = "Note 8 1/2 x 11 英寸"
- Papername(19) = "Envelope #9 3 7/8 x 8 7/8"
- Papername(20) = "Envelope #10 4 1/8 x 9 1/2"
- Papername(21) = "Envelope #11 4 1/2 x 10 3/8"
- Papername(22) = "Envelope #12 4 276 x 11"
- Papername(23) = "Envelope #14 5 x 11 1/2"
- Papername(24) = "C size sheet"
- Papername(25) = "D size sheet"
- Papername(26) = "E size sheet"
- Papername(27) = "Envelope DL 110 x 220毫米"
- Papername(28) = "Envelope C5 162 x 229 毫米"
- Papername(29) = "Envelope C3 324 x 458 毫米"
- Papername(30) = "Envelope C4 229 x 324 毫米"
- Papername(31) = "Envelope C6 114 x 162 毫米"
- Papername(32) = "Envelope C65 114 x 229 毫米"
- Papername(33) = "Envelope B4 250 x 353 毫米"
- Papername(34) = "Envelope B5 176 x 250 毫米"
- Papername(35) = "Envelope B6 176 x 125 毫米"
- Papername(36) = "Envelope 110 x 230 毫米"
- Papername(37) = "Envelope Monarch 3.875 x 7.5 英寸"
- Papername(38) = "6 3/4 Envelope 3 5/8 x 6 1/2 英寸"
- Papername(39) = "US Std Fanfold 14 7/8 x 11 英寸"
- Papername(40) = "German Std Fanfold 8 1/2 x 12 英寸"
- Papername(41) = "German Legal Fanfold 8 1/2 x 13 英寸"
- Papername(42) = "B4 (ISO) 250 x 353 毫米"
- Papername(43) = "Japanese Postcard 100 x 148 毫米"
- Papername(44) = "9 x 11 英寸"
- Papername(45) = "10 x 11 英寸"
- Papername(46) = "15 x 11 英寸"
- Papername(47) = "Envelope Invite 220 x 220 毫米"
- Papername(48) = "" ' RESERVED--DO NOT USE
- Papername(49) = "" ' RESERVED--DO NOT USE
- Papername(50) = "Letter Extra 9 275 x 12 英寸"
- Papername(51) = "Legal Extra 9 275 x 15 英寸"
- Papername(52) = "Tabloid Extra 11.69 x 18 英寸"
- Papername(53) = "A4 Extra 9.27 x 12.69 英寸"
- Papername(54) = "Letter Transverse 8 275 x 11 英寸"
- Papername(55) = "A4 Transverse 210 x 297 毫米"
- Papername(56) = "Letter Extra Transverse 9275 x 12 英寸"
- Papername(57) = "SuperA/SuperA/A4 227 x 356 毫米"
- Papername(58) = "SuperB/SuperB/A3 305 x 487 毫米"
- Papername(59) = "Letter Plus 8.5 x 12.69 英寸"
- Papername(60) = "A4 Plus 210 x 330 毫米"
- Papername(61) = "A5 Transverse 148 x 210 毫米"
- Papername(62) = "B5 (JIS) Transverse 182 x 257 毫米"
- Papername(63) = "A3 Extra 322 x 445 毫米"
- Papername(64) = "A5 Extra 174 x 235 毫米"
- Papername(65) = "B5 (ISO) Extra 201 x 276 毫米"
- Papername(66) = "A2 420 x 594 毫米"
- Papername(67) = "A3 Transverse 297 x 420 毫米"
- Papername(68) = "A3 Extra Transverse 322 x 445 毫米"
- '设计人员依系统情况而定数据(单位:像素点)
- zdxgd = 700 '装订线高度
- Sckd = 300 '标题下划线缩进宽度
- Xhsjg = 50 '下划线间隔
- Xbthjg = 150 '小标题及表尾与报表之间行间隔
- Xbths = Bbxbtgs '小标题行数
- Bwhs = Bbbwhgs + 3 '表尾行数
- Bwzb = "制表:" + Xtczy
- Bwbzdw = "【" + Xtdwm + "】"
- '读入用户定义页面特殊设置
- With Dyymctbl
- '0-报表名称
- Bbmcte = .BbmcLabel
- '1-装订位置
- For jsqte = 0 To 2
- If .Zdoption(jsqte).Value Then
- zdxwz = jsqte
- Exit For
- End If
- Next jsqte
- '2-是否满页打印
- If .MydyCheck.Value = 1 Then
- Sfmy = True
- Else
- Sfmy = False
- End If
- '3-对称页边距
- If .BjdcCheck.Value = 1 Then
- Bbalign = "2"
- Else
- Bbalign = "1"
- End If
- '4-用户指定报表行数
- If .ZdhsCheck.Value = 1 Then
- Zdhs = True
- Zdbbhs = Val(.BbhsText)
- Else
- Zdhs = False
- Zdbbhs = 0
- End If
- '5-无数据记录是否显示空表
- If .KbscCheck = 1 Then
- sfsckb = True
- Else
- sfsckb = False
- End If
- '6-报表起始页编号
- Pagecount = 1
- '7-页内换页是否输出固定列
- If .GdscCheck = 1 Then
- sfscgdl = True
- Else
- sfscgdl = False
- End If
- '8-读 入 报 表 标 题 及 表 体 字 体,字 号
- Btfontname = .Btztlabel
- Btfontsize = .Btzhlabel
- Sjfontname = .SjztLabel
- Sjfontsize = .Sjzhlabel
- '9-读 入 报 表 输 出 列 情 况
- Bbgdscqsl = 0
- Bbgdsczzl = Dyymctbl.BbsclText
- If sfscgdl Then
- bbscQslz = Dyymctbl.BbsclText + 1
- Else
- bbscQslz = 0
- End If
- bbsczzlz = DY_Tybbyldy.DyylGrid.Cols - 1
- '10-读入报表未满页是否连续打印
- If Dyymctbl.LxscCheck = 1 Then
- Sflxdy = True
- Else
- Sflxdy = False
- End If
- '11-报表是否套打方式输出
- If Dyymctbl.TdfsCheck = 1 Then
- Sftdfssc = True
- Else
- Sftdfssc = False
- End If
- '11-读入报表之间间隔(同时可以考虑表间可以加一下划线--页内折线)
- Bjjghs = Val(Dyymctbl.Bjjglabel)
- '12-读入报表表线打印间隔
- Bbbxjg = Val(Dyymctbl.BxjgLabel)
- End With
- DY_Tybbyldy.Caption = "报表预览_" + Bbmcte '显示报表名称
- With DY_Tybbyldy.Tydy
- If DY_Tybbyldy.Tydy.NDevices <= 0 Then
- Tsxx = "本机未安装任何打印机!"
- Call Xtxxts(Tsxx, 0, 1)
- Unload DY_Tybbyldy
- Exit Sub
- End If
- '10-读入[页面设置]中VSprinter的信息
- '包括打印机 , 输出方向, 来源, 左边界
- '右边界,上边界,下边界,自定义纸张大小
- .Device = Dyymctbl.YmszPrinter.Device
- .Orientation = Dyymctbl.YmszPrinter.Orientation
- .PaperBin = Dyymctbl.YmszPrinter.PaperBin
- .MarginLeft = Dyymctbl.YmszPrinter.MarginLeft
- .MarginRight = Dyymctbl.YmszPrinter.MarginRight
- .MarginTop = Dyymctbl.YmszPrinter.MarginTop
- .MarginBottom = Dyymctbl.YmszPrinter.MarginBottom
- If Dyymctbl.YmszPrinter.PaperSize = pprUser Then
- .PaperSize = pprUser
- .PaperWidth = Dyymctbl.YmszPrinter.PageWidth
- .PageHeight = Dyymctbl.YmszPrinter.PaperHeight
- Else
- .PaperSize = Dyymctbl.YmszPrinter.PaperSize
- End If
- '显示简单打印信息
- DY_Tybbyldy.DYStatus.Panels(1).Text = "打印机:" + .Device
- If .PaperSize >= 1 And .PaperSize <= 68 Then
- DY_Tybbyldy.DYStatus.Panels(2).Text = "纸张大小:" + Papername(.PaperSize)
- Else
- DY_Tybbyldy.DYStatus.Panels(2).Text = "纸张大小:" + str(.PaperHeight) + " x " + str(.PaperWidth)
- End If
- If .Orientation = orLandscape Then
- DY_Tybbyldy.DYStatus.Panels(3).Text = "输出方向:" + "横向"
- Else
- DY_Tybbyldy.DYStatus.Panels(3).Text = "输出方向:" + "纵向"
- End If
- Bbhsjsq = DY_Tybbyldy.DyylGrid.FixedRows
- Bwdyrq = "打印日期:" + Format(Date, "yyyy.mm.dd")
- Bwrjmc = "【百利/ERP】"
- Sfdyfyh = False
- .BrushStyle = bsTransparent
- .StartDoc
- '测 试 报 表 放 大 比 例
- .FontName = DY_Tybbyldy.DyylGrid.FontName
- .FontSize = DY_Tybbyldy.DyylGrid.FontSize
- .CalcText = "测试"
- Ztkd1 = .TextWid
- Ztgd1 = .TextHei
- .FontName = Sjfontname
- .FontSize = Sjfontsize
- .CalcText = "测试"
- Ztkd2 = .TextWid
- Ztgd2 = .TextHei
- Kdfdbl = Ztkd2 / Ztkd1 / 1.001
- Gdfdbl = Ztgd2 / Ztgd1
- Bbgdhgd = DY_Tybbyldy.DyylGrid.RowHeight(0) * Gdfdbl
- If DY_Tybbyldy.DyylGrid.Rows > DY_Tybbyldy.DyylGrid.FixedRows Then
- Bbsjhgd = DY_Tybbyldy.DyylGrid.RowHeight(DY_Tybbyldy.DyylGrid.FixedRows) * Gdfdbl
- Else
- Bbsjhgd = DY_Tybbyldy.DyylGrid.RowHeight(DY_Tybbyldy.DyylGrid.Rows - 1) * Gdfdbl
- End If
- '计算高度(含主标题+下划线+小标题,表头+n行数据行,表尾总高度(保持报表完整性)
- '计算主标题+下划线+小标题高度
- Btzgd = 0
- .FontBold = True
- .FontName = Btfontname
- .FontSize = Btfontsize
- .CalcText = Bbzbt
- Btzgd = Btzgd + .TextHei + 2 * Xhsjg
- .FontBold = False
- .FontName = Sjfontname
- .FontSize = Sjfontsize
- .CalcText = "测试"
- Btzgd = Btzgd + Xbths * .TextHei + (Xbths + 1) * Xbthjg + Zdxsjg
- '计算表头+n行数据行高度(如果指定每页报表行数则n=zdbbhs 否则 n=1)
- Btsjhgd = 0
- Btsjhgd = Btsjhgd + DY_Tybbyldy.DyylGrid.FixedRows * Bbgdhgd
- If Zdbbhs <> 0 Then
- Btsjhgd = Btsjhgd + Zdbbhs * Bbsjhgd
- Else
- Btsjhgd = Btsjhgd + Bbsjhgd
- End If
- '计算表尾高度(表尾行之间无间隔)
- Bwzgd = Xbthjg + Bwhs * .TextHei + Bjjghs * .TextHei
- '计算每页报表满页打印行数及报表总页数
- If zdxwz = 1 Then
- Zdxsjg = zdxgd
- End If
- Mybbhs = Int((.PageHeight - .MarginTop - Zdxsjg - Btzgd - .MarginBottom - Bwzgd - DY_Tybbyldy.DyylGrid.FixedRows * Bbgdhgd) / Bbsjhgd)
- '解决由于纸张高度太小出现死循环
- If Mybbhs < 1 Then
- Tsxx = "纸张高度不足以输出一行有效数据行,请重新设置!"
- Call Xtxxts(Tsxx, 0, 4)
- Unload DY_Tybbyldy
- Exit Sub
- End If
- If Zdhs Then
- If Zdbbhs < Mybbhs Then
- Mybbhs = Zdbbhs
- End If
- End If
- '循环前初始化值
- bbQslz = bbscQslz
- Bbynfyh = 1
- bbynbz = "1"
- Bbhsjsqte = Bbhsjsq
- Do While sfsckb Or Bbhsjsq <= DY_Tybbyldy.DyylGrid.Rows - 1
- '打印公司标志
- '.DrawPicture DY_Tybbyldy.Image1.Picture, .MarginLeft, .MarginTop
- '显示打印状态
- Call Sub_SetOperStatus("正在输出打印信息...第" & Trim(str(Pagecount)) & "页")
- '输 出 报 表 装 订 线
- Zdxsjg = 0
- Zdxzjg = 0
- Call Scbbzdx(zdxwz, zdxgd, Zdxsjg, Zdxzjg)
- '计 算 报 表 总 宽 度 及 报 表 起 始 X
- Bbzkd = 0
- '1.计 算 报 表 有 效 区 宽 度(即报表不能超出.marginleft .marginright)
- Yxbbkd = .PageWidth - .MarginLeft - .MarginRight - Zdxzjg
- '2.计算报表真正宽度及本页报表起始终止列值(*固定输出列宽<报表有效宽度)
- If sfscgdl Then
- For Coljsq = Bbgdscqsl To Bbgdsczzl
- Bbzkd = Bbzkd + DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) * Kdfdbl
- Next Coljsq
- End If
- For Coljsq = bbQslz To bbsczzlz
- Bbzkd = Bbzkd + DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) * Kdfdbl
- If Bbzkd <= Yxbbkd Then
- bbzkdte = Bbzkd
- bbzzlz = Coljsq
- Else
- Sfdyfyh = True
- Exit For
- End If
- Next Coljsq
- Bbzkd = bbzkdte
- '计 算 报 表 起 始 X 坐 标
- Select Case Bbalign
- Case "1"
- Bbqsx = .MarginLeft + Zdxzjg
- Case "2"
- If Zdxzjg = 0 Then
- If .PageWidth > Bbzkd Then
- Bbqsx = (.PageWidth - Bbzkd) / 2
- Else
- Bbqsx = .MarginLeft
- End If
- Else
- If .PageWidth - Zdxzjg - .MarginLeft > Bbzkd Then
- Bbqsx = (.PageWidth - Bbzkd - Zdxzjg - .MarginLeft) / 2 + Zdxzjg + .MarginLeft
- Else
- Bbqsx = .MarginLeft + Zdxzjg
- End If
- End If
- End Select
- '本页报表初始动态X,Y坐标(原则:内容输出完毕紧接着移动坐标为下一次输出作准备)
- Bbydx = Bbqsx
- Bbydy = .MarginTop + Zdxsjg
- Do While (Bbydy <= .PageHeight - .MarginBottom - Bwzgd - Bbsjhgd And Bbhsjsq <= DY_Tybbyldy.DyylGrid.Rows - 1) Or sfsckb '直至整个网格输出完毕
- '生 成 报 表 标 题
- .FontBold = True
- .FontName = Btfontname
- .FontSize = Btfontsize
- .CalcText = Bbzbt
- bbzbty = Bbydy
- bbzbtx = Bbzkd / 2 - .TextWid / 2 + Bbydx
- .TextBox Bbzbt, bbzbtx, bbzbty, .TextWid, .TextHei, False
- '非套打方式输出
- If Not Sftdfssc Then
- .DrawLine bbzbtx - Sckd, bbzbty + .TextHei + Xhsjg, bbzbtx + .TextWid + Sckd, bbzbty + .TextHei + Xhsjg
- .DrawLine bbzbtx - Sckd, bbzbty + .TextHei + 2 * Xhsjg, bbzbtx + .TextWid + Sckd, bbzbty + .TextHei + 2 * Xhsjg
- End If
- Bbydy = Bbydy + .TextHei + 2 * Xhsjg + Xbthjg
- .FontBold = False
- .FontName = Sjfontname
- .FontSize = Sjfontsize
- Xbtmaxlen = 0
- For jsqte = 1 To Bbxbtgs
- .CalcText = Bbxbt(jsqte)
- If .TextWid > Xbtmaxlen Then
- Xbtmaxlen = .TextWid
- End If
- Next jsqte
- '生成报表小标题同时在最后小标题行加页号
- For jsqte = 1 To Bbxbtgs
- .CalcText = Bbxbt(jsqte)
- Select Case bbxbtzzxs(jsqte)
- Case 0 '居左
- .TextBox Bbxbt(jsqte), Bbydx, Bbydy, .TextWid, .TextHei, False
- Case 1 '居中
- .TextBox Bbxbt(jsqte), Bbzkd / 2 - Xbtmaxlen / 2 + Bbydx, Bbydy, .TextWid, .TextHei, False
- Case 2 '居右
- .TextBox Bbxbt(jsqte), Bbydx + Bbzkd - .TextWid, Bbydy, .TextWid, .TextHei, False
- End Select
- '输出页号且居右
- If jsqte = Bbxbtgs Then
- If Sfdyfyh Then
- Bbpage = "第" + Trim(str(Pagecount)) + "-" + Trim(str(Bbynfyh)) + "页 "
- Else
- Bbpage = "第" + Trim(str(Pagecount)) + "页 "
- End If
- .CalcText = Bbpage
- .TextBox Bbpage, Bbydx + Bbzkd - .TextWid, Bbydy, .TextWid, .TextHei, False
- End If
- Bbydy = Bbydy + .TextHei + Xbthjg
- Next jsqte
- '生 成 报 表 表 头
- Btkdte = 0
- If sfscgdl <> 0 Then
- Call scbbbt(DY_Tybbyldy.DyylGrid, Bbgdscqsl, Bbgdsczzl, Kdfdbl, Bbgdhgd, Bbydy, Bbydx, Bbqsx, Sftdfssc)
- For Coljsq = Bbgdscqsl To Bbgdsczzl
- Btkdte = Btkdte + DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) * Kdfdbl
- Next Coljsq
- End If
- Call scbbbt(DY_Tybbyldy.DyylGrid, bbQslz, bbzzlz, Kdfdbl, Bbgdhgd, Bbydy, Bbydx + Btkdte, Bbqsx + Btkdte, Sftdfssc)
- Bbydy = Bbydy + DY_Tybbyldy.DyylGrid.FixedRows * Bbgdhgd
- '生 成 报 表 表 体(包括各列列宽,数据内容)
- .CurrentY = Bbydy
- '报表是否套打方式输出
- If Sftdfssc Then
- .TableBorder = tbNone
- Else
- If Bbbxjg > 1 Then
- .TableBorder = tbBoxColumns
- End If
- End If
- .StartTable
- Bbbtkd = ""
- Bbbody = ""
- '填 充 列 宽
- If sfscgdl Then
- For Coljsq = Bbgdscqsl To Bbgdsczzl
- If DY_Tybbyldy.DyylGrid.ColAlignment(Coljsq) = flexAlignRightTop Then
- Zzf = "+>"
- Else
- Zzf = "+"
- End If
- Bbbtkd = Bbbtkd + Zzf + Trim(str(DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) * Kdfdbl)) + "|"
- Next Coljsq
- End If
- For Coljsq = bbQslz To bbzzlz
- If DY_Tybbyldy.DyylGrid.ColAlignment(Coljsq) = flexAlignRightTop Then
- Zzf = "+>"
- Else
- Zzf = "+"
- End If
- If Coljsq = bbzzlz Then
- Bbbtkd = Bbbtkd + Zzf + Trim(str(DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) * Kdfdbl)) + ";"
- Else
- Bbbtkd = Bbbtkd + Zzf + Trim(str(DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) * Kdfdbl)) + "|"
- End If
- Next Coljsq
- '填 充 数 据 内 容
- Bybbhs = 0
- Do While Bybbhs <= Mybbhs And Bbhsjsq <= DY_Tybbyldy.DyylGrid.Rows - 1
- If Zdhs Then
- If Bybbhs >= Zdbbhs Then
- Exit Do
- End If
- End If
- Rowjsq = Bbhsjsq
- If sfscgdl Then
- For Coljsq = Bbgdscqsl To Bbgdsczzl
- If DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) >= Ztkd2 / 2 Then
- DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq) = Thwxzf(DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq))
- If Len(DY_Tybbyldy.DyylGrid.ColFormat(Coljsq)) <> 0 Then
- Bbbody = Bbbody + Format(DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq), DY_Tybbyldy.DyylGrid.ColFormat(Coljsq)) + "|"
- Else
- Bbbody = Bbbody + DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq) + "|"
- End If
- Else
- Bbbody = Bbbody + "|"
- End If
- Next Coljsq
- End If
- For Coljsq = bbQslz To bbzzlz
- If DY_Tybbyldy.DyylGrid.ColWidth(Coljsq) >= Ztkd2 / 2 Then
- If Coljsq = bbzzlz Then
- DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq) = Thwxzf(DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq))
- If Len(DY_Tybbyldy.DyylGrid.ColFormat(Coljsq)) <> 0 Then
- Bbbody = Bbbody + Format(DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq), DY_Tybbyldy.DyylGrid.ColFormat(Coljsq)) + ";"
- Else
- Bbbody = Bbbody + DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq) + ";"
- End If
- Else
- DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq) = Thwxzf(DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq))
- If Len(DY_Tybbyldy.DyylGrid.ColFormat(Coljsq)) <> 0 Then
- Bbbody = Bbbody + Format(DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq), DY_Tybbyldy.DyylGrid.ColFormat(Coljsq)) + "|"
- Else
- Bbbody = Bbbody + DY_Tybbyldy.DyylGrid.TextMatrix(Rowjsq, Coljsq) + "|"
- End If
- End If
- Else
- If Coljsq = bbzzlz Then
- Bbbody = Bbbody + ";"
- Else
- Bbbody = Bbbody + "|"
- End If
- End If
- Next Coljsq
- Bybbhs = Bybbhs + 1
- Bbhsjsq = Bbhsjsq + 1
- Loop
- .AddTable Bbbtkd, "", Bbbody
- '如果指定报表行数,则不进行满页打印
- If Sfmy And Bybbhs < Mybbhs Then
- Bbbody = ""
- For Rowjsq = 1 To Mybbhs - Bybbhs
- If Bbgdsczzl <> 0 Then
- For Coljsq = Bbgdscqsl To Bbgdsczzl
- Bbbody = Bbbody + "|"
- Next Coljsq
- End If
- For Coljsq = bbQslz To bbzzlz
- If Coljsq = bbzzlz Then
- Bbbody = Bbbody + ";"
- Else
- Bbbody = Bbbody + "|"
- End If
- Next Coljsq
- .AddTable Bbbtkd, "", Bbbody
- Bbbody = ""
- Bybbhs = Bybbhs + 1
- Next Rowjsq
- End If
- '设置报表行高度
- For Rowjsq = 1 To Bybbhs
- .TableCell(tcRowHeight, Rowjsq) = Bbsjhgd
- Bbydy = Bbydy + Bbsjhgd
- If Bbbxjg > 1 Then
- If Rowjsq Mod Bbbxjg = 0 And Rowjsq <> Bybbhs Then
- If Not Sftdfssc Then
- .DrawLine Bbqsx, Bbydy, Bbqsx + Bbzkd, Bbydy
- End If
- End If
- End If
- Next Rowjsq
- Lszbj = .MarginLeft
- .MarginLeft = Bbqsx
- .EndTable
- .MarginLeft = Lszbj
- '生 成 报 表 表 尾
- Bbydy = Bbydy + Xbthjg
- If Bbbwhgs <> 0 Then
- Bwhmaxlen = 0
- For jsqte = 1 To Bbbwhgs
- .CalcText = Bbbwh(jsqte)
- If .TextWid > Bwhmaxlen Then
- Bwhmaxlen = .TextWid
- End If
- Next jsqte
- For jsqte = 1 To Bbbwhgs
- .CalcText = Bbbwh(jsqte)
- Select Case Bbbwhzzxs(jsqte)
- Case 0
- .TextBox Bbbwh(jsqte), Bbydx, Bbydy, .TextWid, .TextHei, False
- Case 1
- .TextBox Bbbwh(jsqte), Bbzkd / 2 - Bwhmaxlen / 2 + Bbydx, Bbydy, .TextWid, .TextHei, False
- Case 2
- .TextBox Bbbwh(jsqte), Bbydx + Bbzkd - .TextWid, Bbydy, .TextWid, .TextHei, False
- End Select
- Bbydy = Bbydy + .TextHei
- Next jsqte
- End If
- .CalcText = Bwzb
- .TextBox Bwzb, Bbqsx, Bbydy, .TextWid, .TextHei
- .CalcText = Bwdyrq
- .TextBox Bwdyrq, Bbqsx + Bbzkd - .TextWid, Bbydy, .TextWid, .TextHei
- Bbydy = Bbydy + .TextHei
- .CalcText = Bwbzdw
- .TextBox Bwbzdw, Bbqsx, Bbydy, .TextWid, .TextHei
- .CalcText = Bwrjmc
- .TextBox Bwrjmc, Bbqsx + Bbzkd - .TextWid, Bbydy, .TextWid, .TextHei
- Bbydy = Bbydy + .TextHei + Bjjghs * .TextHei
- If Not (Sflxdy And .PageHeight - Bbydy >= Btzgd + Btsjhgd + Bwzgd) Then
- Exit Do
- End If
- Loop
- '判 断 是 页 内 分 页 还 是 开 始 新 的 一 页
- If bbzzlz = bbsczzlz Then
- '如果为空表仅输出一页
- sfsckb = False
- bbynbz = "0"
- Bbynfyh = 1
- bbQslz = bbscQslz
- bbzzlz = bbscQslz
- If Bbhsjsq <= DY_Tybbyldy.DyylGrid.Rows - 1 Then
- Bbhsjsqte = Bbhsjsq
- .NewPage
- Pagecount = Pagecount + 1
- End If
- Else
- bbynbz = "1"
- Bbhsjsq = Bbhsjsqte
- Bbynfyh = Bbynfyh + 1
- bbQslz = bbzzlz + 1
- .NewPage
- End If
- '解决由于纸张宽度太小出现死循环
- If Bbynfyh > DY_Tybbyldy.DyylGrid.Cols - 1 Then
- Tsxx = "纸张宽度太小不能输出报表,请重新设置!"
- Call Xtxxts(Tsxx, 0, 4)
- Unload DY_Tybbyldy
- Exit Sub
- End If
- Loop
- .EndDoc
- '还原操作状态
- Call Sub_SetOperStatus("")
- '输出打印页号填充滚动条
- DY_Tybbyldy.PageHScroll.Max = .Pagecount
- DY_Tybbyldy.PageHScroll.Min = 1
- DY_Tybbyldy.YlToolbar.Buttons("sy").Enabled = False
- If .Pagecount = 1 Then
- DY_Tybbyldy.YlToolbar.Buttons("xy").Enabled = False
- End If
- End With
- '预 览 打 印
- If bbylte Then
- DY_Tybbyldy.Show 1
- Else
- Call dyscbb(PrintMessageNotShow)
- End If
- End Sub
- Private Sub Scbbzdx(zdxwzte As Integer, zdxgdte As Double, zdxsjgte As Double, zdxzjgte As Double) '输 出 报 表 装 订 线
- With DY_Tybbyldy.Tydy
- If zdxwzte <> 0 Then
- .PenColor = QBColor(12)
- .PenStyle = psDashDot
- Select Case zdxwzte
- Case 1
- .DrawLine 0, zdxgdte, .PageWidth, zdxgdte
- zdxsjgte = zdxgdte
- Case 2
- .DrawLine zdxgdte, 0, zdxgdte, .PageHeight
- zdxzjgte = zdxgdte
- End Select
- .PenColor = QBColor(0)
- .PenStyle = psSolid
- End If
- End With
- End Sub
- Private Sub scbbbt(Cxsjwg, bbQslz&, bbzzlz&, Kdfdbl#, Bbgdhgd#, Bbydy#, Bbydx#, Bbqsx#, Sftdfssc As Boolean) '输出网格任意多列表头
- '参数说明:当前网格,起始列值,终止列值,行宽放大比例,表头行高度,当前Y坐标,当前X坐标,起始X坐标
- Dim Hbrow1&, Hbcol1&, Hbrow2&, Hbcol2& '合 并 单 元 范 围
- Dim Mgzkd&, Zyhs% '每个字宽度,占用行数
- bbydyte = Bbydy
- bbydxte = Bbydx
- With DY_Tybbyldy.Tydy
- For Rowjsq = 0 To Cxsjwg.FixedRows - 1
- For Coljsq = bbQslz To bbzzlz
- Dyxsbz = True
- If Rowjsq <> 0 Or Coljsq <> bbQslz Then
- If Rowjsq <> 0 Then
- If Cxsjwg.TextMatrix(Rowjsq, Coljsq) = Cxsjwg.TextMatrix(Rowjsq - 1, Coljsq) Then
- Dyxsbz = False
- End If
- End If
- If Coljsq <> bbQslz And Dyxsbz Then
- If Cxsjwg.TextMatrix(Rowjsq, Coljsq) = Cxsjwg.TextMatrix(Rowjsq, Coljsq - 1) Then
- Dyxsbz = False
- End If
- End If
- End If
- If Dyxsbz Then
- Cxsjwg.GetMergedRange Rowjsq, Coljsq, Hbrow1, Hbcol1, Hbrow2, Hbcol2
- jxkd = 0
- jxgd = 0
- For hbrowjsq = Hbrow1 To Hbrow2
- jxgd = jxgd + Bbgdhgd
- Next hbrowjsq
- If Hbcol1 < bbQslz Then
- Hbcol1 = bbQslz
- End If
- If Hbcol2 > bbzzlz Then
- Hbcol2 = bbzzlz
- End If
- For hbcoljsq = Hbcol1 To Hbcol2
- jxkd = jxkd + Cxsjwg.ColWidth(hbcoljsq) * Kdfdbl
- Next hbcoljsq
- .CalcText = Cxsjwg.TextMatrix(Rowjsq, Coljsq)
- If jxkd - .TextWid > 0 Then
- textx1 = bbydxte + (jxkd - .TextWid) / 2
- textkd = .TextWid
- texty1 = bbydyte + (jxgd - .TextHei) / 2
- textgd = .TextHei
- Else
- '当网格列宽不足以容下标题时,计算文本框大小及坐标
- If Len(Cxsjwg.TextMatrix(Rowjsq, Coljsq)) = 0 Then
- Mgzkd = 1
- Else
- Mgzkd = .TextWid / Len(Cxsjwg.TextMatrix(Rowjsq, Coljsq))
- End If
- If jxkd > Mgzkd Then
- If Len(Cxsjwg.TextMatrix(Rowjsq, Coljsq)) Mod Int(jxkd / Mgzkd) <> 0 Then
- Zyhs = Int(Len(Cxsjwg.TextMatrix(Rowjsq, Coljsq)) / Int(jxkd / Mgzkd)) + 1
- Else
- Zyhs = Len(Cxsjwg.TextMatrix(Rowjsq, Coljsq)) / Int(jxkd / Mgzkd)
- End If
- If Int(jxgd / .TextHei) < Zyhs Then
- Zyhs = Int(jxgd / .TextHei)
- End If
- textkd = Int(jxkd / Mgzkd) * Mgzkd
- textx1 = bbydxte + (jxkd - textkd) / 2
- textgd = Zyhs * .TextHei
- texty1 = bbydyte + (jxgd - textgd) / 2
- Else
- Zyhs = -1
- textx1 = bbydxte
- texty1 = bbydyte
- textkd = 0
- textgd = 0
- End If
- End If
- If textkd <> 0 Then
- .TextBox Cxsjwg.TextMatrix(Rowjsq, Coljsq), textx1, texty1, textkd, textgd, True
- End If
- If Not Sftdfssc Then
- .DrawLine bbydxte, bbydyte, bbydxte + jxkd, bbydyte
- .DrawLine bbydxte, bbydyte, bbydxte, bbydyte + jxgd
- .DrawLine bbydxte + jxkd, bbydyte, bbydxte + jxkd, bbydyte + jxgd
- .DrawLine bbydxte, bbydyte + jxgd, bbydxte + jxkd, bbydyte + jxgd
- End If
- End If
- bbydxte = bbydxte + Cxsjwg.ColWidth(Coljsq) * Kdfdbl
- Next Coljsq
- bbydxte = Bbqsx
- bbydyte = bbydyte + Bbgdhgd
- Next Rowjsq
- End With
- End Sub
- Public Sub Scyxsjb(Cxsjwg As VSFlexGrid) '生成有效数据表(针对网格隐含和数据行为空行情况的解决方案)
- '过程参数:输出数据网格
- Dim Yxhzjsq%, Yxlzjsq%
- Dim Rowjsq As Long
- With DY_Tybbyldy.DyylGrid
- .Redraw = False '为了加快传送速度
- .FontName = Cxsjwg.FontName
- .FontSize = Cxsjwg.FontSize
- .FixedRows = Cxsjwg.FixedRows
- .MergeCells = flexMergeFixedOnly
- For jsqte = 0 To .FixedRows - 1
- .MergeRow(jsqte) = True
- Next jsqte
- .WordWrap = True
- Yxlzjsq = 0
- For Coljsq = 0 To Cxsjwg.Cols - 1
- If Not Cxsjwg.ColHidden(Coljsq) Then
- Yxlzjsq = Yxlzjsq + 1
- End If
- Next Coljsq
- .Cols = Yxlzjsq
- Yxlzjsq = 0
- For Coljsq = 0 To Cxsjwg.Cols - 1
- If Not Cxsjwg.ColHidden(Coljsq) Then
- .ColAlignment(Yxlzjsq) = Cxsjwg.ColAlignment(Coljsq)
- .ColWidth(Yxlzjsq) = Cxsjwg.ColWidth(Coljsq)
- .ColFormat(Yxlzjsq) = Cxsjwg.ColFormat(Coljsq)
- .MergeCol(Yxlzjsq) = True
- Yxlzjsq = Yxlzjsq + 1
- End If
- Next Coljsq
- Yxhzjsq = 0
- For Rowjsq = 0 To Cxsjwg.Rows - 1
- If (Not Cxsjwg.RowHidden(Rowjsq)) And (Not GridRowEmpty(Cxsjwg, Rowjsq)) Then
- Yxhzjsq = Yxhzjsq + 1
- End If
- Next Rowjsq
- .Rows = Yxhzjsq
- Yxhzjsq = 0
- Yxlzjsq = 0
- For Rowjsq = 0 To Cxsjwg.Rows - 1
- If (Not Cxsjwg.RowHidden(Rowjsq)) And (Not GridRowEmpty(Cxsjwg, Rowjsq)) Then
- For Coljsq = 0 To Cxsjwg.Cols - 1
- If Not Cxsjwg.ColHidden(Coljsq) Then
- If Cxsjwg.ColDataType(Coljsq) = flexDTBoolean And Rowjsq >= .FixedRows Then '布尔型列单独处理
- If Cxsjwg.TextMatrix(Rowjsq, Coljsq) Then
- .TextMatrix(Yxhzjsq, Yxlzjsq) = "√"
- Else
- .TextMatrix(Yxhzjsq, Yxlzjsq) = ""
- End If
- Else
- .TextMatrix(Yxhzjsq, Yxlzjsq) = Cxsjwg.TextMatrix(Rowjsq, Coljsq)
- End If
- Yxlzjsq = Yxlzjsq + 1
- End If
- Next Coljsq
- .RowHeight(Yxhzjsq) = Cxsjwg.RowHeight(Rowjsq)
- Yxlzjsq = 0
- Yxhzjsq = Yxhzjsq + 1
- End If
- Next Rowjsq
- .Redraw = True
- End With
- End Sub
- Public Function GridRowEmpty(Cxsjwg As VSFlexGrid, Rowte As Long) As Boolean '判断网格行是否为空行
- GridRowEmpty = True
- With Cxsjwg
- For jsqte = 0 To .Cols - 1
- If Len(Trim(.TextMatrix(Rowte, jsqte))) <> 0 Then
- GridRowEmpty = False
- Exit Function
- End If
- Next jsqte
- End With
- End Function
- Public Sub dyscbb(Optional PrintMessageNotShow As Boolean) '打 印 输 出 报 表(调用打印提示选择项窗体)
- If Not PrintMessageNotShow Then
- DY_DytsFrm.Show 1
- Else
- DY_DytsFrm.Output_Printer
- End If
- End Sub
- Private Function Thwxzf(Thzfc As String) As String '替换打印中妨碍字符 ";"和"|" 为全角有效字符
- Dim lswz As Integer
- Do While InStr(1, Thzfc, ";") <> 0
- lswz = InStr(1, Thzfc, ";")
- Thzfc = Mid(Thzfc, 1, lswz - 1) + ";" + Mid(Thzfc, lswz + 1, Len(Thzfc))
- Loop
- Do While InStr(1, Thzfc, "|") <> 0
- lswz = InStr(1, Thzfc, "|")
- Thzfc = Mid(Thzfc, 1, lswz - 1) + Mid(Thzfc, lswz + 1, Len(Thzfc))
- Loop
- Thwxzf = Thzfc
- End Function
- '单据打印输出
- Public Sub BillGridPrint(WglrGrid As Object, LrText As Object, GridStr() As String, Szzls As Integer, Grid_code As String, Text_code As String, XtReportCode As String, Optional PrintDirect As Boolean = False, Optional PrintType As String = "default")
- On Error Resume Next
- Dim I As Integer, GridTop As Double, GridLeft As Double, BodyTop As Integer, FixRowHeight As Double
- Dim TableFormat As String, TableBody As String, DataRows As Integer, TableData() As String
- Dim DataRowHeight As Integer, Rowjsq As Integer, GridDataRows As Integer, BillTitlePrint As String
- Dim aDo_Rec As New Recordset, ColSum(), MarginLeft As Integer, MarginTop As Integer, BillTitleLeft As Integer, BillTitleTop As Integer
- Dim Bbsjqfont As String, Bbsjqsize As String
- With DY_Tybbyldy
- '=====================
- Set aDo_Rec = Cw_DataEnvi.DataConnect.Execute("select * from Xt_dybbcs where bbbm='" & XtReportCode & "'")
- .Tydy.PaperSize = aDo_Rec!PaperSize
- .Tydy.Orientation = aDo_Rec!PaperScfx
- .Tydy.MarginLeft = aDo_Rec!bbzbj
- .Tydy.MarginTop = aDo_Rec!bbsbj
- .Tydy.FontName = Trim(aDo_Rec!Bbbtfont)
- .Tydy.FontSize = aDo_Rec!Bbbtsize
- Bbsjqfont = aDo_Rec!Bbsjqfont
- Bbsjqsize = aDo_Rec!Bbsjqsize
- MarginLeft = .Tydy.MarginLeft
- MarginTop = .Tydy.MarginTop
- aDo_Rec.Close
- '=====================
- For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows - 1
- If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- End If
- GridDataRows = GridDataRows + 1
- Next
- '=====================
- Set aDo_Rec = Cw_DataEnvi.DataConnect.Execute("select * from xt_v_billgridPrint where grid_code='" & Grid_code & "' and printgridcode='" & Trim(PrintType) & "' order by colid")
- '================
- If aDo_Rec.RecordCount > 0 Then
- '-----------
- .DyylGrid.FixedRows = aDo_Rec!FixRows: .DyylGrid.Cols = 0
- GridTop = aDo_Rec!PrintGridTop: GridLeft = aDo_Rec!PrintGridLeft
- FixRowHeight = aDo_Rec!FixRowHeight: DataRows = aDo_Rec!PrintDataRows
- DataRowHeight = aDo_Rec!DataRowHeight
- BillTitleLeft = aDo_Rec!BillTitleLeft
- BillTitleTop = aDo_Rec!BillTitleTop
- BillTitlePrint = Trim("" & aDo_Rec!BillTitlePrint)
- '----------
- If aDo_Rec!FixRows = 1 Then BodyTop = aDo_Rec!FixRowHeight + GridTop
- If aDo_Rec!FixRows = 2 Then BodyTop = aDo_Rec!FixRowHeight * 2 + GridTop
- If aDo_Rec!FixRows = 3 Then BodyTop = aDo_Rec!FixRowHeight * 3 + GridTop
- '----------
- aDo_Rec.MoveNext
- '================
- .DyylGrid.MergeCells = flexMergeFixedOnly
- For I = 0 To .DyylGrid.FixedRows - 1
- .DyylGrid.MergeRow(I) = True
- Next I
- I = 0
- '======================
- ReDim TableData(aDo_Rec.RecordCount - 1)
- ReDim ColSum(2, aDo_Rec.RecordCount - 1)
- Do While Not aDo_Rec.EOF '网格头
- If aDo_Rec!YnPrint = False Then
- .DyylGrid.Cols = .DyylGrid.Cols + 1
- .DyylGrid.TextMatrix(0, I) = Trim(aDo_Rec!ColTitle1)
- .DyylGrid.TextMatrix(1, I) = Trim(aDo_Rec!ColTitle2)
- .DyylGrid.TextMatrix(2, I) = Trim(aDo_Rec!ColTitle3)
- .DyylGrid.ColWidth(I) = aDo_Rec!PrintColWidth
- .DyylGrid.MergeCol(I) = True
- '-----------
- If aDo_Rec!ColAlignment = 6 Then
- TableFormat = TableFormat & "+>" & aDo_Rec!PrintColWidth & "|"
- Else
- TableFormat = TableFormat & "+<" & aDo_Rec!PrintColWidth & "|"
- End If
- TableData(I) = Trim(aDo_Rec!ColIndex)
- ColSum(0, I) = aDo_Rec!ColSum_flag
- '-----------
- I = I + 1
- End If
- aDo_Rec.MoveNext
- Loop
- aDo_Rec.Close
- TableFormat = Mid(TableFormat, 1, Len(TableFormat) - 1)
- '---------------
- End If
- '======================
- Dim h As Integer, PrintDataRows As Integer
- Dim PrintRow As Integer: Dim TTF As Boolean
- PrintRow = WglrGrid.FixedRows
- Set aDo_Rec = Cw_DataEnvi.DataConnect.Execute("select * from Xt_v_billtextPrint where text_group_code='" & Text_code & "' and printtextcode='" & Trim(PrintType) & "' order by text_index")
- '<<<<<<<<
- .Tydy.StartDoc
- '------------
- PrintDataRows = GridDataRows (DataRows - 1)
- If GridDataRows Mod (DataRows - 1) > 0 Then PrintDataRows = PrintDataRows + 1
- If PrintDataRows = 0 Then PrintDataRows = 1
- .Tydy.CurrentX = BillTitleLeft + MarginLeft: .Tydy.CurrentY = BillTitleTop + MarginTop
- .Tydy = BillTitlePrint
- .Tydy.FontName = Trim(Bbsjqfont)
- .Tydy.FontSize = Bbsjqsize
- For h = 1 To PrintDataRows
- '==============
- aDo_Rec.MoveFirst
- TableBody = ""
- '----------
- Do While Not aDo_Rec.EOF '表头数据
- If aDo_Rec!YnPrint = True Then
- .Tydy.CurrentX = Val("" & aDo_Rec!printLabelLeft) + MarginLeft: .Tydy.CurrentY = aDo_Rec!PrintTop + MarginTop
- .Tydy = Trim(aDo_Rec!Text_Name) & ":"
- .Tydy.CurrentX = aDo_Rec!PrintLeft + MarginLeft: .Tydy.CurrentY = aDo_Rec!PrintTop + MarginTop
- .Tydy = LrText(aDo_Rec!text_Index)
- End If
- aDo_Rec.MoveNext
- Loop
- '==========
- If DataRows <> 0 Then
- '===================== 表体数据
- TableBody = ""
- TTF = False
- For Rowjsq = PrintRow To WglrGrid.Rows - 1
- If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
- TTF = True
- Exit For
- End If
- '----------------表体数据行
- For I = 0 To UBound(TableData) - 1
- If Trim(WglrGrid.ColFormat(Sydz(TableData(I), GridStr(), Szzls))) = "" Then
- TableBody = TableBody & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz(TableData(I), GridStr(), Szzls))) & "|"
- Else
- TableBody = TableBody & Format(Trim(WglrGrid.TextMatrix(Rowjsq, Sydz(TableData(I), GridStr(), Szzls))), WglrGrid.ColFormat(Sydz(TableData(I), GridStr(), Szzls))) & "|"
- End If
- If ColSum(0, I) = True Then
- ColSum(1, I) = ColSum(1, I) + Val(WglrGrid.TextMatrix(Rowjsq, Sydz(TableData(I), GridStr(), Szzls)))
- End If
- Next I
- TableBody = Mid(TableBody, 1, Len(TableBody) - 1)
- TableBody = TableBody & ";"
- PrintRow = PrintRow + 1
- If (Rowjsq - WglrGrid.FixedRows + 1) - ((DataRows - 1) * h) = 0 Then
- Exit For
- End If
- Next Rowjsq
- For DataRow = (Rowjsq - WglrGrid.FixedRows + 1) - ((DataRows - 1) * (h - 1)) To DataRows
- If DataRow = IIf(TTF, DataRows, DataRows - 1) Then
- TableBody = TableBody & "小计:" & "|"
- '--------
- For I = 1 To UBound(TableData) - 1
- If ColSum(0, I) = True Then
- TableBody = TableBody & Format(Trim(ColSum(1, I)), WglrGrid.ColFormat(Sydz(TableData(I), GridStr(), Szzls))) & "|"
- ColSum(1, I) = 0
- Else
- TableBody = TableBody & " |"
- End If
- Next I
- '--------
- TableBody = Mid(TableBody, 1, Len(TableBody) - 1) & ";"
- Exit For
- End If
- '=============================
- For I = 0 To UBound(TableData) - 1
- TableBody = TableBody & " |"
- Next I
- TableBody = Mid(TableBody, 1, Len(TableBody) - 1) & ";"
- Next DataRow
- '=====================
- Call scbbbt(.DyylGrid, 0, .DyylGrid.Cols - 1, 1, FixRowHeight, GridTop + MarginTop, GridLeft + MarginLeft, GridLeft + MarginLeft, False)
- '====================
- .Tydy.MarginLeft = GridLeft + MarginLeft: .Tydy.CurrentY = BodyTop + MarginTop
- .Tydy.StartTable
- '--------
- .Tydy.AddTable TableFormat, "", TableBody, , , True
- .Tydy.TableCell(tcRows) = DataRows
- For I = 1 To DataRows
- .Tydy.TableCell(tcRowHeight, I) = DataRowHeight
- Next
- '--------
- .Tydy.EndTable
- '===================
- If h < PrintDataRows Then
- .Tydy.NewPage
- End If
- '=================
- End If
- Next h
- '================
- .Tydy.EndDoc
- '判断是直接打印还是预览
- If Not PrintDirect Then
- .Show 1 '预览
- Else
- Call DY_DytsFrm.Output_Printer '直接打印输出
- Unload DY_Tybbyldy '卸载打印预览窗体
- Unload DY_DytsFrm '卸载打印选择提示选项
- End If
- End With
- End Sub
- '单据打印输出
- Public Sub BillTextPrint(Lab_Title As Object, LrText As Object, Text_code As String, XtReportCode As String, Optional PrintDirect As Boolean = False, Optional PrintType As String = "default")
- On Error Resume Next
- Dim aDo_Rec As New Recordset, MarginLeft As Integer, MarginTop As Integer, Bbmc As String
- With DY_Tybbyldy
- '=====================
- Set aDo_Rec = Cw_DataEnvi.DataConnect.Execute("select * from Xt_dybbcs where bbbm='" & XtReportCode & "'")
- .Tydy.PaperSize = aDo_Rec!PaperSize
- .Tydy.Orientation = aDo_Rec!PaperScfx
- .Tydy.MarginLeft = aDo_Rec!bbzbj
- .Tydy.MarginTop = aDo_Rec!bbsbj
- MarginLeft = aDo_Rec!bbzbj
- MarginTop = aDo_Rec!bbsbj
- .Tydy.FontName = Trim(aDo_Rec!Bbbtfont)
- .Tydy.FontSize = aDo_Rec!Bbbtsize
- Bbsjqfont = aDo_Rec!Bbsjqfont
- Bbsjqsize = aDo_Rec!Bbsjqsize
- aDo_Rec.Close
- '=====================
- Set aDo_Rec = Cw_DataEnvi.DataConnect.Execute("select * from Xt_v_billtextPrint where text_group_code='" & Text_code & "' and printtextcode='" & Trim(PrintType) & "' order by text_index")
- '<<<<<<<<
- .Tydy.StartDoc
- If .Tydy.Orientation = 0 Then
- .Tydy.CurrentX = .Tydy.PaperWidth / 2 - Lab_Title.Width / 2
- Else
- .Tydy.CurrentX = .Tydy.PaperHeight / 2 - Lab_Title.Width / 2
- End If
- .Tydy.CurrentY = MarginTop
- .Tydy = Lab_Title
- .Tydy.FontName = Trim(Bbsjqfont)
- .Tydy.FontSize = Bbsjqsize
- '=========
- Do While Not aDo_Rec.EOF '表头数据
- If aDo_Rec!YnPrint = True Then
- .Tydy.CurrentX = Val("" & aDo_Rec!printLabelLeft) + MarginLeft: .Tydy.CurrentY = aDo_Rec!PrintTop + MarginTop
- .Tydy = Trim(aDo_Rec!Text_Name) & ":"
- .Tydy.CurrentX = aDo_Rec!PrintLeft + MarginLeft: .Tydy.CurrentY = aDo_Rec!PrintTop + MarginTop
- .Tydy = LrText(aDo_Rec!text_Index)
- End If
- aDo_Rec.MoveNext
- Loop
- '==========
- .Tydy.EndDoc
- '判断是直接打印还是预览
- If Not PrintDirect Then
- .Show 1 '预览
- Else
- Call DY_DytsFrm.Output_Printer '直接打印输出
- Unload DY_Tybbyldy '卸载打印预览窗体
- Unload DY_DytsFrm '卸载打印选择提示选项
- End If
- End With
- End Sub