VERSION 5.00
Begin VB.Form frm_mtnc_cwpr 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Classification within products range maintenance"
   ClientHeight    =   6075
   ClientLeft      =   7605
   ClientTop       =   465
   ClientWidth     =   9240
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6075
   ScaleWidth      =   9240
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame SSPanel11 
      BackColor       =   &H00C0C0C0&
      BorderStyle     =   0  'None
      Height          =   4335
      Left            =   120
      TabIndex        =   6
      Top             =   840
      Width           =   9015
      Begin VB.ComboBox cbo_code2 
         Height          =   315
         ItemData        =   "MTNC_CWP.frx":0000
         Left            =   1620
         List            =   "MTNC_CWP.frx":0002
         Style           =   2  'Dropdown List
         TabIndex        =   28
         Top             =   360
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code3 
         Height          =   315
         Left            =   3780
         Style           =   2  'Dropdown List
         TabIndex        =   27
         Top             =   360
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code4 
         Height          =   315
         Left            =   5940
         Style           =   2  'Dropdown List
         TabIndex        =   26
         Top             =   360
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code5 
         Height          =   315
         Left            =   8100
         Style           =   2  'Dropdown List
         TabIndex        =   25
         Top             =   360
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code6 
         Height          =   315
         Left            =   1500
         Style           =   2  'Dropdown List
         TabIndex        =   24
         Top             =   1800
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code7 
         Height          =   315
         Left            =   3660
         Style           =   2  'Dropdown List
         TabIndex        =   23
         Top             =   1800
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code8 
         Height          =   315
         Left            =   5820
         Style           =   2  'Dropdown List
         TabIndex        =   22
         Top             =   1800
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code10 
         Height          =   315
         Left            =   1500
         Style           =   2  'Dropdown List
         TabIndex        =   21
         Top             =   3240
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code11 
         Height          =   315
         Left            =   3660
         Style           =   2  'Dropdown List
         TabIndex        =   20
         Top             =   3240
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code12 
         Height          =   315
         Left            =   5820
         Style           =   2  'Dropdown List
         TabIndex        =   19
         Top             =   3240
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.ComboBox cbo_code9 
         Height          =   315
         Left            =   7980
         Style           =   2  'Dropdown List
         TabIndex        =   18
         Top             =   1800
         Visible         =   0   'False
         Width           =   492
      End
      Begin VB.CheckBox chk_Int 
         Caption         =   "Check1"
         Height          =   252
         Left            =   1680
         TabIndex        =   17
         Top             =   4020
         Width           =   252
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   1
         ItemData        =   "MTNC_CWP.frx":0004
         Left            =   300
         List            =   "MTNC_CWP.frx":0006
         Style           =   2  'Dropdown List
         TabIndex        =   16
         Tag             =   "Base_Material_Link"
         Top             =   720
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   3
         ItemData        =   "MTNC_CWP.frx":0008
         Left            =   4380
         List            =   "MTNC_CWP.frx":000A
         Style           =   2  'Dropdown List
         TabIndex        =   15
         Tag             =   "Products_Edges"
         Top             =   720
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   4
         ItemData        =   "MTNC_CWP.frx":000C
         Left            =   6420
         List            =   "MTNC_CWP.frx":000E
         Style           =   2  'Dropdown List
         TabIndex        =   14
         Tag             =   "Products_Families"
         Top             =   720
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   2
         ItemData        =   "MTNC_CWP.frx":0010
         Left            =   2340
         List            =   "MTNC_CWP.frx":0012
         Style           =   2  'Dropdown List
         TabIndex        =   13
         Tag             =   "Colours"
         Top             =   720
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   5
         ItemData        =   "MTNC_CWP.frx":0014
         Left            =   300
         List            =   "MTNC_CWP.frx":0016
         Style           =   2  'Dropdown List
         TabIndex        =   12
         Tag             =   "Products_Patterns"
         Top             =   960
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   6
         ItemData        =   "MTNC_CWP.frx":0018
         Left            =   2340
         List            =   "MTNC_CWP.frx":001A
         Style           =   2  'Dropdown List
         TabIndex        =   11
         Tag             =   "Products_Segmentation"
         Top             =   960
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   7
         ItemData        =   "MTNC_CWP.frx":001C
         Left            =   4380
         List            =   "MTNC_CWP.frx":001E
         Style           =   2  'Dropdown List
         TabIndex        =   10
         Tag             =   "Surfaces"
         Top             =   960
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   8
         ItemData        =   "MTNC_CWP.frx":0020
         Left            =   6420
         List            =   "MTNC_CWP.frx":0022
         Style           =   2  'Dropdown List
         TabIndex        =   9
         Tag             =   "Product_Module"
         Top             =   960
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   10
         ItemData        =   "MTNC_CWP.frx":0024
         Left            =   2340
         List            =   "MTNC_CWP.frx":0026
         Style           =   2  'Dropdown List
         TabIndex        =   7
         Tag             =   "Plants"
         Top             =   1200
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc5 
         Height          =   315
         Left            =   6780
         Style           =   2  'Dropdown List
         TabIndex        =   36
         Top             =   360
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc4 
         Height          =   315
         Left            =   4620
         Style           =   2  'Dropdown List
         TabIndex        =   37
         Top             =   360
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc3 
         Height          =   315
         Left            =   2460
         Style           =   2  'Dropdown List
         TabIndex        =   38
         Top             =   360
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc2 
         Height          =   315
         Left            =   300
         Style           =   2  'Dropdown List
         TabIndex        =   39
         Top             =   360
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc6 
         Height          =   315
         Left            =   300
         Style           =   2  'Dropdown List
         TabIndex        =   35
         Top             =   1800
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc7 
         Height          =   315
         Left            =   2460
         Style           =   2  'Dropdown List
         TabIndex        =   34
         Top             =   1800
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc8 
         Height          =   315
         Left            =   4620
         Style           =   2  'Dropdown List
         TabIndex        =   33
         Top             =   1800
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc9 
         Height          =   315
         Left            =   6780
         Style           =   2  'Dropdown List
         TabIndex        =   32
         Top             =   1800
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc12 
         Height          =   315
         Left            =   4620
         Style           =   2  'Dropdown List
         TabIndex        =   29
         Top             =   3240
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc11 
         Height          =   315
         Left            =   2460
         Style           =   2  'Dropdown List
         TabIndex        =   30
         Top             =   3240
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_desc10 
         Height          =   315
         Left            =   300
         Style           =   2  'Dropdown List
         TabIndex        =   31
         Top             =   3240
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.ComboBox Cbo_Desc 
         Height          =   315
         Index           =   9
         ItemData        =   "MTNC_CWP.frx":0028
         Left            =   300
         List            =   "MTNC_CWP.frx":002A
         Style           =   2  'Dropdown List
         TabIndex        =   8
         Tag             =   "Product_Height"
         Top             =   1200
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc2 
         Height          =   255
         Left            =   300
         TabIndex        =   51
         Tag             =   "Lbl_desc2"
         Top             =   120
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc3 
         Height          =   255
         Left            =   2460
         TabIndex        =   50
         Tag             =   "Lbl_desc3"
         Top             =   120
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc4 
         Height          =   255
         Left            =   4620
         TabIndex        =   49
         Tag             =   "Lbl_desc4"
         Top             =   120
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc5 
         Height          =   255
         Left            =   6780
         TabIndex        =   48
         Tag             =   "Lbl_desc5"
         Top             =   120
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc6 
         Height          =   255
         Left            =   300
         TabIndex        =   47
         Tag             =   "Lbl_desc6"
         Top             =   1560
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc7 
         Height          =   255
         Left            =   2460
         TabIndex        =   46
         Tag             =   "Lbl_desc7"
         Top             =   1560
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc8 
         Height          =   255
         Left            =   4620
         TabIndex        =   45
         Tag             =   "Lbl_desc8"
         Top             =   1560
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc9 
         Height          =   255
         Left            =   6780
         TabIndex        =   44
         Tag             =   "Lbl_desc9"
         Top             =   1560
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc10 
         Height          =   255
         Left            =   300
         TabIndex        =   43
         Tag             =   "Lbl_desc10"
         Top             =   3000
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc11 
         Height          =   255
         Left            =   2460
         TabIndex        =   42
         Tag             =   "Lbl_desc11"
         Top             =   3000
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label Lbl_desc12 
         Height          =   255
         Left            =   4620
         TabIndex        =   41
         Tag             =   "Lbl_desc12"
         Top             =   3000
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label lbl_Int 
         Caption         =   "Internet flag"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   40
         Top             =   4020
         Width           =   1455
      End
   End
   Begin VB.CommandButton cmd_Execute 
      Height          =   615
      Left            =   6720
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   5400
      Width           =   675
   End
   Begin VB.CommandButton cmd_Save 
      Height          =   615
      Left            =   7560
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   5400
      Width           =   675
   End
   Begin VB.CommandButton cmd_Quit 
      Height          =   615
      Left            =   8400
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   5400
      Width           =   675
   End
   Begin VB.ComboBox cbo_CategoryCode 
      Height          =   288
      Left            =   5160
      Style           =   2  'Dropdown List
      TabIndex        =   2
      Top             =   360
      Visible         =   0   'False
      Width           =   492
   End
   Begin VB.ComboBox cbo_Category 
      Height          =   300
      Left            =   3720
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   360
      Width           =   2175
   End
   Begin VB.Label lbl_Category 
      Caption         =   "Category"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3720
      TabIndex        =   1
      Tag             =   "lbl_Category"
      Top             =   120
      Width           =   2175
   End
