If Tables("维护日志").Current Is Nothing Then
Return
End If
If Tables("维护日志").Current.Locked = True
MessageBox.Show("请点击修改日志后再执行本操作!~","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
Dim dr As DataRow = Tables("维护日志").Current.DataRow
Dim dlg As New OpenFileDialog
dlg.Filter = "文件|*.*"
If dlg.ShowDialog = DialogResult.OK Then
Dim fj As DataRow =DataTables("附件").AddNew
fj("ID")= dr("ID")
Dim mc() As String = dlg.FileName.Split("\")
fj("附件名称")=mc(mc.Length-1)
Dim s() As String = dlg.FileName.Split(".") '获取扩展名,防止文件名中含有.?这样可以取最后一个数组内容加.获取扩展名
fj("扩展名")= "." & s(s.Length-1)
DataTables("附件").save
fj.SQLInsertFile("内容",dlg.FileName) '插入文件
End If
'刷新列表
Dim lbx As WinForm.ListBox = Forms("日志录入").Controls("ListBox1")
lbx.ComboList = DataTables("附件").GetComboListString("附件名称","ID='" & Tables("维护日志").Current("ID") & "'")
删除按钮:
If Tables("维护日志").Current Is Nothing Then
Return
End If
If Tables("维护日志").Current.Locked = True
MessageBox.Show("请点击修改本条日志后再执行本操作!~","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
Dim lbx As WinForm.ListBox = e.Form.Controls("ListBox1")
If MessageBox.Show("确认删除附件:" & lbx.SelectedItem & "吗?","删除提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)=6 Then
DataTables("附件").SQLDeleteFor("ID='" & Tables("维护日志").Current("ID") & "' and 附件名称='" & lbx.SelectedItem & "'")
MessageBox.Show("删除成功!","删除提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
''刷新列表
lbx.ComboList = DataTables("附件").SQLGetComboListString("附件名称","ID='" & Tables("维护日志").Current("ID") & "'")
查看按钮
If Tables("维护日志").Current Is Nothing Then
Return
End If
Dim lbx As WinForm.ListBox = e.Form.Controls("ListBox1")
If lbx.SelectedItem Is Nothing
MessageBox.Show("请先选择要打开的附件再执行本操作!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
Dim dr As DataRow = DataTables("附件").Find("附件名称='" & lbx.SelectedItem & "' and ID='" & Tables("维护日志").Current("ID") & "'")
Dim fl As String = ProjectPath & "fujian\" & lbx.SelectedItem
MessageBox.Show(fl)
MessageBox.Show("附件名称='" & lbx.SelectedItem & "' and ID='" & Tables("维护日志").Current("ID") & "'")
If dr.SQLLoadFile("内容",fl) Then '如果提取文件成功
Dim Proc As New Process '打开文件
Proc.File = fl
Proc.Start()
Else
Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If