VERSION 5.00
Begin VB.UserControl A_SrchTxt 
   AutoRedraw      =   -1  'True
   ClientHeight    =   1305
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   4800
   EditAtDesignTime=   -1  'True
   ScaleHeight     =   1305
   ScaleWidth      =   4800
   ToolboxBitmap   =   "A_SrchTxt.ctx":0000
   Begin VB.CommandButton bt_search 
      Caption         =   "..."
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   270
      Left            =   2970
      TabIndex        =   1
      Top             =   135
      Width           =   315
   End
   Begin VB.TextBox txt_search 
      BackColor       =   &H00FFFFFF&
      Height          =   330
      Left            =   105
      TabIndex        =   0
      Top             =   105
      Width           =   3270
   End
End
Attribute VB_Name = "A_SrchTxt"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

'Curseur & données
Private mo_ArmDb As Object
Private mb_Created As Boolean
Private mb_use_framework_connection As Boolean
Private ms_ConnectString As String
Private ms_UID As String

Private m_Language As String

Private m_Key1 As String
Private m_Key2 As String
Private m_Text As String

Private m_TypeSearch As String
Private m_CodeCustomer As String
Private m_CodeContact As String
Private m_CodeProject As String
Private m_CodeCustomerRequired As Boolean
Private m_CodeContactRequired As Boolean
Private m_CodeProjectRequired As Boolean

Private mi_Charset As Integer

Public Event OnClick()
Public Event OnValid()
Public Event OnDelete()

Public Property Set ArmDb(ByRef ao_local_connection As Object)

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:ArmDb_Set"
    #End If
    CapMouseOff
    
    If Not (ao_local_connection Is Nothing) Then
        Set mo_ArmDb = ao_local_connection
        mb_use_framework_connection = True
    End If

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:ArmDb_Set"
    #End If
    CapMouseOn
    
End Property

Property Let ConnectString(as_ConnectString As String)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:ConnectString_Let", "as_ConnectString=" & as_ConnectString
    #End If
    CapMouseOff
    
    ms_UID = ConnectionStringValidation(as_ConnectString)
    If ms_UID = "" Then GoTo Trace_End
    
    ms_ConnectString = as_ConnectString
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:ConnectString_Let"
    #End If
    CapMouseOn
    
End Property

Property Let Language(ALng As String)

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Language_Let", "ALng=" & ALng
    #End If
    CapMouseOff
    
    m_Language = ALng
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Language_Let"
    #End If
    CapMouseOn

End Property

Public Property Let Charset(ai_Value As Integer)
  
    #If CompDebugPR Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Charset_Let", "ai_Value=" & ai_Value
    #End If
  
    mi_Charset = ai_Value
    txt_search.Font.Charset = mi_Charset

    #If CompDebugPR Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Charset_Let"
    #End If
    
End Property

Public Property Get Charset() As Integer
  
    #If CompDebugPR Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Charset_Get"
    #End If
  
    Charset = mi_Charset

    #If CompDebugPR Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Charset_Get", "Result=" & Charset
    #End If
    
End Property

Property Let CodeCustomerRequired(ATag As Boolean)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:CodeCustomerRequired_Let", "ATag=" & ATag
    #End If
    
    m_CodeCustomerRequired = ATag
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:CodeCustomerRequired_Let"
    #End If
End Property

Property Let CodeContactRequired(ATag As Boolean)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:CodeContactRequired_Let", "ATag=" & ATag
    #End If
    
    m_CodeContactRequired = ATag
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:CodeContactRequired_Let"
    #End If
End Property
Property Let CodeProjectRequired(ATag As Boolean)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:CodeProjectRequired_Let", "ATag=" & ATag
    #End If
    
    m_CodeProjectRequired = ATag
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:CodeProjectRequired_Let"
    #End If
End Property


Property Let CodeCustomer(ACode As String)

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:CodeCustomer_Let", "ACode=" & ACode
    #End If
    
    m_CodeCustomer = ACode
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:CodeCustomer_Let"
    #End If
    
End Property

Property Let CodeContact(ACode As String)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:CodeContact_Let", "ACode=" & ACode
    #End If
    
    m_CodeContact = ACode
   
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:CodeContact_Let"
    #End If

End Property

Property Let Key1(AKey As String)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Key1_Let", "AKey=" & AKey
    #End If
    
    m_Key1 = AKey
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Key1_Let"
    #End If
    
End Property

Property Let CodeProject(ACode As String)

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:CodeProject_Let", "ACode=" & ACode
    #End If
    
    m_CodeProject = ACode
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:CodeProject_Let"
    #End If
   
End Property

Public Sub Clear()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Clear"
    #End If
    
    m_Key1 = ""
    m_Key2 = ""
    m_Text = ""

    m_TypeSearch = ""
    m_CodeCustomer = ""
    m_CodeContact = ""
    m_CodeProject = ""

    txt_search.Text = ""
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Clear"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "A_SrchTxt:Clear"
    CapMouseOn
End Sub

Property Let Locked(ATag As Boolean)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Locked_Let", "ATag=" & ATag
    #End If
    
    txt_search.Locked = ATag
    bt_search.Enabled = Not ATag
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Locked_Let"
    #End If
    
End Property

Property Let Text(AValue As String)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Text_Let", "AValue=" & AValue
    #End If
    
    m_Text = AValue
    txt_search.Text = m_Text
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Text_Let"
    #End If
    
End Property

Property Let TypeSearch(AType As String)

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:TypeSearch_Let", "AType=" & AType
    #End If
    
    m_TypeSearch = AType
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:TypeSearch_Let"
    #End If

