VERSION 5.00
Begin VB.Form TestMar2 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   6495
   ClientLeft      =   795
   ClientTop       =   300
   ClientWidth     =   6825
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6495
   ScaleWidth      =   6825
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmd_Out2 
      Height          =   600
      Left            =   2930
      Style           =   1  'Graphical
      TabIndex        =   22
      Top             =   5100
      Width           =   600
   End
   Begin VB.CommandButton cmd_In2 
      Height          =   600
      Left            =   2930
      Style           =   1  'Graphical
      TabIndex        =   21
      Top             =   4400
      Width           =   600
   End
   Begin VB.CommandButton cmd_Out 
      Height          =   600
      Left            =   2930
      Style           =   1  'Graphical
      TabIndex        =   20
      Top             =   2200
      Width           =   600
   End
   Begin VB.CommandButton cmd_In 
      Height          =   600
      Left            =   2930
      Style           =   1  'Graphical
      TabIndex        =   19
      Top             =   1500
      Width           =   600
   End
   Begin VB.PictureBox ButtonBox 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   612
      Left            =   0
      ScaleHeight     =   585
      ScaleWidth      =   9405
      TabIndex        =   13
      Top             =   0
      Width           =   9432
      Begin VB.PictureBox pic_Save 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "TESTMAR2.frx":0000
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   120
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   18
         Top             =   120
         Width           =   384
      End
      Begin VB.PictureBox pic_Quit 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   384
         Left            =   2280
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   17
         Top             =   120
         Width           =   384
      End
      Begin VB.PictureBox pic_Undo 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "TESTMAR2.frx":030A
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   660
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   16
         Top             =   120
         Width           =   384
      End
      Begin VB.PictureBox pic_Toolbox 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   1200
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   15
         Top             =   120
         Visible         =   0   'False
         Width           =   384
      End
      Begin VB.PictureBox pic_Camera 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   384
         Left            =   1740
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   14
         Top             =   120
         Visible         =   0   'False
         Width           =   384
      End
   End
   Begin VB.ListBox Lst_CountryIn 
      Height          =   1815
      Left            =   4320
      Sorted          =   -1  'True
      TabIndex        =   8
      Top             =   4320
      Width           =   2010
   End
   Begin VB.ListBox lst_CountryToDelete 
      Height          =   840
      Left            =   3840
      Sorted          =   -1  'True
      TabIndex        =   7
      Top             =   3720
      Visible         =   0   'False
      Width           =   1530
   End
   Begin VB.ListBox lst_CountryToInsert 
      Height          =   840
      Left            =   2280
      Sorted          =   -1  'True
      TabIndex        =   6
      Top             =   3720
      Visible         =   0   'False
      Width           =   1530
   End
   Begin VB.ListBox lst_CountryOut 
      Height          =   1815
      Left            =   120
      Sorted          =   -1  'True
      TabIndex        =   5
      Top             =   4320
      Width           =   2010
   End
   Begin VB.ListBox lst_MarketToDelete 
      Height          =   450
      Left            =   2460
      Sorted          =   -1  'True
      TabIndex        =   4
      Top             =   3120
      Visible         =   0   'False
      Width           =   1530
   End
   Begin VB.ListBox lst_MarketToInsert 
      Height          =   450
      Left            =   2400
      Sorted          =   -1  'True
      TabIndex        =   3
      Top             =   1080
      Visible         =   0   'False
      Width           =   1530
   End
   Begin VB.ListBox lst_MarketOut 
      Height          =   2400
      Left            =   180
      Sorted          =   -1  'True
      TabIndex        =   2
      Top             =   1260
      Width           =   2010
   End
   Begin VB.ListBox lst_Marketin 
      Height          =   2400
      Left            =   4260
      Sorted          =   -1  'True
      TabIndex        =   1
      Top             =   1260
      Width           =   2010
   End
   Begin VB.ListBox lst_CountryOutNotShow 
      Height          =   840
      Left            =   0
      Sorted          =   -1  'True
      TabIndex        =   0
      Top             =   4540
      Visible         =   0   'False
      Width           =   2055
   End
   Begin VB.Label lbl_Exceptions 
      Alignment       =   2  'Center
      Caption         =   "Exceptions"
      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            =   4260
      TabIndex        =   12
      Top             =   4000
      Width           =   1995
   End
   Begin VB.Label lbl_Countries 
      Alignment       =   2  'Center
      Caption         =   "Countries"
      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            =   180
      TabIndex        =   11
      Top             =   4000
      Width           =   1995
   End
   Begin VB.Label lbl_Selected 
      Alignment       =   2  'Center
      Caption         =   "Selected"
      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            =   4260
      TabIndex        =   10
      Top             =   960
      Width           =   1995
   End
   Begin VB.Label lbl_Available 
      Alignment       =   2  'Center
      Caption         =   "Available"
      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        =   9
      Top             =   960
      Width           =   1995
   End
