VERSION 5.00
Begin VB.Form SrchTxtForm 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   3930
   ClientLeft      =   15
   ClientTop       =   15
   ClientWidth     =   7710
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3930
   ScaleWidth      =   7710
   StartUpPosition =   3  'Windows Default
   Begin DSWMGR.ToolbarControl toolbar 
      Height          =   690
      Left            =   30
      TabIndex        =   1
      Top             =   60
      Width           =   7635
      _ExtentX        =   13467
      _ExtentY        =   1217
   End
   Begin DSWMGR.ArmGrid grdlst 
      Height          =   3105
      Left            =   -15
      TabIndex        =   0
      Top             =   780
      Width           =   7665
      _ExtentX        =   13520
      _ExtentY        =   5477
   End
End
Attribute VB_Name = "SrchTxtForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
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_UID As String

Private m_Language As String

Private m_Key1 As String
Private m_Key2 As String
Private m_Text As String
Private mSelectedItemFull As String
    
Private m_TypeSearch As String
Private m_CodeCustomer As String
Private m_CodeContact As String
Private m_CodeProject As String
Private m_ColDesc As Integer
Private mi_Charset As Integer


Public Property Set ArmDb(ByRef ao_local_connection As Object)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:ArmDb_Set"
    #End If
    MouseOff
    If Not (ao_local_connection Is Nothing) Then
        Set mo_ArmDb = ao_local_connection
        mb_use_framework_connection = True
        Set grdlst.ArmDb = mo_ArmDb
        Set toolbar.ArmDb = mo_ArmDb
    End If
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:ArmDb_Set"
    #End If
    MouseOn
End Property


