D
Darker
Есть свойство для подсчета элементов списка по критерию
Хотел не копипастить циклы, а закинуть в процедурку, так условие не знаю как передать в качестве "параметра"
Нуждаюсь в рефакторинге
Код:
Property Get DocInfoCollCount(ExType As Integer, ByForm As String, ExKind As String, StopAtFirst As Boolean) As Long '---- ExType - вид исполнителя, ByForm - форма
Dim c As Long
c=0
If ExType>CONST_ALLEXTYPE Then
If Not CheckExistingListTag("ExType") Then Print Getthreadinfo(1)&". Не сработал подсчет по типу исполнителя. Из-за отсутствия ExType":Goto ex
End If
If ByForm<>CONST_ALLFORM Then
If Not CheckExistingListTag("form") Then Print Getthreadinfo(1)&". Не сработал подсчет по форме исполнителя. Из-за отсутствия form":Goto ex
End If
If ExKind>CONST_ALLEXKIND Then
If Not CheckExistingListTag("ExIsCorr") Then Print Getthreadinfo(1)&". Не сработал подсчет по виду исполнителя. Из-за отсутствия ExIsCorr":Goto ex
End If
If ExKind=CONST_KINDEXECUTOR Or ExKind=CONST_KINDCORRESPONDENT Then
If ExType=CONST_INNER Or ExType=CONST_OUTER Then'-------------------------- Внутренние
If ExType=CONST_INNER Then tempType="InnerExecutors" Else tempType="OuterExecutors"
If ByForm=CONST_ALLFORM Then '---- Все формы
Forall DI In DocInfoColl
If DI.Field("ExIsCorr")=ExKind And DI.Field("ExType")=tempType Then c=c+1: If StopAtFirst Then Goto ex
End Forall
Else'----------------------------------------------- По заданной форме
Forall DI In DocInfoColl
If DI.Field("ExIsCorr")=ExKind And DI.Field("ExType")=tempType And DI.Field("form")=ByForm Then c=c+1: If StopAtFirst Then Goto ex
End Forall
End If
Else
If ByForm=CONST_ALLFORM Then'---- Все формы
Forall DI In DocInfoColl
If I.Field("ExIsCorr")=ExKind Then c=c+1: If StopAtFirst Then Goto ex
End Forall
Else'----------------------------------------------- По заданной форме
Forall DI In DocInfoColl
If DI.Field("ExIsCorr")=ExKind And DI.Field("form")=ByForm Then c=c+1: If StopAtFirst Then Goto ex
End Forall
End If
End If
Else
If ExType=CONST_INNER Or ExType=CONST_OUTER Then'-------------------------- Внутренние
If ExType=CONST_INNER Then tempType="InnerExecutors" Else tempType="OuterExecutors"
If ByForm=CONST_ALLFORM Then '---- Все формы
Forall DI In DocInfoColl
If DI.Field("ExType")=tempType Then c=c+1: If StopAtFirst Then Goto ex
End Forall
Else'----------------------------------------------- По заданной форме
Forall DI In DocInfoColl
If DI.Field("ExType")=tempType And DI.Field("form")=ByForm Then c=c+1: If StopAtFirst Then Goto ex
End Forall
End If
Else
If ByForm=CONST_ALLFORM Then'---- Все формы
Forall DI In DocInfoColl
c=c+1
If StopAtFirst Then Goto ex
End Forall
Else'----------------------------------------------- По заданной форме
Forall DI In DocInfoColl
If DI.Field("form")=ByForm Then c=c+1: If StopAtFirst Then Goto ex
End Forall
End If
End If
End If
ex: DocInfoCollCount=c
End Property
Нуждаюсь в рефакторинге