VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Test_Market_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   5925
   ClientLeft      =   1380
   ClientTop       =   840
   ClientWidth     =   7800
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   5925
   ScaleWidth      =   7800
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.TabStrip tbs_Market 
      Height          =   375
      Left            =   120
      TabIndex        =   30
      Top             =   1260
      Width           =   7575
      _ExtentX        =   13361
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   2
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Contained countries"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Accepted standards"
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin VB.CommandButton SSC_dropped 
      Height          =   276
      Left            =   2880
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   5460
      Width           =   252
   End
   Begin VB.CommandButton cmd_Save 
      Height          =   612
      Left            =   6300
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   5160
      Width           =   612
   End
   Begin VB.CommandButton cmd_Quit 
      Height          =   612
      Left            =   7020
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   5160
      Width           =   612
   End
   Begin VB.ComboBox Cbo_Type 
      Enabled         =   0   'False
      Height          =   288
      Left            =   2280
      Style           =   2  'Dropdown List
      TabIndex        =   11
      Top             =   480
      Visible         =   0   'False
      Width           =   1812
   End
   Begin VB.ComboBox Cbo_Type2 
      Enabled         =   0   'False
      Height          =   288
      Left            =   3540
      Style           =   2  'Dropdown List
      TabIndex        =   10
      TabStop         =   0   'False
      Top             =   480
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_Category 
      Height          =   288
      Left            =   180
      Style           =   2  'Dropdown List
      TabIndex        =   8
      Top             =   480
      Width           =   1812
   End
   Begin VB.ComboBox cbo_Category2 
      Height          =   288
      Left            =   1440
      Style           =   2  'Dropdown List
      TabIndex        =   7
      TabStop         =   0   'False
      Top             =   480
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.CheckBox chk_Int 
      Caption         =   "Check1"
      Height          =   252
      Left            =   1680
      TabIndex        =   3
      Top             =   5100
      Width           =   252
   End
   Begin VB.TextBox txt_dropped 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   1680
      Locked          =   -1  'True
      TabIndex        =   2
      Top             =   5460
      Width           =   1212
   End
   Begin VB.TextBox Txt_desc 
      Height          =   285
      Left            =   1980
      MaxLength       =   50
      TabIndex        =   0
      Top             =   960
      Width           =   3135
   End
   Begin VB.Frame frm_tabMarket 
      Height          =   3435
      Index           =   1
      Left            =   120
      TabIndex        =   24
      Top             =   1560
      Width           =   7575
      Begin MSFlexGridLib.MSFlexGrid grd_Standard 
         Height          =   2475
         Left            =   60
         TabIndex        =   31
         Top             =   900
         Width           =   7455
         _ExtentX        =   13150
         _ExtentY        =   4366
         _Version        =   393216
         Cols            =   6
         FixedCols       =   0
         AllowBigSelection=   0   'False
         SelectionMode   =   1
         AllowUserResizing=   1
      End
      Begin VB.PictureBox ButtonBox 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   612
         Left            =   120
         ScaleHeight     =   585
         ScaleWidth      =   7365
         TabIndex        =   25
         Top             =   240
         Width           =   7392
         Begin VB.PictureBox pic_delete 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   0  'None
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   384
            Left            =   1320
            ScaleHeight     =   390
            ScaleWidth      =   390
            TabIndex        =   29
            Top             =   120
            Width           =   384
         End
         Begin VB.PictureBox pic_upd 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   0  'None
            DragIcon        =   "TESTMK.frx":0000
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   384
            Left            =   720
            ScaleHeight     =   390
            ScaleWidth      =   390
            TabIndex        =   28
            Top             =   120
            Width           =   384
         End
         Begin VB.PictureBox pic_refresh 
            AutoSize        =   -1  'True
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   0  'None
            Height          =   384
            Left            =   1920
            ScaleHeight     =   390
            ScaleWidth      =   390
            TabIndex        =   27
            Top             =   120
            Width           =   384
         End
         Begin VB.PictureBox pic_add 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   0  'None
            DragIcon        =   "TESTMK.frx":030A
            BeginProperty Font 
               Name            =   "Arial"
               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        =   26
            Top             =   120
            Width           =   384
         End
      End
   End
   Begin VB.Frame frm_tabMarket 
      Height          =   3435
      Index           =   0
      Left            =   120
      TabIndex        =   15
      Top             =   1560
      Width           =   7575
      Begin VB.ListBox lst_ToDelete 
         Height          =   645
         Left            =   2880
         Sorted          =   -1  'True
         TabIndex        =   21
         Top             =   2580
         Visible         =   0   'False
         Width           =   1530
      End
      Begin VB.ListBox lst_ToInsert 
         Height          =   645
         Left            =   2820
         Sorted          =   -1  'True
         TabIndex        =   20
         Top             =   240
         Visible         =   0   'False
         Width           =   1530
      End
      Begin VB.PictureBox pic_In 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   3420
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   19
         Top             =   1320
         Width           =   408
      End
      Begin VB.PictureBox pic_Out 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   3420
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   18
         Top             =   2040
         Width           =   408
      End
      Begin VB.ListBox lst_CountryOut 
         Height          =   2010
         Left            =   600
         Sorted          =   -1  'True
         TabIndex        =   17
         Top             =   720
         Width           =   2010
      End
      Begin VB.ListBox lst_CountryIn 
         Height          =   2010
         Left            =   4680
         Sorted          =   -1  'True
         TabIndex        =   16
         Top             =   720
         Width           =   2010
      End
      Begin VB.Label lbl_Selected 
         Alignment       =   2  'Center
         Caption         =   "Selected"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   4680
         TabIndex        =   23
         Top             =   420
         Width           =   1995
      End
      Begin VB.Label lbl_Available 
         Alignment       =   2  'Center
         Caption         =   "Available"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   600
         TabIndex        =   22
         Top             =   420
         Width           =   1995
      End
   End
   Begin VB.Label Lbl_Type 
      Alignment       =   2  'Center
      Caption         =   "Type"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   2280
      TabIndex        =   12
      Top             =   180
      Visible         =   0   'False
      Width           =   1812
   End
   Begin VB.Label lbl_Categ 
      Alignment       =   2  'Center
      Caption         =   "Category"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   180
      TabIndex        =   9
      Top             =   180
      Width           =   1812
   End
   Begin VB.Label lbl_Drop 
      Caption         =   "Drop date"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   5
      Top             =   5460
      Width           =   1452
   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          =   252
      Left            =   120
      TabIndex        =   4
      Top             =   5100
      Width           =   1452
   End
   Begin VB.Label lbl_desc 
      Caption         =   "Description"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   180
      TabIndex        =   1
      Top             =   960
      Width           =   1752
   End
