VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "mscomctl.OCX"
Begin VB.Form C_media 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Media choice"
   ClientHeight    =   6765
   ClientLeft      =   2475
   ClientTop       =   1185
   ClientWidth     =   7320
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6765
   ScaleWidth      =   7320
   ShowInTaskbar   =   0   'False
   Begin VB.Frame SSPanel2 
      BackColor       =   &H00C0C0C0&
      BorderStyle     =   0  'None
      Height          =   3255
      Left            =   120
      TabIndex        =   11
      Top             =   3480
      Width           =   7155
      Begin VB.CommandButton cmd_DisplayAll 
         Caption         =   "Display all"
         Height          =   312
         Left            =   120
         TabIndex        =   14
         Top             =   0
         Width           =   1392
      End
      Begin VB.PictureBox pic_next25All 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   6000
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   12
         Top             =   2760
         Visible         =   0   'False
         Width           =   408
      End
      Begin MSComctlLib.TreeView tvw_mediaAll 
         Height          =   2835
         Left            =   120
         TabIndex        =   16
         Top             =   360
         Width           =   6915
         _ExtentX        =   12197
         _ExtentY        =   5001
         _Version        =   393217
         Style           =   7
         Appearance      =   1
      End
      Begin VB.ListBox lst_MD_CodeAll 
         Enabled         =   0   'False
         Height          =   840
         Left            =   3960
         TabIndex        =   13
         Top             =   600
         Visible         =   0   'False
         Width           =   1872
      End
      Begin VB.Label lbl_MediaAll 
         Caption         =   "Media :"
         Height          =   225
         Left            =   3660
         TabIndex        =   15
         Top             =   120
         Width           =   2265
      End
   End
   Begin MSComctlLib.TreeView tvw_media 
      Height          =   2835
      Left            =   120
      TabIndex        =   10
      Top             =   600
      Width           =   5835
      _ExtentX        =   10292
      _ExtentY        =   5001
      _Version        =   393217
      Style           =   7
      Appearance      =   1
   End
   Begin MSComctlLib.ImageList img_pictList 
      Left            =   6120
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      MaskColor       =   16711935
      _Version        =   393216
   End
   Begin VB.PictureBox pic_next25 
      AutoSize        =   -1  'True
      Height          =   408
      Left            =   6000
      ScaleHeight     =   345
      ScaleWidth      =   345
      TabIndex        =   6
      Top             =   2820
      Width           =   408
   End
   Begin VB.PictureBox pic_pic 
      BackColor       =   &H00FFFFFF&
      Height          =   3012
      Left            =   6480
      ScaleHeight     =   2955
      ScaleWidth      =   615
      TabIndex        =   1
      Top             =   360
      Width           =   672
      Begin VB.PictureBox pic_UnDo 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   120
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   9
         Top             =   600
         Visible         =   0   'False
         Width           =   384
      End
      Begin VB.PictureBox pic_PrintResult 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         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        =   4
         Top             =   1080
         Visible         =   0   'False
         Width           =   384
      End
      Begin VB.PictureBox pic_Save 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         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        =   8
         Top             =   120
         Visible         =   0   'False
         Width           =   384
      End
      Begin VB.PictureBox pic_help 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "C_MEDIA.frx":0000
         DrawStyle       =   5  'Transparent
         FillColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   384
         Left            =   120
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   5
         Top             =   2520
         Width           =   384
      End
      Begin VB.PictureBox pic_Refresh 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "C_MEDIA.frx":030A
         DrawStyle       =   5  'Transparent
         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        =   3
         Top             =   1560
         Width           =   384
      End
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "C_MEDIA.frx":0614
         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        =   2
         TabStop         =   0   'False
         Top             =   2040
         Width           =   384
      End
   End
   Begin VB.Frame SSP_Choice 
      BackColor       =   &H00C0C0C0&
      BorderStyle     =   0  'None
      Height          =   1215
      Left            =   120
      TabIndex        =   17
      Top             =   4560
      Width           =   7095
      Begin VB.TextBox txt_MediaTitle 
         ForeColor       =   &H00000000&
         Height          =   288
         Left            =   0
         MaxLength       =   80
         TabIndex        =   21
         Top             =   660
         Width           =   5832
      End
      Begin VB.PictureBox pic_In 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   2460
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   20
         Top             =   120
         Width           =   408
      End
      Begin VB.PictureBox pic_Full 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00C0C0C0&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   6000
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   19
         Top             =   600
         Visible         =   0   'False
         Width           =   384
      End
      Begin VB.TextBox txt_MediaCode 
         ForeColor       =   &H00000000&
         Height          =   288
         Left            =   0
         MaxLength       =   20
         TabIndex        =   18
         Top             =   240
         Visible         =   0   'False
         Width           =   912
      End
   End
   Begin VB.ListBox lst_MD_Code 
      Enabled         =   0   'False
      Height          =   840
      Left            =   4080
      TabIndex        =   7
      Top             =   600
      Visible         =   0   'False
      Width           =   1872
   End
   Begin VB.Label lbl_Media 
      Caption         =   "Media :"
      Height          =   228
      Left            =   3720
      TabIndex        =   0
      Top             =   120
      Width           =   2268
   End