End
Attribute VB_Name = "frm_mtnc_cwpr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' Multipurpose global variables used in this form
' gut_param.str26 : used as integer to define for which Test category this form will be used.
'                   Must be equal to "" if we use it for the initial goal of this form (media module)
' gut_Param.Str22 :

Dim mi_Concurr As Integer
Dim mb_Cbo2NotLoaded As Boolean
Dim mb_Cbo3NotLoaded As Boolean
Dim mb_Cbo4NotLoaded As Boolean
Dim mb_Cbo5NotLoaded As Boolean
Dim mb_Cbo6NotLoaded As Boolean
Dim mb_Cbo7NotLoaded As Boolean
Dim mb_Cbo8NotLoaded As Boolean
Dim mb_Cbo9NotLoaded As Boolean
Dim mb_Cbo10NotLoaded As Boolean
Dim mb_Cbo11NotLoaded As Boolean
Dim mb_Cbo12NotLoaded As Boolean


'define if the combo are mandatory when we control before validation
Dim mb_cbo2Mandatory As Boolean
Dim mb_cbo3Mandatory As Boolean
Dim mb_cbo4Mandatory As Boolean
Dim mb_cbo5Mandatory As Boolean
Dim mb_cbo6Mandatory As Boolean
Dim mb_cbo7Mandatory As Boolean
Dim mb_cbo8Mandatory As Boolean
Dim mb_cbo9Mandatory As Boolean
Dim mb_cbo10Mandatory As Boolean
Dim mb_cbo11Mandatory As Boolean
Dim mb_cbo12Mandatory As Boolean

'start change
' constantes to define the code of each type of test at Visual basic level
Const TSTTYP_HUMDRES As Integer = 3
Const TSTTYP_FIREREAC As Integer = 4
Const TSTTYP_SOUNDABS As Integer = 5
Const TSTTYP_LIGHTREF As Integer = 7
Const TSTTYP_HYGIENE As Integer = 10
Const TSTTYP_WASH As Integer = 11
Const TSTTYP_FIRERESIS As Integer = 15
Const TSTTYP_SOUNDATT As Integer = 16
Const TSTTYP_SOUNDRED As Integer = 17
Const TSTTYP_SCRUB As Integer = 18
Const TSTTYP_INVALID As Integer = -1

'variable to record the type of test used
'the value of the type of test (test category) is passed to the form with gut_Param.Str26
'in case of this form is used for the maintenace of test_link_products
'by default this variable is equal to TSTTYP_INVALID
Dim mi_Tsttyp As Integer

Dim InfoCombos() As Infocombo
Private Type Infocombo
    TableName As String
    FieldName As String
    Loaded As Boolean
    Mandatory As Boolean
    DefaultCode As String
    Used As Boolean
    MsgId As Integer
    FillProc As String
    CboCode() As String
    DropFlag() As String
    SelectedCode As String
    Z_Order As Integer
    Label As String
End Type

Const C_ALL As String = "A"
Const C_NONE As String = "N"
Const C_NOT_USED As String = "NOT USED"
Const C_FORM As String = "frm_mtnc_cwpr"

Dim ComboParameters() As ComboParameter
Private Type ComboParameter
    TableName As String
    TableCode As String
    FillProc As String
    Mandatory As String
    AssociatedLabel As String
    MsgId As Integer
    Z_Order As Integer
End Type
Dim m_Code As String

' task 409 JN begin
Private mo_medMan As MediaManager

'P592 Error management
Private mNumber As Long
Private mSource As String
Private mDesc As String


Public Property Set MediaManager(ByRef ao_medMan As MediaManager)
    Set mo_medMan = ao_medMan
End Property
' task 409 end

Private Function Control() As Boolean

'start change
' Control if each field is filled
' we use mb_cboXXMandatory to know if field is mandatory
' so these boolean must be assigned in the form load
' or in a event of mandatory of these field depend of
' JJB 15/04/1999

Control = KO

If cbo_Category = "" Then
    cbo_Category.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (cbo_Desc2 = "") And mb_cbo2Mandatory Then
    cbo_Desc2.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (cbo_Desc3 = "") And mb_cbo3Mandatory Then
    cbo_Desc3.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (cbo_Desc4 = "") And mb_cbo4Mandatory Then
    cbo_Desc4.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (Cbo_desc5 = "") And mb_cbo5Mandatory Then
    Cbo_desc5.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (Cbo_desc6 = "") And mb_cbo6Mandatory Then
    Cbo_desc6.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (Cbo_desc7 = "") And mb_cbo7Mandatory Then
    Cbo_desc7.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (Cbo_desc8 = "") And mb_cbo8Mandatory Then
    Cbo_desc8.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (Cbo_desc9 = "") And mb_cbo9Mandatory Then
    Cbo_desc9.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (Cbo_desc10 = "") And mb_cbo10Mandatory Then
    Cbo_desc10.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If
If (Cbo_desc11 = "") And mb_cbo11Mandatory Then
    Cbo_desc11.SetFocus
    If LCase(gs_TableName) = "test_link_products" Then
        SendMessage 154, "Please complete the Plant / Supplier field", gut_LangLogin.Code
    Else
        SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    End If
    Exit Function
End If

Control = OK
End Function

Private Sub get_sc_csts()
'in this function we load the label of each field in the working language used
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Field As String
Dim ls_Text As String
   
On Error GoTo ErrHandler

Select Case gs_TableName
Case "Test_Link_Products"
    ls_req = gs_ParamReqCsts & ",'" & QuoteParam(gut_LangWork.Code) & "'"
Case "media_manager"
    ls_req = "EXEC Screen_Csts 'mtnc_cwpr','" & QuoteParam(gut_LangWork.Code) & "'"
'P592 begin
Case "ProductsFamilies_Group"
'P592 end
    ls_req = "EXEC Screen_Csts 'Grid_WebGroup','" & QuoteParam(gut_LangWork.Code) & "'"
End Select

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If

'P592 begin
If gs_TableName = "ProductsFamilies_Group" Then
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Field = ODBCData(ll_Statement, 1)
            ls_Text = ODBCData(ll_Statement, 2)
            Select Case ls_Field
                Case "title": Caption = ls_Text
                Case "bm":   Lbl_desc2 = ls_Text
                Case "sh":   Lbl_desc3 = ls_Text
                Case "pe":   Lbl_desc4 = ls_Text
                Case "pf":   Lbl_desc5 = ls_Text
            End Select
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
'P592 end
Else
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Field = ODBCData(ll_Statement, 1)
            ls_Text = ODBCData(ll_Statement, 2)
            Select Case ls_Field
                Case "title": Caption = ls_Text
                Case "bm":   Lbl_desc2 = ls_Text
                Case "col":  Lbl_desc3 = ls_Text
                Case "pe":   Lbl_desc4 = ls_Text
                Case "pf":   Lbl_desc5 = ls_Text
                Case "pp":   Lbl_desc6 = ls_Text
                Case "ps":   Lbl_desc7 = ls_Text
                Case "surf": Lbl_desc8 = ls_Text
                Case "pm":   Lbl_desc9 = ls_Text
                Case "lbl_desc10": Lbl_desc10 = ls_Text
                Case "lbl_desc11": Lbl_desc11 = ls_Text
                Case "lbl_Int": lbl_Int.Caption = ls_Text
            End Select
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End If

Exit Sub

ErrHandler:
StdError
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub

Private Sub Cbo_category_Click()
Dim ls_Text As String

On Error GoTo ErrHandler
MouseOff

cbo_Desc2.Clear
cbo_Desc3.Clear
cbo_Desc4.Clear
Cbo_desc5.Clear
Cbo_desc6.Clear
Cbo_desc7.Clear
Cbo_desc8.Clear
Cbo_desc9.Clear
Cbo_desc10.Clear
Cbo_desc11.Clear
Cbo_desc12.Clear
chk_Int.value = vbChecked