End
Attribute VB_Name = "Test_Market_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim mi_MarketCode As Integer
Dim ms_IntFlag As String
Dim mb_CategNotLoaded As Boolean
Dim mb_TypeNotLoaded As Boolean

Private Sub Cbo_category_Click()
Dim ls_Req As String

MouseOff

If UCase(gs_Action) = "ADD" Then
    lst_CountryOut.Clear
    
    ls_Req = "Test_Market_contains_cbo " & cbo_Category2.List(cbo_Category.ListIndex) & ", '" & gut_LangWork.Code & "'"

    FillLstSingle ls_Req, lst_CountryOut
End If

MouseOn

End Sub

Private Sub Cbo_category_DropDown()
'/* debut modif */
Dim ls_Categ As String

MouseOff
If mb_CategNotLoaded Then
    mb_CategNotLoaded = KO
    If cbo_Category.ListIndex <> -1 Then
        ls_Categ = cbo_Category2.List(cbo_Category.ListIndex)
    Else
        ls_Categ = ""
    End If
    cbo_Category2.Clear
    cbo_Category.Clear
    FillCbo "Test_Category4", cbo_Category2, cbo_Category
    If ls_Categ <> "" Then
        cbo_Category.ListIndex = ComboFindItem(cbo_Category2, ls_Categ)
    End If
