VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} PART_CONDEDIT 
   Caption         =   "Слагаемые условия"
   ClientHeight    =   1830
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5685
   OleObjectBlob   =   "PART_CONDEDIT.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "PART_CONDEDIT"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public pnMode As Integer    ' Режим загрузки
Public pnNumOtb As Integer  ' Link отбора
Public pnTypeOtb As Integer ' Тип поля отбора
Public pnZnak As Integer    ' Link знака
Public pnZnakItog As Integer ' Link знака итога
Public pcValue As String    ' Значение отбора
Public pnNumRazdel As Integer ' Раздел
Public pnLinkSpr As Integer ' LINK справочника - не передается
Public pcNameOtb As String  ' Наименование отбора
Public pcNameZnak As String ' Наименование знака
' -------------------------------------------------------------------------------------------------------
' Процедура инициализации формы
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Public Sub Form_init()
Dim lnRowZnak As Integer, lnColumnZnak As Integer, nCnt As Long
With Sheets("Service").Range("TABLE_SPR")
    lnRowZnak = .row
    lnColumnZnak = .column
    For nCnt = 1 To .Rows.count - 1
        If (Sheets("Service").Cells(lnRowZnak + nCnt, lnColumnZnak + 1) = pnNumRazdel) Or (Sheets("Service").Cells(lnRowZnak + nCnt, lnColumnZnak + 1) = 0) Then
            Me.CmbNAMEOTB.AddItem Sheets("Service").Cells(lnRowZnak + nCnt, lnColumnZnak + 2)
        End If
    Next
    Me.CmbNAMEOTB.AddItem ""
    If Me.CmbNAMEOTB.ListCount = 0 Then ' Нет условий отбора
        MsgBox "Нет возможности сформировать условия отбора!", vbOKOnly + vbInformation, pcNameApp + "Внимание"
        GoTo unl:
    Else
        Me.CmbNAMEOTB.ListIndex = 0
    End If
End With

If pnMode = 1 Then ' Редактирование
    Me.CmbNAMEOTB.value = pcNameOtb
    Me.CmbZNAK.value = pcNameZnak
    Me.TxtValue.value = pcValue
Else ' Новое слагаемое
    ' Определим LINK SPR
    With Sheets("Service")
        .Range("AB37") = Me.CmbNAMEOTB.value
        pnLinkSpr = .Range("Z45")
        .Range("AB37") = ""
    End With
End If
Exit Sub
unl:
pbFormCancel = True
End Sub

Private Sub CmbItogZNAK_Change()
'    If Me.TxtValue <> "" Then
'        Me.CmdOk.Enabled = True
   'End If
End Sub
Private Sub CmbNAMEOTB_Change()
' Определим LINK SPR
If Me.CmbNAMEOTB.value <> "" Then
    With Sheets("Service")
        .Range("AB37") = Me.CmbNAMEOTB.value
        .Range("Z37") = ""
        pnLinkSpr = .Range("Z45")
        .Range("AB37") = ""
    End With
End If
Me.TxtValue = ""
End Sub
Private Sub CmbZNAK_Change()
Dim lnCount_part As Integer
        
If Me.CmbZNAK.value <> "" Then
    With Sheets("Service")
        .Range("W26") = """" + Me.CmbZNAK.value + """"
        lnCount_part = .Range("U28")
        .Range("W26") = ""
    End With
    Me.CmdVALUE.Enabled = Not (lnCount_part = 0)
    Me.TxtValue.Enabled = Not (lnCount_part = 0)
    Me.CmbNAMEOTB.Enabled = Not (lnCount_part = 0)
End If
End Sub

Private Sub CmdExit_Click()
    Unload Me
End Sub
Private Sub CmdOk_Click()
Dim lcNewKey As String, lcKey As String
pbFormCancel = True
Me.Hide
End Sub
Private Sub CmdVALUE_Click()
Call SEEK_POP_GET_DATA(pnLinkSpr, False)
If pbFormCancel Then
    Me.TxtValue = SEEK_POP.pcRetValue
    Unload SEEK_POP
    If Me.TxtValue <> "" Then
        Me.CmdOk.Enabled = True
    End If
End If
End Sub
Private Sub CommandButton1_Click()
Call SEEK_POP_GET_DATA(3, False)
If pbFormCancel Then
    Me.TxtValue = SEEK_POP.pcRetValue
    Unload SEEK_POP
    If Me.TxtValue <> "" Then
        Me.CmdOk.Enabled = True
    End If
End If
End Sub
Private Sub UserForm_Initialize()
Dim lnRowZnak As Long
Dim lnColumnZnak As Long
Dim lcNameZnak As String
Dim nCnt As Long
With Sheets("Service").Range("TABLE_SHABLON_COND")
    lnRowZnak = .row
    lnColumnZnak = .column
    For nCnt = 1 To .Rows.count - 1
        If Sheets("Service").Cells(lnRowZnak + nCnt, lnColumnZnak + 1) = 2 Then
            lcNameZnak = Sheets("Service").Cells(lnRowZnak + nCnt, lnColumnZnak + 2)
            lcNameZnak = VBA.Right(Left(lcNameZnak, VBA.Len(lcNameZnak) - 1), VBA.Len(lcNameZnak) - 2)
            Me.CmbZNAK.AddItem lcNameZnak
        Else
            lcNameZnak = Sheets("Service").Cells(lnRowZnak + nCnt, lnColumnZnak + 2)
            lcNameZnak = VBA.Right(Left(lcNameZnak, VBA.Len(lcNameZnak) - 1), VBA.Len(lcNameZnak) - 2)
            Me.CmbOper.AddItem lcNameZnak
        End If
    Next
    Me.CmbZNAK.AddItem ""
    Me.CmbOper.AddItem ""
    Me.CmbZNAK.value = "="
End With
Me.Caption = pcNameApp + Me.Caption
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 1 Or CloseMode = 0 Then
    pbFormCancel = False
End If

End Sub