cbo_Code2.Clear
cbo_Code3.Clear
cbo_Code4.Clear
cbo_code5.Clear
cbo_code6.Clear
cbo_code7.Clear
cbo_code8.Clear
cbo_code9.Clear
cbo_code10.Clear
cbo_code11.Clear
cbo_code12.Clear

If cbo_Category.ListIndex <> -1 And gs_Action = "add" Then
    SSPanel11.Visible = OK
    mb_Cbo2NotLoaded = OK
    mb_Cbo3NotLoaded = OK
    mb_Cbo4NotLoaded = OK
    mb_Cbo5NotLoaded = OK
    mb_Cbo6NotLoaded = OK
    mb_Cbo7NotLoaded = OK
    Select Case gs_TableName
    Case "Test_Link_Products"
        HideOldControls
        DynamicSet
        
        Clear_Combos
        
        Lbl_desc2.Visible = OK
        Lbl_desc3.Visible = OK
        Lbl_desc4.Visible = OK
        Lbl_desc5.Visible = OK
        Lbl_desc6.Visible = OK
        Lbl_desc7.Visible = OK
        Lbl_desc8.Visible = OK
        Lbl_desc9.Visible = OK
        Lbl_desc9.Visible = OK
        Lbl_desc10.Visible = OK
        Lbl_desc11.Visible = OK
        
        Init_Array

        'display allowed combos
        Dim ll_count As Long
        Dim ll_Idx As Long
        ll_count = UBound(InfoCombos)
        For ll_Idx = 0 To ll_count
            If InfoCombos(ll_Idx).Used = True Then
                On Error GoTo NextRcd
                Cbo_Desc(ll_Idx).Visible = True
                If InfoCombos(ll_Idx).Mandatory = True Then LabelBold InfoCombos(ll_Idx).Label
NextRcd:
            End If
        Next ll_Idx
        
        ' For knowing number of records impcated by the criteria list
        cmd_Execute.Visible = True

    Case "media_manager"
        Lbl_desc2.Visible = OK
        cbo_Desc2.Visible = OK
        Lbl_desc3.Visible = OK
        cbo_Desc3.Visible = OK
        Lbl_desc4.Visible = OK
        cbo_Desc4.Visible = OK
        Lbl_desc5.Visible = OK
        Cbo_desc5.Visible = OK
        Lbl_desc6.Visible = OK
        Cbo_desc6.Visible = OK
        Lbl_desc7.Visible = OK
        Cbo_desc7.Visible = OK
        
        If cbo_CategoryCode.List(cbo_Category.ListIndex) = "C001" Or cbo_CategoryCode.List(cbo_Category.ListIndex) = "C006" Then
            mb_Cbo8NotLoaded = OK
            Lbl_desc8.Visible = OK
            Cbo_desc8.Visible = OK
            mb_Cbo9NotLoaded = OK
            Lbl_desc9.Visible = OK
            Cbo_desc9.Visible = OK
            mb_cbo8Mandatory = OK
            mb_cbo9Mandatory = OK
        Else
            mb_cbo8Mandatory = KO
            mb_cbo9Mandatory = KO
            Lbl_desc8.Visible = KO
            Cbo_desc8.Visible = KO
            Lbl_desc9.Visible = KO
            Cbo_desc9.Visible = KO
        End If
        
'P592 begin
    Case "ProductsFamilies_Group"
        HideOldControls
        DynamicSet
        
        Clear_Combos
        
        Lbl_desc2.Visible = True
        Lbl_desc3.Visible = True
        Lbl_desc4.Visible = True
        Lbl_desc5.Visible = True
        
'for avoiding to create a new combo ==> special feature: colour replaced by shape.
        Cbo_Desc.Item(2).Tag = "Shapes"
        
        Init_Array

        'display allowed combos
        ll_count = UBound(InfoCombos)
        For ll_Idx = 0 To ll_count
            If InfoCombos(ll_Idx).Used = True Then
                On Error GoTo NextRcd2
                Cbo_Desc(ll_Idx).Visible = True
                If InfoCombos(ll_Idx).Mandatory = True Then LabelBold InfoCombos(ll_Idx).Label
NextRcd2:
            End If
        Next ll_Idx
'P592 end
        
    End Select

Else
    SSPanel11.Visible = KO
    Lbl_desc2.Visible = KO
    cbo_Desc2.Visible = KO
    Lbl_desc3.Visible = KO
    cbo_Desc3.Visible = KO
    Lbl_desc4.Visible = KO
    cbo_Desc4.Visible = KO
    Lbl_desc5.Visible = KO
    Cbo_desc5.Visible = KO
    Lbl_desc6.Visible = KO
    Cbo_desc6.Visible = KO
    Lbl_desc7.Visible = KO
    Cbo_desc7.Visible = KO
    Lbl_desc8.Visible = KO
    Cbo_desc8.Visible = KO
    Lbl_desc9.Visible = KO
    Cbo_desc9.Visible = KO
    Lbl_desc10.Visible = KO
    Cbo_desc10.Visible = KO
    Lbl_desc11.Visible = KO
    Cbo_desc11.Visible = KO
    Lbl_desc12.Visible = KO
    Cbo_desc12.Visible = KO
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_Desc_Click(Index As Integer)
Dim l_Ctr As Long

On Error GoTo ErrHandler
MouseOff

If Cbo_Desc(Index).ListIndex <> -1 And Cbo_Desc(Index).ListCount > 0 Then
    'Retrouver la combo
    For l_Ctr = 0 To UBound(InfoCombos)
        If InfoCombos(l_Ctr).TableName = Cbo_Desc(Index).Tag Then
            InfoCombos(l_Ctr).SelectedCode = ""
            InfoCombos(l_Ctr).SelectedCode = InfoCombos(l_Ctr).CboCode(Cbo_Desc(Index).ItemData(Cbo_Desc(Index).ListIndex) + 1)
            If UCase(InfoCombos(l_Ctr).DropFlag(Cbo_Desc(Index).ItemData(Cbo_Desc(Index).ListIndex) + 1)) = "X" Then
                SendMessage 70, "Inactive item", gut_LangLogin.Code
            End If
            Exit For
        End If
    Next
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_Desc_DropDown(Index As Integer)
Dim ls_Desc2 As String
Dim ls_Text As String
Dim ls_req As String
Dim i As Integer

On Error GoTo ErrHandler
MouseOff

'Est-ce que la combo est déjà chargée si oui on sort
If InfoCombos(Index).Loaded = False Then
    InfoCombos(Index).Loaded = True
    If Cbo_Desc(Index).ListIndex <> -1 Then
        'Sauvegarder éventuellemnt le code présent
        ls_Text = Cbo_Desc(Index).Text
    Else
        ls_Text = ""
    End If
    
    'Exécuter la requete de chargement desc & code
    'Cas particulier pour Plant/supplier : cg_code pas à fournir
    If Index = 10 Then
        ls_req = "EXEC " & InfoCombos(Index).FillProc & " '" & gut_LangWork.Code & "'"
    Else
        ls_req = "EXEC " & InfoCombos(Index).FillProc & "'" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    End If
    'renseigner le tableau des codes de de la combo
    FillCboCode ls_req, Cbo_Desc(Index), Cbo_Desc(Index).Tag
    
    'Se repositionner sur le code sauvegardé
    If ls_Text <> "" Then
        For i = 0 To Cbo_Desc(Index).ListCount - 1
            If Cbo_Desc(Index).List(i) = ls_Text Then
                Cbo_Desc(Index).ListIndex = i
                Exit For
            End If
        Next
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc10_Click()

On Error GoTo ErrHandler
MouseOff