End If
MouseOn
'/* fin modif */
End Sub


Private Sub Cbo_type_DropDown()
'/* debut modif */

Dim ls_Type As String
Dim ls_Req As String

MouseOff
If mb_TypeNotLoaded Then
    mb_TypeNotLoaded = KO
    If cbo_Type.ListIndex <> -1 Then
        ls_Type = Cbo_Type2.List(cbo_Type.ListIndex)
    Else
        ls_Type = ""
    End If
    Cbo_Type2.Clear
    cbo_Type.Clear
    ls_Req = "EXEC Test_Type_cbo " _
     & cbo_Category2.List(cbo_Category.ListIndex) _
     & ", '" & gut_LangWork.Code & "'"
    FillCbo ls_Req, Cbo_Type2, cbo_Type
    If ls_Type <> "" Then
        cbo_Type.ListIndex = ComboFindItem(Cbo_Type2, ls_Type)
    End If
End If
MouseOn
MouseOn
'/* fin modif */
End Sub


Private Sub Form_Load()

Dim ls_Req As String

On Error GoTo suite

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)
SSC_dropped.Picture = LoadResPicture(RES_DOWN2, vbResIcon)

pic_add.Picture = LoadResPicture(RES_ADD, 1)
pic_delete.Picture = LoadResPicture(RES_DELETE, 1)
pic_refresh.Picture = LoadResPicture(RES_REFRESH, 1)
pic_upd.Picture = LoadResPicture(RES_MODIFY, 1)
pic_In.Picture = LoadResPicture(RES_RIGHT, 1)
pic_Out.Picture = LoadResPicture(RES_LEFT, 1)
    
    ' NEW 22.1.2005 remove SSTab begin
    Call InitTabStrip(tbs_Market, frm_tabMarket)
    ' NEW 22.1.2005 remove SSTab end

Getcsts
grd_Standard.ColWidth(0) = 1
grd_Standard.ColWidth(1) = 2000
'/* Debut Modif */
'grd_Standard.ColWidth(2) = 1
'grd_Standard.ColWidth(3) = 2000
grd_Standard.ColWidth(2) = 1500
grd_Standard.ColWidth(3) = 1
grd_Standard.ColWidth(4) = 1
grd_Standard.ColWidth(5) = 1
grd_Standard.ColAlignment(1) = flexAlignLeftCenter
grd_Standard.ColAlignment(2) = flexAlignLeftCenter
'/* Fin modif */
Set gut_Param2.Parent = Me
gut_Param2.Str1 = gs_TableCode
Select Case gs_Action
Case "Add"
    ' NEW 22.1.2005 remove SSTab begin
    tbs_Market.Tabs.Remove ("_1")
    ' NEW 22.1.2005 remove SSTab end
'    tab_Market.TabVisible(1) = KO
    '/* Debut modif */
    mb_CategNotLoaded = OK
    mb_TypeNotLoaded = OK
    '/* Fin modif */
' pour éviter de saisir un pays dans 2 marchés différents, il faut attendre de connaître le cat_code
'    FillLstSingle "Countries" , lst_CountryOut
Case "Update"
    mi_MarketCode = gs_TableCode
    '/*** modif ****/
    cbo_Category.Enabled = KO
    cbo_Category.AddItem gs_TableCode4
    cbo_Category2.AddItem gs_TableCode3
    cbo_Category.ListIndex = 0
    
   
    txt_Desc = gs_TableCode5
    If gs_TableCode6 = "X" Then
        chk_Int.value = 1
    End If
    txt_dropped = gs_TableCode7
    '/*** fin modif ***/
    ls_Req = "EXEC Test_Market_Contains_t_lst " _
        & gs_TableCode & ", '" _
        & gut_LangWork.Code & "'"
    FillLstSingle ls_Req, Lst_CountryIn
    ls_Req = "EXEC Test_Market_Contains_t_lst2 " & cbo_Category2.List(cbo_Category.ListIndex) & ", '" & gut_LangWork.Code & "'"
    FillLstSingle ls_Req, lst_CountryOut
    '/*** modif temp ****/
    FillGridAccepts 3
    '/*** fin modif temp ***/