End
Attribute VB_Name = "C_media"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim ms_Media As String
Dim mi_Status As Integer
Dim ml_CurrCount As Long
Dim ml_TotCount As Long
Dim ms_OldType As String
Dim ms_OldLang As String
Dim ml_Statement As Long
Dim mo_typeNode As MSComctlLib.Node, mo_langNode As MSComctlLib.Node

Dim ms_MediaAll As String
Dim mi_StatusAll As Integer
Dim ml_CurrCountAll As Long
Dim ml_TotCountAll As Long
Dim ms_OldTypeAll As String
Dim ms_OldLangAll As String
Dim ml_StatementAll As Long
Dim mo_typeNodeAll As MSComctlLib.Node, mo_langNodeAll As MSComctlLib.Node

Public ms_Desc As String
Public mi_OldMediaIc As Integer

Private Sub ShowTrash()
    If gs_MediaCode = txt_MediaCode And gs_MediaCode <> "" Then
        pic_Full.Visible = OK
    Else
        pic_Full.Visible = KO
    End If
End Sub

Private Function FillMore25() As Boolean

Dim ls_CurrentType As String
Dim ls_CurrentLang As String
Dim ls_CurrentValue As String
Dim li_Count As Integer
Dim li_Icon As Integer
Dim lo_Node As MSComctlLib.Node


On Error GoTo suite

FillMore25 = OK
li_Count = 0

Do While mi_Status = SQL_SUCCESS Or mi_Status = SQL_SUCCESS_WITH_INFO
    mi_Status = SQLFetch(ml_Statement)
    If mi_Status = SQL_SUCCESS Or mi_Status = SQL_SUCCESS_WITH_INFO Then
        ml_CurrCount = ml_CurrCount + 1
        lbl_Media = ms_Media & " " & ml_CurrCount '& " / " & ml_TotCount
        ls_CurrentType = ODBCData(ml_Statement, 1)
        If ls_CurrentType <> ms_OldType Then
            ms_OldType = ls_CurrentType
'            out_Media.ListIndex = -1
'            out_Media.AddItem ls_CurrentType
            lst_MD_Code.AddItem "N/A"
            
            Set mo_typeNode = InsertNode(tvw_media, "", "_0_" & li_Count, ls_CurrentType, RES_CLOSEFOLDER, RES_OPENFOLDER, , vbResBitmap)
            mo_typeNode.Expanded = True
            
            ms_OldLang = ODBCData(ml_Statement, 2)
'            out_Media.AddItem ms_OldLang, out_Media.ListCount - 1
            lst_MD_Code.AddItem "N/A"
'            out_Media.Expand(out_Media.ListCount - 2) = OK
            li_Icon = ODBCData(ml_Statement, 3)
'            out_Media.Image(out_Media.ListCount - 1) = LoadResPicture(li_Icon, 1)
            
            'debug.assert (Not lo_typeNode Is Nothing)
            Set mo_langNode = InsertNode(tvw_media, mo_typeNode.Key, "_1_" & li_Count, ms_OldLang, li_Icon, li_Icon, , vbResIcon)
            mo_langNode.Expanded = True
            
            ls_CurrentValue = ODBCData(ml_Statement, 4) & " / " & ODBCData(ml_Statement, 5)
'            out_Media.AddItem ODBCData(ml_Statement, 4) & " / " & ODBCData(ml_Statement, 5), out_Media.ListCount - 1
            lst_MD_Code.AddItem ODBCData(ml_Statement, 6)
