VERSION 5.00
Begin VB.Form C_SimpleDesc_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   6000
   ClientLeft      =   240
   ClientTop       =   945
   ClientWidth     =   9090
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6000
   ScaleWidth      =   9090
   ShowInTaskbar   =   0   'False
   Begin VB.Frame frm_Bas 
      Height          =   972
      Left            =   0
      TabIndex        =   12
      Top             =   4980
      Width           =   9072
      Begin VB.CommandButton spp_save 
         Default         =   -1  'True
         Height          =   612
         Left            =   7620
         Style           =   1  'Graphical
         TabIndex        =   6
         Top             =   240
         Width           =   612
      End
      Begin VB.CommandButton SSC_dropped 
         Height          =   276
         Left            =   2880
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   540
         Width           =   252
      End
      Begin VB.CommandButton ssp_quit 
         Height          =   612
         Left            =   8340
         Style           =   1  'Graphical
         TabIndex        =   7
         Top             =   240
         Width           =   612
      End
      Begin VB.TextBox txt_dropped 
         ForeColor       =   &H00FF0000&
         Height          =   288
         Left            =   1680
         Locked          =   -1  'True
         TabIndex        =   4
         Top             =   540
         Width           =   1212
      End
      Begin VB.CheckBox chk_Int 
         Height          =   252
         Left            =   1680
         TabIndex        =   3
         Top             =   240
         Width           =   252
      End
      Begin VB.Label lbl_Int 
         Caption         =   "Internet flag"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   252
         Left            =   120
         TabIndex        =   14
         Top             =   240
         Width           =   1572
      End
      Begin VB.Label lbl_Drop 
         Caption         =   "Drop date"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   252
         Left            =   120
         TabIndex        =   13
         Top             =   540
         Width           =   1572
      End
   End
   Begin VB.ComboBox cbo_Market2 
      Height          =   288
      Left            =   3000
      Style           =   2  'Dropdown List
      TabIndex        =   9
      TabStop         =   0   'False
      Top             =   120
      Visible         =   0   'False
      Width           =   396
   End
   Begin VB.TextBox txt_Descr 
      Height          =   288
      Left            =   1680
      MaxLength       =   80
      TabIndex        =   2
      Top             =   840
      Width           =   3792
   End
   Begin VB.ComboBox cbo_Market 
      Height          =   288
      Left            =   1680
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   120
      Width           =   1992
   End
   Begin VB.TextBox txt_Numeric 
      Height          =   288
      Left            =   1680
      MaxLength       =   10
      TabIndex        =   1
      Top             =   480
      Width           =   1092
   End
   Begin VB.Frame frm_Vdv 
      Height          =   3732
      Left            =   0
      TabIndex        =   15
      Top             =   1200
      Width           =   9072
      Begin VB.ListBox lst_ToInsert 
         Height          =   645
         Left            =   3720
         Sorted          =   -1  'True
         TabIndex        =   19
         Top             =   480
         Visible         =   0   'False
         Width           =   1524
      End
      Begin VB.ListBox lst_ToDelete 
         Height          =   645
         Left            =   3780
         Sorted          =   -1  'True
         TabIndex        =   18
         Top             =   2820
         Visible         =   0   'False
         Width           =   1524
      End
      Begin VB.PictureBox pic_In 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   4260
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   17
         TabStop         =   0   'False
         Top             =   1620
         Width           =   408
      End
      Begin VB.PictureBox pic_Out 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   4260
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   16
         TabStop         =   0   'False
         Top             =   2340
         Width           =   408
      End
      Begin VB.ListBox lst_Selected 
         Appearance      =   0  'Flat
         Height          =   2565
         ItemData        =   "C_MTNC3.frx":0000
         Left            =   4860
         List            =   "C_MTNC3.frx":0007
         TabIndex        =   23
         Top             =   840
         Width           =   4095
      End
      Begin VB.ListBox lst_NotSelected 
         Appearance      =   0  'Flat
         Height          =   2565
         ItemData        =   "C_MTNC3.frx":0019
         Left            =   120
         List            =   "C_MTNC3.frx":0020
         TabIndex        =   24
         Top             =   840
         Width           =   4095
      End
      Begin VB.Label lbl_NotSelected 
         Alignment       =   2  'Center
         Caption         =   "Not selected"
         Height          =   252
         Left            =   120
         TabIndex        =   22
         Top             =   360
         Width           =   4092
      End
      Begin VB.Label lbl_Recommended 
         Alignment       =   2  'Center
         Height          =   252
         Left            =   120
         TabIndex        =   21
         Top             =   120
         Width           =   8832
      End
      Begin VB.Label lbl_Selected 
         Alignment       =   2  'Center
         Caption         =   "Selected"
         Height          =   252
         Left            =   4860
         TabIndex        =   20
         Top             =   360
         Width           =   4092
      End
   End
   Begin VB.Label lbl_Market 
      Caption         =   "Market"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   10
      Top             =   120
      Width           =   1572
   End
   Begin VB.Label lbl_Descr 
      Caption         =   "Description"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   8
      Top             =   840
      Width           =   1572
   End
   Begin VB.Label lbl_Numeric 
      Caption         =   "Numeric value"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   11
      Top             =   480
      Width           =   1572
   End
End
Attribute VB_Name = "C_SimpleDesc_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' external references and constants
Private Declare Function SendMessageAPI Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Private Const SM_CYHSCROLL = 3
Private Const SM_CXVSCROLL = 2
Private Const WM_HSCROLL = &H114
Private Const WM_VSCROLL = &H115
Private Const SB_BOTTOM = 7
Private Const LB_SETHORIZONTALEXTENT = &H194


'Competitive D.B
Public mb_CompetitiveDB As Boolean
Private ml_NextID As Long
Private ml_UCode As Long

Dim mb_MarketNotLoaded As Boolean
Dim ms_Code As String
Dim ms_SCDesc As String

Private Sub Cbo_market_DropDown()

Dim ls_Market As String