Case "Delete"
    txt_Desc.Enabled = KO
    chk_Int.Enabled = KO
    SSC_dropped.Visible = KO
    pic_In.Enabled = KO
    pic_Out.Enabled = KO
    pic_In.Visible = KO
    pic_Out.Visible = KO
    pic_add.Enabled = KO
    pic_delete.Enabled = KO
    pic_upd.Enabled = KO
    mi_MarketCode = gs_TableCode
    ButtonBox.Visible = KO

    
    '/* debut modif */
    cbo_Category.Enabled = KO
    cbo_Category.AddItem gs_TableCode4
    cbo_Category2.AddItem gs_TableCode3
    cbo_Category.ListIndex = 0
    
    txt_Desc = gs_TableCode5
    If gs_TableCode6 = "X" Then
        chk_Int.value = 1
    End If
    txt_dropped = gs_TableCode7
    '/* fin modif */
    ls_Req = "EXEC Test_Market_Contains_t_lst " _
        & gs_TableCode & ", '" _
        & gut_LangWork.Code & "'"
    FillLstSingle ls_Req, Lst_CountryIn
    '/* modif temp */
    FillGridAccepts 3
    '/* fin modif temp */

'start change
Case "MoreInfo"
    txt_Desc.Enabled = KO
    chk_Int.Enabled = KO
    SSC_dropped.Visible = KO
    cmd_Save.Visible = KO
    pic_In.Enabled = KO
    pic_Out.Enabled = KO
    pic_In.Visible = KO
    pic_Out.Visible = KO
    pic_add.Enabled = KO
    pic_delete.Enabled = KO
    pic_upd.Enabled = KO
    mi_MarketCode = gs_TableCode
    ButtonBox.Visible = KO
    
    cbo_Category.Enabled = KO
    cbo_Category.AddItem gs_TableCode4
    cbo_Category2.AddItem gs_TableCode3
    cbo_Category.ListIndex = 0
    
    txt_Desc = gs_TableCode5
    If gs_TableCode6 = "X" Then
        chk_Int.value = 1
    End If
    txt_dropped = gs_TableCode7
    ls_Req = "EXEC Test_Market_Contains_t_lst " _
        & gs_TableCode & ", '" _
        & gut_LangWork.Code & "'"
    FillLstSingle ls_Req, Lst_CountryIn
    FillGridAccepts 3
'end change

End Select
    
    ' NEW 22.1.2005 remove SSTab begin
    Call SetTabStripVisible(tbs_Market, frm_tabMarket, True)
    ' NEW 22.1.2005 remove SSTab end


MouseOn
Exit Sub

suite:
StdError
End Sub
Private Sub grd_Standard_Click()

MouseOff
If grd_Standard.Row > 0 Then
    grd_Standard.HighLight = flexHighlightAlways
    If grd_Standard.TextMatrix(grd_Standard.Row, 0) = "" Then
        'no valid line select
        grd_Standard.HighLight = flexHighlightNever
    Else
        gut_Param2.Str2 = grd_Standard.TextMatrix(grd_Standard.Row, 0)
        gut_Param2.Str3 = grd_Standard.TextMatrix(grd_Standard.Row, 1)
        gut_Param2.Str4 = grd_Standard.TextMatrix(grd_Standard.Row, 2)
        gut_Param2.Str5 = grd_Standard.TextMatrix(grd_Standard.Row, 3)
        gut_Param2.Str6 = grd_Standard.TextMatrix(grd_Standard.Row, 4)
        gut_Param2.Str7 = grd_Standard.TextMatrix(grd_Standard.Row, 5)
    End If
