VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} ADDSTR_FORM 
   Caption         =   "Атрибуты строки"
   ClientHeight    =   2505
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6855
   OleObjectBlob   =   "ADDSTR_FORM.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "ADDSTR_FORM"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Option Explicit

Public privBK As String, privName As String, privCode As String, privRazdel As Integer, _
        strBK As String, strName As String, strCode As String, strRazdel As String, _
        enablBK As Boolean, enablName As Boolean, enablCode As Boolean, enablRazdel As Boolean, _
        poTarget As Object
' -------------------------------------------------------------------------------------------------------
' Отмена
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub CmdCancel_Click()
    pbFormCancel = False
    Unload Me
End Sub
' -------------------------------------------------------------------------------------------------------
' Шрифт
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub CmdFont_Click()
With Me.CDLFont
    .FontName = Me.poTarget.Font.name
    .FontSize = Me.poTarget.Tag
    .FontItalic = Me.poTarget.Font.Italic
    .FontUnderline = Me.poTarget.Font.Underline
    .FontStrikethru = Me.poTarget.Font.Strikethrough
    .FontBold = Me.poTarget.Font.Bold
    .Color = Me.poTarget.ForeColor
    .FontName = Me.poTarget.Font.name
    .Flags = &H1 + &H100 + &H200
    .ShowFont
    Me.poTarget.Font.name = .FontName
    Me.poTarget.Tag = .FontSize
    Me.poTarget.Font.Italic = .FontItalic
    Me.poTarget.Font.Underline = .FontUnderline
    Me.poTarget.Font.Strikethrough = .FontStrikethru
    Me.poTarget.Font.Bold = .FontBold
    Me.poTarget.ForeColor = .Color
    Me.poTarget.SetFocus
    Me.CmdOK.Enabled = True
End With
End Sub
' -------------------------------------------------------------------------------------------------------
' Ок
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub CmdOk_Click()
With Me
    .privBK = VBA.Trim(.TextBox3.Text)
    .privName = VBA.Trim(.TextBox1.Text)
    .privCode = VBA.Trim(.TextBox2.Text)
    .privRazdel = .ComboBox1.ListIndex + 1
    pbFormCancel = True
    .Hide
End With
End Sub
' -------------------------------------------------------------------------------------------------------
' Раздел
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub ComboBox1_Change()
    Me.CmdOK.Enabled = (IIf((Me.TextBox1.Text) = "", False, True) Or Not Me.TextBox1.Enabled) And _
                       (IIf((Me.TextBox2.Text) = "", False, True) Or Not Me.TextBox2.Enabled) And _
                       (IIf((Me.TextBox3.Text) = "", False, True) Or Not Me.TextBox3.Enabled) And _
                       (IIf(VBA.Trim(Me.ComboBox1.Text) = "", False, True) Or Not Me.ComboBox1.Enabled)
End Sub
' -------------------------------------------------------------------------------------------------------
' Наименование показателя
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub TextBox1_Change()
    Me.CmdOK.Enabled = (IIf((Me.TextBox1.Text) = "", False, True) Or Not Me.TextBox1.Enabled) And _
                       (IIf((Me.TextBox2.Text) = "", False, True) Or Not Me.TextBox2.Enabled) And _
                       (IIf((Me.TextBox3.Text) = "", False, True) Or Not Me.TextBox3.Enabled) And _
                       (IIf((Me.ComboBox1.Text) = "", False, True) Or Not Me.ComboBox1.Enabled)
End Sub
' -------------------------------------------------------------------------------------------------------
' Наименование показателя
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set poTarget = Nothing
    Set poTarget = Me.ActiveControl
End Sub
' -------------------------------------------------------------------------------------------------------
' Код отчетности
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub TextBox2_Change()
    Me.CmdOK.Enabled = (IIf((Me.TextBox1.Text) = "", False, True) Or Not Me.TextBox1.Enabled) And _
                       (IIf((Me.TextBox2.Text) = "", False, True) Or Not Me.TextBox2.Enabled) And _
                       (IIf((Me.TextBox3.Text) = "", False, True) Or Not Me.TextBox3.Enabled) And _
                       (IIf((Me.ComboBox1.Text) = "", False, True) Or Not Me.ComboBox1.Enabled)
End Sub
' -------------------------------------------------------------------------------------------------------
' Код отчетности
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set poTarget = Nothing
    Set poTarget = Me.ActiveControl
End Sub
' -------------------------------------------------------------------------------------------------------
' КБК
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub TextBox3_Change()
    Me.CmdOK.Enabled = (IIf((Me.TextBox1.Text) = "", False, True) Or Not Me.TextBox1.Enabled) And _
                       (IIf((Me.TextBox2.Text) = "", False, True) Or Not Me.TextBox2.Enabled) And _
                       (IIf((Me.TextBox3.Text) = "", False, True) Or Not Me.TextBox3.Enabled) And _
                       (IIf((Me.ComboBox1.Text) = "", False, True) Or Not Me.ComboBox1.Enabled)