MouseOff
If mb_MarketNotLoaded Then
    mb_MarketNotLoaded = KO
    If cbo_Market.ListIndex <> -1 Then
        ls_Market = cbo_Market2.List(cbo_Market.ListIndex)
    Else
        ls_Market = ""
    End If
    cbo_Market2.Clear
    cbo_Market.Clear
    Select Case gut_Param.Str1
    Case "Offer_Internet"
        FillCbo "Offer_Type", cbo_Market2, cbo_Market
    Case "AcoustAW", "AcoustNRC", "AcoustDncW", "AcoustRW", "AcoustCAC", "Dnfw", "AbsClass", "RedInd", "Rain", "EquivSoundAbs"
        cbo_Market2.AddItem "0"
        cbo_Market.AddItem ""
        FillCbo "EXEC Tech_" & gut_Param.Str21 & "_Option_cbo '" & gut_LangWork.Code & "'", cbo_Market2, cbo_Market
    Case "FireReac"
        FillCbo "EXEC Test_Market_cbo 4, '" & gut_LangWork.Code & "'", cbo_Market2, cbo_Market
    Case "FireRes"
        FillCbo "EXEC Test_Market_cbo 15, '" & gut_LangWork.Code & "'", cbo_Market2, cbo_Market
    Case "Hyper_Base_Material"
        FillCbo "Hyper_Base_Material", cbo_Market2, cbo_Market
    Case "Product_Combine"
        FillCbo "Pattern_Group", cbo_Market2, cbo_Market
    
    'Competitive D.B
    Case "MKT_SBM"
        FillCbo "MKT_Super_categories_cbo '" & gut_LangWork.Code & "'", cbo_Market2, cbo_Market
    Case "MKT_BM"
        FillCbo "MKT_Super_base_material_cbo '" & gut_LangWork.Code & "'", cbo_Market2, cbo_Market
    End Select
    If ls_Market <> "" Then
        cbo_Market.ListIndex = ComboFindItem(cbo_Market2, ls_Market)
    End If
End If
MouseOn

End Sub

Private Sub Form_Load()

On Error GoTo suite

MouseOff

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

' the pictures for the buttons
spp_save.Picture = LoadResPicture(RES_OK, 1)
ssp_quit.Picture = LoadResPicture(RES_QUIT, 1)
SSC_dropped.Picture = LoadResPicture(RES_DOWN2, vbResIcon)

' the pictures for the arrows
pic_In.Picture = LoadResPicture(RES_RIGHT, 1)
pic_Out.Picture = LoadResPicture(RES_LEFT, 1)
GetCaptions

'Competitive DB ?
If mb_CompetitiveDB Then
    ml_UCode = prg.U_Code
    If ml_UCode = 0 Then
        SendMessage 2101, "Failure while getting your ID login, can you contact IT support please.", gut_LangLogin.Code
    End If
End If

Select Case gs_TableName
Case "Tech"
    Select Case gut_Param.Str1
    Case "AcoustAW", "AcoustRW", "AcoustDncW", "Dnfw", "RedInd", "EquivSoundAbs"
'   Market, numeric, desc and fillempty
' task 789
    Case "AbsClass"
        lbl_Numeric.Visible = KO
        txt_Numeric.Visible = KO
    Case "AcoustNRC", "AcoustCAC"
'   Market, numeric and desc
        frm_Vdv.Visible = KO
        frm_Bas.Top = 1200
        Me.Height = 2630
    Case "FireReac", "Rain"
'   Market, desc and fillempty
        lbl_Numeric.Visible = KO
        txt_Numeric.Visible = KO
        lbl_Descr.Top = 500
        txt_Descr.Top = 500
        frm_Vdv.Top = 800
        frm_Bas.Top = 4550
        Me.Height = 6000
    Case "FireRes"
'   Market and desc
        lbl_Numeric.Visible = KO
        txt_Numeric.Visible = KO
        frm_Vdv.Visible = KO
        lbl_Descr.Top = 500
        txt_Descr.Top = 500
        frm_Bas.Top = 800
        Me.Height = 2280
    Case "Humidity", "Light"
'   Numeric, desc and fillempty
        lbl_Market.Visible = KO
        cbo_Market.Visible = KO
        lbl_Numeric.Top = 120
        txt_Numeric.Top = 120
        lbl_Descr.Top = 500
        txt_Descr.Top = 500
        frm_Vdv.Top = 800
        frm_Bas.Top = 4550
        Me.Height = 6000
    Case "Density", "Thermal", "Weight"
'   Numeric and desc
        lbl_Market.Visible = KO
        cbo_Market.Visible = KO
        lbl_Numeric.Top = 120
        txt_Numeric.Top = 120
        lbl_Descr.Top = 500
        txt_Descr.Top = 500
        frm_Vdv.Visible = KO
        frm_Bas.Top = 800
        Me.Height = 2250
' JUNA Task213 update
    Case "Hygiene", "Price", "Wash", "Impact", "Air_Quality", "Recycled_Content", "Cleanable", "AntiMicrobial"
'   Desc and fillempty
        lbl_Market.Visible = KO
        cbo_Market.Visible = KO
        lbl_Numeric.Visible = KO
        txt_Numeric.Visible = KO
        lbl_Descr.Top = 200
        txt_Descr.Top = 200
        frm_Vdv.Top = 600
        frm_Bas.Top = 4400
        Me.Height = 5870
    Case Else
'   Desc
        lbl_Market.Visible = KO
        cbo_Market.Visible = KO
        lbl_Numeric.Visible = KO
        txt_Numeric.Visible = KO
        frm_Vdv.Visible = KO
        lbl_Descr.Top = 120
        txt_Descr.Top = 120
        frm_Bas.Top = 500
        Me.Height = 1970
    End Select
Case "Media_Quality_On_Screen", "Definition", "Market_Objectives", "Support", "Media_Interest", "Source_Type", "Type_Of_Memo", "Type_Of_View", "Visible_On", "Media_Type", "Recommended_Area"
'   Desc
    lbl_Market.Visible = KO
    cbo_Market.Visible = KO
    lbl_Numeric.Visible = KO
    txt_Numeric.Visible = KO
    frm_Vdv.Visible = KO
    frm_Bas.Top = 1200
    lbl_Int.Visible = KO
    chk_Int.Visible = KO
    lbl_Drop.Visible = KO
    txt_dropped.Visible = KO
    SSC_dropped.Visible = KO
    Me.Height = 2568
Case "Test_Category", "Tech_Value_Option", "Company_Activity", "Offer_Type"
'   Desc
    lbl_Market.Visible = KO
    cbo_Market.Visible = KO
    lbl_Numeric.Visible = KO
    txt_Numeric.Visible = KO
    frm_Vdv.Visible = KO
    lbl_Descr.Top = 120
    txt_Descr.Top = 120
    frm_Bas.Top = 500
    Me.Height = 1970
Case "Hyper_Base_Material", "Product_Combine", "Offer_Internet"
'   Market and desc
    lbl_Numeric.Visible = KO
    txt_Numeric.Visible = KO
    frm_Vdv.Visible = KO
    frm_Bas.Top = 800
    lbl_Descr.Top = 500
    txt_Descr.Top = 500
    Me.Height = 2260
Case "Quot_MetalSystem", "Quot_MetalBorder", "Quot_MetalFinish", "Quot_MetalMaterial", "Quot_MetalGasket", "Quot_MetalPerforation", "Quot_MetalEdge", "Quot_MetalAcoustic"
'   Desc
    lbl_Market.Visible = KO
    cbo_Market.Visible = KO
    lbl_Numeric.Visible = KO
    txt_Numeric.Visible = KO
    frm_Vdv.Visible = KO
    lbl_Int.Visible = KO
    chk_Int.Visible = KO
    lbl_Drop.Visible = KO
    txt_dropped.Visible = KO
    SSC_dropped.Visible = KO
    lbl_Descr.Top = 120
    txt_Descr.Top = 120
    frm_Bas.Top = 500
    Me.Height = 1970