End If
MouseOn

End Sub

Private Sub pic_add_Click()

MouseOff
gut_Param2.action = "Add"
ShowMtncScreen
MouseOn

End Sub
Private Sub pic_delete_Click()

MouseOff
If grd_Standard.HighLight = flexHighlightAlways Then
    gut_Param2.action = "Delete"
    ShowMtncScreen
Else
    SendMessage 1, "Please, select a record", gut_LangLogin.Code
End If
MouseOn

End Sub


Private Sub pic_In_Click()

If lst_CountryOut.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_ToDelete, lst_CountryOut.Text) Then
        lst_ToInsert.AddItem lst_CountryOut.Text
    End If
    Lst_CountryIn.AddItem lst_CountryOut.Text
    lst_CountryOut.RemoveItem lst_CountryOut.ListIndex
End If

End Sub
Private Sub pic_Out_Click()

If Lst_CountryIn.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_ToInsert, Lst_CountryIn.Text) Then
        lst_ToDelete.AddItem Lst_CountryIn.Text
    End If
    lst_CountryOut.AddItem Lst_CountryIn.Text
    Lst_CountryIn.RemoveItem Lst_CountryIn.ListIndex
End If

End Sub
Private Sub pic_refresh_Click()

MouseOff
FillGridAccepts 3
MouseOn

End Sub
Private Sub pic_upd_Click()

MouseOff
If grd_Standard.HighLight = flexHighlightAlways Then
    gut_Param2.action = "Update"
    ShowMtncScreen
Else
    SendMessage 1, "Please, select a record", gut_LangLogin.Code
End If
MouseOn

End Sub
Private Sub cmd_save_Click()

Dim ls_Line As String

On Error GoTo suite

MouseOff
gb_Return = OK
Select Case gs_Action
Case "Add"
    If Control Then
        If BeginTran(gl_Environment, gl_Database) Then
            If AddMarket Then
                If CommitTran(gl_Environment, gl_Database) Then
                    '/* Debut Modif */
                    ls_Line = mi_MarketCode & Chr(9) & 1 & Chr(9) & cbo_Category2.List(cbo_Category.ListIndex) & Chr(9) & cbo_Category.List(cbo_Category.ListIndex) & Chr(9) & txt_Desc & Chr(9) & ms_IntFlag & Chr(9) & txt_dropped
                    C_main.Grid.AddItem ls_Line
                    C_main.Grid.Row = C_main.Grid.Rows - 1
                    mb_CategNotLoaded = OK
                    mb_TypeNotLoaded = OK
                    cbo_Category.Clear
                    cbo_Category2.Clear
                    '/* Fin Modif */
                    txt_Desc = ""
                    chk_Int.value = 0
                    txt_dropped = ""
                    Lst_CountryIn.Clear
                    lst_CountryOut.Clear
                    lst_ToInsert.Clear
                    FillLstSingle "Test_Market_contains_cbo " & cbo_Category2.List(cbo_Category.ListIndex), lst_CountryOut
                    txt_Desc.SetFocus
                Else
                    RollbackTran gl_Environment, gl_Database
                    SendMessage 4, "Insert failed", gut_LangLogin.Code
                End If
            Else
                RollbackTran gl_Environment, gl_Database
            End If
        Else
            SendMessage 4, "Insert failed", gut_LangLogin.Code
        End If
    End If
Case "Update"
    If Control Then
        If BeginTran(gl_Environment, gl_Database) Then
            If UpdMarket Then
                If CommitTran(gl_Environment, gl_Database) Then
                    C_main.Grid.RemoveItem C_main.Grid.Row
                    '/* debut modif */
                    ls_Line = mi_MarketCode & Chr(9) & CInt(gs_TableCode2) + 1 & Chr(9) & cbo_Category2.List(cbo_Category.ListIndex) & Chr(9) & cbo_Category.List(cbo_Category.ListIndex) & Chr(9) & txt_Desc & Chr(9) & ms_IntFlag & Chr(9) & txt_dropped
                    '/* fin modif */
                    C_main.Grid.AddItem ls_Line, C_main.Grid.Row
                    Unload Me
                Else
                    RollbackTran gl_Environment, gl_Database
                    SendMessage 3, "Update failed", gut_LangLogin.Code
                End If
            Else
                RollbackTran gl_Environment, gl_Database
            End If
        Else
            SendMessage 3, "Update failed", gut_LangLogin.Code
        End If
    End If