'            out_Media.Expand(out_Media.ListCount - 2) = OK
        
            'debug.assert (Not lo_langNode Is Nothing)
            Set lo_Node = InsertNode(tvw_media, mo_langNode.Key, "_2_" & (lst_MD_Code.ListCount - 1), ls_CurrentValue)
            lo_Node.Expanded = True
        Else
            ls_CurrentLang = ODBCData(ml_Statement, 2)
            If ls_CurrentLang <> ms_OldLang Then
                ms_OldLang = ls_CurrentLang
'                out_Media.AddItem ls_CurrentLang, TListFindItem(out_Media, ls_CurrentType)
                lst_MD_Code.AddItem "N/A"
                li_Icon = ODBCData(ml_Statement, 3)

'                out_Media.Image(out_Media.ListCount - 1) = LoadResPicture(li_Icon, 1)
                
                'Debug.Assert (Not mo_typeNode Is Nothing)
                Set mo_langNode = InsertNode(tvw_media, mo_typeNode.Key, "_1_" & li_Count, ms_OldLang, li_Icon, li_Icon, , vbResIcon)
                mo_langNode.Expanded = True
                
                ls_CurrentValue = ODBCData(ml_Statement, 4) & " / " & ODBCData(ml_Statement, 5)
'                out_Media.AddItem ODBCData(ml_Statement, 4) & " / " & ODBCData(ml_Statement, 5), out_Media.ListCount - 1

                lst_MD_Code.AddItem ODBCData(ml_Statement, 6)
'                out_Media.Expand(out_Media.ListCount - 2) = OK

                'debug.assert (Not lo_langNode Is Nothing)
                Set lo_Node = InsertNode(tvw_media, mo_langNode.Key, "_2_" & (lst_MD_Code.ListCount - 1), ls_CurrentValue)
                lo_Node.Expanded = True
            Else
                ls_CurrentValue = ODBCData(ml_Statement, 4) & " / " & ODBCData(ml_Statement, 5)
'                out_Media.AddItem ODBCData(ml_Statement, 4) & " / " & ODBCData(ml_Statement, 5), TListFindItem(out_Media, ls_CurrentLang)
                lst_MD_Code.AddItem ODBCData(ml_Statement, 6)
            
                'debug.assert (Not lo_langNode Is Nothing)
                Set lo_Node = InsertNode(tvw_media, mo_langNode.Key, "_2_" & (lst_MD_Code.ListCount - 1), ls_CurrentValue)
                lo_Node.Expanded = True
            End If
        End If
        DoEvents
        li_Count = li_Count + 1
        If li_Count = 25 Then
            Exit Do
        End If
    End If
Loop
If mi_Status <> SQL_SUCCESS And mi_Status <> SQL_SUCCESS_WITH_INFO Then
    SQLFreeStatement ml_Statement, SQL_DROP
    FillMore25 = KO
End If
Exit Function

suite:
SQLFreeStatement ml_Statement, SQL_DROP
FillMore25 = KO
StdError
End Function

Private Sub FillResultsAll()

On Error GoTo Err_FillResultsAll

Dim li_Count As Integer

lbl_MediaAll = ms_MediaAll & " ???"
Call tvw_mediaAll.Nodes.Clear
'out_MediaAll.Clear
'pic_PrintResult.Visible = KO
DoEvents
ml_TotCountAll = 0
ms_OldTypeAll = ""
ms_OldLangAll = ""
Set mo_typeNodeAll = Nothing
Set mo_langNodeAll = Nothing

li_Count = 0
If SQLSubmitServer(gl_Environment, gl_Database, ml_StatementAll, gut_Param2.Str6) Then
    SQLRowCount ml_StatementAll, ml_TotCountAll
    mi_StatusAll = SQL_SUCCESS
    pic_next25All.Visible = FillMore25All
'    If ml_TotCountAll > 0 Then
'        pic_PrintResult.Visible = OK
'    End If
End If
lbl_MediaAll = ms_MediaAll & " " & ml_CurrCountAll '& " / " & ml_TotCountAll
Exit Sub

Err_FillResultsAll:
SQLFreeStatement ml_StatementAll, SQL_DROP
StdError
End Sub

Private Function FillMore25All() As Boolean

Dim ls_CurrentType As String
Dim ls_CurrentLang As String
Dim ls_CurrentValue As String
Dim li_Count As Integer
Dim li_Icon As Integer
Dim lo_Node As MSComctlLib.Node


On Error GoTo suite

FillMore25All = OK
li_Count = 0

Set lo_Node = Nothing