'Competive D.B
Case "MKT_Super_Base_Material", "MKT_Base_Material"
' cbo + desc without internet part
    lbl_Numeric.Visible = False
    txt_Numeric.Visible = False
    frm_Vdv.Visible = False
    lbl_Int.Visible = False
    chk_Int.Visible = False
    lbl_Drop.Visible = False
    txt_dropped.Visible = False
    SSC_dropped.Visible = False
    lbl_Market.Move 200, 300, 2500
    cbo_Market.Move 120, 600, 2500
    lbl_Descr.Move 3100, 300, 3000
    txt_Descr.Move 3000, 650, 3500
    frm_Bas.Move 20, 1200
    Me.Height = 2600
Case Else
'   Desc
    lbl_Market.Visible = KO
    cbo_Market.Visible = KO
    lbl_Numeric.Visible = KO
    txt_Numeric.Visible = KO
    frm_Vdv.Visible = KO
    lbl_Descr.Top = 120
    txt_Descr.Top = 120
    frm_Bas.Top = 500
    Me.Height = 1970
End Select

mb_MarketNotLoaded = OK

If gs_Action = "Add" Then
    If gs_TableName = "Tech" Then
        cbo_Market2.AddItem "0"
        cbo_Market.AddItem ""
        cbo_Market.ListIndex = 0
    End If
Else
    Select Case gs_TableName
        Case "Offer_Internet"
        cbo_Market.Enabled = KO
        cbo_Market2.AddItem gs_TableCode2
        cbo_Market.AddItem gs_TableCode5
        cbo_Market.ListIndex = 0
        txt_Descr = gs_TableCode4
        If gs_TableCode6 = "X" Then
            chk_Int.Value = 1
        End If
        txt_dropped = gs_TableCode7
    Case "Media_Quality_On_Screen", "Definition", "Market_Objectives", "Support", "Media_Interest", "Source_Type", "Type_Of_Memo", "Type_Of_View", "Visible_On", "Media_Type"
        txt_Descr = gs_TableCode2
        If gs_TableCode4 = "X" Then
            chk_Int.Value = 1
        End If
        txt_dropped = gs_TableCode5
    Case "Tech"
        txt_Descr = gs_TableCode5
        Select Case gut_Param.Str1
        Case "FireReac", "FireRes"
            cbo_Market.Enabled = KO
            cbo_Market2.AddItem gs_TableCode
            cbo_Market.AddItem gs_TableCode2
            cbo_Market.ListIndex = 0
            If gs_TableCode7 = "X" Then
                chk_Int.Value = 1
            End If
            txt_dropped = gs_TableCode8
        Case "AcoustAW", "AcoustNRC", "AcoustDncW", "AcoustRW", "AcoustCAC", "Dnfw", "AbsClass", "RedInd", "Rain", "EquivSoundAbs"
            cbo_Market.Enabled = KO
            cbo_Market2.AddItem gs_TableCode
            cbo_Market.AddItem gs_TableCode2
            cbo_Market.ListIndex = 0
            txt_Numeric = gs_TableCode6
            If gs_TableCode7 = "X" Then
                chk_Int.Value = 1
            End If
            txt_dropped = gs_TableCode8
        Case "Density", "Humidity", "Light", "Thermal", "Weight"
            cbo_Market2.AddItem "0"
            cbo_Market.AddItem ""
            cbo_Market.ListIndex = 0
            txt_Numeric = gs_TableCode6
            If gs_TableCode7 = "X" Then
                chk_Int.Value = 1
            End If
            txt_dropped = gs_TableCode8
        Case Else
            cbo_Market2.AddItem "0"
            cbo_Market.AddItem ""
            cbo_Market.ListIndex = 0
            If gs_TableCode7 = "X" Then
                chk_Int.Value = 1
            End If
            txt_dropped = gs_TableCode8
        End Select
    Case "Hyper_Base_Material"
        cbo_Market.Enabled = KO
        cbo_Market2.AddItem gs_TableCode3
        cbo_Market.AddItem gs_TableCode4
        cbo_Market.ListIndex = 0
        txt_Descr = gs_TableCode5
        If gs_TableCode6 = "X" Then
            chk_Int.Value = 1
        End If
        txt_dropped = gs_TableCode7
    Case "Product_Combine"
        cbo_Market.Enabled = KO
        cbo_Market2.AddItem gs_TableCode
        cbo_Market.AddItem gs_TableCode3
        cbo_Market.ListIndex = 0
        txt_Descr.Enabled = KO
        txt_Descr = gs_TableCode4
        If gs_TableCode5 = "X" Then
            chk_Int.Value = 1
        End If
        txt_dropped = gs_TableCode6
    Case "Glossary_Topic"
        txt_Descr = gs_TableCode
        If gs_TableCode3 = "X" Then
            chk_Int.Value = 1
        End If
        txt_dropped = gs_TableCode4
    'Competitive DB
    Case "MKT_Super_Base_Material"
        txt_Descr = gs_TableCode5
        cbo_Market.Enabled = False
        cbo_Market2.AddItem gs_TableCode3
        cbo_Market.AddItem gs_TableCode4
        cbo_Market.ListIndex = 0
    Case "MKT_Base_Material"
        txt_Descr = gs_TableCode6
        cbo_Market.Enabled = False
        cbo_Market2.AddItem gs_TableCode4
        cbo_Market.AddItem gs_TableCode5
        cbo_Market.ListIndex = 0
        
    Case Else
        txt_Descr = gs_TableCode3
        If gs_TableCode4 = "X" Then
            chk_Int.Value = 1
        End If
        txt_dropped = gs_TableCode5
    End Select
    'disabled all controls for delete
    If gs_Action = "Delete" Then
        cbo_Market.Enabled = KO
        txt_Numeric.Enabled = KO
        txt_Descr.Enabled = KO
        pic_In.Visible = KO
        pic_Out.Visible = KO
        chk_Int.Enabled = KO
        txt_dropped.Enabled = KO
        SSC_dropped.Visible = KO
    'used on dble click on C_Main
    ElseIf gs_Action = "MoreInfo" Then
            cbo_Market.Enabled = KO
            txt_Numeric.Enabled = KO
            txt_Descr.Enabled = KO
            pic_In.Visible = KO
            pic_Out.Visible = KO
            chk_Int.Enabled = KO
            txt_dropped.Enabled = KO
            SSC_dropped.Visible = KO
            spp_save.Visible = KO
    End If