Case "Delete"
    MouseOn
    ' test if test market is linked with BI_Public_Value - task284 JUNA
    If beforeDeleteCheck(gs_TableCode) Then
    
    If SendMessage(5, "Delete record ?", gut_LangLogin.Code, vbQuestion + vbYesNo, "Delete ") = vbYes Then
        MouseOff
        If DltMarket Then
            C_main.Grid.RemoveItem C_main.Grid.Row
            Unload Me
        End If
    End If
    Else
        Call SendMessage(281, "#Cannot Delete this Market - Child records exist in Tech Published Values' ", gut_LangLogin.Code, vbOKOnly, "Delete ")
    End If
End Select
MouseOn
Exit Sub

suite:
Select Case Err
Case 30015
    C_main.FillGrid
    Unload Me
Case Else
    StdError
    MouseOn
End Select
End Sub

' check if record can be deleted
Private Function beforeDeleteCheck(ByVal as_TMK_code As String) As Boolean
Const REQ As String = "SELECT TOP 1 BI_SAP_code FROM BI_Public_Value WHERE TMK_code=$TMK_CODE$"
On Error GoTo errHandler
    Dim ls_req As String
    Dim ll_Statement As Long
    Dim li_Status As Integer
    Dim ll_lngrows As Long
    
    beforeDeleteCheck = False
    ls_req = Replace(REQ, "$TMK_CODE$", as_TMK_code)
    
    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)
        beforeDeleteCheck = (ll_lngrows = 0)
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 282, "#Check failed", gut_LangLogin.Code
    End If
    
    Exit Function
errHandler:
    Dim ls_errSrc As String
    Dim ls_errDesc As String
    Dim ll_errNum As Long
    ls_errSrc = Err.Source
    ls_errDesc = Err.Description
    ll_errNum = Err.Number
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Err.Source = ls_errSrc
    Err.Description = ls_errDesc
    Err.Number = ll_errNum
    
    StdError
End Function

Private Sub SSC_dropped_Click()

On Error GoTo suite

MouseOff
gb_Return = KO
gs_Date = txt_dropped
Dates.show 1
If gb_Return Then
    txt_dropped = gs_Date
End If
MouseOn
Exit Sub

suite:
StdError
End Sub
Private Sub cmd_Quit_Click()

MouseOff
Unload Me

End Sub
Private Function UpdMarket() As Boolean

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

UpdMarket = KO

On Error GoTo suite

If chk_Int.value = 1 Then
    ms_IntFlag = "X"
Else
    ms_IntFlag = ""
End If
If txt_dropped <> "" Then
    ls_DropFlag = "X"
    ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
End If
ls_Req = "EXEC Test_Market_upd " _
    & gs_TableCode & ", '" _
    & QuoteParam(txt_Desc) & "', '" _
    & ms_IntFlag & "', '" _
    & ls_DropFlag & "', '" _
    & ls_DropDate & "', " _
    & gs_TableCode2
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 2, "Another user changed the record", 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
For li_Count = 0 To lst_ToInsert.ListCount - 1
    ls_Req = "EXEC Test_Market_Contains_Ins " _
        & mi_MarketCode & ", '" _
        & gut_LangWork.Code & "', '" _
        & lst_ToInsert.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_ToDelete.ListCount - 1
    ls_Req = "EXEC Test_Market_Contains_Del " _
        & mi_MarketCode & ", '" _
        & gut_LangWork.Code & "', '" _
        & lst_ToDelete.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
