BeforeAddFile:
例子:
If e.DataCol.name = "附件" Then
Select Case e.DataTable.Name
Case "审查管理"
If _username = e.DataRow("项目经理") OrElse _username = e.DataRow("编写设计") Then
e.Cancel = False
Dim filepath As String = "/审查管理/" & e.DataRow("编写设计")
If ftp1.DirExists(filepath) = False Then
ftp1.MakeDir(filepath)
End If
e.path = filepath
ftp1.RootDir = filepath
Else
e.cancel = True
End If
Case "文件管理"
If _username = e.DataRow("发布人") OrElse (_usergroup.Contains(e.DataRow("发布部门")) AndAlso (_userroles = "部门领导" OrElse _userroles = "财务领导" OrElse _userroles = "生产领导")) Then
e.Cancel = False
If e.DataRow.IsNull("文号年份") Then
MessageBox.Show("《文号年份》不能空")
e.Cancel=True
Return
End If
Dim filepath As String = "/文件管理/" & e.DataRow("文号年份") & "/" & e.DataRow("发布人")
If ftp1.DirExists("/文件管理/" & e.DataRow("文号年份")) = False Then
ftp1.MakeDir("/文件管理/" & e.DataRow("文号年份"))
End If
If ftp1.DirExists(filepath) = False Then
ftp1.MakeDir(filepath)
End If
e.path = filepath
ftp1.RootDir = filepath
Else
e.cancel = True
End If
Case "固资申请","合同评审"
If (_username = e.DataRow("申请人") AndAlso e.DataRow.IsNull("审批日期")) OrElse _userroles = "开发者" Then
e.Cancel = False
Dim ab1 As Date = e.DataRow("申请日期") ’含时间
Dim ab2 As String = CStr(ab1)
ab2=ab2.SubString(0,4) & ab2.SubString(5,2) & ab2.SubString(8,2) & ab2.SubString(11,2) & ab2.SubString(14,2)
Dim str As String = e.DataTable.Name
Dim filepath As String = "/" & str & "/" & e.DataRow("申请人") & "/" & ab2
If ftp1.DirExists("/" & str & "/" & e.DataRow("申请人")) = False Then
ftp1.MakeDir("/" & str & "/" & e.DataRow("申请人"))
End If
If ftp1.DirExists(filepath) = False Then
ftp1.MakeDir(filepath)
End If
e.path = filepath
ftp1.RootDir = filepath
Else
e.cancel = True
End If
End Select
End If