有两个按键生成PDF文件放在附件中,一个半成品报告、一个成品报告,下面代码任生成一个文件就会把前一个覆盖清除(后台文件没删除)
即先生成半成品报告,再按成品报告,附件列表中就只有成品报告,半成品报告没了
怎么做个判断,代码如下
半成品生成报告按钮
Dim c As WinForm.DateTimePicker = e.Form.Controls("报告日期")
Dim z As WinForm.ComboBox = e.Form.Controls("执行标准")
If c.Value=Nothing Then
MessageBox.Show("请输入报告日期!")
Return
ElseIf z.Value=Nothing Then
MessageBox.Show("请选择执行标准!")
Return
Else
Dim Book As New XLS.Book(ProjectPath & "templets\p\半成品检验报告.xls")
Dim r As Row = e.Form.controls("检验表").Table.Current
Dim fl As String = "\\192.168.1.18\$BPR$\PG\QC_CP\" &r("检验编号")& "_" & r("批号") & "半成品报告.pdf"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Relations.Add("成品报告关联",DataTables("成品报告编辑_检验表").DataCols("执行标准"),DataTables("成品报告编辑_检验标准").DataCols("执行标准"))
Relations.Add("成品报告关联2",DataTables("成品报告编辑_检验表").DataCols("检验编号"),DataTables("产品检验_生产明细").DataCols("检验编号"))
Book.Build() '生成细节区
Book.SaveToPDF(fl) '保存为PDF文件
Dim Proc As New Process '打开PDF文件
Proc.File = fl
Proc.Start()
If Relations.Count > 0 Then
Relations.Delete("成品报告关联")
Relations.Delete("成品报告关联2")
End If
r("附件") = r("检验编号")& "_" &r("批号") & "半成品报告.pdf"
End If
成品报告生成铵钮
Dim c As WinForm.DateTimePicker = e.Form.Controls("报告日期")
Dim z As WinForm.ComboBox = e.Form.Controls("执行标准")
If c.Value=Nothing Then
MessageBox.Show("请输入报告日期!")
Return
ElseIf z.Value=Nothing Then
MessageBox.Show("请选择执行标准!")
Return
Else
Dim Book As New XLS.Book(ProjectPath & "templets\p\成品检验报告.xls")
Dim r As Row = e.Form.controls("检验表").Table.Current
Dim fl As String = "\\192.168.1.18\$BPR$\PG\QC_CP\" &r("检验编号")& "_" & r("批号") & "成品报告.pdf"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Relations.Add("成品报告关联",DataTables("成品报告编辑_检验表").DataCols("执行标准"),DataTables("成品报告编辑_检验标准").DataCols("执行标准"))
Relations.Add("成品报告关联2",DataTables("成品报告编辑_检验表").DataCols("检验编号"),DataTables("产品检验_生产明细").DataCols("检验编号"))
Book.Build() '生成细节区
Book.SaveToPDF(fl) '保存为PDF文件
Dim Proc As New Process '打开PDF文件
Proc.File = fl
Proc.Start()
If Relations.Count > 0 Then
Relations.Delete("成品报告关联")
Relations.Delete("成品报告关联2")
End If
r("附件") = r("检验编号")& "_" &r("批号") & "成品报告.pdf"
End If
[此贴子已经被作者于2020/10/24 23:18:39编辑过]