Do While mi_StatusAll = SQL_SUCCESS Or mi_StatusAll = SQL_SUCCESS_WITH_INFO
    mi_StatusAll = SQLFetch(ml_StatementAll)
    If mi_StatusAll = SQL_SUCCESS Or mi_StatusAll = SQL_SUCCESS_WITH_INFO Then
        ml_CurrCountAll = ml_CurrCountAll + 1
        lbl_MediaAll = ms_MediaAll & " " & ml_CurrCountAll '& " / " & ml_TotCountAll
        ls_CurrentType = ODBCData(ml_StatementAll, 1)
        If ls_CurrentType <> ms_OldTypeAll Then
            ms_OldTypeAll = ls_CurrentType
            
'            out_MediaAll.ListIndex = -1
'            out_MediaAll.AddItem ls_CurrentType
            lst_MD_CodeAll.AddItem "N/A"
            
            Set mo_typeNodeAll = InsertNode(tvw_mediaAll, "", "_0_" & li_Count, ls_CurrentType, RES_CLOSEFOLDER, RES_OPENFOLDER, , vbResBitmap)
            mo_typeNodeAll.Expanded = True
            
            ms_OldLangAll = ODBCData(ml_StatementAll, 2)
'            out_MediaAll.AddItem ms_OldLangAll, out_MediaAll.ListCount - 1
            lst_MD_CodeAll.AddItem "N/A"
'            out_MediaAll.Expand(out_MediaAll.ListCount - 2) = OK
            li_Icon = ODBCData(ml_StatementAll, 3)
'            out_MediaAll.Image(out_MediaAll.ListCount - 1) = LoadResPicture(li_Icon, 1)
            
            Set mo_langNodeAll = InsertNode(tvw_mediaAll, mo_typeNodeAll.Key, "_1_" & li_Count, ms_OldLangAll, li_Icon, li_Icon, , vbResIcon)
            mo_langNodeAll.Expanded = True
            
            ls_CurrentValue = ODBCData(ml_StatementAll, 4) & " / " & ODBCData(ml_StatementAll, 5)
'            out_MediaAll.AddItem ls_CurrentValue, out_MediaAll.ListCount - 1
            lst_MD_CodeAll.AddItem ODBCData(ml_StatementAll, 6)
'            out_MediaAll.Expand(out_MediaAll.ListCount - 2) = OK
        
            Set lo_Node = InsertNode(tvw_mediaAll, mo_langNodeAll.Key, "_2_" & (lst_MD_CodeAll.ListCount - 1), ls_CurrentValue)
            lo_Node.Expanded = True
        Else
            ls_CurrentLang = ODBCData(ml_StatementAll, 2)
            If ls_CurrentLang <> ms_OldLangAll Then
                ms_OldLangAll = ls_CurrentLang
'                out_MediaAll.AddItem ls_CurrentLang, TListFindItem(out_MediaAll, ls_CurrentType)
                lst_MD_CodeAll.AddItem "N/A"
                li_Icon = ODBCData(ml_StatementAll, 3)

'                out_MediaAll.Image(out_MediaAll.ListCount - 1) = LoadResPicture(li_Icon, 1)
                
                Set mo_langNodeAll = InsertNode(tvw_mediaAll, mo_typeNodeAll.Key, "_1_" & li_Count, ms_OldLangAll, li_Icon, li_Icon, , vbResIcon)
                mo_langNodeAll.Expanded = True
                
                ls_CurrentValue = ODBCData(ml_StatementAll, 4) & " / " & ODBCData(ml_StatementAll, 5)
'                out_MediaAll.AddItem ls_CurrentValue, out_MediaAll.ListCount - 1
                lst_MD_CodeAll.AddItem ODBCData(ml_StatementAll, 6)
'                out_MediaAll.Expand(out_MediaAll.ListCount - 2) = OK
            
                Set lo_Node = InsertNode(tvw_mediaAll, mo_langNodeAll.Key, "_2_" & (lst_MD_CodeAll.ListCount - 1), ls_CurrentValue)
                lo_Node.Expanded = True
            Else
                ls_CurrentValue = ODBCData(ml_StatementAll, 4) & " / " & ODBCData(ml_StatementAll, 5)
'                out_MediaAll.AddItem ls_CurrentValue, TListFindItem(out_MediaAll, ls_CurrentLang)
                lst_MD_CodeAll.AddItem ODBCData(ml_StatementAll, 6)
            
                Set lo_Node = InsertNode(tvw_mediaAll, mo_langNodeAll.Key, "_2_" & (lst_MD_CodeAll.ListCount - 1), ls_CurrentValue)
                lo_Node.Expanded = True
            End If
        End If
        DoEvents
        li_Count = li_Count + 1
        If li_Count = 25 Then
            Exit Do
        End If
    End If