UpdMarket = OK
Exit Function

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Function
Private Function AddMarket() As Boolean

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

AddMarket = KO

On Error GoTo suite

If chk_Int.value = 1 Then
    ms_IntFlag = "X"
Else
    ms_IntFlag = ""
End If
If txt_dropped <> "" Then
    ls_DropFlag = "X"
    ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
End If
'/* Debut modif */
ls_Req = "EXEC Test_Market_ins " _
    & cbo_Category2.List(cbo_Category.ListIndex) & ",'" _
    & QuoteParam(txt_Desc) & "', '" _
    & ms_IntFlag & "', '" _
    & ls_DropFlag & "', '" _
    & ls_DropDate & "'"
'/* Fin Modif */'
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQLRowCount(ll_Statement, ll_lngrows)
    If ll_lngrows = 0 Then
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Insert failed", gut_LangLogin.Code
        Exit Function
    Else
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            mi_MarketCode = ODBCData(ll_Statement, 1)
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        Else
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
            SendMessage 4, "Insert failed", gut_LangLogin.Code
            Exit Function
        End If
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    SendMessage 4, "Insert failed", gut_LangLogin.Code
    Exit Function
End If
For li_Count = 0 To lst_ToInsert.ListCount - 1
    ls_Req = "EXEC Test_Market_Contains_ins " _
        & mi_MarketCode & ", '" _
        & gut_LangWork.Code & "', '" _
        & lst_ToInsert.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 4, "Insert failed", gut_LangLogin.Code
            Exit Function
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Insert failed", gut_LangLogin.Code
        Exit Function
    End If
Next li_Count
AddMarket = OK
Exit Function

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Function
Private Function DltMarket() As Boolean

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long

DltMarket = KO

On Error GoTo suite

ls_Req = "EXEC Test_Market_del " _
 & gs_TableCode & ", " _
 & gs_TableCode2
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 7, "Delete failed : concurrency problem ?", gut_LangLogin.Code
    Else
        DltMarket = OK
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    SendMessage 6, "Delete failed", gut_LangLogin.Code
End If
Exit Function

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

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Field As String, ls_Text As String

On Error GoTo suite

ls_Req = "EXEC Screen_Csts 'mtnc_Test_Mark', '" & 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 = Left(ODBCData(ll_Statement, 2), 30)
        Select Case ls_Field
        Case "title": Caption = ls_Text
        Case "titleA": If gs_Action = "Add" Then Caption = Caption & " - " & ls_Text
        Case "titleU": If gs_Action = "Update" Then Caption = Caption & " - " & ls_Text
        Case "titleD": If gs_Action = "Delete" Then Caption = Caption & " - " & ls_Text
        Case "titleI": If gs_Action = "MoreInfo" Then Caption = Caption & " - " & ls_Text
        Case "lbl_Desc": lbl_Desc.Caption = ls_Text
        Case "lbl_Int": lbl_Int = ls_Text
        Case "lbl_Drop": lbl_Drop = ls_Text
        Case "tab_Market(0)": tbs_Market.Tabs("_0").Caption = ls_Text
        Case "lbl_Available": lbl_Available.Caption = ls_Text
        Case "lbl_Selected": lbl_Selected.Caption = ls_Text
        Case "tab_Market(1)": tbs_Market.Tabs("_1").Caption = ls_Text
        '/* debut modif */
        Case "c1"
            grd_Standard.Row = 0
            grd_Standard.Col = 1
            grd_Standard.Text = ls_Text
        Case "c2"
            grd_Standard.Row = 0
            grd_Standard.Col = 2
            grd_Standard.Text = ls_Text
'        Case "c4"
'            grd_Standard.Row = 0
'            grd_Standard.Col = 4
'            grd_Standard.Text = ls_Text
        '/* fin modif */
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub
Private Function Control() As Boolean

Control = KO
'/*** Debut Modif ****/
If cbo_Category.ListIndex = -1 Then
    cbo_Category.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
