Dim ifo As new FileInfo(e.SourceFolder & "\" & e.FileName)
Dim ids As Integer = 307200
'If ifo.Length > 720*1280 Then
If ifo.Length > ids Then
MessageBox.Show("对不起图片太大了, 图片像素最大为【720*1280】,文件最大300KB!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.cancel=True
Else
If e.DataCol.Name = "第一学历证件" Then
Dim dr As DataRow = e.DataRow
If dr.IsNull("工作单位") Then
MessageBox.Show("工作单位不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
ElseIf Dr.IsNull("姓名") Then
MessageBox.Show("姓名不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
ElseIf Dr.IsNull("乡镇名称") Then
MessageBox.Show("乡镇名称不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
'ElseIf Dr.IsNull("证件号码") Then
'MessageBox.Show("身份证号码不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
'e.Cancel = True
ElseIf Dr.IsNull("工作单位") Then
MessageBox.Show("工作单位不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
Else
e.SubFolder = "证件" & "\" & dr("乡镇名称") & "\" & dr("工作单位") & "\" & "第一学历"
'e.FileName = dr("证件号码") & ".jpg"
EncryptFile(e.SourceFolder & "\" & e.FileName, ProjectPath & "Attachments/" & e.SubFolder & "/" & dr("序号") & "_加密.jpg", "fox123")
e.FileName = dr("序号") & ".jpg"
End If
End If
End If
或
Dim dr As Row = e.Table.Current
If dr IsNot Nothing Then
Dim SubFolder As String = "证件" & "\" & dr("乡镇名称") & "\" & dr("工作单位") & "\" & "第一学历"
Dim FileName As String = "xx" & ".jpg"
If FileSys.FileExists(ProjectPath & "Attachments/" & SubFolder & "/" & dr("序号") & "_加密.jpg") Then
DecryptFile(ProjectPath & "Attachments/" & SubFolder & "/" & dr("序号") & "_加密.jpg", ProjectPath & "Attachments/" & SubFolder & "/" & FileName, "fox123")
Dim pv As WinForm.PictureViewer = e.Form.Controls("PictureViewer1")
pv.DeleteFile("Attachments/" & SubFolder & "/" & FileName)
End If
End If