Foxtable(狐表)用户栏目专家坐堂 → [求助] 增加代码功能


  共有1852人关注过本帖树形打印复制链接

主题:[求助] 增加代码功能

帅哥哟,离线,有人找我吗?
sanny
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:797 积分:5901 威望:0 精华:0 注册:2018/11/3 8:24:00
[求助] 增加代码功能  发帖心情 Post By:2021/2/21 10:12:00 [只看该作者]

老师,

以下可以帮忙加两个功能: 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



 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107135 积分:544918 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/2/21 20:52:00 [只看该作者]

1、Dim fl As String =  ProjectPath &  dr("_Identify") & ".doc"
改为
Dim fl As String =  "D:\pic\" &  dr("产品名") & ".jpg"

2、没有打印图片的功能,您可以打开图片,然后在图片浏览器中选择打印

Dim Proc As New Process
Proc
.File = 
fl
Proc
.Start

 回到顶部