'If Cbo_type.ListIndex = -1 Then
'    Cbo_type.SetFocus
'    SendMessage 8, "Value must be filled in",gut_LangLogin.Code
'    Exit Function
'End If
'/**** Fin Modif *****/
If txt_Desc.Text = "" Then
    txt_Desc.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Lst_CountryIn.ListCount = 0 Then
    Lst_CountryIn.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
Control = OK

End Function
'/* debut modif */
Private Sub FillGridAccepts(ByVal li_NBcol As Integer)

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Count As Integer
Dim li_Count2 As Integer

On Error GoTo suite
grd_Standard.Rows = 2
grd_Standard.Row = 1
For li_Count2 = 0 To li_NBcol
    grd_Standard.Col = li_Count2
    grd_Standard.Text = ""
Next li_Count2
ls_Req = "EXEC Test_Market_Accepts_t_lst " _
    & gs_TableCode & ", '" _
    & gut_LangWork.Code & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Count = 1
    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
            grd_Standard.Rows = li_Count + 1
            grd_Standard.Row = li_Count
            For li_Count2 = 0 To li_NBcol
                grd_Standard.Col = li_Count2
                grd_Standard.Text = ODBCData(ll_Statement, li_Count2 + 1)
            Next li_Count2
            li_Count = li_Count + 1
        End If
    Loop
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
grd_Standard.Row = 0
grd_Standard.Col = 0
grd_Standard.HighLight = flexHighlightNever     '= KO
Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub
Private Sub ShowMtncScreen()

gut_Param2.Return = KO
Test_MarketA_mtnc.show 1
ButtonBox.Refresh
If gut_Param2.Return Then FillGridAccepts 3

End Sub

' NEW 22.1.2005 remove SSTab begin
Private Sub InitTabStrip(ByVal ao_tbStrip As MSComctlLib.TabStrip, ByRef ao_tabs As Object)
Dim lo_Object As Object
    For Each lo_Object In ao_tabs
        Select Case ao_tbStrip.Placement
            Case tabPlacementLeft
                Call lo_Object.Move(ao_tbStrip.Left + ao_tbStrip.Width, ao_tbStrip.Top)
            Case tabPlacementTop
                Call lo_Object.Move(ao_tbStrip.Left, ao_tbStrip.Top + ao_tbStrip.Height)
            Case tabPlacementRight
                Call lo_Object.Move(ao_tbStrip.Left - lo_Object.Width, ao_tbStrip.Top)
            Case tabPlacementBottom
                Call lo_Object.Move(ao_tbStrip.Left, ao_tbStrip.Top - lo_Object.Height)
        End Select
    Next
    
    For Each lo_Object In ao_tbStrip.Tabs
        lo_Object.Key = "_" & lo_Object.Index - 1
    Next
End Sub

Private Sub UpdateTabStrip(ByVal ao_tbStrip As MSComctlLib.TabStrip, ByRef ao_tabs As Object)
Dim lo_Object As Object
    For Each lo_Object In ao_tabs
        lo_Object.Visible = (lo_Object.Index = CLng(Mid(ao_tbStrip.SelectedItem.Key, 2)))
    Next
End Sub

Private Sub SetTabStripVisible(ByRef ao_tbStrip As MSComctlLib.TabStrip, ByRef ao_tabs As Object, ByVal ab_Visible As Boolean)
    ao_tbStrip.Visible = ab_Visible

    If ab_Visible Then
        Call UpdateTabStrip(ao_tbStrip, ao_tabs)
    Else
        Dim lo_Object As Object
        ' hide all tabs
        For Each lo_Object In ao_tabs
            lo_Object.Visible = False
        Next
    End If
End Sub

Private Sub tbs_Market_Click()
    MouseOff
    Call UpdateTabStrip(tbs_Market, frm_tabMarket)
    MouseOn
End Sub
' NEW 22.1.2005 remove SSTab end

