Dim rs As List(Of Row) = Tables("投标保函费用管理").GetCheckedRows
If rs.Count > 0 Then '如果存在符合条件的行
WaitShow() '打开加载进度
Dim tm As String = ProjectPath & "Attachments\投标保函费用支付凭证.docx" '指定模板文件
Dim fl1 As String = ProjectPath & "Reports\投标保函费用支付凭证.docx" '指定目标文件
Dim fl2 As String = ProjectPath & "Reports\投标保函费用支付凭证.pdf" '指定目标PDF文件
Dim wrt As New WordReport(Tables("投标保函费用管理"), tm, fl1) '定义一个WordReport
For Each r As Row In rs '逐行生成报表
Dim dr As DataRow = DataTables("分支机构管理").sqlFind("[所属机构] = '" & r("所属机构") & "'")
If dr IsNot Nothing Then
wrt.Replace("[负责人]", dr("姓名")) '用代码替换负责人
End If
Dim dr1 As DataRow = DataTables("审核意见表").sqlFind("[审核部门] = '财务部制单' And [Id] = '" & r("Id") & "'")
If dr1 IsNot Nothing Then
wrt.Replace("[制单人]", dr1("审核人")) '用代码替换制单人
End If
Dim dr2 As DataRow = DataTables("审核意见表").sqlFind("[审核部门] = '财务部经理' And [Id] = '" & r("Id") & "'")
If dr2 IsNot Nothing Then
wrt.Replace("[复核人]", dr2("审核人")) '用代码替换复核人
End If
Dim dr3 As DataRow = DataTables("审核意见表").SQLFind("[表名称] = '" & "投标保函费用管理" & "' And [Id] = '" & r("Id") & "'", "审核日期 DESC")
If dr3 IsNot Nothing Then
wrt.ReplaceOne("[复核日期]", Format(dr3("审核日期"), "yyyy-MM-dd")) '用代码替换制单人
End If
wrt.BuildOne(r)
r.Checked = False
Next
wrt.SaveToPDF(fl2) '保存为PDF文件
wrt.Quit() '退出
Dim Proc As New Process '打开PDF文件
Proc.File = fl2
Proc.Start()
WaitClose() '关闭加载进度
Else
MessageBox.Show("请先勾选你需要打印的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If