End If
If gs_TableName = "Tech" Then
    Select Case gut_Param.Str1
' JUNA Task213 update
    Case "AcoustAW", "AcoustRW", "AcoustDncW", "FireReac", "Humidity", "Hygiene", "Light", "Price", "Wash", "Impact", "Air_Quality", "Recycled_Content", "Cleanable", "AntiMicrobial", "Dnfw", "AbsClass", "RedInd", "Rain", "EquivSoundAbs"
        FillVdv
    End Select
End If
MouseOn
Exit Sub

suite:
StdError
End Sub


Private Sub spp_save_Click()

On Error GoTo suite

MouseOff
gb_Return = OK
Select Case gs_Action
Case "Add"
    'Competitive Db
    If mb_CompetitiveDB Then
        ml_NextID = NextID(gs_TableName)
        If ml_NextID = 0 Then
            MouseOn
            Exit Sub
        End If
    End If
    
    If gs_TableName = "Tech" Then
        Select Case gut_Param.Str1
' JUNA task213 insert
        Case "AcoustAW", "AcoustRW", "AcoustDncW", "FireReac", "Humidity", "Hygiene", "Light", "Price", "Wash", "Impact", "Air_Quality", "Recycled_Content", "Cleanable", "AntiMicrobial", "Dnfw", "AbsClass", "RedInd", "Rain", "EquivSoundAbs"
            GeneralAddVdv
        Case Else
            GeneralAdd
        End Select
    Else
        GeneralAdd
    End If
Case "Update"
    If gs_TableName = "Tech" Then
        Select Case gut_Param.Str1
' JUNA task213 insert
        Case "AcoustAW", "AcoustRW", "AcoustDncW", "FireReac", "Humidity", "Hygiene", "Light", "Price", "Wash", "Impact", "Air_Quality", "Recycled_Content", "Cleanable", "AntiMicrobial", "Dnfw", "AbsClass", "RedInd", "Rain", "EquivSoundAbs"
            GeneralUpdateVdv
        Case Else
            GeneralUpdate
        End Select
    Else
        GeneralUpdate
    End If
Case "Delete"
    If DeleteRow Then
        C_main.Grid.RemoveItem C_main.Grid.Row
        Unload Me
        Exit Sub
    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
Private Sub pic_In_Click()

MouseOff
If lst_NotSelected.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_ToDelete, lst_NotSelected.Text) Then
        lst_ToInsert.AddItem lst_NotSelected.Text
    End If
    lst_Selected.AddItem lst_NotSelected
    lst_NotSelected.RemoveItem lst_NotSelected.ListIndex
    Call lstAddHScroll(lst_NotSelected)       ' task287 JUNA
    Call lstAddHScroll(lst_Selected)          ' task287 JUNA
End If
MouseOn

End Sub
Private Sub pic_Out_Click()

MouseOff
If lst_Selected.ListIndex <> -1 Then
    If Not RemoveItemLst(lst_ToInsert, lst_Selected.Text) Then
        lst_ToDelete.AddItem lst_Selected.Text
    End If
    lst_NotSelected.AddItem lst_Selected
    lst_Selected.RemoveItem lst_Selected.ListIndex
    Call lstAddHScroll(lst_NotSelected)         ' task287 JUNA
    Call lstAddHScroll(lst_Selected)            ' task287 JUNA
End If
MouseOn

End Sub
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 ssp_quit_Click()

MouseOff
Unload Me

End Sub
Private Function UpdateRow() 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 ls_IntFlag As String
Dim ls_DropFlag As String
Dim ls_DropDate As String

UpdateRow = KO

On Error GoTo suite

If Control Then
    If chk_Int.Value = 1 Then ls_IntFlag = "X"
    If txt_dropped <> "" Then
        ls_DropFlag = "X"
        ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
    End If
    Select Case gs_TableName
         Case "Offer_Internet"
        ls_req = gs_ParamReqUpd & " " _
            & gs_TableCode & ", '" _
            & QuoteParam(txt_Descr) & "', " _
            & cbo_Market2.List(cbo_Market.ListIndex) & ", '" _
            & ls_IntFlag & "', '" & ls_DropFlag & "', '" _
            & ls_DropDate & "', " & gs_TableCode3
    Case "Media_Quality_On_Screen", "Definition", "Market_Objectives", "Support", "Media_Interest", "Source_Type", "Type_Of_Memo", "Type_Of_View", "Visible_On", "Media_Type"
        ls_req = gs_ParamReqUpd & " '" _
            & QuoteParam(gs_TableCode) & "', '" _
            & QuoteParam(txt_Descr) & "', " _
            & gs_TableCode3
    Case "Tech"
        Select Case gut_Param.Str1
        Case "AcoustAW", "AcoustNRC", "AcoustDncW", "AcoustRW", "AcoustCAC", "Density", "Humidity", "Light", "Thermal", "Weight", "Dnfw", "AbsClass", "RedInd", "Rain", "EquivSoundAbs"
            ls_req = gs_ParamReqUpd & " " _
                & gs_TableCode3 & ", '" _
                & QuoteParam(txt_Descr) & "', " _
                & txt_Numeric & ", '" _
                & ls_IntFlag & "', '" & ls_DropFlag & "', '" _
                & ls_DropDate & "', " & gs_TableCode4
        Case Else
            ls_req = gs_ParamReqUpd & " " _
                & gs_TableCode3 & ", '" _
                & QuoteParam(txt_Descr) & "', 0, '" _
                & ls_IntFlag & "', '" & ls_DropFlag & "', '" _
                & ls_DropDate & "', " & gs_TableCode4
        End Select
    Case "Hyper_Base_Material"
        ls_req = gs_ParamReqUpd & " " _
            & gs_TableCode & ", '" _
            & QuoteParam(txt_Descr) & "', '" _
            & gs_TableCode3 & "', " & gs_TableCode2 & ", '" _
            & ls_IntFlag & "', '" & ls_DropFlag & "', '" _
            & ls_DropDate & "'"
    Case "Product_Combine"
        ls_req = gs_ParamReqUpd & " " _
            & gs_TableCode & ", '" _
            & gs_TableCode4 & "', '" _
            & QuoteParam(txt_Descr) & "', '" _
            & ls_IntFlag & "', '" & ls_DropFlag & "', '" _
            & ls_DropDate & "', " & gs_TableCode2
    'Competitive DB
    Case "MKT_Super_Base_Material", "MKT_Base_Material"
        ls_req = Replace(gs_ParamReqUpd, "$Key$", gs_TableCode)
        ls_req = Replace(ls_req, "$Desc$", QuoteParam(txt_Descr.Text))
        ls_req = Replace(ls_req, "$UID$", ml_UCode)
    
    Case Else
        If IsPosInt(gs_TableCode) Then
            ls_req = gs_ParamReqUpd & " " _
                & gs_TableCode & ", '" _
                & QuoteParam(txt_Descr) & "', '" _
                & ls_IntFlag & "', '" _
                & ls_DropFlag & "', '" _
                & ls_DropDate & "', " _
                & gs_TableCode2
        Else
            ls_req = gs_ParamReqUpd & " '" _
                & QuoteParam(gs_TableCode) & "', '" _
                & QuoteParam(txt_Descr) & "', '" _
                & ls_IntFlag & "', '" _
                & ls_DropFlag & "', '" _
                & ls_DropDate & "', " _
                & gs_TableCode2
        End If
    End Select
    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 2, "Another user change the record", gut_LangLogin.Code
        Else
            UpdateRow = OK
            'Modifs dans la grille
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
       End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 3, "Update failed", gut_LangLogin.Code
    End If
