VERSION 5.00
Begin VB.Form PrdSeek 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "#Product search"
   ClientHeight    =   8100
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   11970
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   8100
   ScaleWidth      =   11970
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Tag             =   "Title"
   Begin Project1.ArmGrid grd_search 
      Height          =   4215
      Left            =   0
      TabIndex        =   23
      Top             =   3960
      Width           =   12015
      _ExtentX        =   21193
      _ExtentY        =   7435
   End
   Begin Project1.ToolBr tb_top 
      Align           =   1  'Align Top
      Height          =   615
      Left            =   0
      TabIndex        =   22
      Top             =   0
      Width           =   11970
      _ExtentX        =   21114
      _ExtentY        =   1085
   End
   Begin VB.Frame frmFilters 
      Height          =   3255
      Left            =   0
      TabIndex        =   1
      Top             =   600
      Width           =   11895
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   10
         Left            =   9120
         TabIndex        =   34
         Top             =   2640
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   9
         Left            =   9120
         TabIndex        =   33
         Top             =   2160
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   8
         Left            =   9120
         TabIndex        =   32
         Top             =   1680
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   7
         Left            =   9120
         TabIndex        =   31
         Top             =   1200
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   6
         Left            =   9120
         TabIndex        =   30
         Top             =   720
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   5
         Left            =   5280
         TabIndex        =   29
         Top             =   2640
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   4
         Left            =   5280
         TabIndex        =   28
         Top             =   2160
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   3
         Left            =   5280
         TabIndex        =   27
         Top             =   1680
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   2
         Left            =   1560
         TabIndex        =   26
         Top             =   2640
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   1
         Left            =   1560
         TabIndex        =   25
         Top             =   2160
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_filter 
         Height          =   345
         Index           =   0
         Left            =   1560
         TabIndex        =   24
         Top             =   1680
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   609
      End
      Begin VB.Frame Frame1 
         Height          =   1335
         Left            =   120
         TabIndex        =   18
         Tag             =   "frm_Drop"
         Top             =   120
         Width           =   2295
         Begin VB.OptionButton opt_Standard 
            Caption         =   "#All"
            Height          =   255
            Index           =   0
            Left            =   240
            TabIndex        =   21
            Tag             =   "opt_All"
            Top             =   240
            Value           =   -1  'True
            Width           =   1935
         End
         Begin VB.OptionButton opt_Standard 
            Caption         =   "#Standard"
            Height          =   255
            Index           =   1
            Left            =   240
            TabIndex        =   20
            Tag             =   "opt_Standard"
            Top             =   600
            Width           =   1935
         End
         Begin VB.OptionButton opt_Standard 
            Caption         =   "#Special"
            Height          =   255
            Index           =   2
            Left            =   240
            TabIndex        =   19
            Tag             =   "opt_Special"
            Top             =   960
            Width           =   1935
         End
      End
      Begin VB.Frame frm_Drop 
         Height          =   1335
         Left            =   2520
         TabIndex        =   14
         Tag             =   "frm_Drop"
         Top             =   120
         Width           =   2295
         Begin VB.OptionButton opt_Dropped 
            Caption         =   "#Non dropped"
            Height          =   255
            Index           =   2
            Left            =   240
            TabIndex        =   17
            Tag             =   "opt_NonDropped"
            Top             =   960
            Width           =   1935
         End
         Begin VB.OptionButton opt_Dropped 
            Caption         =   "#Dropped"
            Height          =   255
            Index           =   1
            Left            =   240
            TabIndex        =   16
            Tag             =   "opt_Dropped"
            Top             =   600
            Width           =   1935
         End
         Begin VB.OptionButton opt_Dropped 
            Caption         =   "#All"
            Height          =   255
            Index           =   0
            Left            =   240
            TabIndex        =   15
            Tag             =   "opt_All2"
            Top             =   240
            Value           =   -1  'True
            Width           =   1935
         End
      End
      Begin VB.TextBox txt_shortcode 
         Height          =   315
         Left            =   9120
         MaxLength       =   20
         TabIndex        =   0
         Tag             =   "txt_SCode"
         Top             =   240
         Width           =   2175
      End
      Begin VB.Label lbl_SCode 
         Caption         =   "#S_Code"
         Height          =   255
         Left            =   7800
         TabIndex        =   13
         Tag             =   "lbl_SCode"
         Top             =   300
         Width           =   1335
      End
      Begin VB.Label lbl_Module 
         Caption         =   "#Module"
         Height          =   255
         Left            =   7800
         TabIndex        =   12
         Tag             =   "lbl_Module"
         Top             =   2700
         Width           =   1335
      End
      Begin VB.Label lbl_Shape 
         Caption         =   "#Shape"
         Height          =   255
         Left            =   7800
         TabIndex        =   11
         Tag             =   "lbl_Shape"
         Top             =   2220
         Width           =   1335
      End
      Begin VB.Label lbl_Surface 
         Caption         =   "#Surface"
         Height          =   255
         Left            =   7800
         TabIndex        =   10
         Tag             =   "lbl_Surface"
         Top             =   1740
         Width           =   1335
      End
      Begin VB.Label lbl_EdgeWidth 
         Caption         =   "#Edge width"
         Height          =   255
         Left            =   7800
         TabIndex        =   9
         Tag             =   "lbl_EdgeWidth"
         Top             =   1260
         Width           =   1335
      End
      Begin VB.Label lbl_EdgeLength 
         Caption         =   "#Edge length"
         Height          =   255
         Left            =   7800
         TabIndex        =   8
         Tag             =   "lbl_EdgeLength"
         Top             =   780
         Width           =   1335
      End
      Begin VB.Label lbl_ProdRange 
         Caption         =   "#Product range"
         Height          =   255
         Left            =   3960
         TabIndex        =   7
         Tag             =   "lbl_ProdRange"
         Top             =   2700
         Width           =   1335
      End
      Begin VB.Label lbl_Pattern 
         Caption         =   "#Pattern"
         Height          =   255
         Left            =   3960
         TabIndex        =   6
         Tag             =   "lbl_Pattern"
         Top             =   2220
         Width           =   1335
      End
      Begin VB.Label lbl_Colour 
         Caption         =   "#Colour"
         Height          =   255
         Left            =   3960
         TabIndex        =   5
         Tag             =   "lbl_Colour"
         Top             =   1740
         Width           =   1335
      End
      Begin VB.Label lbl_Family 
         Caption         =   "#Family"
         Height          =   255
         Left            =   240
         TabIndex        =   4
         Tag             =   "lbl_Family"
         Top             =   2700
         Width           =   1215
      End
      Begin VB.Label lbl_BaseMat 
         Caption         =   "#Base material"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   3
         Tag             =   "lbl_BaseMat"
         Top             =   2220
         Width           =   1300
      End
      Begin VB.Label lbl_Category 
         Caption         =   "#Category"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Tag             =   "lbl_Category"
         Top             =   1740
         Width           =   1300
      End
   End