End
Attribute VB_Name = "TestMar2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim m_Array_Loaded As Boolean
Dim MarketsCountries() As MarketCountry
Private Type MarketCountry
    TMK_Code As Integer
    TMK_Desc As String
    CT_Code As String
    CT_Desc As String
End Type
Dim m_Countries() As String

Private Sub Form_Load()

On Error GoTo suite

MouseOff

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

'pictures of the menu bar
pic_Camera.Picture = LoadResPicture(RES_PHOTO, 1)
pic_Undo.Picture = LoadResPicture(RES_CANCEL, 1)
pic_Save.Picture = LoadResPicture(RES_OK, 1)
pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_Toolbox.Picture = LoadResPicture(RES_TOOL, 1)

'pictures of the buttons on the screen
cmd_In.Picture = LoadResPicture(RES_RIGHT, 1)
cmd_Out.Picture = LoadResPicture(RES_LEFT, 1)
cmd_In2.Picture = LoadResPicture(RES_RIGHT, 1)
cmd_Out2.Picture = LoadResPicture(RES_LEFT, 1)
top = 0
left = 0

m_Array_Loaded = False

ReadConstants
Select Case gs_Action

Case "Update"
    
    FillTabMarket

End Select

MouseOn
Exit Sub

suite:
MouseOn
StdError
End Sub

Private Function UpdTestMarket() As Boolean
'------------------------------------------------------------------
' Name : UpdTestMarket
'
' Purpose : insert or update a row in table Market
'
' Parameters : None
' Return values : true if updated
'                 false if update failed
'
' review : 04/01/1999 by JJB
'------------------------------------------------------------------

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim ls_Line As String
Dim li_Count As Integer
'Dim ls_DropFlag As String
'Dim ls_DropDate As String

UpdTestMarket = KO

On Error GoTo suite

For li_Count = 0 To lst_MarketToInsert.ListCount - 1
    ls_Req = "EXEC Test_link_Markets_Ins " _
        & CStr(gi_TestCode) & ", '" _
        & gut_LangLogin.Code & "', '" _
        & lst_MarketToInsert.List(li_Count) & "'"
    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
            SendMessage 3, "Update failed", gut_LangLogin.Code
            Exit Function
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 3, "Update failed", gut_LangLogin.Code
        Exit Function
    End If
Next li_Count

For li_Count = 0 To lst_MarketToDelete.ListCount - 1
    ls_Req = "EXEC Test_Link_Markets_Del " _
        & CStr(gi_TestCode) & ", '" _
        & gut_LangLogin.Code & "', '" _
        & lst_MarketToDelete.List(li_Count) & "'"
    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
            SendMessage 3, "Update failed", gut_LangLogin.Code
            Exit Function
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 3, "Update failed", gut_LangLogin.Code
        Exit Function
    End If
Next li_Count
For li_Count = 0 To lst_CountryToInsert.ListCount - 1
    ls_Req = "EXEC Test_Countries_exception_Ins " _
        & CStr(gi_TestCode) & ", '" _
        & gut_LangLogin.Code & "', '" _
        & lst_CountryToInsert.List(li_Count) & "'"
    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
            SendMessage 3, "Update failed", gut_LangLogin.Code
            Exit Function
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 3, "Update failed", gut_LangLogin.Code
        Exit Function
    End If
Next li_Count
For li_Count = 0 To lst_CountryToDelete.ListCount - 1
    ls_Req = "EXEC Test_Countries_exception_Del " _
        & CStr(gi_TestCode) & ", '" _
        & gut_LangLogin.Code & "', '" _
        & lst_CountryToDelete.List(li_Count) & "'"
    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
            SendMessage 3, "Update failed", gut_LangLogin.Code
            Exit Function
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 3, "Update failed", gut_LangLogin.Code
        Exit Function
    End If
Next li_Count
UpdTestMarket = OK
Exit Function

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Function


Private Sub FillTabMarket()

lst_Marketin.Clear
lst_MarketOut.Clear
lst_MarketToInsert.Clear
lst_MarketToDelete.Clear

Lst_CountryIn.Clear
lst_CountryOut.Clear
lst_CountryOutNotShow.Clear
lst_CountryToInsert.Clear
lst_CountryToDelete.Clear

FillLstSingle "Exec Test_link_Markets_t_lst " & CStr(gi_TestCode) & ",'" & gut_LangLogin.Code & "'", lst_Marketin
FillLstSingle "Exec Test_link_Markets_t_lst2 " & CStr(gi_TestCode) & ",'" & gut_LangLogin.Code & "'", lst_MarketOut
FillLstSingle "Exec Test_countries_exception_t_lst " & CStr(gi_TestCode) & ",'" & gut_LangLogin.Code & "'", Lst_CountryIn