End If
Exit Function

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Function
Private Function AddRow() 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 ls_IntFlag As String
Dim ls_DropFlag As String
Dim ls_DropDate As String

AddRow = KO

On Error GoTo suite

If chk_Int.Value = 1 Then ls_IntFlag = "X"
If txt_dropped <> "" Then
    ls_DropFlag = "X"
    ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
End If
Select Case gs_TableName
Case "Offer_Internet"
    ls_req = gs_ParamReqIns & " '" _
        & QuoteParam(txt_Descr) & "', " _
        & cbo_Market2.List(cbo_Market.ListIndex) & ", '" _
        & ls_IntFlag & "', '" _
        & ls_DropFlag & "', '" _
        & ls_DropDate & "'"
Case "Media_Quality_On_Screen", "Definition", "Market_Objectives", "Support", "Media_Interest", "Source_Type", "Type_Of_Memo", "Type_Of_View", "Visible_On", "Media_Type"
    ls_req = gs_ParamReqIns & " '" _
        & QuoteParam(txt_Descr) & "'"
Case "Tech"
    Select Case gut_Param.Str1
    Case "AcoustAW", "AcoustNRC", "AcoustDncW", "AcoustRW", "AcoustCAC", "Dnfw", "RedInd", "EquivSoundAbs"
        ls_req = gs_ParamReqIns & " " _
            & cbo_Market2.List(cbo_Market.ListIndex) & ",'" _
            & QuoteParam(txt_Descr) & "'," _
            & txt_Numeric & ",'" _
            & ls_IntFlag & "','" _
            & ls_DropFlag & "','" _
            & ls_DropDate & "'"
    Case "AbsClass"
        ls_req = gs_ParamReqIns & " " _
            & cbo_Market2.List(cbo_Market.ListIndex) & ",'" _
            & QuoteParam(txt_Descr) & "'," _
            & 0 & ",'" _
            & ls_IntFlag & "','" _
            & ls_DropFlag & "','" _
            & ls_DropDate & "'"
    Case "FireReac", "FireRes", "Rain"
        ls_req = gs_ParamReqIns & " " _
            & cbo_Market2.List(cbo_Market.ListIndex) & ",'" _
            & QuoteParam(txt_Descr) & "',0,'" _
            & ls_IntFlag & "','" _
            & ls_DropFlag & "','" _
            & ls_DropDate & "'"
    Case "Density", "Humidity", "Light", "Thermal", "Weight"
        ls_req = gs_ParamReqIns & " 0,'" _
            & QuoteParam(txt_Descr) & "'," _
            & txt_Numeric & ",'" _
            & ls_IntFlag & "','" _
            & ls_DropFlag & "','" _
            & ls_DropDate & "'"
    Case Else
        ls_req = gs_ParamReqIns & " 0,'" _
            & QuoteParam(txt_Descr) & "',0,'" _
            & ls_IntFlag & "','" _
            & ls_DropFlag & "','" _
            & ls_DropDate & "'"
    End Select
Case "Product_Combine"
    ls_req = gs_ParamReqIns & " '" _
        & QuoteParam(UCase(txt_Descr)) & "', " _
        & cbo_Market2.List(cbo_Market.ListIndex) & ", '" _
        & ls_IntFlag & "', '" _
        & ls_DropFlag & "', '" _
        & ls_DropDate & "'"
Case "Hyper_Base_Material"
    ls_req = gs_ParamReqIns & " '" _
        & QuoteParam(txt_Descr) & "', '" _
        & cbo_Market2.List(cbo_Market.ListIndex) & "', '" _
        & ls_IntFlag & "', '" _
        & ls_DropFlag & "', '" _
        & ls_DropDate & "'"
Case "Grid_Description", "Grid_Manufacturer"
    ls_req = gs_ParamReqIns & " '" _
        & QuoteParam(txt_Descr) & "', '" _
        & ls_IntFlag & "', '" _
        & ls_DropFlag & "','" _
        & ls_DropDate & "'"
'Competitive DB
Case "MKT_Super_Base_Material", "MKT_Base_Material"
        ls_req = Replace(gs_ParamReqIns, "$Key$", ml_NextID)
        ls_req = Replace(ls_req, "$Cbo$", cbo_Market2.List(cbo_Market.ListIndex))
        ls_req = Replace(ls_req, "$Desc$", QuoteParam(txt_Descr))
        ls_req = Replace(ls_req, "$Creator$", ml_UCode)

Case Else
    ls_req = gs_ParamReqIns & " '" _
        & QuoteParam(txt_Descr) & "','" _
        & ls_IntFlag & "','" _
        & ls_DropFlag & "','" _
        & ls_DropDate & "'"
End Select

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
        C_main.FillGrid
    Else
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ms_Code = ODBCData(ll_Statement, 1)
            AddRow = OK
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    SendMessage 4, "Insert failed", gut_LangLogin.Code
End If
Exit Function

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

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

DeleteRow = KO

On Error GoTo suite

MouseOn
If SendMessage(5, "Delete record ?", gut_LangLogin.Code, vbQuestion + vbYesNo, "Delete ") = vbYes Then
    MouseOff
    Select Case gs_TableName
    Case "Offer_Internet"
            ls_req = gs_ParamReqDel & " " _
                & gs_TableCode & "," _
                & gs_TableCode3
    Case "Media_Quality_On_Screen", "Definition", "Market_Objectives", "Support", "Media_Interest", "Source_Type", "Type_Of_Memo", "Type_Of_View", "Visible_On", "Media_Type"
        ls_req = gs_ParamReqDel & " '" _
            & gs_TableCode & "', " _
            & gs_TableCode3
    Case "Tech"
        ls_req = gs_ParamReqDel & " " _
            & gs_TableCode3 & ", " & gs_TableCode4
    Case "Product_Combine"
            ls_req = gs_ParamReqDel & " " _
                & gs_TableCode & ", '" _
                & gs_TableCode4 & "', " _
                & gs_TableCode2
    'Competitive DB
    Case "MKT_Super_Base_Material", "MKT_Base_Material"
        ls_req = Replace(gs_ParamReqDel, "$Key$", gs_TableCode)
        ls_req = Replace(ls_req, "$UID$", ml_UCode)
    
    Case Else
        If IsPosInt(gs_TableCode) Then
            ls_req = gs_ParamReqDel & " " _
                & gs_TableCode & ", " _
                & gs_TableCode2
        Else
            ls_req = gs_ParamReqDel & " '" _
                & QuoteParam(gs_TableCode) & "', " _
                & gs_TableCode2
        End If
    End Select
    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 7, "Delete failed : concurrency problem ?", gut_LangLogin.Code
        Else
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
            DeleteRow = OK
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 6, "Delete failed", gut_LangLogin.Code
    End If