End Sub
' -------------------------------------------------------------------------------------------------------
' КБК
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set poTarget = Nothing
    Set poTarget = Me.ActiveControl
    Me.CmdOK.Enabled = (IIf((Me.TextBox1.Text) = "", False, True) Or Not Me.TextBox1.Enabled) And _
                       (IIf((Me.TextBox2.Text) = "", False, True) Or Not Me.TextBox2.Enabled) And _
                       (IIf((Me.TextBox3.Text) = "", False, True) Or Not Me.TextBox3.Enabled) And _
                       (IIf((Me.ComboBox1.Text) = "", False, True) Or Not Me.ComboBox1.Enabled)

End Sub
Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set poTarget = Nothing
    Set poTarget = Me.ActiveControl
End Sub
Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set poTarget = Nothing
    Set poTarget = Me.ActiveControl
End Sub
Private Sub TextBox6_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set poTarget = Nothing
    Set poTarget = Me.ActiveControl
End Sub
' -------------------------------------------------------------------------------------------------------
' КБК
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim сSql, bName As String
Dim oRecordSet As Object

    On Error GoTo doError
    If (Sheets("Service").Range("F4").Text <> "") And (KeyCode = 13) And (TextBox3.Text <> "") Then
        On Error GoTo ttt
        If oAdoConnect Is Nothing Then
            Call AdoSrvConnect
        End If
        GoTo lll
ttt:
        init_template.cSrv = VBA.Trim(Sheets("Service").Range("A3").value)
        init_template.cUser = VBA.Trim(Sheets("Service").Range("A5").value)
        init_template.cPwd = decode_psw(VBA.Trim(Sheets("Service").Range("A6").value))
        init_template.cDb = VBA.Trim(Sheets("Service").Range("A4").value)
        init_template.nNtUser = VBA.Val(VBA.Trim(Sheets("Service").Range("A22").value))
        Call AdoSrvConnect
lll:
        Set oRecordSet = CreateObject("ADODB.RecordSet")
        сSql = "SELECT NAME AS vvv FROM S_KBK WHERE CODE LIKE  ''" + TextBox3.Text + "%''"
        oRecordSet.Open сSql, oAdoConnect, 2, 1, 1
        ' получим LINK  объекта
        If oRecordSet.EOF = False Then
             bName = oRecordSet.Fields("vvv")   'заполнение таблицы с данными
        Else
            MsgBox ("Такого кода в базе не существует !")
            Exit Sub
        End If
        If Sheets("Service").Range("F5").Text = "NAME" Then
            TextBox1.Text = bName
        End If
        oRecordSet.Close
        Set oRecordSet = Nothing
    End If
    Exit Sub
doError:
    Call ERROR_EVENT("ADDSTR_FORM.UserForm_Initialize")
End Sub
' -------------------------------------------------------------------------------------------------------
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub UserForm_Activate()
With Me
    .ComboBox1.ListIndex = 0 '.privRazdel - 1
    .TextBox1.Text = .privName
    .TextBox2.Text = .privCode
    .TextBox3.Text = .privBK
    If .strBK <> "" Then
       .Label4.Caption = .strBK
    End If
    If .strName <> "" Then
       .Label1.Caption = .strName
    End If
    If .strCode <> "" Then
       .Label2.Caption = .strCode
    End If
    If .strRazdel <> "" Then
       .Label3.Caption = .strRazdel
    End If
    .ComboBox1.Enabled = enablRazdel
    .TextBox1.Enabled = enablName
    .TextBox2.Enabled = enablCode
    .TextBox3.Enabled = enablBK
    Me.CmdOK.Enabled = (IIf((Me.TextBox1.Text) = "", False, True) Or Not Me.TextBox1.Enabled) And _
                       (IIf((Me.TextBox2.Text) = "", False, True) Or Not Me.TextBox2.Enabled) And _
                       (IIf((Me.TextBox3.Text) = "", False, True) Or Not Me.TextBox3.Enabled) And _
                       (IIf((Me.ComboBox1.Text) = "", False, True) Or Not Me.ComboBox1.Enabled)
End With
End Sub
' -------------------------------------------------------------------------------------------------------
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub UserForm_Initialize()
Dim lnColumn As Long, lnRow As Long, lnRowCount As Long
Dim lSheets As Object, nCnt As Long

On Error GoTo doError

Set lSheets = Sheets("Service")
With lSheets.Range("S_RAZDEL")
    lnRowCount = .Rows.count
    lnRow = .row
    lnColumn = .column
End With
If lSheets.Range("B23").value = 1 Then
    For nCnt = lnRow + 1 To lnRow + lnRowCount - 1
        Me.ComboBox1.AddItem lSheets.Cells(nCnt, lnColumn + 1)
    Next
Else
    Me.ComboBox1.AddItem lSheets.Range("B19").Text
End If
Me.Caption = pcNameApp + Me.Caption

Exit Sub
doError:
    Call ERROR_EVENT("ADDSTR_FORM.UserForm_Initialize")
End Sub
' -------------------------------------------------------------------------------------------------------
' EdiS\07.10.10\bugs-16042
' -------------------------------------------------------------------------------------------------------
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
End Sub
' -------------------------------------------------------------------------------------------------------