Loop
If mi_StatusAll <> SQL_SUCCESS And mi_StatusAll <> SQL_SUCCESS_WITH_INFO Then
    SQLFreeStatement ml_StatementAll, SQL_DROP
    FillMore25All = KO
End If
Exit Function

suite:
SQLFreeStatement ml_StatementAll, SQL_DROP
FillMore25All = KO
StdError
End Function


Private Sub cmd_DisplayAll_Click()
MouseOff
ml_CurrCountAll = 0
FillResultsAll
MouseOn
End Sub

Private Sub Form_Load()
Dim li_Count As Integer

MouseOff

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

pic_PrintResult.Picture = LoadResPicture(RES_PRINT, 1)
pic_refresh.Picture = LoadResPicture(RES_REFRESH, 1)
pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_next25.Picture = LoadResPicture(RES_DOWN, 1)
pic_next25All.Picture = LoadResPicture(RES_DOWN, 1)
pic_help.Picture = LoadResPicture(RES_HELP, 1)
pic_Save.Picture = LoadResPicture(RES_OK, 1)

pic_Full.Picture = LoadResPicture(RES_DELETEFULL, 1)
pic_In.Picture = LoadResPicture(RES_DOWN2, 1)
pic_Undo.Picture = LoadResPicture(RES_CANCEL, 1)

    ' NEW remove TreeView begin
    Call InitImageList(img_pictList)
    Call InitTreeView(tvw_media, img_pictList)
    Call InitTreeView(tvw_mediaAll, img_pictList)
    ' NEW remove TreeView end

Getcsts
Select Case gut_Param2.Str1
Case "Display"
    Top = 1580 + frmMain.Top
    Left = 3280 + frmMain.Left
    Width = 8650
    Height = 7750
    If gut_Param2.Str6 = "" Then
        SSPanel2.Visible = KO
        cmd_DisplayAll.Visible = KO
        lbl_MediaAll.Visible = KO
        tvw_mediaAll.Visible = KO
'        out_MediaAll.Visible = KO
        pic_next25All.Visible = KO
        pic_next25.Top = 5050
        tvw_media.Height = 5150
'        out_Media.Height = 5150
    End If
Case Else
    Top = 1000
    Left = 2000
    Width = 7200
    If gs_Action = "Update" Or gs_Action = "Add" Then
        Height = 6000
    Else
        Height = 4500
    End If
    cmd_DisplayAll.Visible = KO
    lbl_MediaAll.Visible = KO
'    out_MediaAll.Visible = KO
    tvw_mediaAll.Visible = KO
    pic_next25All.Visible = KO
    
    SSPanel2.Visible = KO
    pic_next25.Top = 3550
    tvw_media.Height = 3650
'    out_Media.Height = 3650
End Select
ml_CurrCount = 0
FillResults
Select Case gs_TableName
Case "Colours", "Products_Edges", "Products_Patterns", "Surfaces"
    If gs_MediaCode <> "" Then
        For li_Count = 1 To lst_MD_Code.ListCount
            If lst_MD_Code.List(li_Count) = gs_MediaCode Then
'                C_media.out_Media.ListIndex = li_Count
'                txt_MediaCode = gs_MediaCode
'                txt_MediaTitle = C_media.out_Media.List(C_media.out_Media.ListIndex)
                
                ' NEW remove TreeView begin NOT TESTED !!!!!!!!!!!!!!
                Set C_media.tvw_media.SelectedItem = C_media.tvw_media.Nodes("_2_" & li_Count)
                txt_MediaCode = gs_MediaCode
                txt_MediaTitle = C_media.tvw_media.Nodes("_2_" & li_Count).Text
                ' NEW remove TreeView end

                Exit For
            End If
        Next
        If gs_Action = "Update" Or gs_Action = "Add" Then
            pic_Save.Visible = OK
            pic_Save.Enabled = OK
        
            ShowTrash
            pic_Undo.Visible = OK
            pic_Undo.Enabled = OK
            SSP_Choice.Visible = OK
        End If
    Else
        'MJJB
        If ml_CurrCount > 0 And gs_Action = "Update" Or gs_Action = "Add" Then
        'If ml_TotCount > 0 And gs_Action = "Update" Or gs_Action = "Add" Then
        'EJJB
            pic_Save.Visible = OK
            pic_Save.Enabled = OK
            
            ShowTrash
            pic_Undo.Visible = OK
            pic_Undo.Enabled = OK
            SSP_Choice.Visible = OK
        End If
    End If