End If
MouseOff
Exit Function

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

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

On Error GoTo suite

ls_req = gs_ParamReqCsts & ", '" & 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), 80)
        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_Market": lbl_Market = ls_Text
        Case "lbl_Numeric": lbl_Numeric = ls_Text
        Case "lbl_Desc": lbl_Descr = ls_Text
        Case "lbl_Int": lbl_Int = ls_Text
        Case "lbl_Drop": lbl_Drop = ls_Text
        Case "lbl_Notselected": lbl_NotSelected = ls_Text
        Case "lbl_Selected": lbl_Selected = ls_Text
        Case "lbl_Recommended": lbl_Recommended = ls_Text
        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 FillVdv() As Boolean

Dim ls_req As String

Select Case gs_Action
Case "Add"
    ' we fill the two lists
    lst_NotSelected.Clear
    lst_Selected.Clear
    ls_req = "EXEC " & gut_Param.Str1 & "_Link_cbo " _
        & " 0, 0, '" & gut_LangWork.Code & "'"
        Call FillLstSingle(ls_req, lst_NotSelected)
Case Else
    ' we fill the two lists
    lst_NotSelected.Clear
    lst_Selected.Clear
    Select Case gs_TableName
    Case "Tech"
        ls_req = gs_TableCode3 & ", " & cbo_Market2.List(cbo_Market.ListIndex) & ", '" & gut_LangWork.Code & "'"
    Case Else
        ls_req = gs_TableCode3 & ", 0, '" & gut_LangWork.Code & "'"
    End Select
        Call FillLstSingle("EXEC " & gut_Param.Str1 & "_Link_cbo " & ls_req, lst_NotSelected)
        Call FillLstSingle("EXEC " & gut_Param.Str1 & "_Link_cbo2 " & ls_req, lst_Selected)
End Select

    Call lstAddHScroll(lst_NotSelected)       ' task287 JUNA
    Call lstAddHScroll(lst_Selected)          ' task287 JUNA

End Function

Private Function Control() As Boolean

Control = KO
Select Case gs_TableName
Case "Offer_Internet"
    If cbo_Market.ListIndex = -1 Then
        cbo_Market.SetFocus
        SendMessage 8, "Value must be filled in", gut_LangLogin.Code
        Exit Function
    End If
    If txt_Descr.Text = "" Then
        txt_Descr.SetFocus
        SendMessage 8, "Value must be filled in", gut_LangLogin.Code
        Exit Function
    End If
Case "Tech"
    Select Case gut_Param.Str1
    Case "AcoustAW", "AcoustRW", "AcoustDncW", "FireReac", "Dnfw", "AbsClass", "RedInd", "Rain", "EquivSoundAbs"
        'controle du vidoir devidoir un element doit etre dans la partie droite
        If lst_Selected.ListCount = 0 Then
            lst_Selected.SetFocus
            SendMessage 8, "Value must be filled in", gut_LangLogin.Code
            Exit Function
        End If
    End Select
    If txt_Descr.Text = "" Then
        txt_Descr.SetFocus
        SendMessage 8, "Value must be filled in", gut_LangLogin.Code
        Exit Function
    End If
'task 789 : "AbsClass"
    Select Case gut_Param.Str1
    Case "FireReac", "FireRes", "AbsClass", "Rain"
        If cbo_Market.ListIndex = -1 Then
            cbo_Market.SetFocus
            SendMessage 8, "Value must be filled in", gut_LangLogin.Code
            Exit Function
        End If
    
    Case "AcoustAW", "AcoustNRC", "AcoustDncW", "AcoustRW", "AcoustCAC", "Dnfw", "RedInd", "EquivSoundAbs"
        If cbo_Market.ListIndex = -1 Then
            cbo_Market.SetFocus
            SendMessage 8, "Value must be filled in", gut_LangLogin.Code
            Exit Function
        End If
        If txt_Numeric = "" Then
            txt_Numeric.SetFocus
            SendMessage 8, "Value must be filled in", gut_LangLogin.Code
            Exit Function
        End If
        If Not CheckNumericValue(txt_Numeric) Then
            txt_Numeric.SetFocus
            SendMessage 12, "Value must be numeric", gut_LangLogin.Code
            Exit Function
        End If
    Case "Density", "Humidity", "Light", "Thermal", "Weight"
        If txt_Numeric = "" Then
            txt_Numeric.SetFocus
            SendMessage 8, "Value must be filled in", gut_LangLogin.Code
            Exit Function
        End If
        If Not CheckNumericValue(txt_Numeric) Then
            txt_Numeric.SetFocus
            SendMessage 12, "Value must be numeric", gut_LangLogin.Code
            Exit Function
        End If
    End Select
Case "Product_Combine"
    If cbo_Market.ListIndex = -1 Then
        cbo_Market.SetFocus
        SendMessage 8, "Value must be filled in", gut_LangLogin.Code
        Exit Function
    End If
    If txt_Descr.Text = "" Then
        txt_Descr.SetFocus
        SendMessage 8, "Value must be filled in", gut_LangLogin.Code
        Exit Function
    Else
        If Not ShortCodeExist(txt_Descr) Then
            txt_Descr.SetFocus
            SendMessage 112, "Short code does not exsit !!", gut_LangLogin.Code
            Exit Function
        End If
    End If
Case Else
    If txt_Descr.Text = "" Then
        txt_Descr.SetFocus
        SendMessage 8, "Value must be filled in", gut_LangLogin.Code
        Exit Function
    End If
End Select
Control = OK

End Function
Private Function AddLink() As Boolean

Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim i  As Integer
Dim ls_IntFlag As String
Dim ls_DropFlag As String
Dim ls_DropDate As String
Dim li_Lenght As Integer
Dim li_pos As Integer
Dim ls_HBMdesc As String
Dim ls_CGdesc As String
Dim ls_CCdesc As String
Dim ls_CLdesc As String
Dim ls_VATdesc As String
Dim ls_RestList As String

AddLink = KO

