老师,
以下可以帮忙加两个功能: 1. 将图片另存到指定的目前中,目录名 D:\pic\,图片名取当前记录的产品名, 2.直接打印这图片。谢谢。
按钮名称 | 代码 |
打开文件 | If Tables("员工").Current Is Nothing Then Return End If Dim dr As DataRow = Tables("员工").Current.DataRow Dim fl As String = ProjectPath & dr("_Identify") & ".doc" If dr.SQLLoadFile("附件",fl) Then '如果提取文件成功 Dim Proc As New Process '打开文件 Proc.File = fl Proc.Start() Else Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) End If |
插入文件 | If Tables("员工").Current Is Nothing Then Return End If Dim dr As DataRow = Tables("员工").Current.DataRow If dr.RowState = DataRowState.Added Then '如果是新增行,必须先保存才能插入文件 dr.Save() End If Dim dlg As New OpenFileDialog dlg.Filter = "Word文件|*.doc" If dlg.ShowDialog =DialogResult.OK Then dr.SQLInsertFile("附件",dlg.FileName) '插入文件 End If 提示:请自行思考一下,为什么新增行必须先保存才能插入文件呢? |
删除文件 | If Tables("员工").Current IsNot Nothing Then Tables("员工").Current.DataRow.SQLSetValue("附件",Nothing) '从后台删除附件列内容 End If |
插入照片 | If Tables("员工").Current Is Nothing Then Return End If Dim dr As DataRow = Tables("员工").Current.DataRow Dim dlg As New OpenFileDialog dlg.Filter = "图形文件|*.bmp;*.jpg;*.gif;*.png" If dlg.ShowDialog = DialogResult.OK Then dr.SQLInsertFile("照片",dlg.FileName) '插入文件 Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1") pic.Image = GetImage(dlg.FileName) End If |
删除照片 | If Tables("员工").Current IsNot Nothing Then Tables("员工").Current.DataRow.SQLSetValue("照片",Nothing) '从后台删除照片列内容 Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1") pic.Image = Nothing End If |