End Select
MouseOn

End Sub
Private Sub Getcsts()

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

On Error GoTo suite

ls_req = "EXEC Screen_Csts 'Media_choice', '" & gut_LangLogin.Code & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ls_Field = ODBCData(ll_Statement, 1)
        ls_Text = ODBCData(ll_Statement, 2)
        Select Case ls_Field
        Case "title"
            If gut_Param2.Str1 = "Maintenance" Then
                Caption = ls_Text & " (" & gut_Param2.Str4 & " = " & gut_Param2.Str5 & ")"
            Else
                Caption = ""
            End If
        Case "lbl_Media"
            ms_Media = ls_Text
            lbl_Media = ms_Media
        Case "lbl_MediaAll"
            ms_MediaAll = ls_Text
            lbl_MediaAll = ms_MediaAll
        Case "lbl_DispAll"
            cmd_DisplayAll.Caption = 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 Sub Form_Unload(Cancel As Integer)
    SQLFreeStatement ml_Statement, SQL_DROP
End Sub



'Private Sub out_Media_DblClick()
'On Error GoTo Err_Out_Media_DblClick
'MouseOff
'If out_Media.Indent(out_Media.ListIndex) = 2 Then
'    gs_MediaCode = C_media.lst_MD_Code.List(C_media.out_Media.ListIndex)
    
'    Media_dsp.ms_Caller = "media"
'    Media_dsp.show 1
'End If
'MouseOn
'Exit Sub

'Err_Out_Media_DblClick:
''MouseOn
'SendMessage 106, "No media associated or impossible to display it.", gut_LangLogin.Code
'MouseOn

'End Sub

'Private Sub out_MediaAll_DblClick()
'On Error GoTo Err_Out_MediaAll_DblClick
'MouseOff
'If out_MediaAll.Indent(out_MediaAll.ListIndex) = 2 Then
'    gs_MediaCode = C_media.lst_MD_CodeAll.List(C_media.out_MediaAll.ListIndex)
    
'    Media_dsp.ms_Caller = "media"
'    Media_dsp.show 1
'End If
'MouseOn
'Exit Sub

'Err_Out_MediaAll_DblClick:
''MouseOn
'SendMessage 106, "No media associated or impossible to display it.", gut_LangLogin.Code
'MouseOn
'End Sub

Private Sub pic_Full_Click()
Dim ls_req As String
Dim li_Status As Integer
Dim ll_Statement As Long
    ls_req = "EXEC Int_Media_Ass_del '" & ms_Desc & ", 'E'," & mi_OldMediaIc
    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
                ' OK
        Else
            SendMessage 7, "Delete Failed: concurrency problem.", gut_LangLogin.Code
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End If
    gs_MediaCode = ""
    Unload Me
End Sub

Private Sub pic_help_Click()

MouseOff
frm_help.show 1
MouseOn

End Sub

Private Sub pic_In_Click()
'If out_Media.Indent(out_Media.ListIndex) = 2 Then
'    txt_MediaCode = C_media.lst_MD_Code.List(C_media.out_Media.ListIndex)
'    txt_MediaTitle = C_media.out_Media.List(C_media.out_Media.ListIndex)
'    ShowTrash
'End If
' NEW remove TreeView begin NOT TESTED !!!!!!!!!!!!!!
If Not tvw_media.SelectedItem Is Nothing Then
    If tvw_media.SelectedItem.Key Like "_2_*" Then
        txt_MediaCode = C_media.lst_MD_Code.List(Mid(C_media.tvw_media.SelectedItem.Key, 4))
        txt_MediaTitle = C_media.tvw_media.SelectedItem.Text
        ShowTrash
    End If
End If
End Sub

Private Sub pic_next25_Click()

MouseOff
pic_next25.Visible = FillMore25
MouseOn

End Sub

Private Sub pic_next25All_Click()

MouseOff
pic_next25All.Visible = FillMore25All
MouseOn

End Sub

Private Sub pic_PrintResult_Click()

If Printers.Count = 0 Then
    SendMessage 135, "No printer is installed on your computer. Please, contact your system administrator.", gut_LangLogin.Code
    Exit Sub
End If

MouseOff
Call TreeViewPrint(tvw_media)
'TListPrint out_Media
MouseOn

End Sub
Private Sub pic_quit_Click()