On Error GoTo suite
' gestion des listes
For i = 0 To lst_ToInsert.ListCount - 1
    ls_RestList = lst_ToInsert.List(i)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_CGdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_RestList = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_HBMdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_RestList = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_CCdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_RestList = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_CLdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_VATdesc = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    ls_req = "EXEC " & gut_Param.Str1 & "_Link_ins " _
        & cbo_Market2.List(cbo_Market.ListIndex) & ", " & ms_Code & ", '" & gut_LangWork.Code & "', '" _
        & QuoteParam(ls_HBMdesc) & "', '" _
        & QuoteParam(ls_CGdesc) & "', '" _
        & QuoteParam(ls_CCdesc) & "', '" _
        & QuoteParam(ls_CLdesc) & "', '" _
        & QuoteParam(ls_VATdesc) & "'"
    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
            Exit Function
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        Exit Function
    End If
Next i
AddLink = OK
Exit Function

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

Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim i  As Integer
Dim li_Lenght As Integer
Dim li_pos As Integer
Dim ls_HBMdesc As String
Dim ls_CGdesc As String
Dim ls_CCdesc As String
Dim ls_CLdesc As String
Dim ls_VATdesc As String
Dim ls_RestList As String

On Error GoTo suite

DeleteLink = KO
For i = 0 To lst_ToDelete.ListCount - 1
    ls_RestList = lst_ToDelete.List(i)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_CGdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_RestList = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_HBMdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_RestList = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_CCdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_RestList = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    li_Lenght = Len(ls_RestList)
    li_pos = InStr(1, ls_RestList, "/")
    ls_CLdesc = Mid(ls_RestList, 1, li_pos - 1)
    ls_VATdesc = Mid(ls_RestList, li_pos + 1, li_Lenght - li_pos)
    ls_req = "EXEC " & gut_Param.Str1 & "_Link_del " _
        & cbo_Market2.List(cbo_Market.ListIndex) & ", " & ms_Code & ", '" _
        & gut_LangWork.Code & "', '" _
        & QuoteParam(ls_HBMdesc) & "', '" _
        & QuoteParam(ls_CGdesc) & "', '" _
        & QuoteParam(ls_CCdesc) & "', '" _
        & QuoteParam(ls_CLdesc) & "', '" _
        & QuoteParam(ls_VATdesc) & "'"
    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
            Exit Function
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        Exit Function
    End If
Next i
DeleteLink = OK
Exit Function

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

Dim ls_Line As String
Dim ls_IntFlag As String

On Error GoTo suite

If Control Then
    If AddRow Then
        ' add the line in Cmain
        If chk_Int.Value = 1 Then
            ls_IntFlag = "X"
        Else
            ls_IntFlag = ""
        End If
        Select Case gs_TableName
        Case "Offer_Internet"
            ls_Line = ms_Code & Chr(9) & cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & 1 & Chr(9) & txt_Descr & Chr(9) & cbo_Market & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        Case "Tech"
            ls_Line = cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & cbo_Market & Chr(9) & ms_Code & Chr(9) & 1 & Chr(9) & txt_Descr & Chr(9) & txt_Numeric & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        Case "Media_Quality_On_Screen", "Definition", "Market_Objectives", "Support", "Media_Interest", "Source_Type", "Type_Of_Memo", "Type_Of_View", "Visible_On", "Media_Type"
            ls_Line = ms_Code & Chr(9) & txt_Descr & Chr(9) & 1
        Case "Hyper_Base_Material"
            ls_Line = ms_Code & Chr(9) & 1 & Chr(9) & cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & cbo_Market & Chr(9) & txt_Descr & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        Case "Product_Combine"
            ls_Line = ms_Code & Chr(9) & 1 & Chr(9) & cbo_Market & Chr(9) & UCase(txt_Descr) & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        Case "Glossary_Topic"
            ls_Line = txt_Descr & Chr(9) & 1 & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        'Competitive DB
        Case "MKT_Super_Base_Material"
            ls_Line = ml_NextID & Chr(9) & 1 & Chr(9) & cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & cbo_Market & Chr(9) & txt_Descr & Chr(9) & "0" & Chr(9) & "0" & Chr(9) & "" & Chr(9) & ""
        Case "MKT_Base_Material"
            Call Get_SCDesc(cbo_Market2.List(cbo_Market.ListIndex))
            ls_Line = ml_NextID & Chr(9) & 1 & Chr(9) & ms_SCDesc & Chr(9) & cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & cbo_Market & Chr(9) & txt_Descr & Chr(9) & "0" & Chr(9) & "0" & Chr(9) & "" & Chr(9) & ""
        
        Case Else
            ls_Line = ms_Code & Chr(9) & 1 & Chr(9) & txt_Descr & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        End Select
        C_main.Grid.AddItem ls_Line
        C_main.Grid.Row = C_main.Grid.Rows - 1
        If gs_TableName <> "Product_Combine" Then
            cbo_Market.ListIndex = -1
        End If
        txt_Numeric = ""
        txt_Descr = ""
        txt_Descr.SetFocus
        chk_Int.Value = 0
        txt_dropped = ""
        If gl_NbLineDisplay < 2 Then
            C_main.FillGrid
        End If
    End If ' AddRow
End If 'Control
Exit Sub

suite:
StdError
End Sub
Private Sub GeneralAddVdv()

Dim ls_Line As String
Dim ls_IntFlag As String

On Error GoTo suite

If Control Then
    If BeginTran(gl_Environment, gl_Database) Then
        If AddRow Then
            If AddLink Then
                If CommitTran(gl_Environment, gl_Database) Then
                    ' add the line in Cmain
                    If chk_Int.Value = 1 Then
                        ls_IntFlag = "X"
                    Else
                        ls_IntFlag = ""
                    End If
                    ls_Line = cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & cbo_Market & Chr(9) & ms_Code & Chr(9) & 1 & Chr(9) & txt_Descr & Chr(9) & txt_Numeric & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
                    C_main.Grid.AddItem ls_Line
                    C_main.Grid.Row = C_main.Grid.Rows - 1
                    ' reinit fields for an another entry
                    cbo_Market.ListIndex = -1
                    txt_Numeric = ""
                    txt_Descr = ""
                    txt_Descr.SetFocus
                    chk_Int.Value = 0
                    txt_dropped = ""
                    FillVdv
                    If gl_NbLineDisplay < 2 Then
                        C_main.FillGrid
                    End If
                Else ' commit trans
                    RollbackTran gl_Environment, gl_Database
                    SendMessage 4, "Insert failed", gut_LangLogin.Code
                End If
            Else ' AddLink
                RollbackTran gl_Environment, gl_Database
                SendMessage 4, "Insert failed", gut_LangLogin.Code
            End If
        Else ' AddRow
            RollbackTran gl_Environment, gl_Database
            SendMessage 4, "Insert failed", gut_LangLogin.Code
        End If
    Else ' BeginTrans
        SendMessage 4, "Insert failed", gut_LangLogin.Code
    End If
