Äëÿ çàïóñêà äàííîãî ìàêðîñà íåîáõîäèìî ïåðåéòè â ðåæèì «Ñêëàäñêîé ó÷åò»-«Ó÷åòíûå êàðòî÷êè», âûäåëèòü íîìåíêëàòóðíûå ïîçèöèè è çàïóñòèòü ìàêðîñ.

 

Ìàêðîñ «Çàêðûòü ïóñòûå ó÷åòíûå êàðòî÷êè ó âûäåëåííûõ ïîçèöèé». Ïîçâîëÿåò ïåðåáèðàòü âûäåëåííûå çàïèñè â ñïèñêå íîìåíêëàòóðû, îòûñêèâàòü ïóñòûå êàðòî÷êè è çàêðûâàòü èõ.

 

Sub FormMacro_CloseCard(TCSActiveModule)
'
' Ìàêðîñ äëÿ çàêðûòèÿ ïóñòûõ ó÷åòíûõ êàðòî÷åê
' ó âûäåëåííûõ çàïèñåé   
' 
'
Dim BM                               'òåêóùàÿ ïîçèöèÿ êóðñîðà
Dim pbStr                            'ïðîãðåñáàð
Dim I                                     'ñëóæåáíàÿ ïåðåìåííàÿ
Dim NMkId                          'ID íîìåíêëàòóðû
Dim DepartmentID             'ID ïîäðàçäåëåíèÿ
Dim BalanceNmkCards      'Èíòåðôåéñ "Ó÷åòíûå êàðòî÷êè"
Dim NmkCardTotal            'Èíòåðôåéñ "Îáîðîòû ïî ó÷åòíûì êàðòî÷êàì"
 
If TCSActiveModule.SelectedRowsCount > 0 Then                          'Eñëè åñòü âûäåëåííûå çàïèñè
     DepartmentID=TCSActiveModule.Properties( "CEHA_ID" ).AsInteger    'Çàïîìíèòü ID ïîäðàçäåëåíèÿ, ãäå íàõîäèòñÿ êàðòîòåêà
            TCSActiveModule.First                                      'Âñòàòü íà íà÷àëî 
        For I = 0 To TCSActiveModule.SelectedRowsCount - 1             'ïåðåáèðàåì âûäåëåííûå çàïèñè íîìåíêëàòóðû êàðòîòåêè
            If TCSActiveModule.GotoSelectedRow(I) Then                 'ïîçèöèîíèðîâàíèå íà î÷åðåäíóþ âûäåëåííóþ çàïèñü
            NMkId =  TCSActiveModule.Properties( "NMK_ID" ).AsInteger  'Âçÿòü ID íîìåíêëàòóðû
            Set BalanceNmkCards = TCSApp.Inventory.BalanceNmkCards( DepartmentID, NMkId ) 'Ïîëó÷èì èíòåðôåéñ "Ó÷åòíûå êàðòî÷êè" 
            BalanceNmkCards.First                                      'Âñòàåì íà ïåðâóþ çàïèñü â êàðòîòåêå 
               Do While Not BalanceNmkCards.EOF                        'Ïåðåáèðàåì çàïèñè êàðòîòåêè
                  If BalanceNmkCards.Properties( "CLOSED" ).DisplayText="F" Then        'Åñëè êàðòî÷êà íå çàêðûòà     
                     Set NmkCardTotal = BalanceNmkCards.Properties("BalanceNmkCardTotal").AsIDispatch'Ïîëó÷àåì èíòåðôåéñ ê îáîðîòàì ïî êàðòî÷êå
                     If  NmkCardTotal.Properties("TOTALQUAN_END").AsFloat = 0 Then      'È ïðîâåðÿåì, åñòü ëè îñòàòîê íà êàðòî÷êå (íå âàæíî, ïîëîæèòåëüíûé èëè îòðèöàòåëüíûé)
                         Call BalanceNmkCards.Edit                                      'Åñëè íåò, òî áåðåì åå íà ðåäàêòèðîâàíèå
                         BalanceNmkCards.Properties( "CLOSED" ).Value="T"               'Åñëè íåò, òî çàêðûòü êàðòî÷êó
                         Call BalanceNmkCards.SaveChanges                               'Ñîõðàíèòü êàðòî÷êó, è åñëè ïðîèçîøëà
                         Call BalanceNmkCards.CancelChanges                             'îøèáêà, îòìåíèòü âñå èçìåíåíèÿ
                      End If                                                            '
                     Set NmkCardTotal = Nothing                                         'Îñâîáîäèòü èíòåðôåéñ ê îáîðîòàì ïî êàðòî÷êå
                  End If                                                                '
                  BalanceNmkCards.Next                                                  'Ïåðåáèðàåì çàïèñè êàðòîòåêè
               Loop                                                                     'Êîíåö öèêëà ïî íîìåíêëàòóðå
            Set BalanceNmkCards = Nothing                                               'Îñâîáîäèòü èíòåðôåéñ "Ó÷åòíûå êàðòî÷êè"   
            End If                                                                      '
        Next                                                                            '
Else
Call TCSApp.ShowErrorMessage("Âûäåëèòå çàïèñè äëÿ êîòîðûõ íåîáõîäèìî çàêðûòü ïóñòûå ó÷åòíûå êàðòî÷êè!")  
End If
End Sub
 

! Ñì. òàêæå:

18.2  ðåæèìå «Ñêëàäñêîé ó÷åò»