MouseOff
'MJJB
SQLFreeStatement ml_Statement, SQL_DROP
SQLFreeStatement ml_StatementAll, SQL_DROP
'EJJB
Unload Me
MouseOn

End Sub
Private Sub FillResults()

On Error GoTo Err_FillResults

Dim li_Count As Integer

lbl_Media = ms_Media & " ???"
Call tvw_media.Nodes.Clear
'out_Media.Clear
pic_PrintResult.Visible = KO
DoEvents
ml_TotCount = 0
ms_OldType = ""
ms_OldLang = ""
Set mo_typeNode = Nothing
Set mo_langNode = Nothing

li_Count = 0
If SQLSubmitServer(gl_Environment, gl_Database, ml_Statement, gut_Param2.Str3) Then
    SQLRowCount ml_Statement, ml_TotCount
    mi_Status = SQL_SUCCESS
    pic_next25.Visible = FillMore25
    If ml_TotCount > 0 Then
        pic_PrintResult.Visible = OK
    End If
End If
lbl_Media = ms_Media & " " & ml_CurrCount '& " / " & ml_TotCount
Exit Sub

Err_FillResults:
SQLFreeStatement ml_Statement, SQL_DROP
StdError
End Sub
Private Sub pic_refresh_Click()
Dim li_Count As Integer

MouseOff
ml_CurrCount = 0
'MJJB
SQLFreeStatement ml_Statement, SQL_DROP
SQLFreeStatement ml_StatementAll, SQL_DROP
'EJJB
FillResults
If gut_Param2.Str1 <> "Display" Then
    If txt_MediaCode <> "" Then
        For li_Count = 1 To lst_MD_Code.ListCount
            If lst_MD_Code.List(li_Count) = txt_MediaCode Then
'                 C_media.out_Media.ListIndex = li_Count
'                 txt_MediaCode = gs_MediaCode
'                 txt_MediaTitle = C_media.out_Media.List(C_media.out_Media.ListIndex)

                 ' NEW remove TreeView begin NOT TESTED !!!!!!!!!!!!!!
                 ' select item in TreeView
                 Set C_media.tvw_media.SelectedItem = C_media.tvw_media.Nodes("_2_" & li_Count)
                 txt_MediaCode = gs_MediaCode
                 txt_MediaTitle = C_media.tvw_media.SelectedItem.Text
                 Exit For
            End If
        Next
    End If
End If
MouseOn

End Sub



Private Sub pic_Save_Click()

If txt_MediaCode <> "" Then
    gs_MediaCode = txt_MediaCode
    Unload Me
Else
    SendMessage 1, "Select a record first, please", gut_LangLogin.Code
    MouseOn
End If

End Sub


Private Sub pic_UnDo_Click()
Dim li_Count As Integer
If gs_MediaCode <> "" Then
    For li_Count = 1 To lst_MD_Code.ListCount
        If lst_MD_Code.List(li_Count) = gs_MediaCode Then
'            C_media.out_Media.ListIndex = li_Count
'            txt_MediaCode = gs_MediaCode
'            txt_MediaTitle = C_media.out_Media.List(C_media.out_Media.ListIndex)
            
            Set C_media.tvw_media.SelectedItem = C_media.tvw_media.Nodes("_2_" & li_Count)
            txt_MediaCode = gs_MediaCode
            txt_MediaTitle = C_media.tvw_media.SelectedItem.Text
            
            ShowTrash
            Exit For
        End If
    Next
Else
    txt_MediaCode = ""
    txt_MediaTitle = ""
    ShowTrash
End If
End Sub


' NEW remove TreeView begin
Private Function InsertNode(ByVal ao_tvw As MSComctlLib.TreeView, ByVal ao_parentKey As String, ByVal as_Key As String, ByVal as_Text As String, Optional ByVal al_Image As Long = -1, Optional ByVal al_imageSel As Long = -1, Optional ByVal al_relationship As MSComctlLib.TreeRelationshipConstants = tvwChild, Optional ByVal al_imageType As LoadResConstants = vbResIcon) As MSComctlLib.Node
    Dim lo_retNode As MSComctlLib.Node
    Set lo_retNode = GetNode(ao_tvw, as_Key)
    If lo_retNode Is Nothing Then
        Set lo_retNode = ao_tvw.Nodes.Add(IIf(ao_parentKey = "", Null, ao_parentKey), _
                                          al_relationship, _
                                          as_Key, _
                                          as_Text, _
                                          GetImageIndex(ao_tvw.ImageList, al_Image, al_imageType), _
                                          GetImageIndex(ao_tvw.ImageList, al_imageSel, al_imageType))
    End If
    Set InsertNode = lo_retNode