End If ' control
Exit Sub

suite:
StdError
End Sub
Private Sub GeneralUpdate()

Dim ls_Line As String
Dim ls_IntFlag As String

On Error GoTo suite

If Control Then
    If UpdateRow Then
        If chk_Int.Value = 1 Then
            ls_IntFlag = "X"
        Else
            ls_IntFlag = ""
        End If
' WARNING this will fail if C_main.Grid contain only one row
' JUNA task213 update - bug fix, removeItem fail if removing last line ( fix is: add then remove )
        Select Case gs_TableName
         Case "Offer_Internet"
            ls_Line = gs_TableCode & Chr(9) & gs_TableCode2 & Chr(9) & CInt(gs_TableCode3) + 1 & Chr(9) & txt_Descr & Chr(9) & cbo_Market & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        Case "Media_Quality_On_Screen", "Definition", "Market_Objectives", "Support", "Media_Interest", "Source_Type", "Type_Of_Memo", "Type_Of_View", "Visible_On", "Media_Type"
            ls_Line = gs_TableCode & Chr(9) & txt_Descr & Chr(9) & CInt(gs_TableCode3) + 1
        Case "Tech"
            ls_Line = gs_TableCode & Chr(9) & gs_TableCode2 & Chr(9) & gs_TableCode3 & Chr(9) & CInt(gs_TableCode4) + 1 & Chr(9) & txt_Descr & Chr(9) & txt_Numeric & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        Case "Hyper_Base_Material"
            ls_Line = gs_TableCode & Chr(9) & CInt(gs_TableCode2) + 1 & Chr(9) & gs_TableCode3 & Chr(9) & gs_TableCode4 & Chr(9) & txt_Descr & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        Case "Product_Combine"
            ls_Line = gs_TableCode & Chr(9) & CInt(gs_TableCode2) + 1 & Chr(9) & gs_TableCode3 & Chr(9) & txt_Descr & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        'Competitive DB
        Case "MKT_Super_Base_Material"
            ls_Line = gs_TableCode & Chr(9) & CInt(gs_TableCode2) + 1 & Chr(9) & gs_TableCode3 & Chr(9) & gs_TableCode4 & Chr(9) & txt_Descr & Chr(9) & "0" & Chr(9) & "0" & Chr(9) & "" & Chr(9) & ""
        Case "MKT_Base_Material"
            ls_Line = gs_TableCode & Chr(9) & 1 & Chr(9) & gs_TableCode3 & Chr(9) & cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & cbo_Market & Chr(9) & txt_Descr & Chr(9) & "0" & Chr(9) & "0" & Chr(9) & "" & Chr(9) & ""
        
        Case Else
            ls_Line = gs_TableCode & Chr(9) & CInt(gs_TableCode2) + 1 & Chr(9) & txt_Descr & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
        End Select
        C_main.Grid.AddItem ls_Line, C_main.Grid.Row
        C_main.Grid.RemoveItem C_main.Grid.Row + 1
        Unload Me
        Exit Sub
    End If
End If
Exit Sub

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


Private Sub GeneralUpdateVdv()

Dim ls_Line As String
Dim ls_IntFlag As String

On Error GoTo suite

ms_Code = gs_TableCode3
If Control Then
    If BeginTran(gl_Environment, gl_Database) Then
        If UpdateRow Then
            If DeleteLink Then
                If AddLink Then
                    If CommitTran(gl_Environment, gl_Database) Then
                    ' add the line in Cmain
                        If chk_Int.Value = 1 Then
                            ls_IntFlag = "X"
                        Else
                            ls_IntFlag = ""
                        End If
' JUNA task213 update - bug fix, removeItem fail if removing last line ( fix is: add then remove )
                        ls_Line = cbo_Market2.List(cbo_Market.ListIndex) & Chr(9) & cbo_Market & Chr(9) & ms_Code & Chr(9) & CInt(gs_TableCode4) + 1 & Chr(9) & txt_Descr & Chr(9) & txt_Numeric & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
                        C_main.Grid.AddItem ls_Line
                        C_main.Grid.RemoveItem C_main.Grid.Row
                        C_main.Grid.Row = C_main.Grid.Rows - 1
                        Unload Me
                    Else ' commit trans
                        RollbackTran gl_Environment, gl_Database
                        SendMessage 4, "Update failed", gut_LangLogin.Code
                    End If
                Else ' AddLink
                    RollbackTran gl_Environment, gl_Database
                    SendMessage 4, "Update failed", gut_LangLogin.Code
                End If
            Else ' DeleteLink
                RollbackTran gl_Environment, gl_Database
                SendMessage 4, "Update failed", gut_LangLogin.Code
            End If
        Else ' UpdateRow
            RollbackTran gl_Environment, gl_Database
        End If
    Else ' BeginTrans
        SendMessage 4, "Update failed", gut_LangLogin.Code
    End If
End If ' control
Exit Sub

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

Private Function ShortCodeExist(Short As String) As Boolean
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Desc As String

ShortCodeExist = KO

On Error GoTo suite

ls_req = "EXEC ShortCodeExist '" & Short & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ls_Desc = ODBCData(ll_Statement, 1)
        ShortCodeExist = OK
    End If
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Function

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

Public Property Let CompetitiveDB(ab_CompetitiveDB As Boolean)
    mb_CompetitiveDB = ab_CompetitiveDB
End Property

Private Sub Get_SCDesc(al_Code As Long)
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer

On Error GoTo Err_GetDesc

ms_SCDesc = ""

ls_req = "EXEC MKT_Super_Categories_t_sel $Code$, '$Lang$'"
ls_req = Replace(ls_req, "$Code$", al_Code)
ls_req = Replace(ls_req, "$Lang$", gut_LangLogin.Code)

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

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

Private Sub lstAddHScroll(ByRef ao_lst As ListBox)
On Error GoTo ErrHandler
    Dim ll_lMaxItemWidth As Long
    Dim ll_i As Long
    ll_lMaxItemWidth = 0
    ' depends on the scalewidth
    ' if scalemode is Twips then Divide M by 15 to get Pixels
    For ll_i = 0 To ao_lst.ListCount - 1
        If ao_lst.Parent.TextWidth(ao_lst.List(ll_i)) > ll_lMaxItemWidth Then ll_lMaxItemWidth = ao_lst.Parent.TextWidth(ao_lst.List(ll_i))
    Next
    Call SendMessageAPI(ao_lst.hwnd, LB_SETHORIZONTALEXTENT, ll_lMaxItemWidth / Screen.TwipsPerPixelX + GetSystemMetrics(SM_CXVSCROLL) + 2, 0)
    Exit Sub
ErrHandler:
    StdError
End Sub