If Cbo_desc10.ListIndex <> -1 And Cbo_desc10.Visible = -1 Then
    If cbo_code10.ItemData(Cbo_desc10.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc10_DropDown()
'start change
Dim ls_Desc10 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo10NotLoaded Then
    mb_Cbo10NotLoaded = KO
    If Cbo_desc10.ListIndex <> -1 Then
        ls_Text = cbo_code10.List(Cbo_desc10.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_code10.Clear
    Cbo_desc10.Clear
    ' in case we link test to products by criteria we let the user to enter a all values
    Select Case gs_TableName
    Case "Test_Link_Products"
        ls_req = "EXEC Product_Height_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','E'"
    Case Else
        ls_req = "EXEC Product_Height_cbo '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','E'"
    End Select
    FillCbo ls_req, cbo_code10, Cbo_desc10
    If ls_Text <> "" Then
        Cbo_desc10.ListIndex = ComboFindItem(cbo_code10, ls_Text)
    End If
End If

MouseOn
'end change
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc11_Click()

On Error GoTo ErrHandler
MouseOff

If Cbo_desc11.ListIndex <> -1 And Cbo_desc11.Visible = -1 Then
    If cbo_code11.ItemData(Cbo_desc11.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc11_DropDown()
'start change
Dim ls_Desc11 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo11NotLoaded Then
    mb_Cbo11NotLoaded = KO
    If Cbo_desc11.ListIndex <> -1 Then
        ls_Text = cbo_code11.List(Cbo_desc11.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_code11.Clear
    Cbo_desc11.Clear
    If gs_TableName = "Test_Link_Products" Then
        ls_req = "EXEC Plants_cbo5 '" & gut_LangWork.Code & "'"
    Else
        ls_req = "EXEC Plants_cbo '" & gut_LangWork.Code & "'"
    End If
    FillCbo ls_req, cbo_code11, Cbo_desc11
    If ls_Text <> "" Then
        Cbo_desc11.ListIndex = ComboFindItem(cbo_code11, ls_Text)
    End If
End If

MouseOn
'end change
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc12_Click()

On Error GoTo ErrHandler
MouseOff
If Cbo_desc12.ListIndex <> -1 And Cbo_desc12.Visible = -1 Then
    If cbo_code12.ItemData(Cbo_desc12.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc2_Click()

On Error GoTo ErrHandler
MouseOff

If cbo_Desc2.ListIndex <> -1 And cbo_Desc2.Visible = -1 Then
    If cbo_Code2.ItemData(cbo_Desc2.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc2_DropDown()
Dim ls_Desc2 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo2NotLoaded Then
    mb_Cbo2NotLoaded = KO
    If cbo_Desc2.ListIndex <> -1 Then
        ls_Text = cbo_Code2.List(cbo_Desc2.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_Code2.Clear
    cbo_Desc2.Clear
    ls_req = "EXEC Base_Material_Link_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_Code2, cbo_Desc2
    If ls_Text <> "" Then
        cbo_Desc2.ListIndex = ComboFindItem(cbo_Code2, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc3_Click()

On Error GoTo ErrHandler
MouseOff

If cbo_Desc3.ListIndex <> -1 And cbo_Desc3.Visible = -1 Then
    If cbo_Code3.ItemData(cbo_Desc3.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc3_DropDown()
Dim ls_Desc3 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo3NotLoaded Then
    mb_Cbo3NotLoaded = KO
    If cbo_Desc3.ListIndex <> -1 Then
        ls_Text = cbo_Code3.List(cbo_Desc3.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_Code3.Clear
    cbo_Desc3.Clear
    ls_req = "EXEC Colours_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_Code3, cbo_Desc3
    If ls_Text <> "" Then
        cbo_Desc3.ListIndex = ComboFindItem(cbo_Code3, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc4_Click()

On Error GoTo ErrHandler
MouseOff

If cbo_Desc4.ListIndex <> -1 And cbo_Desc4.Visible = -1 Then
    If cbo_Code4.ItemData(cbo_Desc4.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc4_DropDown()
Dim ls_Desc4 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo4NotLoaded Then
    mb_Cbo4NotLoaded = KO
    If cbo_Desc4.ListIndex <> -1 Then
        ls_Text = cbo_Code4.List(cbo_Desc4.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_Code4.Clear
    cbo_Desc4.Clear
    ls_req = "EXEC Products_Edges_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_Code4, cbo_Desc4
    If ls_Text <> "" Then
        cbo_Desc4.ListIndex = ComboFindItem(cbo_Code4, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc5_Click()

On Error GoTo ErrHandler
MouseOff

If Cbo_desc5.ListIndex <> -1 And Cbo_desc5.Visible = -1 Then
    If cbo_code5.ItemData(Cbo_desc5.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc5_DropDown()
Dim ls_Desc5 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo5NotLoaded Then
    mb_Cbo5NotLoaded = KO
    If Cbo_desc5.ListIndex <> -1 Then
        ls_Text = cbo_code5.List(Cbo_desc5.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_code5.Clear
    Cbo_desc5.Clear
    
    ls_req = "EXEC Products_Families_cbo3 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_code5, Cbo_desc5
    If ls_req <> "" Then
        Cbo_desc5.ListIndex = ComboFindItem(cbo_code5, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc6_Click()

On Error GoTo ErrHandler
MouseOff

If Cbo_desc6.ListIndex <> -1 And Cbo_desc6.Visible = -1 Then
    If cbo_code6.ItemData(Cbo_desc6.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc6_DropDown()
Dim ls_Desc6 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo6NotLoaded Then
    mb_Cbo6NotLoaded = KO
    If Cbo_desc6.ListIndex <> -1 Then
        ls_Text = cbo_code6.List(Cbo_desc6.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_code6.Clear
    Cbo_desc6.Clear
    ls_req = "EXEC Products_Patterns_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_code6, Cbo_desc6
    If ls_Text <> "" Then
        Cbo_desc6.ListIndex = ComboFindItem(cbo_code6, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc7_Click()

On Error GoTo ErrHandler
MouseOff

If Cbo_desc7.ListIndex <> -1 And Cbo_desc7.Visible = -1 Then
    If cbo_code7.ItemData(Cbo_desc7.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc7_DropDown()
Dim ls_Desc7 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo7NotLoaded Then
    mb_Cbo7NotLoaded = KO
    If Cbo_desc7.ListIndex <> -1 Then
        ls_Text = cbo_code7.List(Cbo_desc7.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_code7.Clear
    Cbo_desc7.Clear
    ls_req = "EXEC Products_Segmentation_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_code7, Cbo_desc7
    If ls_Text <> "" Then
        Cbo_desc7.ListIndex = ComboFindItem(cbo_code7, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc8_Click()

On Error GoTo ErrHandler
MouseOff

If Cbo_desc8.ListIndex <> -1 And Cbo_desc8.Visible = -1 Then
    If cbo_code8.ItemData(Cbo_desc8.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc8_DropDown()
Dim ls_Desc8 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo8NotLoaded Then
    mb_Cbo8NotLoaded = KO
    If Cbo_desc8.ListIndex <> -1 Then
        ls_Text = cbo_code8.List(Cbo_desc8.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_code8.Clear
    Cbo_desc8.Clear
    ls_req = "EXEC Surfaces_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_code8, Cbo_desc8
    If ls_Text <> "" Then
        Cbo_desc8.ListIndex = ComboFindItem(cbo_code8, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc9_Click()

On Error GoTo ErrHandler
MouseOff

If Cbo_desc9.ListIndex <> -1 And Cbo_desc9.Visible = -1 Then
    If cbo_code9.ItemData(Cbo_desc9.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Cbo_desc9_DropDown()
Dim ls_Desc9 As String
Dim ls_Text As String
Dim ls_req As String

On Error GoTo ErrHandler
MouseOff

If mb_Cbo9NotLoaded Then
    mb_Cbo9NotLoaded = KO
    If Cbo_desc9.ListIndex <> -1 Then
        ls_Text = cbo_code9.List(Cbo_desc9.ListIndex)
    Else
        ls_Text = ""
    End If
    cbo_code9.Clear
    Cbo_desc9.Clear
    ls_req = "EXEC Product_Module_cbo2 '" & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','E'"
    FillCbo ls_req, cbo_code9, Cbo_desc9
    If ls_Text <> "" Then
        Cbo_desc9.ListIndex = ComboFindItem(cbo_code9, ls_Text)
    End If
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub Form_Load()
Dim lv_Data As Variant      ' task 409 JN
Dim lv_DataCat As Variant   ' task 409 JN
Dim lv_labels As Variant    ' task 409 JN

On Error GoTo ErrHandler

MouseOff

If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me

cmd_Save.Picture = LoadResPicture(RES_OK, 1)
cmd_Quit.Picture = LoadResPicture(RES_QUIT, 1)
cmd_Execute.Picture = LoadResPicture(RES_FILLGRID, 1)

cmd_Execute.Visible = False

mb_cbo2Mandatory = KO
mb_cbo3Mandatory = KO
mb_cbo4Mandatory = KO
mb_cbo5Mandatory = KO
mb_cbo6Mandatory = KO
mb_cbo7Mandatory = KO
mb_cbo8Mandatory = KO
mb_cbo9Mandatory = KO
mb_cbo10Mandatory = KO
mb_cbo11Mandatory = KO
mb_cbo12Mandatory = KO

Select Case gs_TableName
Case "media_manager"
    mb_cbo2Mandatory = OK
    mb_cbo3Mandatory = OK
    mb_cbo4Mandatory = OK
    mb_cbo5Mandatory = OK
    mb_cbo6Mandatory = OK
    mb_cbo7Mandatory = OK
    chk_Int.Visible = OK
    lbl_Int.Visible = OK
    chk_Int.value = vbChecked

Case "Test_Link_Products"
    chk_Int.Visible = KO
    lbl_Int.Visible = KO

    If gut_Param.Str26 = "" Then
        mi_Tsttyp = TSTTYP_INVALID
    Else
        mi_Tsttyp = CInt(gut_Param.Str26)
    End If

'P592 begin
Case "ProductsFamilies_Group"
    mb_cbo2Mandatory = True
    mb_cbo3Mandatory = True
    mb_cbo4Mandatory = True
    mb_cbo5Mandatory = True
    chk_Int.Visible = False
    lbl_Int.Visible = False
'P592 begin

End Select

get_sc_csts

SSPanel11.Visible = 0
' task 409 JN begin
If Not mo_medMan Is Nothing Then
    lv_labels = mo_medMan.Item_Marketing_GridColumnLabels
    lbl_Category.Caption = lv_labels(0)     'frm_main_cwpr.lbl_Categ
End If

Select Case gs_Action
    Case "add":
        ' used for "Test_Link_Products"
        ' used for "media_manager"
        FillCbo "Category", cbo_CategoryCode, cbo_Category
    Case "upd":
        ' not used for "Test_Link_Products"
        ' used for "media_manager"
' task 409 JN   begin
        lv_DataCat = mo_medMan.Item_Product_CategoryData
        lv_Data = mo_medMan.Item_Product_GridLine
        cbo_Category.AddItem lv_DataCat(1)
        cbo_CategoryCode.AddItem lv_DataCat(0)
        cbo_Category.ListIndex = 0
        cbo_Category.Enabled = KO
        mb_Cbo2NotLoaded = OK
        chk_Int.value = IIf(lv_Data(1) = "Y", vbChecked, vbUnchecked)
        cbo_Desc2.AddItem lv_Data(2)
        cbo_Desc2.ListIndex = 0
        Lbl_desc2.Visible = OK
        cbo_Desc2.Visible = OK
        mb_Cbo3NotLoaded = OK
        cbo_Desc3.AddItem lv_Data(3)
        cbo_Desc3.ListIndex = 0
        Lbl_desc3.Visible = OK
        cbo_Desc3.Visible = OK
        mb_Cbo4NotLoaded = OK
        cbo_Desc4.AddItem lv_Data(4)
        cbo_Desc4.ListIndex = 0
        Lbl_desc4.Visible = OK
        cbo_Desc4.Visible = OK
        mb_Cbo5NotLoaded = OK
        Cbo_desc5.AddItem lv_Data(5)
        Cbo_desc5.ListIndex = 0
        Lbl_desc5.Visible = OK
        Cbo_desc5.Visible = OK
        mb_Cbo6NotLoaded = OK
        Cbo_desc6.AddItem lv_Data(6)
        Cbo_desc6.ListIndex = 0
        Lbl_desc6.Visible = OK
        Cbo_desc6.Visible = OK
        mb_Cbo7NotLoaded = OK
        Cbo_desc7.AddItem lv_Data(7)
        Cbo_desc7.ListIndex = 0
        Lbl_desc7.Visible = OK
        Cbo_desc7.Visible = OK
        Select Case cbo_CategoryCode.List(0)
            Case "C001", "C006":
                mb_Cbo8NotLoaded = OK
                Cbo_desc8.AddItem lv_Data(8)
                Cbo_desc8.ListIndex = 0
                Lbl_desc8.Visible = OK
                Cbo_desc8.Visible = OK
                mb_Cbo9NotLoaded = OK
                Cbo_desc9.AddItem lv_Data(9)
                Cbo_desc9.ListIndex = 0
                Lbl_desc9.Visible = OK
                Cbo_desc9.Visible = OK
            Case Else:
        End Select
        mi_Concurr = GetConcurrency("EXEC media_Product_Classif_iCon_sel '" & QuoteParam(lv_Data(0)) & "'")
        SSPanel11.Visible = OK
    Case "del":
        ' not used for "Test_Link_Products"
        ' used for "media_manager"
        lv_DataCat = mo_medMan.Item_Product_CategoryData
        lv_Data = mo_medMan.Item_Product_GridLine
        cbo_Category.AddItem lv_DataCat(1)
        cbo_CategoryCode.AddItem lv_DataCat(0)
        cbo_Category.ListIndex = 0
        cbo_Category.Enabled = KO
        cbo_Desc2.Enabled = KO
        cbo_Desc3.Enabled = KO
        cbo_Desc4.Enabled = KO
        Cbo_desc5.Enabled = KO
        Cbo_desc6.Enabled = KO
        Cbo_desc7.Enabled = KO
        Cbo_desc8.Enabled = KO
        Cbo_desc9.Enabled = KO
        chk_Int.Enabled = KO
        chk_Int.value = IIf(lv_Data(1) = "Y", vbChecked, vbUnchecked)
        cbo_Desc2.AddItem lv_Data(2)
        cbo_Desc2.ListIndex = 0
        Lbl_desc2.Visible = OK
        cbo_Desc2.Visible = OK
        cbo_Desc3.AddItem lv_Data(3)
        cbo_Desc3.ListIndex = 0
        Lbl_desc3.Visible = OK
        cbo_Desc3.Visible = OK
        cbo_Desc4.AddItem lv_Data(4)
        cbo_Desc4.ListIndex = 0
        Lbl_desc4.Visible = OK
        cbo_Desc4.Visible = OK
        Cbo_desc5.AddItem lv_Data(5)
        Cbo_desc5.ListIndex = 0
        Lbl_desc5.Visible = OK
        Cbo_desc5.Visible = OK
        Cbo_desc6.AddItem lv_Data(6)
        Cbo_desc6.ListIndex = 0
        Lbl_desc6.Visible = OK
        Cbo_desc6.Visible = OK
        Cbo_desc7.AddItem lv_Data(7)
        Cbo_desc7.ListIndex = 0
        Lbl_desc7.Visible = OK
        Cbo_desc7.Visible = OK
        Select Case cbo_CategoryCode.List(0)
            Case "C001", "C006":
                Cbo_desc8.AddItem lv_Data(8)
                Cbo_desc8.ListIndex = 0
                Lbl_desc8.Visible = OK
                Cbo_desc8.Visible = OK
                Cbo_desc9.AddItem lv_Data(9)
                Cbo_desc9.ListIndex = 0
                Lbl_desc9.Visible = OK
                Cbo_desc9.Visible = OK
        End Select
        mi_Concurr = GetConcurrency("EXEC media_Product_Classif_iCon_sel '" & QuoteParam(lv_Data(0)) & "'")
        SSPanel11.Visible = OK
End Select
'end change

'P592 begin
If gs_TableName = "ProductsFamilies_Group" Then
Dim ll_Idx As Long
    For ll_Idx = 0 To cbo_Category.ListCount - 1
        If cbo_CategoryCode.List(ll_Idx) = "C001" Then
            cbo_Category.ListIndex = ll_Idx
            cbo_Category.Enabled = False
            Exit For
        End If
    Next
End If
'P592 end

MouseOn
Exit Sub

ErrHandler:
'Resume
    StdError
End Sub

Private Sub cmd_save_Click()

On Error GoTo ErrHandler

MouseOff
gb_Return = OK

Select Case gs_Action
    Case "add"
        'Caller ? ==> Control ? ==> Insert ?
        Select Case gs_TableName
        Case "media_manager"
            If Control Then
                If Not Validate_add_prod Then SendMessage 4, "Association with products failed.", gut_LangLogin.Code
            End If
        Case "Test_Link_Products"
            If Control2 Then
                If Count_Products <> 0 Then
                    If Not Insert_TestProduct Then
                        MouseOn
                        SendMessage 188, "Association with products failed.", gut_LangLogin.Code
                        Exit Sub
                    End If
                Else
                    MouseOn
                    SendMessage 189, "No products responding to the actual criteria list.", gut_LangLogin.Code
                    Exit Sub
                End If
            Else
                MouseOn
                Exit Sub
            End If
'P592 begin
        Case "ProductsFamilies_Group"
            If Control2 Then
                If Not Insert_WebGroup Then SendMessage 289, "The Web group combination insert failed.", gut_LangLogin.Code
            Else
                MouseOn
                Exit Sub
            End If

        End Select
    
    Case "del"
        If Not Validate_Del_Prod Then
            SendMessage 2, "Another user change the record. Refresh your screen and try again.", gut_LangLogin.Code
        Else
            Unload Me
        End If
'P592 end
    Case "upd"
        If Not Validate_upd_prod Then
            SendMessage 2, "Another user change the record. Refresh your screen and try again.", gut_LangLogin.Code
        Else
            Unload Me
        End If
End Select

If gs_TableName = "Test_Link_Products" Then
    Unload Me
End If

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Function Validate_add_prod()
Dim ls_req As String
Dim ll_Statement As Long
Dim ll_LngID As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim lS_Code As String
Dim i As Integer
Dim li_exist As Integer

On Error GoTo Err_AddProd

Validate_add_prod = False
mSource = C_FORM & "/Validate_add_prod:"

'phase 1
    'start change
Select Case gs_TableName
Case "media_manager"
        If cbo_CategoryCode.List(cbo_Category.ListIndex) = "C001" Or cbo_CategoryCode.List(cbo_Category.ListIndex) = "C006" Then
            ls_req = "EXEC Media_Product_Classif_ins '"
            ls_req = ls_req & QuoteParam(gs_MediaCode) & "','"
            ls_req = ls_req & QuoteParam(cbo_CategoryCode.List(cbo_Category.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_Code2.List(cbo_Desc2.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_Code4.List(cbo_Desc4.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_code5.List(Cbo_desc5.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_code8.List(Cbo_desc8.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_code6.List(Cbo_desc6.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_code7.List(Cbo_desc7.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_code9.List(Cbo_desc9.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_Code3.List(cbo_Desc3.ListIndex)) & "','"
            If chk_Int.value = vbChecked Then
                ls_req = ls_req & "Y'"
            Else
                ls_req = ls_req & "'"
            End If
        Else
            ls_req = "EXEC Media_Product_Classif_ins '"
            ls_req = ls_req & QuoteParam(gs_MediaCode) & "','"
            ls_req = ls_req & QuoteParam(cbo_CategoryCode.List(cbo_Category.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_Code2.List(cbo_Desc2.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_Code4.List(cbo_Desc4.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_code5.List(Cbo_desc5.ListIndex)) & "','B000','"
            ls_req = ls_req & QuoteParam(cbo_code6.List(Cbo_desc6.ListIndex)) & "','"
            ls_req = ls_req & QuoteParam(cbo_code7.List(Cbo_desc7.ListIndex)) & "','Not concerned','"
            ls_req = ls_req & QuoteParam(cbo_Code3.List(cbo_Desc3.ListIndex)) & "','"
            If chk_Int.value = vbChecked Then
                ls_req = ls_req & "Y'"
            Else
                ls_req = ls_req & "'"
            End If
        End If
End Select

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQL_SUCCESS
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            lS_Code = ODBCData(ll_Statement, 1)
        End If
    Loop
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

If lS_Code = "" Then
    Err.Raise C_ERRORRAISE + 4, "frm_mntc_cwpr/validate_add_prod", "Association with products failed"
End If

'start change
Select Case gs_TableName
Case "media_manager"
    Dim lv_DataCat As Variant   ' task 409 JN
    Call mo_medMan.Item_Product_CategoryAdd(cbo_CategoryCode.List(cbo_Category.ListIndex), Array(cbo_CategoryCode.List(cbo_Category.ListIndex), cbo_Category.Text), True)
        
    lv_DataCat = mo_medMan.Item_Product_CategoryData
    If Not IsEmpty(lv_DataCat) Then                 ' bugfix JN 12/06/2007
    If lv_DataCat(0) = cbo_CategoryCode.List(cbo_Category.ListIndex) Then
        ' task 408 JN
        If cbo_CategoryCode.List(cbo_Category.ListIndex) = "C001" Or cbo_CategoryCode.List(cbo_Category.ListIndex) = "C006" Then
            Call mo_medMan.Item_Product_Add( _
                        Array(lS_Code, _
                                IIf(chk_Int.value = vbChecked, "Y", ""), _
                                cbo_Desc2.Text, _
                                cbo_Desc3.Text, _
                                cbo_Desc4.Text, _
                                Cbo_desc5.Text, _
                                Cbo_desc6.Text, _
                                Cbo_desc7.Text, _
                                Cbo_desc8.Text, _
                                Cbo_desc9.Text))
        Else
            Call mo_medMan.Item_Product_Add( _
                        Array(lS_Code, _
                                IIf(chk_Int.value = vbChecked, "Y", ""), _
                                cbo_Desc2.Text, _
                                cbo_Desc3.Text, _
                                cbo_Desc4.Text, _
                                Cbo_desc5.Text, _
                                Cbo_desc6.Text, _
                                Cbo_desc7.Text))
        End If
    End If
    End If
End Select
'end change

Validate_add_prod = True
Exit Function

Err_AddProd:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Function

Private Function Validate_Del_Prod() As Boolean

Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim li_Found As Integer
Dim i As Integer

On Error GoTo ErrHandler

If SendMessage(5, "Delete record ?", gut_LangLogin.Code, vbQuestion + vbYesNo, "Delete ") = vbNo Then
    Exit Function
End If

Validate_Del_Prod = False
mSource = C_FORM & "/Validate_Del_Prod:"

' task 409 JN
ls_req = "EXEC Media_Product_Classif_del '"
ls_req = ls_req & QuoteParam(mo_medMan.Item_Product_Code) & "'," & mi_Concurr
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLRowCount(ll_Statement, ll_lngrows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_lngrows = 0 Then
        Err.Raise C_ERRORRAISE + 2, mSource, "Another user change the record. Refresh your screen and try again."
        Exit Function
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If
' task 409 JN

Validate_Del_Prod = True
Call mo_medMan.Item_Product_Del(mo_medMan.Item_Product_Code)
Exit Function

ErrHandler:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Function

Private Function Validate_upd_prod() As Boolean
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long

On Error GoTo ErrHandler
Validate_upd_prod = False
mSource = C_FORM & "/Validate_upd_prod:"

If cbo_CategoryCode.List(cbo_Category.ListIndex) = "C001" Or cbo_CategoryCode.List(cbo_Category.ListIndex) = "C006" Then
    ls_req = "EXEC Media_Product_Classif_upd '"
    ls_req = ls_req & QuoteParam(mo_medMan.Item_Product_Code) & "','"   ' task 409 JN
    ls_req = ls_req & QuoteParam(cbo_Code2.List(cbo_Desc2.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_Code4.List(cbo_Desc4.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_code5.List(Cbo_desc5.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_code8.List(Cbo_desc8.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_code6.List(Cbo_desc6.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_code7.List(Cbo_desc7.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_code9.List(Cbo_desc9.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_Code3.List(cbo_Desc3.ListIndex)) & "','"
    If chk_Int.value = vbChecked Then
        ls_req = ls_req & "Y'," & mi_Concurr
    Else
        ls_req = ls_req & "'," & mi_Concurr
    End If
 Else
    ls_req = "EXEC Media_Product_Classif_upd '"
    ls_req = ls_req & QuoteParam(mo_medMan.Item_Product_Code) & "','"   ' task 409 JN
    ls_req = ls_req & QuoteParam(cbo_Code2.List(cbo_Desc2.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_Code4.List(cbo_Desc4.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_code5.List(Cbo_desc5.ListIndex)) & "','','"
    ls_req = ls_req & QuoteParam(cbo_code6.List(Cbo_desc6.ListIndex)) & "','"
    ls_req = ls_req & QuoteParam(cbo_code7.List(Cbo_desc7.ListIndex)) & "','','"
    ls_req = ls_req & QuoteParam(cbo_Code3.List(cbo_Desc3.ListIndex)) & "','"
    If chk_Int.value = vbChecked Then
        ls_req = ls_req & "Y'," & mi_Concurr
    Else
        ls_req = ls_req & "'," & mi_Concurr
    End If
End If

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLRowCount(ll_Statement, ll_lngrows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_lngrows = 0 Then
        Err.Raise C_ERRORRAISE + 2, mSource, "Another user change the record. Refresh your screen and try again."
        Exit Function
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If

' task 408 JN
If cbo_CategoryCode.List(cbo_Category.ListIndex) = "C001" Or cbo_CategoryCode.List(cbo_Category.ListIndex) = "C006" Then
    Call mo_medMan.Item_Product_Upd( _
                mo_medMan.Item_Product_Code, _
                Array(mo_medMan.Item_Product_Code, _
                        IIf(chk_Int.value = vbChecked, "Y", ""), _
                        cbo_Desc2.Text, _
                        cbo_Desc3.Text, _
                        cbo_Desc4.Text, _
                        Cbo_desc5.Text, _
                        Cbo_desc6.Text, _
                        Cbo_desc7.Text, _
                        Cbo_desc8.Text, _
                        Cbo_desc9.Text))
Else
    Call mo_medMan.Item_Product_Upd( _
                mo_medMan.Item_Product_Code, _
                Array(mo_medMan.Item_Product_Code, _
                        IIf(chk_Int.value = vbChecked, "Y", ""), _
                        cbo_Desc2.Text, _
                        cbo_Desc3.Text, _
                        cbo_Desc4.Text, _
                        Cbo_desc5.Text, _
                        Cbo_desc6.Text, _
                        Cbo_desc7.Text))
End If

Validate_upd_prod = True
Exit Function

ErrHandler:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Function

Private Sub cmd_Execute_Click()
Dim ls_req As String
Dim l_Count As Long, l_Idx As Long
Dim l_Plant As Boolean

On Error GoTo ErrHandler
MouseOff

If Not Control2 Then
    MouseOn
    Exit Sub
End If

If Count_Products = 0 Then
    MouseOn
    SendMessage 189, "No products responding to the actual criteria list.", gut_LangLogin.Code
    Exit Sub
End If

'Plant or supplier ?
l_Plant = True
l_Count = UBound(InfoCombos)
For l_Idx = 0 To l_Count
    If UCase(InfoCombos(l_Idx).TableName) = "PLANTS" Then
        If UCase(Mid(InfoCombos(l_Idx).SelectedCode, 1, 1)) = "P" Then
            ls_req = "EXEC Base_Item_lst3 '"
        Else
            ls_req = "EXEC Base_Item_lst4 '"
            l_Plant = False
        End If
    End If
Next

ls_req = ls_req & QuoteParam(cbo_CategoryCode.List(cbo_Category.ListIndex)) & "'"
    
Build_Req ls_req

Test_Criteria.m_Req = ls_req
Test_Criteria.m_Plant = l_Plant
Test_Criteria.show 1

MouseOn
Exit Sub

ErrHandler:
    StdError
End Sub

Private Sub cmd_Quit_Click()

On Error GoTo ErrHandler

Unload Me

Exit Sub

ErrHandler:
    StdError
End Sub

Private Function Default_Values(ByVal as_TableName As String, ByVal as_code As String, ByVal ai_i As Integer) As Boolean
Dim ls_req As String
Dim ls_ReqToExecute As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim lS_Code As String

Const C_REQ_GETDEFAULTCODE As String = "SELECT $code$ from $matable$ where language_code ='E' and All_None ='$type$' and cg_code = '$cg_code$'"

On Error GoTo Err_DftValues

Default_Values = False

ls_req = Replace(C_REQ_GETDEFAULTCODE, "$code$", as_code, , , vbTextCompare)
ls_req = Replace(ls_req, "$matable$", as_TableName, , , vbTextCompare)
ls_req = Replace(ls_req, "$cg_code$", QuoteParam(cbo_CategoryCode.List(cbo_Category.ListIndex)))

'find "all" if exists
ls_ReqToExecute = Replace(ls_req, "$type$", C_ALL, , , vbTextCompare)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_ReqToExecute) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If

Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        InfoCombos(ai_i).DefaultCode = ODBCData(ll_Statement, 1)
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

If InfoCombos(ai_i).DefaultCode <> C_NOT_USED Then Exit Function

'find "none" if exists
ls_ReqToExecute = Replace(ls_req, "$type$", C_NONE, , , vbTextCompare)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_ReqToExecute) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If

Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        InfoCombos(ai_i).DefaultCode = ODBCData(ll_Statement, 1)
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

Exit Function

Err_DftValues:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Function

Private Function Control2() As Boolean
Dim ll_Idx As Long, ll_Ctr As Long, li_MsgId As Integer

Control2 = KO

If cbo_Category = "" Then
    cbo_Category.SetFocus
    SendMessage 73, "You must fill every fields", gut_LangLogin.Code
    Exit Function
End If

ll_Ctr = UBound(ComboParameters)
For ll_Idx = 0 To ll_Ctr
    
    On Error GoTo NextOne
    
    If Cbo_Desc.Item(ll_Idx).Visible = True Then
        For ll_Ctr = 0 To UBound(InfoCombos)
            'recherche avec le tag
            If InfoCombos(ll_Ctr).TableName = Cbo_Desc.Item(ll_Idx).Tag Then
             'on regarde si la desc est mandatorysi oui et si rien n'est présent ==> erreur
                If InfoCombos(ll_Ctr).Mandatory = True And Cbo_Desc.Item(ll_Idx).Text = "" Then
                    Cbo_Desc.Item(ll_Idx).SetFocus
                    'récupérer le label à concaténer si il existe
                    If InfoCombos(ll_Ctr).MsgId <> 0 Then
                        li_MsgId = InfoCombos(ll_Ctr).MsgId
                    Else
                        li_MsgId = 177
                    End If
                    SendMessage li_MsgId, "You must fill every fields", gut_LangLogin.Code
                    Exit Function
               End If
            End If
        Next ll_Ctr
    End If
  
NextOne:
Next

Control2 = OK
End Function

Private Sub Init_Array()
Dim ll_Combocount As Long
Dim ll_Idx As Long
Dim ll_j As Long
Dim ll_count As Long
Dim ll_Cnt2 As Long
Dim ll_Ctr As Long

On Error GoTo Err_Init_Array

ll_Combocount = Cbo_Desc.Count

' Sizing array
ReDim InfoCombos(ll_Combocount)

' Init array with defaults
ll_count = UBound(InfoCombos)
For ll_Idx = 0 To ll_count
    InfoCombos(ll_Idx).TableName = C_NOT_USED
    InfoCombos(ll_Idx).FieldName = C_NOT_USED
    InfoCombos(ll_Idx).Loaded = False
    InfoCombos(ll_Idx).Mandatory = True
    InfoCombos(ll_Idx).DefaultCode = C_NOT_USED
    InfoCombos(ll_Idx).Used = False
    InfoCombos(ll_Idx).MsgId = 0
    InfoCombos(ll_Idx).SelectedCode = C_NOT_USED
    InfoCombos(ll_Idx).Z_Order = 0
Next

' Maintenant, il faut charger les bonnes valeurs de chaque combos, qu'on identifie par leur tag
ll_count = Cbo_Desc.UBound
'fill array ComboParameters with Combo_Parameter SQL Table
GetComboParameter gs_TableName

Dim ls_Tag As String
For ll_Idx = 0 To ll_count
    ' Existing combo ? Some gaps could exists
    On Error GoTo NotFound
    ls_Tag = Cbo_Desc.Item(ll_Idx).Tag
    On Error GoTo Err_Init_Array
    
' GET INFO FROM TAG & SQL table
    InfoCombos(ll_Idx).TableName = Cbo_Desc.Item(ll_Idx).Tag ' pour tester
    For ll_Ctr = 0 To UBound(ComboParameters)
        If ComboParameters(ll_Ctr).TableName = Cbo_Desc.Item(ll_Idx).Tag Then
            InfoCombos(ll_Idx).Used = True
            InfoCombos(ll_Idx).FieldName = ComboParameters(ll_Ctr).TableCode
            InfoCombos(ll_Idx).MsgId = ComboParameters(ll_Ctr).MsgId
            InfoCombos(ll_Idx).FillProc = ComboParameters(ll_Ctr).FillProc
            InfoCombos(ll_Idx).Z_Order = ComboParameters(ll_Ctr).Z_Order
            InfoCombos(ll_Idx).Label = ComboParameters(ll_Ctr).AssociatedLabel
            
            If UCase(ComboParameters(ll_Ctr).Mandatory) = "N" Then
                InfoCombos(ll_Idx).Mandatory = False
                'Default codes if exist
                Default_Values InfoCombos(ll_Idx).TableName, InfoCombos(ll_Idx).FieldName, ll_Idx
            End If
        
        End If
    Next ll_Ctr
    
    GoTo NextOne
        
NotFound:
    ' fill gaps in the array
    InfoCombos(ll_Idx).TableName = C_NOT_USED
    InfoCombos(ll_Idx).Used = False
    
NextOne:
Next
    
Exit Sub

Err_Init_Array:
End Sub

Private Sub GetComboParameter(ByVal as_Caller As String)
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim lS_Code As String
Dim i As Integer

On Error GoTo Err_GetComboParameter

ls_req = "EXEC Combo_Parameter_lst '" & as_Caller & "'"

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If

ReDim ComboParameters(1)
i = 1

Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ReDim Preserve ComboParameters(i)
        ComboParameters(i).TableName = ODBCData(ll_Statement, 1)
        ComboParameters(i).TableCode = ODBCData(ll_Statement, 2)
        ComboParameters(i).FillProc = ODBCData(ll_Statement, 3)
        ComboParameters(i).Mandatory = ODBCData(ll_Statement, 4)
        ComboParameters(i).AssociatedLabel = ODBCData(ll_Statement, 5)
        ComboParameters(i).MsgId = CInt(ODBCData(ll_Statement, 6))
        ComboParameters(i).Z_Order = CInt(ODBCData(ll_Statement, 7))
        i = i + 1
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

Exit Sub

Err_GetComboParameter:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub

Public Sub FillCboCode(as_req As String, a_Combo As ComboBox, a_Tag As String)
Dim ll_Statement As Long
Dim li_Status As Integer
Dim lS_Code As String
Dim i As Integer
Dim l_Ctr As Long

On Error GoTo ErrHandler

'find the combo FROM TAG
'clear the former code of the combo
'clear the former drop code of the combo
For l_Ctr = 0 To UBound(InfoCombos)
    If InfoCombos(l_Ctr).TableName = a_Tag Then
        ReDim InfoCombos(l_Ctr).CboCode(1)
        ReDim InfoCombos(l_Ctr).DropFlag(1)
        Exit For
    End If
Next
i = 1

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, as_req) Then
    li_Status = SQL_SUCCESS
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            'code
            ReDim Preserve InfoCombos(l_Ctr).CboCode(i)
            InfoCombos(l_Ctr).CboCode(i) = ODBCData(ll_Statement, 1)
            
            'description
            a_Combo.AddItem ODBCData(ll_Statement, 2)
            
            'drop flag
            ReDim Preserve InfoCombos(l_Ctr).DropFlag(i)
            InfoCombos(l_Ctr).DropFlag(i) = ODBCData(ll_Statement, 3)
            
            a_Combo.ItemData(i - 1) = i - 1
            i = i + 1
        End If
    Loop
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

ErrHandler:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub

Private Function Insert_TestProduct() As Boolean
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim lS_Code As String
Dim l_Count As Long, l_Idx As Long

Insert_TestProduct = False

On Error GoTo Err_AddProd
mSource = C_FORM & "/Insert_TestProduct:"

ls_req = "EXEC Test_Link_Products_ins2 "
ls_req = ls_req & gut_Param.Str22 & ",'"
ls_req = ls_req & QuoteParam(cbo_CategoryCode.List(cbo_Category.ListIndex)) & "'"
    
'relecture des combos à l'écran
l_Count = UBound(InfoCombos)
For l_Idx = 0 To l_Count
    If InfoCombos(l_Idx).TableName <> C_NOT_USED Then
        If InfoCombos(l_Idx).SelectedCode <> C_NOT_USED Then
            RetrieveCode InfoCombos(l_Idx).TableName, False
        Else
            RetrieveCode InfoCombos(l_Idx).TableName, True
        End If
        
        If m_Code = "" Or m_Code = C_NOT_USED Then
            mDesc = "No value selected in combo"
            mNumber = C_ERRORRAISE + 190
            Err.Raise mNumber, mSource, mDesc
        End If
        
        ls_req = ls_req & ",'" & QuoteParam(m_Code) & "'"
    End If
Next

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQL_SUCCESS
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            lS_Code = ODBCData(ll_Statement, 1)
        End If
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

If lS_Code = "" Then
    mDesc = "Insert failed"
    mNumber = C_ERRORRAISE + 4
    Err.Raise mNumber, mSource, mDesc
End If


Insert_TestProduct = True
Exit Function

Err_AddProd:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Function

Private Sub RetrieveCode(as_Table As String, ab_DefaultCode As Boolean)
Dim l_Ctr As Long

m_Code = ""

For l_Ctr = 0 To UBound(InfoCombos)
    If UCase(InfoCombos(l_Ctr).TableName) = UCase(as_Table) Then
        Exit For
    End If
Next

If ab_DefaultCode Then
    m_Code = InfoCombos(l_Ctr).DefaultCode
Else
    m_Code = InfoCombos(l_Ctr).SelectedCode
End If

End Sub

Private Sub HideOldControls()

cbo_Desc2.Visible = False
cbo_Desc3.Visible = False
cbo_Desc4.Visible = False
Cbo_desc5.Visible = False
Cbo_desc6.Visible = False
Cbo_desc7.Visible = False
Cbo_desc8.Visible = False
Cbo_desc9.Visible = False
Cbo_desc10.Visible = False
Cbo_desc11.Visible = False
Cbo_desc12.Visible = False

cbo_Code2.Visible = False
cbo_Code3.Visible = False
cbo_Code4.Visible = False
cbo_code5.Visible = False
cbo_code6.Visible = False
cbo_code7.Visible = False
cbo_code8.Visible = False
cbo_code9.Visible = False
cbo_code10.Visible = False
cbo_code11.Visible = False
cbo_code12.Visible = False
    
End Sub

Private Sub DynamicSet()

On Error Resume Next
'set top position
Cbo_Desc(1).Top = cbo_Desc2.Top
Cbo_Desc(2).Top = cbo_Desc3.Top
Cbo_Desc(3).Top = cbo_Desc4.Top
Cbo_Desc(4).Top = Cbo_desc5.Top
Cbo_Desc(5).Top = Cbo_desc6.Top
Cbo_Desc(6).Top = Cbo_desc7.Top
Cbo_Desc(7).Top = Cbo_desc8.Top
Cbo_Desc(8).Top = Cbo_desc9.Top
Cbo_Desc(9).Top = Cbo_desc10.Top
Cbo_Desc(10).Top = Cbo_desc11.Top

'set left position
Cbo_Desc(1).Left = cbo_Desc2.Left
Cbo_Desc(2).Left = cbo_Desc3.Left
Cbo_Desc(3).Left = cbo_Desc4.Left
Cbo_Desc(4).Left = Cbo_desc5.Left
Cbo_Desc(5).Left = Cbo_desc6.Left
Cbo_Desc(6).Left = Cbo_desc7.Left
Cbo_Desc(7).Left = Cbo_desc8.Left
Cbo_Desc(8).Left = Cbo_desc9.Left
Cbo_Desc(9).Left = Cbo_desc10.Left
Cbo_Desc(10).Left = Cbo_desc11.Left

End Sub

Private Function Count_Products() As Long
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim li_Rows As Integer

Count_Products = 0

On Error GoTo Err_CntProd

ls_req = "EXEC Base_Item_cnt '"
ls_req = ls_req & QuoteParam(cbo_CategoryCode.List(cbo_Category.ListIndex)) & "'"
    
Build_Req ls_req

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQL_SUCCESS
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            Count_Products = CInt(ODBCData(ll_Statement, 1))
        End If
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

Exit Function

Err_CntProd:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Function

Private Sub Build_Req(as_req As String)
Dim l_Count As Long, l_Idx As Long

On Error GoTo Err_BuildReq
'~ read combos sorted
l_Count = UBound(InfoCombos)
For l_Idx = 0 To l_Count
    If InfoCombos(l_Idx).TableName <> C_NOT_USED Then
        If InfoCombos(l_Idx).SelectedCode = InfoCombos(l_Idx).DefaultCode Or InfoCombos(l_Idx).SelectedCode = C_NOT_USED Then
            as_req = as_req & ",null"
        Else
            as_req = as_req & ",'" & InfoCombos(l_Idx).SelectedCode & "'"
        End If
    End If
Next

Err_BuildReq:
End Sub

Private Sub Clear_Combos()
Dim l_Idx As Long, l_Count As Long

On Error GoTo Err_ClearCbo

l_Count = Cbo_Desc.UBound

For l_Idx = 1 To l_Count
    Cbo_Desc.Item(l_Idx).Clear
Next

Err_ClearCbo:
End Sub

Private Sub LabelBold(a_Label As String)
Dim ls_Count As Integer

On Error GoTo Err_LabelBold

For ls_Count = 0 To Me.Count - 1
    If UCase(TypeName(Me.Controls(ls_Count))) = "LABEL" Then
        If UCase(Me.Controls(ls_Count).Tag) = UCase(a_Label) Then
            Me.Controls(ls_Count).FontBold = True
            Exit Sub
        End If
    End If
Next
Exit Sub

Err_LabelBold:
End Sub
'P592 begin
Private Function Insert_WebGroup() As Boolean
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long

Dim l_Count As Long, l_Idx As Long

Insert_WebGroup = False

On Error GoTo Err_AddWebGroup

mSource = C_FORM & "/Insert_WebGroup:"
ls_req = "EXEC Grid_WebGroup_ins " & gs_TableCode

'relecture des combos à l'écran
l_Count = UBound(ComboParameters)
For l_Idx = 0 To l_Count
    If InfoCombos(l_Idx).TableName <> C_NOT_USED Then
        If InfoCombos(l_Idx).SelectedCode <> C_NOT_USED Then
            RetrieveCode InfoCombos(l_Idx).TableName, False
        Else
            RetrieveCode InfoCombos(l_Idx).TableName, True
        End If
        
        If m_Code = "" Or m_Code = C_NOT_USED Then
            mDesc = "No value selected in combo"
            mNumber = C_ERRORRAISE + 190
            Err.Raise mNumber, mSource, mDesc
        End If
        
        ls_req = ls_req & ",'" & QuoteParam(m_Code) & "'"
    End If
Next

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLRowCount(ll_Statement, ll_lngrows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_lngrows = 0 Then
        Err.Raise C_ERRORRAISE + 289, C_FORM & "/Insert_WebGroup", ls_req & " failed"
    End If
Else
'TODO: Existing link message
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    mDesc = "Grid_WebGroup_ins failure"
    mNumber = C_ERRORRAISE + 190
    Err.Raise mNumber, mSource, mDesc
End If

Insert_WebGroup = True
Exit Function

Err_AddWebGroup:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Function
'P592 end