End Function

Private Function GetNode(ByVal ao_tvw As MSComctlLib.TreeView, ByVal as_Key As String) As MSComctlLib.Node
    Dim lo_Node As MSComctlLib.Node
    
    Set GetNode = Nothing
    For Each lo_Node In ao_tvw.Nodes
        If lo_Node.Key = as_Key Then
            Set GetNode = lo_Node
            Exit For
        End If
    Next
End Function

Private Function GetImageIndex(ByVal ao_ImageList As MSComctlLib.ImageList, ByVal al_resIndex As Long, ByVal al_resType As LoadResConstants) As Variant
    If (ao_ImageList Is Nothing) Or (al_resIndex = -1) Then
        GetImageIndex = Empty
        Exit Function
    End If
    
    Dim lo_image As MSComctlLib.ListImage
    For Each lo_image In ao_ImageList.ListImages
        If lo_image.Key = "_" & al_resIndex Then
            GetImageIndex = lo_image.Index
            Exit Function
        End If
    Next
    
    GetImageIndex = LoadImage(ao_ImageList, al_resIndex, al_resType)
End Function

Private Function LoadImage(ByVal ao_ImageList As MSComctlLib.ImageList, ByVal al_resIndex As Long, ByVal al_resType As LoadResConstants) As Long
    Dim lo_image As MSComctlLib.ListImage
    Set lo_image = ao_ImageList.ListImages.Add(, "_" & al_resIndex, LoadResPicture(al_resIndex, al_resType))
    LoadImage = lo_image.Index
End Function

Private Sub InitTreeView(ByRef ao_tvw As MSComctlLib.TreeView, Optional ByVal ao_imgList As MSComctlLib.ImageList = Nothing)
    ao_tvw.HideSelection = False        ' don't hide selection when lostFocus
    ao_tvw.LineStyle = tvwTreeLines
    ao_tvw.LabelEdit = tvwManual        ' disable edit labels
    ao_tvw.Indentation = 300
    Set ao_tvw.ImageList = ao_imgList
End Sub

Private Sub InitImageList(ByRef ao_imgList As MSComctlLib.ImageList)
    ao_imgList.ImageHeight = 16
    ao_imgList.ImageWidth = 16
    ao_imgList.MaskColor = vbMagenta
    
    
    ' at least one image must be loaded to correctly initialize imagelist
    Call LoadImage(ao_imgList, RES_OPENFOLDER, vbResBitmap)
    
End Sub
' NEW remove TreeView end


Private Sub tvw_media_DblClick()
On Error GoTo Err_Out_Media_DblClick
MouseOff
'If out_Media.Indent(out_Media.ListIndex) = 2 Then
'debug.assert (Not tvw_media.SelectedItem Is Nothing)
If tvw_media.SelectedItem.Key Like "_2_*" Then
'    gs_MediaCode = C_media.lst_MD_Code.List(C_media.out_Media.ListIndex)
    gs_MediaCode = C_media.lst_MD_Code.List(C_media.tvw_media.SelectedItem.Index - 1)
    
    Media_dsp.ms_Caller = "media"
    Media_dsp.show 1
End If
MouseOn
Exit Sub

Err_Out_Media_DblClick:
'MouseOn
SendMessage 106, "No media associated or impossible to display it.", gut_LangLogin.Code
MouseOn

End Sub

Private Sub tvw_mediaAll_DblClick()
On Error GoTo Err_Out_MediaAll_DblClick
MouseOff
'If out_MediaAll.Indent(out_MediaAll.ListIndex) = 2 Then
'debug.assert (Not tvw_mediaAll.SelectedItem Is Nothing)
If tvw_mediaAll.SelectedItem.Key Like "_2_*" Then
'    gs_MediaCode = C_media.lst_MD_CodeAll.List(C_media.out_MediaAll.ListIndex)
    gs_MediaCode = C_media.lst_MD_CodeAll.List(Mid(C_media.tvw_mediaAll.SelectedItem.Key, 4))
    
    Media_dsp.ms_Caller = "media"
    Media_dsp.show 1
End If
MouseOn
Exit Sub

Err_Out_MediaAll_DblClick:
'MouseOn
SendMessage 106, "No media associated or impossible to display it.", gut_LangLogin.Code
MouseOn

End Sub
