Dim ModuleName As String = Args(0) '单据名称
Dim correlationTable As String '关联表
'------获取窗体发布的Datatable-----
Dim ModuleListCmd As New SQLCommand
Dim ModuleListTable As DataTable
ModuleListCmd.ConnectionName = DataSource
ModuleListCmd.CommandText="Select * F rom {窗体发布}"
ModuleListTable = ModuleListCmd.ExecuteReader()
'-----------------------------------------------------
Dim dr As DataRow
dr = ModuleListTable.Find("单据 = '" & ModuleName & "'")
If dr IsNot Nothing Then
If dr.Isnull("关联表") Then
correlationTable = dr("主表")
Else
correlationTable = dr("关联表")
End If
LockBaseMainForm() '锁定主界面
'如果要动态加载的表包含关联表
If correlationTable.Contains("|") Then
For Each TableName As String In correlationTable.Split("|")
If DataTables.Contains(TableName) = False Then
DataTables.Load(TableName)
End If
Dim r As DataRow
r = ModuleListTable.Find("主表 = '" & TableName & "'")
If r IsNot Nothing Then
If r("单据")<>ModuleName Then
If forms.Contains(r("单据")) = True AndAlso Forms(r("单据")).Opened = False Then
Tables(TableName).Visible = False
ElseIf forms.Contains(r("单据")) = False And Tables(TableName).DataTable.Type = 3 Then
Tables(TableName).Visible = False
End If
End If
End If
Next
Else
'如果要动态加载的表不包含关联表
If DataTables.Contains(correlationTable) = False Then
DataTables.Load(correlationTable)
End If
End If
UnLockBaseMainForm() '解锁主界面
End If