End Sub

Private Sub ReadConstants()

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Field, ls_Text As String
Dim ls_Title As String
On Error GoTo Err_ReadConstants


ls_Req = "EXEC Screen_Csts 'TestGen', '" & gut_LangLogin.Code & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) 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
        ls_Field = ODBCData(ll_Statement, 1)
        ls_Text = ODBCData(ll_Statement, 2)
        Select Case ls_Field
        Case "title2": Caption = ls_Text
        Case "titleA"
            If gs_Action = "Add" Then
                ls_Title = ls_Text
            End If
        Case "titleU"
            If gs_Action = "Update" Then
                ls_Title = ls_Text
            End If
        Case "titleD"
            If gs_Action = "Delete" Then
                ls_Title = ls_Text
            End If
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Caption = Caption & " : " & ls_Title
Exit Sub

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

Private Sub Lst_CountryIn_DblClick()
    cmd_out2_Click
End Sub

Private Sub lst_CountryOut_DblClick()
    cmd_in2_Click
End Sub

Private Sub lst_MarketIn_Click()
Dim li_CountCountryIn As Integer
Dim li_CountCountryOut As Integer

' show the list of countries of the market dblclicked
MouseOff

ReDim m_Countries(0)
lst_CountryOut.Clear

FillLstSingle "Exec Test_Market_contains_t_lst3 '" & QuoteParam(lst_Marketin.List(lst_Marketin.ListIndex)) & "'," & gs_CodeCategory & ",'" & gut_LangLogin.Code & "'", lst_CountryOut
' but delete all countries that are in countries exception
For li_CountCountryIn = 0 To Lst_CountryIn.ListCount - 1
    For li_CountCountryOut = 0 To lst_CountryOut.ListCount - 1
        'fill possible countries array for a selected market
        ReDim Preserve m_Countries(li_CountCountryOut)
        m_Countries(li_CountCountryOut) = lst_CountryOut.List(li_CountCountryOut)
        If lst_CountryOut.List(li_CountCountryOut) = Lst_CountryIn.List(li_CountCountryIn) Then
            lst_CountryOut.RemoveItem li_CountCountryOut
            lst_CountryOutNotShow.AddItem Lst_CountryIn.List(li_CountCountryIn)
            Exit For
        End If
    Next
Next


MouseOn

End Sub

Private Sub cmd_In_Click()
Dim li_Count As Integer

MouseOff
If lst_MarketOut.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_MarketToDelete, lst_MarketOut.Text) Then
        lst_MarketToInsert.AddItem lst_MarketOut.Text
    End If
    lst_Marketin.AddItem lst_MarketOut
    ' select the added item
    For li_Count = 0 To lst_Marketin.ListCount - 1
          If lst_Marketin.List(li_Count) = lst_MarketOut Then
            lst_Marketin.Selected(li_Count) = OK
          End If
    Next li_Count
'    MsgBox lst_MarketIn.ListIndex
    lst_MarketOut.RemoveItem lst_MarketOut.ListIndex
End If
MouseOn
End Sub

Private Sub cmd_in2_Click()
MouseOff
If lst_CountryOut.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_CountryToDelete, lst_CountryOut.Text) Then
        lst_CountryToInsert.AddItem lst_CountryOut.Text
    End If
    Lst_CountryIn.AddItem lst_CountryOut
    lst_CountryOutNotShow.AddItem lst_CountryOut
    lst_CountryOut.RemoveItem lst_CountryOut.ListIndex
End If
MouseOn

End Sub

Private Sub cmd_out_Click()
MouseOff
lst_CountryOut.Clear
If lst_Marketin.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_MarketToInsert, lst_Marketin.Text) Then
        lst_MarketToDelete.AddItem lst_Marketin.Text
    End If
    lst_MarketOut.AddItem lst_Marketin
    lst_Marketin.RemoveItem lst_Marketin.ListIndex

End If
MouseOn
End Sub


Private Sub cmd_out2_Click()
Dim li_CountCountryOutNotShow As Integer
Dim l_Array As Integer

MouseOff
If Lst_CountryIn.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_CountryToInsert, Lst_CountryIn.Text) Then
        lst_CountryToDelete.AddItem Lst_CountryIn.Text
    End If
    For li_CountCountryOutNotShow = 0 To lst_CountryOutNotShow.ListCount - 1
            If lst_CountryOutNotShow.List(li_CountCountryOutNotShow) = Lst_CountryIn Then
                lst_CountryOutNotShow.RemoveItem li_CountCountryOutNotShow
                'Is the country removed from exception is a part of the market in with focus
                For l_Array = 0 To UBound(m_Countries)
                    If Lst_CountryIn = m_Countries(l_Array) Then
                        lst_CountryOut.AddItem Lst_CountryIn
                        Exit For
                    End If
                Next l_Array
             Exit For
        End If
    Next
    Lst_CountryIn.RemoveItem Lst_CountryIn.ListIndex
