以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  调用打印机  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=153338)

--  作者:outcat
--  发布时间:2020/8/7 12:28:00
--  调用打印机
老师,我写一个打印函数,这个是参数配置表获取到系统打印机,已维护好,我是有 打印类型 两种,票据 报表,当选择的是入库单、出库单是,调取打印类型为 票据,打印机名称为该类型的打印机, 下面是已经写好了,在 入库单打印时,调用这个函数,不起作用,老师,你看一下,是怎么回事。

Dim e = args(0)
Dim 参数类型 As String = args(1)
Dim 参数名称 As String = args(2)
Dim 配置参数 As String = args(3)
Dim 打印类型 As String = args(4)
Dim 打印机名称 As String = args(5)
Dim dr As DataRow = DataTables("参数配置表").find("参数名称=\'" & 参数名称 & "\'and 打印类型 = \'" & 参数名称 & "\' and 打印机名称 = \'" & 参数名称 & "\'And 参数类型=\'是否启用打印\' And 配置参数=\'是\'")
If dr IsNot Nothing Then
    Dim doc As PrintDoc = e.Form.GernatePrintDoc()
    For Each c As object In Doc.Body.Children
        If Typeof c Is prt.RenderTable Then
            Dim t As prt.RenderTable = c
            t.Rows(0).Style.Font = new font("宋体", 10, fontstyle.bold)   \'第一行,即标题行加粗
            \'t.Rows(t.Rows.count-1).Style.Font = new font("宋体", 10, fontstyle.bold) \'最后一行,即标题加粗,这里是打印表格明细,不需要
            For i As Integer = 0 To t.Rows.count-1
                For j As Integer = 0 To t.Cols.count-1
                    t.cells(i,j).Style.BackColor = Color.white
                    t.cells(i,j).Style.TextColor = Color.black
                Next
            Next
        End If
    Next
    doc.Print()
Else
    Return Nothing
End If

--  作者:outcat
--  发布时间:2020/8/7 12:41:00
--  
Dim dr As DataRow = DataTables("参数配置表").find("参数名称=\'" & 参数名称 & "\'and 打印类型 = \'" & 打印类型 & "\' and 打印机名称 = \'" & 打印机名称 & "\'And 参数类型=\'是否启用打印\' And 配置参数=\'是\'")  

不好意思,上面发错了

--  作者:有点蓝
--  发布时间:2020/8/7 13:28:00
--  
"参数配置表"查询后有什么用?没看到有使用的地方
--  作者:outcat
--  发布时间:2020/8/7 13:53:00
--  
老师,脑子糊涂了,这个还有个指定打印机的参数,这个忘记设置了,算是找到问题了

现在  汇总报表 打印
Dim pg As WinForm.SplitPanel = e.Form.Controls("SplitContainer1").Panel2
Dim doc As PrintDoc = e.Form.GernatePrintDoc(pg)   

也要在这里弄成函数调用,可是定义这个得时候   SplitContainer1  这个值在不同的窗口是不一样的,这个值怎么弄呢,老师

--  作者:有点蓝
--  发布时间:2020/8/7 13:59:00
--  
把控件作为参数传输过去

函数
dim kj  = args(0)
Dim doc As PrintDoc = e.Form.GernatePrintDoc(kj)  

按钮
Dim pg As WinForm.SplitPanel = e.Form.Controls("SplitContainer1").Panel2
Functions.Execute("xxx函数",pg)