End
Attribute VB_Name = "PrdSeek"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'******** INTERFACE
Private m_Language As String
Private ms_SelectedItemCode As String
Private ms_SelectedItemDesc As String
Private mi_SysClassifCode As Integer

'******** Connection Cursor
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

'******** Stored Procedures
Private ms_ScreenName As String
Private ms_searchProcStoc As String
Private ms_cboCriteriaProcStoc(0 To 10) As String

'********
Private mi_nbOfCriteria As Integer
Private mi_DescColIndex As Integer

'******** Search Criterias
Private ms_filter() As String
'store all the search criterias, even recursive

Private p_DefaultValues(MAX_VALUE) As DefaultValue
Private p_DefaultValuesCount As Integer
Private p_DefaultValuesLoaded As Boolean

Private ms_CT_Code As String


Public Property Get CT_Code() As String
    CT_Code = ms_CT_Code
End Property

Public Property Let CT_Code(ByVal as_Value As String)
    ms_CT_Code = as_Value
End Property


Public Property Set ArmDb(ByRef ao_local_connection As Object)
Dim i As Integer

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:ArmDb_Set"
    #End If
    CapMouseOff
    
    If Not (ao_local_connection Is Nothing) Then
        Set mo_ArmDb = ao_local_connection
        mb_use_framework_connection = True
     
        Set tb_top.ArmDb = mo_ArmDb
        Set grd_search.ArmDb = mo_ArmDb
        
        For i = 0 To 10
            Set cbo_filter(i).ArmDb = mo_ArmDb
        Next
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:ArmDb_Set"
    #End If
    CapMouseOn