End Property

Public Sub Unload_A_Com()
   
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Unload_A_COM"
    #End If
    
    ASC_DisconnectFromDB mo_ArmDb, ms_UID, mb_Created

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Unload_A_COM"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "A_SrchTxt:Unload_A_COM"
    CapMouseOn
End Sub

Property Get Key1() As String

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Key1_Get"
    #End If
    
    Key1 = m_Key1
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Key1_Get", "Result=" & Key1
    #End If
    
End Property
Property Get Key2() As String

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Key2_Get"
    #End If
    
    Key2 = m_Key2
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Key2_Get", "Result=" & Key2
    #End If

End Property
Property Get Text() As String

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Text_Get"
    #End If
    
    Text = m_Text
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Text_Get", "Result=" & Text
    #End If
    
End Property

Private Sub bt_search_Click()
Dim lo_SrchTxtForm As SrchTxtForm

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:bt_search_Click"
    #End If
    
    RaiseEvent OnClick
    
    If Trim$(m_CodeCustomer) = "" And m_CodeCustomerRequired Then
        txt_search.Text = ""
        Call ASC_SendMessage(mo_ArmDb, m_Language, 918, "You must select a customer !")
        
    ElseIf Trim$(m_CodeContact) = "" And m_CodeContactRequired Then
        txt_search.Text = ""
        Call ASC_SendMessage(mo_ArmDb, m_Language, 919, "You must select a contact !")
    ElseIf Trim$(m_CodeProject) = "" And m_CodeProjectRequired Then
        txt_search.Text = ""
        Call ASC_SendMessage(mo_ArmDb, m_Language, 920, "You must select a project !")
    Else
        
    Set lo_SrchTxtForm = New SrchTxtForm
    Load lo_SrchTxtForm
    lo_SrchTxtForm.ConnectString = ms_ConnectString
    If mb_use_framework_connection = True Then Set lo_SrchTxtForm.ArmDb = mo_ArmDb
    lo_SrchTxtForm.Language = m_Language
    
    lo_SrchTxtForm.CodeCustomer = m_CodeCustomer
    lo_SrchTxtForm.CodeContact = m_CodeContact
    lo_SrchTxtForm.CodeProject = m_CodeProject
' IMPLEMENT PROCESS T298.1-A.PR_001
    lo_SrchTxtForm.TypeSearch = IIf(m_TypeSearch = "PrimContact", "Contact", m_TypeSearch)
' END PROCESS T298.1-A.PR_001
    lo_SrchTxtForm.Charset = mi_Charset
    
    lo_SrchTxtForm.Load_A_Com
    lo_SrchTxtForm.LoadGrid
    CapMouseOn True
    lo_SrchTxtForm.show vbModal
    CapMouseOff True
    
    If lo_SrchTxtForm.Key1 <> "" Then
        m_Text = lo_SrchTxtForm.Text
        m_Key1 = lo_SrchTxtForm.Key1
        m_Key2 = lo_SrchTxtForm.Key2
' IMPLEMENT PROCESS T298.1-A.PR_002
        If m_TypeSearch = "PrimContact" Then
            txt_search.Text = LTrim(Split(Split(lo_SrchTxtForm.SelectedItemFull, "®©®©")(2), "®©")(1) & " " & m_Text)
        Else
        txt_search.Text = m_Text
        End If
' END PROCESS T298.1-A.PR_002
        RaiseEvent OnValid
    End If

    lo_SrchTxtForm.Unload_A_Com
    Unload lo_SrchTxtForm
    Set lo_SrchTxtForm = Nothing
    
    End If

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:bt_search_Click"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "A_SrchTxt:bt_search_Click"
    CapMouseOn
End Sub

Property Let Enabled(ATag As Boolean)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Enabled_Let", "ATag=" & ATag
    #End If
    
    txt_search.Enabled = ATag
    bt_search.Enabled = ATag
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Enabled_Let"
    #End If
End Property


Public Sub Load_A_Com()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:Load_A_Com"
    #End If
    
    VerifyInitialization mo_ArmDb, ms_ConnectString, m_Language, Me
    
    m_CodeCustomerRequired = False
    m_CodeContactRequired = False
    m_CodeProjectRequired = False
      
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:Load_A_Com"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "A_SrchTxt:Load_A_Com"
    CapMouseOn
End Sub

Private Sub txt_search_KeyPress(KeyAscii As Integer)

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:txt_search_KeyPress", "KeyAscii=" & KeyAscii
    #End If
    
    If txt_search.Locked = False Then
        m_Text = ""
        m_Key1 = ""
        m_Key2 = ""
        RaiseEvent OnDelete
        KeyAscii = 0
        txt_search.Text = ""
    End If

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:txt_search_KeyPress"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "A_SrchTxt:txt_search_KeyPress"
    CapMouseOn
End Sub

Private Sub UserControl_Resize()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:UserControl_Resize"
    #End If
    
    txt_search.Top = 0
    txt_search.Left = 0
    txt_search.Width = UserControl.Width
    bt_search.Left = txt_search.Width - bt_search.Width - 35
    bt_search.Top = 35

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:UserControl_Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "A_SrchTxt:UserControl_Resize"
    CapMouseOn
End Sub

Public Sub SetFocus()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "A_SrchTxt:SetFocus"
    #End If
    
    txt_search.SetFocus

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "A_SrchTxt:SetFocus"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "A_SrchTxt:SetFocus"
    CapMouseOn
End Sub