End If
MouseOn

End Sub

Private Sub lst_Marketin_DblClick()
    cmd_out_Click
End Sub

Private Sub lst_MarketOut_DblClick()
    cmd_In_Click
End Sub

Private Sub pic_quit_Click()
MouseOff
Unload Me
MouseOn
End Sub

Private Sub pic_Save_Click()

If Not Control Then Exit Sub

MouseOff

If UpdTestMarket() Then
    gb_Return = OK
    Unload Me
End If

MouseOn

End Sub

Private Sub pic_UnDo_Click()

FillTabMarket

End Sub

Private Function Control() As Boolean
Dim l_In As Integer, l_MaxArr As Long, l_Arr As Long, l_MktIn As Long
Dim l_Mkt As Long
Dim l_Market As String, l_Country As String
Dim l_Bool As Boolean, l_Exist As Boolean

Control = False

'control on exception list
If Lst_CountryIn.ListCount <> 0 Then
    'No market selected.
    If lst_Marketin.ListCount = 0 Then
        lst_Marketin.SetFocus
        SendMessage 192, "No market selected.", gut_LangLogin.Code
        MouseOn
        Exit Function
    End If
    
    'Exception match with at least one selected maket ?
    If Not m_Array_Loaded Then Fill_MarketsCountries
    
    l_MaxArr = UBound(MarketsCountries)
    l_Market = ""
    l_Bool = False
    
    'Read countries execption list
    For l_In = 0 To Lst_CountryIn.ListCount - 1
        'What is the market for this exception ?
        For l_Arr = 0 To l_MaxArr
            If MarketsCountries(l_Arr).CT_Desc = Lst_CountryIn.List(l_In) Then
                l_Market = MarketsCountries(l_Arr).TMK_Desc
                Exit For
            End If
        Next l_Arr
        'Is this market in selected list ?
        l_Bool = False
        For l_MktIn = 0 To lst_Marketin.ListCount - 1
            If lst_Marketin.List(l_MktIn) = l_Market Then
                l_Bool = True
                Exit For
            End If
        Next l_MktIn
        
        If Not l_Bool Then
            lst_Marketin.SetFocus
            'SendMessage 193, "Excepted country not contained in a selected market.", gut_LangLogin.Code
            MsgBox "Excepted country: " & Lst_CountryIn.List(l_In) & " not contained in a selected market."
            MouseOn
            Exit Function
        End If
    Next l_In

    'All countries of a market are in exception ?
    'Read market selected list
    For l_Mkt = 0 To lst_Marketin.ListCount - 1
        'What are the countries for this market ?
        l_Bool = False
        
        For l_Arr = 0 To l_MaxArr
            If MarketsCountries(l_Arr).TMK_Desc = lst_Marketin.List(l_Mkt) Then
                l_Country = MarketsCountries(l_Arr).CT_Desc
                'Read countries execption list
                l_Exist = False
                
                For l_In = 0 To Lst_CountryIn.ListCount - 1
                    'is the country in the exception list ?
                    If Lst_CountryIn.List(l_In) = l_Country Then
                        l_Exist = True
                        Exit For
                    End If
                Next l_In
                
                'If country is not in exception ==> stop reading for this market, no error
                If Not l_Exist Then
                    l_Bool = True
                    Exit For
                End If
            End If
        Next l_Arr
        
        
        If Not l_Bool Then
            lst_Marketin.SetFocus
            'SendMessage 194, "All the countries of the selected market are in exception list.", gut_LangLogin.Code
            MsgBox "All the countries of market: " & lst_Marketin.List(l_Mkt) & " are in exception list."
            MouseOn
            Exit Function
        End If
    Next l_Mkt
    
End If

Control = True

End Function

Private Sub Fill_MarketsCountries()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim i As Integer

On Error GoTo Err_Fill_MarketsCountries

If m_Array_Loaded Then Exit Sub

ls_Req = "EXEC Test_Market_Contains_lst " & gs_CodeCategory & ",'" & gut_LangLogin.Code & "'"
ReDim MarketsCountries(1)
i = 1

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) 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
        ReDim Preserve MarketsCountries(i)
        MarketsCountries(i).TMK_Code = ODBCData(ll_Statement, 1)
        MarketsCountries(i).TMK_Desc = ODBCData(ll_Statement, 2)
        MarketsCountries(i).CT_Code = ODBCData(ll_Statement, 3)
        MarketsCountries(i).CT_Desc = ODBCData(ll_Statement, 4)
        i = i + 1
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

m_Array_Loaded = True
Exit Sub

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


