Dim pc2 As WinForm.PictureBox = e.Form.Controls("PictureBox1")
Dim kp As WinForm.TabControl = e.Form.Controls("TabControl1")
Dim web1 As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
web1.Address = Nothing
If FileSys.DirectoryExists(ProjectPath & "预览文件") Then '如果目录存在
If Tables("收文列表.文件附件").Current Is Nothing Then
Return
End If
Dim dr As DataRow = Tables("收文列表.文件附件").Current.DataRow
Dim fl As String = ProjectPath & "预览文件\" & dr("文件名")
If FileSys.FileExists(fl) AndAlso CRCCheckFile(fl) = dr.SQLGetValue("CRC值") Then '如果本地存在同名文件且CRC校验值相同
'则直接使用本地文件
If fl.EndsWith(".jpg") OrElse fl.EndsWith(".png") OrElse fl.EndsWith(".bmp") OrElse fl.EndsWith(".gif") Then
pc2.Image= GetImage(fl)
kp.SelectedIndex=0
Else If fl.EndsWith(".txt") OrElse fl.EndsWith(".zip") OrElse fl.EndsWith(".rar") OrElse fl.EndsWith(".pdf") OrElse fl.EndsWith(".exe") Then
Dim Proc As New Process '打开文件
Proc.File = fl
Proc.Start()
Else
web1.Address = fl
kp.SelectedIndex=1
End If
Else '否则从数据库提取文件
If dr.SQLLoadFile("附件",fl) = False Then '如果提取文件失败
Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
End If
End If