Property Let Language(ALng As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:Language_Let", "ALng=" & ALng
    #End If
    m_Language = ALng
    
    toolbar.Language = m_Language
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:Language_Let"
    #End If
End Property

'set charset of report
Public Property Let Charset(ai_Value As Integer)
  
    #If CompDebugPR Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:Charset_Let", "ai_Value=" & ai_Value
    #End If
  
    mi_Charset = ai_Value
    grdlst.Font.Charset = mi_Charset
    grdlst.Font.Name = "Arial"

    #If CompDebugPR Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm: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, "SrchTxtForm:Charset_Get"
    #End If
  
    Charset = mi_Charset

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

Property Let CodeCustomer(ACode As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:CodeCustomer_Let", "ACode=" & ACode
    #End If
    m_CodeCustomer = ACode
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:CodeCustomer_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, "SrchTxtForm:CodeProject_Let", "ACode=" & ACode
    #End If
    m_CodeProject = ACode
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:CodeProject_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, "SrchTxtForm:CodeContact_Let", "ACode=" & ACode
    #End If
    m_CodeContact = ACode
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:CodeContact_Let"
    #End If
End Property

Private Sub EraseAll()

    On Error GoTo Trace_Err
    MouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:EraseAll"
    #End If
    
    m_Key1 = ""
    m_Key2 = ""
    m_Text = ""

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:EraseAll"
    #End If
    MouseOn
    Exit Sub

Trace_Err:
'    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SrchTxtForm:EraseAll"
    MouseOn
End Sub
Public Sub Load_A_Com()

    On Error GoTo Trace_Err
    MouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:Load_A_Com"
    #End If
    
'    VerifyInitialization mo_ArmDb, ms_ConnectString, m_Language, Me
    
    grdlst.Load_A_Com
    toolbar.Load_A_Com
    
    Call toolbar.SetToolbarInfoStringParameters("001EESFGIDRW®07028®QE/BAC®AHHBIILTT", "001")
    Call toolbar.DisplayFace("0")

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:Load_A_Com"
    #End If
    MouseOn
    Exit Sub

Trace_Err:
'    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SrchTxtForm:Load_A_Com"
    MouseOn
End Sub

Public Sub Unload_A_Com()

    On Error GoTo Trace_Err
    MouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:Unload_A_Com"
    #End If
    
    grdlst.Unload_A_Com
    toolbar.Unload_A_Com
    
'    ASC_DisconnectFromDB mo_ArmDb, ms_UID, mb_Created
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:Unload_A_Com"
    #End If
    MouseOn
    Exit Sub

Trace_Err:
'    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SrchTxtForm:Unload_A_Com"
    MouseOn
End Sub

Private Sub grdlst_DblClick()
    
    On Error GoTo Trace_Err
    MouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:grdlst_DblClick"
    #End If
    
    ValidSelection

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:grdlst_DblClick"
    #End If
    MouseOn
    Exit Sub

Trace_Err:
'    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SrchTxtForm:grdlst_DblClick"
    MouseOn
End Sub

Property Let TypeSearch(AType As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:TypeSearch_Let", "AType=" & AType
    #End If
    m_TypeSearch = AType
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:TypeSearch_Let"
    #End If
End Property

Private Sub ValidSelection()
Dim ll_KeySize As Long

    On Error Resume Next
    
    ll_KeySize = UBound(grdlst.CurrentKey)
    
    On Error GoTo Trace_Err
    MouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:ValidSelection"
    #End If
    
    If grdlst.Row < 0 Then
        Call ASC_SendMessage(mo_ArmDb, m_Language, 921, "#Please, select a line")
        GoTo Trace_End
    End If
    
    m_Key1 = ""
    m_Key2 = ""
    m_Text = ""
    mSelectedItemFull = ""
    
    If ll_KeySize >= 0 Then m_Key1 = CStr(grdlst.CurrentKey(0))
    If ll_KeySize >= 1 Then m_Key2 = CStr(grdlst.CurrentKey(1))
    
    If m_Key1 = "" Then GoTo Trace_End
    m_Text = grdlst.CurrentLine(m_ColDesc)
    
    Dim lIdx As Long, lCount As Long
    Dim lBuffer As Variant
    lCount = grdlst.Cols - 1
    ReDim lBuffer(lCount)
    For lIdx = 0 To lCount
        lBuffer(lIdx) = grdlst.Columns(lIdx).Name & "®©" & grdlst.CurrentLine(grdlst.Columns(lIdx).Name)
    Next
    mSelectedItemFull = Join(lBuffer, "®©" & "®©")
    
    Me.Hide

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:ValidSelection"
    #End If
    MouseOn
    Exit Sub

Trace_Err:
'    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SrchTxtForm:ValidSelection"
    MouseOn
End Sub

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

Property Get Key2() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:Key2_Get"
    #End If
    Key2 = m_Key2
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm: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, "SrchTxtForm:Text_Get"
    #End If
    Text = m_Text
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:Text_Get", "Result=" & Text
    #End If
End Property
Public Sub LoadGrid()
Dim la_Columns() As String

    On Error GoTo Trace_Err
    MouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:LoadGrid"
    #End If
    
    grdlst.MultiSelect = False
    
    Select Case m_TypeSearch
    
        Case "Customer"
            ReDim la_Columns(9)
            
            la_Columns(0) = "CCU_CapKey" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "CCU_CapKey" & CH_LDELIMIT & "CCU_CapKey"
            la_Columns(1) = "CCU_desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_desc" & CH_LDELIMIT & "CCU_desc"
            la_Columns(2) = "CCU_Addr1" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Addr1" & CH_LDELIMIT & "CCU_Addr1"
            la_Columns(3) = "CCU_Addr2" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Addr2" & CH_LDELIMIT & "CCU_Addr2"
            la_Columns(4) = "CCU_Town" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Town" & CH_LDELIMIT & "CCU_Town"
            la_Columns(5) = "CCU_Zip" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Zip" & CH_LDELIMIT & "CCU_Zip"
            la_Columns(6) = "CCU_Tel" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Tel" & CH_LDELIMIT & "CCU_Tel"
            la_Columns(7) = "CCU_Fax" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Fax" & CH_LDELIMIT & "CCU_Fax"
            la_Columns(8) = "CCT_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCT_Desc" & CH_LDELIMIT & "CCT_Desc"
            la_Columns(9) = "CP_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CP_Desc" & CH_LDELIMIT & "CP_Desc"
            
            grdlst.SetColumns la_Columns
            
            grdlst.Requests = "exec Claim_Customer_t_lst6_SAMPLE " & "'" & m_CodeCustomer & "'" & ", " & "'" & m_Language & "'"
            If grdlst.Execute = False Then
'                If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grdlst.ArmDb, "SrchTxtForm:LoadGrid", "Requests=", grdlst.Requests
            End If
            m_ColDesc = 1
        
        Case "Project"
            ReDim la_Columns(6)
        
            la_Columns(0) = "SP_CapKey" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "SP_CapKey" & CH_LDELIMIT & "SP_CapKey"
            la_Columns(1) = "SP_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_Desc" & CH_LDELIMIT & "SP_Desc"
            la_Columns(2) = "SP_Zip" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_Zip" & CH_LDELIMIT & "SP_Zip"
            la_Columns(3) = "SP_Town" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_Town" & CH_LDELIMIT & "SP_Town"
            la_Columns(4) = "SP_size" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_size" & CH_LDELIMIT & "SP_size"
            la_Columns(5) = "SS_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SS_Desc" & CH_LDELIMIT & "SS_Desc"
            la_Columns(6) = "SP_dateFollowUp" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_dateFollowUp" & CH_LDELIMIT & "SP_dateFollowUp"
            
            grdlst.SetColumns la_Columns
            
            If m_CodeContact <> "" Then
                grdlst.Requests = "exec sales_project_t_lst4 " & "'" & m_CodeCustomer & "'" & ", " & "'" & m_CodeContact & "'" & ", " & "'" & m_Language & "'"
            Else
                grdlst.Requests = "exec sales_project_t_lst5 " & "'" & m_CodeCustomer & "'" & ", " & "'" & m_Language & "'"
            End If
            If grdlst.Execute = False Then
'                If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grdlst.ArmDb, "SrchTxtForm:LoadGrid", "Requests=", grdlst.Requests
            End If
            m_ColDesc = 1
    
        Case "Contact"
            ReDim la_Columns(5)
            
            la_Columns(0) = "CNT_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "CNT_code" & CH_LDELIMIT & "CNT_code"
            la_Columns(1) = "CNT_LastName" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_LastName" & CH_LDELIMIT & "CNT_LastName"
            la_Columns(2) = "TIT_desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "TIT_desc" & CH_LDELIMIT & "TIT_desc"
            la_Columns(3) = "CCU_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Desc" & CH_LDELIMIT & "CCU_Desc"
            la_Columns(4) = "JOB_Desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "JOB_Desc" & CH_LDELIMIT & "JOB_Desc"
            la_Columns(5) = "CNT_telOffice" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_telOffice" & CH_LDELIMIT & "CNT_telOffice"
            
            grdlst.SetColumns la_Columns
            
            If m_CodeProject <> "" Then
                If m_CodeCustomer <> "" Then
                    'CodeProject and CodeCustomer
                    grdlst.Requests = "exec cap_contact_t_lst4 " & "'" & m_CodeProject & "'" & ", " & "'" & m_CodeCustomer & "'" & ", " & "'" & m_Language & "'"
                Else
                    'CodeProject
                    grdlst.Requests = "exec cap_contact_t_lst5 " & "'" & m_CodeProject & "'" & ", " & "'" & m_Language & "'"
                End If
            Else
                If m_CodeCustomer <> "" Then
                    'CodeCustomer
                    grdlst.Requests = "exec cap_contact_t_lst6 " & "'" & m_CodeCustomer & "'" & ", " & "'" & m_Language & "'"
                End If
            End If
            
            If grdlst.Execute = False Then
'                If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grdlst.ArmDb, "SrchTxtForm:LoadGrid", "Requests=", grdlst.Requests
            End If
            m_ColDesc = 1
    
    End Select

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:LoadGrid"
    #End If
    MouseOn
    Exit Sub

Trace_Err:
'    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SrchTxtForm:LoadGrid"
    MouseOn
End Sub

Public Property Get SelectedItemFull() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:SelectedItemFull_Get"
    #End If
    
    SelectedItemFull = mSelectedItemFull
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:SelectedItemFull_Get", "Result=" & mSelectedItemFull
    #End If
End Property


Private Sub toolbar_action(ByVal as_Role As String, as_Language As String)

    On Error GoTo Trace_Err
    MouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "SrchTxtForm:toolbar_action", "as_ActionType=" & as_ActionType
    #End If
    
    Select Case as_Role
    
        Case "H"
            ValidSelection
            
        Case "I"
            m_Key1 = ""
            m_Key2 = ""
            m_Text = ""
            Me.Hide
        
        Case "T"
            m_Key1 = ""
            m_Key2 = ""
            m_Text = ""
            Me.Hide
    
        Case Else
            m_Key1 = ""
            m_Key2 = ""
            m_Text = ""
            Me.Hide
    
    End Select

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "SrchTxtForm:toolbar_action"
    #End If
    MouseOn
    Exit Sub

Trace_Err:
'    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "SrchTxtForm:toolbar_action"
    MouseOn

End Sub
