Dim ltbox As WinForm.ListBox = e.Form.Controls("zjListBox1")
Dim fdr As Row = Tables("现场图像").current
'==========判断项目编号是否带"-"===========
Dim pstr As Integer = fdr("项目编号").IndexOf("-")
Dim phr As String
If pstr > 0 Then
phr = fdr("项目编号").SubString(0,fdr("项目编号").IndexOf("-"))
Else
phr = fdr("项目编号")
End If
If fdr IsNot Nothing Then
If fdr.IsNull("工程部位") Then
MessageBox.Show("请先输入图像所在工程部位!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
For Each flt As String In ltbox.Items
Dim ndr As Row = Tables("现场图像.图像明细").AddNew
Dim i As Integer = Tables("现场图像.图像明细").Rows.Count
Dim fl = fdr("工程部位") & "-" & format(i, "00")
ndr("图像名称") = fl
ndr("图像类型") = flt.SubString(flt.LastIndexOf("."))
ndr.Save '必须先保存
ndr.DataRow.SQLInsertFile("附件",flt) '插入文件
ndr.DataRow.SQLSetValue("CRC", CRCCheckFile(flt)) '保存crc检验值 fdr("项目编号")
''==============图像本地保存===============
If fdr.IsNull("单位工程") = False Then
Dim pth As String = ProjectPath & "Attachments\用户工程\" & phr & fdr("工程名称") & "\现场图像\" & fdr("单位工程") & "\" & fdr("类别") & "\"
If FileSys.DirectoryExists(pth) = False Then
FileSys.CreateDirectory(pth)
End If
Dim th As String = pth & ndr("图像名称") & ndr("图像类型")
FileSys.CopyFile(flt,th,True)
Else
Dim pth As String = ProjectPath & "Attachments\用户工程\" & phr & fdr("工程名称") & "\现场图像\" & fdr("类别") & "\"
If FileSys.DirectoryExists(pth) = False Then
FileSys.CreateDirectory(pth)
End If
Dim th As String = pth & ndr("图像名称") & ndr("图像类型")
FileSys.CopyFile(flt,th,True)
End If
Next
End If
End If
ltbox.Items.Clear() '清除列表数据
第二段参考:
Dim imgb As Image = GetImage("d:\底图.jpg") '获得一个Image对象,表示生成的图片
Dim bmp As New Bitmap(imgb.width, imgb.height) '生成一个空白图片
Dim g = Graphics.FromImage(bmp)
Dim fnt As New Font("黑体",40)
Dim msg As String = "foxtable"
g.DrawString(msg,fnt,Brushes.Red,20,40) '在指定的位置,用指定的画刷和字体,绘制指定的文本
bmp.Save("d:\test122.jpg")
bmp.Dispose() 'dispose()方法关闭的窗体可以使用pack 或 show 方法恢复,并且可以恢复到dispose前的状态