End Property

Public Property Let ConnectString(as_ConnectString As String)
Dim i As Integer

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek: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
    
    tb_top.ConnectString = ms_ConnectString
    grd_search.ConnectString = ms_ConnectString
    For i = 0 To 10
        cbo_filter(i).ConnectString = ms_ConnectString
    Next
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:ConnectString_Let"
    #End If
    CapMouseOn
End Property

Public Property Let Language(as_Language As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:Language_Let", "as_Language=" & as_Language
    #End If
    m_Language = as_Language
    tb_top.Language = as_Language
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:Language_Let"
    #End If
End Property

Public Property Let SysClassifCode(ai_SC_code As Integer)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:SysClassifCode_Let", "ai_SC_code=" & ai_SC_code
    #End If
    mi_SysClassifCode = ai_SC_code
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:SysClassifCode_Let"
    #End If
End Property

Public Property Get SelectedItemCode() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:SelectedItemCode_Get"
    #End If
    SelectedItemCode = ms_SelectedItemCode
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:SelectedItemCode_Get", "Result=" & SelectedItemCode
    #End If
End Property

Public Property Get SelectedItemDesc() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:SelectedItemDesc_Get"
    #End If
    SelectedItemDesc = ms_SelectedItemDesc
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:SelectedItemDesc_Get", "Result=" & SelectedItemDesc
    #End If
End Property

Private Sub cbo_filter_ComboItemSelected(Index As Integer)
Dim i As Integer
Dim ls_CboCriteriaProcStoc As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:cbo_filter_ComboItemSelected", "Index=" & Index
    #End If
    
    Select Case Index
    Case 0
        ClearCbo 1
        ls_CboCriteriaProcStoc = ms_cboCriteriaProcStoc(1)
        ReplaceInString ls_CboCriteriaProcStoc
        cbo_filter(1).FirstBlankItem = False
        cbo_filter(1).Request = ls_CboCriteriaProcStoc
        cbo_filter(1).Enabled = True
        EnableCbo False, 2
    
    Case 1
        ClearCbo 2
        EnableCbo True, 2
    
        For i = 2 To 10
            ls_CboCriteriaProcStoc = ms_cboCriteriaProcStoc(i)
            ReplaceInString ls_CboCriteriaProcStoc
            cbo_filter(i).FirstBlankItem = True
            cbo_filter(i).Request = ls_CboCriteriaProcStoc
        Next
    End Select

    grd_search.ClearGrid

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

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, "PrdSeek:Load_A_Com"
    #End If
    
    VerifyInitialization mo_ArmDb, ms_ConnectString, m_Language, Me
    
    RefreshFilters
    InitControls
    
    LoadLabels mo_ArmDb, Me, "Cap_Product_Seek", m_Language

    If p_DefaultValuesLoaded = False Then
        p_DefaultValuesCount = GetScreenDefaultValues(mo_ArmDb, ms_UID, m_Language, "Cap_Product_Seek", p_DefaultValues)
        p_DefaultValuesLoaded = True
    End If
    DisplayScreenDefaultValues Me.Controls, p_DefaultValues, p_DefaultValuesCount

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

Private Sub Form_Initialize()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:Form_Initialize"
    #End If
    
    mi_SysClassifCode = 1
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:Form_Initialize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:Form_Initialize"
    CapMouseOn
End Sub

Private Sub grd_search_DblClick()
    If grd_search.Row >= 0 Then
        ms_SelectedItemCode = grd_search.CurrentKey(0)
        ms_SelectedItemDesc = grd_search.CurrentKey(0) & " - " & grd_search.CurrentLine(1)
        Me.Hide
    End If
End Sub

Private Sub tb_top_Action(ByVal as_ActionType As String)
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:tb_top_Action", "as_ActionType=" & as_ActionType
    #End If
    
    Select Case UCase$(as_ActionType)
    Case "VALID"
        If grd_search.Row >= 0 Then
            ms_SelectedItemCode = grd_search.CurrentKey(0)
            ms_SelectedItemDesc = grd_search.CurrentKey(0) & " - " & grd_search.CurrentLine(1)
            Me.Hide
        Else
            Call ASC_SendMessage(mo_ArmDb, m_Language, 921, "#Please, select a line")
        End If
    Case "FIND"
        ErrorOFF
        CorrectCodeStr mo_ArmDb, m_Language, cbo_filter(1), True
        If Not ErrorFound Then
            grd_search.Visible = True
            FindData
        End If
    Case "REFRESH"
        RefreshFilters
        grd_search.Visible = False
    Case "QUIT"
        ms_SelectedItemCode = ""
        ms_SelectedItemDesc = ""
        Me.Hide
    Case "ADD"
        OpenPrdAdd "Add", "", CStr(mi_SysClassifCode), m_Language, mb_use_framework_connection, ms_ConnectString, mo_ArmDb
    Case "UNDO"
        ms_SelectedItemCode = ""
        ms_SelectedItemDesc = ""
        InitControls False
    End Select
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:tb_top_Action"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:tb_top_Action"
    CapMouseOn
End Sub

Private Sub FindData()
Dim ls_searchProcStoc As String
Dim ls_filter As String
Dim ls_Like As String
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:FindData"
    #End If
    
    ls_searchProcStoc = ms_searchProcStoc
    
    'replace all $$ in the query
    ReplaceInString ls_searchProcStoc
    
    'load Grid with this query
    'grd_search.FillAllOption = True
    grd_search.Requests = ls_searchProcStoc
    If grd_search.Execute = False Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grd_search.ArmDb, "PrdSeek:FindData", "Requests=", grd_search.Requests
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:FindData"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:FindData"
    CapMouseOn
End Sub

Private Sub ReplaceInString(as_searchproc As String)
Dim i As Integer
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:ReplaceInString", "as_searchproc=" & as_searchproc
    #End If
    
    'replace the $$ in the query
    
    as_searchproc = Replace(as_searchproc, "$lang$", "'" & m_Language & "'")
    as_searchproc = Replace(as_searchproc, "$SC$", mi_SysClassifCode)
    as_searchproc = Replace(as_searchproc, "$short$", "'" & txt_shortcode & "'")
    as_searchproc = Replace(as_searchproc, "$ct_code$", ms_CT_Code, , , vbTextCompare)
    
    Select Case WhichOptIsTrue(opt_Dropped, 2)
    Case 0
        as_searchproc = Replace(as_searchproc, "$drop$", "''")
    Case 1
        as_searchproc = Replace(as_searchproc, "$drop$", "'Y'")
    Case 2
        as_searchproc = Replace(as_searchproc, "$drop$", "'N'")
    End Select
    
    
    Select Case WhichOptIsTrue(opt_Standard, 2)
    Case 0
        as_searchproc = Replace(as_searchproc, "$STD$", "''")
    Case 1
        as_searchproc = Replace(as_searchproc, "$STD$", "'STD'")
    Case 2
        as_searchproc = Replace(as_searchproc, "$STD$", "'SPC'")
    End Select
    
    as_searchproc = Replace(as_searchproc, "$CG$", "'" & GetCodeFromCombo(cbo_filter(0)) & "'")
    
    For i = 0 To 10
        as_searchproc = Replace(as_searchproc, "$" & CStr(i) & "$", "'" & GetCodeFromCombo(cbo_filter(i)) & "'")
    Next i
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:ReplaceInString"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:ReplaceInString"
    CapMouseOn
End Sub

Private Function RefreshFilters()
Dim i As Integer

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:RefreshFilters"
    #End If
    
    ClearCbo 1
    EnableCbo False, 2
    
    opt_Standard(0).value = True
    'BEGIN TASK BUG/FEATURE 67
    'product seek is called from product add/validation only
    opt_Dropped(2).value = True
    'END TASK BUG/FEATURE 67
    txt_shortcode.Text = ""
    
    grd_search.Visible = False
    
    ms_SelectedItemCode = ""
    ms_SelectedItemDesc = ""
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:RefreshFilters", "Result=" & RefreshFilters
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:RefreshFilters"
    CapMouseOn
End Function

Private Function WhichOptIsTrue(ByRef ao_opt As Object, ai_maxIndex As Integer) As Integer
Dim i As Integer
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:WhichOptIsTrue", "ai_maxIndex=" & ai_maxIndex
    #End If
    
    For i = 0 To ai_maxIndex
        If ao_opt(i).value = True Then
            WhichOptIsTrue = i
            GoTo Trace_End
        End If
    Next i
    WhichOptIsTrue = 0
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:WhichOptIsTrue", "Result=" & WhichOptIsTrue
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:WhichOptIsTrue"
    CapMouseOn
End Function

Private Sub InitControls(Optional ab_Load_A_Com As Boolean = True)
Dim i As Integer
Dim ls_ProcStock As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:InitControls"
    #End If
    
    grd_search.Visible = False
    'BEGIN TASK BUG/FEATURE 67
    'product seek is called from product add/validation only
    opt_Dropped(2).value = True
    'END TASK BUG/FEATURE 67
    opt_Standard(0).value = True
    
    grd_search.Load_A_COM
    tb_top.Load_A_COM
    tb_top.DrivenByCapture = True
    For i = 0 To 10
        cbo_filter(i).Load_A_COM
    Next
    
    InitBusinessObject
    
    cbo_filter(0).FirstBlankItem = False
    cbo_filter(0).Enabled = False
    ls_ProcStock = ms_cboCriteriaProcStoc(0)
    ReplaceInString ls_ProcStock
    cbo_filter(0).Request = ls_ProcStock
    cbo_filter(0).Load
    
    DefaultCategory
        
    If ab_Load_A_Com = True Then
        'toolbar
        tb_top.ClearAllIcons
        tb_top.PictureDisplayed = "P_Valid=1 P_Undo=2 P_Find=4 P_Refresh=5 P_Add=7 P_Quit=-1"
        tb_top.Refresh
    
        'screen_csts
        LoadLabels mo_ArmDb, Me.Controls, ms_ScreenName, m_Language
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:InitControls"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:InitControls"
    CapMouseOn
End Sub

Private Sub InitBusinessObject()
Dim la_Columns(5) As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:InitBusinessObject"
    #End If
    
    ms_ScreenName = "Cap_Product_Seek"
    ms_searchProcStoc = "exec Cap_System_lst $lang$, $0$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $9$, $10$, $STD$, $drop$, $SC$, $short$, '$ct_code$'"
    mi_DescColIndex = 2

    la_Columns(0) = "S_code" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "1" & CH_LDELIMIT & "S_code" & CH_LDELIMIT & "S_code"
    la_Columns(1) = "S_desc" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "S_desc" & CH_LDELIMIT & "S_desc"
    la_Columns(2) = "COLOUR_desc" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "COLOUR_desc" & CH_LDELIMIT & "COLOUR_desc"
    'IMPLEMENT PROCESS T298.6-A.PROCESS PR_002
    la_Columns(3) = "PD_desc" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PD_desc" & CH_LDELIMIT & "PD_desc"
    'END PROCESS T298.6-A.PROCESS PR_002
    la_Columns(4) = "PE_desc" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PE_desc_L" & CH_LDELIMIT & "PE_desc"
    la_Columns(5) = "PE_desc" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PE_desc_W" & CH_LDELIMIT & "PE_desc"
    grd_search.MultiSelect = False
    grd_search.SetColumns la_Columns
    
'    grd_search.ColMapString = "FIELD=00 COL=0 WIDTH=2000 KEY1=YES"
'    grd_search.ColMapString = "FIELD=01 COL=1 WIDTH=2000"
'    grd_search.ColMapString = "FIELD=02 COL=2 WIDTH=2000"
'    grd_search.ColMapString = "FIELD=03 COL=3 WIDTH=2000"
'    grd_search.ColMapString = "FIELD=04 COL=4 WIDTH=2000"
'    grd_search.ColMapString = "FIELD=05 COL=5 WIDTH=2000"
    

    ms_cboCriteriaProcStoc(0) = "exec Categories_cbo '" & m_Language & "'"
    ms_cboCriteriaProcStoc(1) = "exec Super_Base_Material_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(2) = "exec Products_Families_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(3) = "exec Colours_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(4) = "exec Products_Patterns_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(5) = "exec Products_Segmentation_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(6) = "exec Products_Edges_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(7) = "exec Products_Edges_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(8) = "exec Surfaces_cbo $CG$, '" & m_Language & "'"
    ms_cboCriteriaProcStoc(9) = "exec Shapes_cbo $CG$, '" & m_Language & "'"
    'IMPLEMENT PROCESS T298.6-A.PROCESS PR_001
    ms_cboCriteriaProcStoc(10) = "exec Product_Dimension_cbo $CG$, '" & m_Language & "'"
    'END PROCESS T298.6-A.PROCESS PR_001
    
'    grd_search.FillAllOption = True
    'grd_search.ConnectString = ms_ConnectString
    grd_search.LoadConstants ptSQL, "EXEC screen_csts_lst2 '" & ms_ScreenName & "' , 'grid', '" & m_Language & "'", ctColumns

    grd_search.Requests = ""
    
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:InitBusinessObject"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:InitBusinessObject"
    CapMouseOn
End Sub

Public Sub Unload_A_COM()
Dim i As Integer

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:Unload_A_COM"
    #End If
    
    grd_search.Unload_A_COM
    tb_top.Unload_A_COM
    For i = 0 To 10
        cbo_filter(i).Unload_A_COM
    Next
    
    ASC_DisconnectFromDB mo_ArmDb, ms_UID, mb_Created
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:Unload_A_COM"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:Unload_A_COM"
    CapMouseOn
End Sub

Private Sub EnableCbo(ab_Enabled As Boolean, ai_firstIndex As Integer)
Dim i As Integer
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:EnableCbo"
    #End If
    
    For i = ai_firstIndex To 10
        cbo_filter(i).Enabled = ab_Enabled
    Next i
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:EnableCbo"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:EnableCbo"
    CapMouseOn
End Sub

Private Sub ClearCbo(ai_firstIndex As Integer)
Dim i As Integer
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:ClearCbo", "ai_firstIndex=" & ai_firstIndex
    #End If
    
    For i = ai_firstIndex To 10
        cbo_filter(i).Clear
    Next i
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:ClearCbo"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:ClearCbo"
    CapMouseOn
End Sub

Private Sub DefaultCategory()
Dim as_cboCriteriaProcStoc  As String
        
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:DefaultCategory"
    #End If
    
    Select Case mi_SysClassifCode
    Case 1
        cbo_filter(0).SearchItem "C001", 0, 0
    Case 2
        cbo_filter(0).SearchItem "C002", 0, 0
'    Case 3
'        cbo_filter(0).SearchItem "?",0,0
    End Select

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


Function OpenPrdAdd(AMode As String, AProductKey As String, ASCCode As String, ALanguage As String, ab_Use_FrameWord_Connection As Boolean, as_ConnectString As String, ao_Armdb As Object) As String
Dim PrdFrm As PrdAdd
Dim ls_S_code As String
Dim ls_S_Desc As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "PrdSeek:OpenPrdAdd", "AProductKey=" & AProductKey, "ASCCode=" & ASCCode, "ALanguage=" & ALanguage, "ab_Use_FrameWord_Connection=" & ab_Use_FrameWord_Connection, "as_ConnectString=" & as_ConnectString
    #End If
    
    Set PrdFrm = New PrdAdd
    Load PrdFrm
    
    'Connection
    PrdFrm.ConnectString = as_ConnectString
    If ab_Use_FrameWord_Connection = True Then
        Set PrdFrm.ArmDb = ao_Armdb
    End If
    
    'Mode
    PrdFrm.Mode = AMode
    
    'Key
    PrdFrm.ProductCode = AProductKey
    PrdFrm.SCCode = ASCCode
    PrdFrm.Language = ALanguage
   
    PrdFrm.Load_A_COM
    
    CapMouseOn True
    PrdFrm.show vbModal
    CapMouseOff True
    
    ls_S_code = PrdFrm.Code
    ls_S_Desc = PrdFrm.Desc
    
    Call PrdFrm.Unload_A_COM
    Unload PrdFrm
    Set PrdFrm = Nothing

    If ls_S_code <> "" Then
        ms_SelectedItemCode = ls_S_code
        ms_SelectedItemDesc = ls_S_Desc
        Me.Hide
    End If

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "PrdSeek:OpenPrdAdd"
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "PrdSeek:OpenPrdAdd"
    OpenPrdAdd = ""
    CapMouseOn
    
End Function

