VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frm_main_mc 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Marketing classification"
   ClientHeight    =   5565
   ClientLeft      =   90
   ClientTop       =   900
   ClientWidth     =   9480
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   5565
   ScaleWidth      =   9480
   ShowInTaskbar   =   0   'False
   Begin VB.Frame frm_Language 
      BackColor       =   &H00FFFFFF&
      ClipControls    =   0   'False
      ForeColor       =   &H00FFFFFF&
      Height          =   2595
      Left            =   4980
      TabIndex        =   14
      Top             =   480
      Visible         =   0   'False
      Width           =   915
      Begin MSComctlLib.ListView lvw_Language 
         Height          =   2415
         Left            =   60
         TabIndex        =   15
         Top             =   120
         Width           =   765
         _ExtentX        =   1349
         _ExtentY        =   4260
         View            =   3
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         HideColumnHeaders=   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         Appearance      =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   1
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Object.Width           =   882
         EndProperty
      End
   End
   Begin VB.Frame SSP_General 
      BackColor       =   &H80000009&
      BorderStyle     =   0  'None
      Height          =   615
      Left            =   0
      TabIndex        =   2
      Top             =   0
      Width           =   9495
      Begin VB.PictureBox pic_Quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.frx":0000
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   8280
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   13
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_add 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.frx":030A
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   240
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   12
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_delete 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   1620
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   11
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_help 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.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            =   8880
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   10
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_log 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.frx":091E
         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            =   3660
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   9
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_upd 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.frx":0C28
         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            =   960
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   8
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_refresh 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   384
         Left            =   4320
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   7
         Top             =   105
         Width           =   384
      End
      Begin VB.PictureBox pic_search 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.frx":0F32
         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            =   2280
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   6
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_print 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   3000
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   5
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_Language 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.frx":123C
         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            =   5040
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   4
         Top             =   90
         Width           =   384
      End
      Begin VB.PictureBox pic_media 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "MAIN_MC.frx":1546
         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            =   6060
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   3
         Top             =   75
         Width           =   384
      End
   End
   Begin VB.ComboBox cbo_MediaCode 
      Height          =   300
      ItemData        =   "MAIN_MC.frx":1850
      Left            =   6840
      List            =   "MAIN_MC.frx":1852
      TabIndex        =   0
      Text            =   "Combo1"
      Top             =   3840
      Visible         =   0   'False
      Width           =   1695
   End
   Begin MSComctlLib.ImageList img_pictList 
      Left            =   8820
      Top             =   4920
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      MaskColor       =   8388736
      _Version        =   393216
   End
   Begin MSFlexGridLib.MSFlexGrid Grid 
      Height          =   4455
      Left            =   180
      TabIndex        =   16
      Top             =   840
      Width           =   8835
      _ExtentX        =   15584
      _ExtentY        =   7858
      _Version        =   393216
      Cols            =   7
      FixedCols       =   0
      AllowUserResizing=   1
   End
   Begin VB.Label lbl_category 
      Height          =   252
      Left            =   3120
      TabIndex        =   1
      Top             =   0
      Visible         =   0   'False
      Width           =   1212
   End
End
Attribute VB_Name = "frm_main_mc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mi_Xav As Integer
Dim mi_Yav As Integer
Dim mi_Xav2 As Integer
Dim mi_Yav2 As Integer
Dim mb_Selected As Boolean
Private Sub def_permission()
Dim ls_Perm As String
Dim ll_Statement As Long
Dim ll_LngID As Long
Dim li_Status As Integer
Dim ls_Req As String

On Error GoTo suite

ls_Req = "EXEC Check_Security media_advert_classif, " & prg.LoginName
pic_add.Visible = 0
pic_delete.Visible = 0
pic_upd.Visible = 0

If gut_LangWork.Code = "E" Then
    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_Perm = ODBCData(ll_Statement, 1)
            If ls_Perm = "Insert" Then
                pic_add.Visible = OK
            End If
            If ls_Perm = "Delete" Then
                pic_delete.Visible = OK
            End If
            If ls_Perm = "Update" Then
                pic_upd.Visible = OK
            End If
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End If
Exit Sub

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


Public Sub ClearGrid()

Dim i As Integer

Grid.HighLight = flexHighlightNever
Grid.Cols = 5
Grid.Rows = 2
Grid.Row = 1
For i = 0 To Grid.Cols - 1
    Grid.Col = i
    Grid.Text = ""
    Grid.ColWidth(i) = 2000
Next i

End Sub
Public Sub FillGrid()

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

On Error GoTo suite

ls_Req = "EXEC media_advert_classif_t_lst '" & QuoteParam(gs_MediaCode) & "','" & QuoteParam(gut_LangWork.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
        Grid.Row = Grid.Rows - 1
        For li_Count = 0 To 4
            Grid.Col = li_Count
            Grid.Text = ODBCData(ll_Statement, li_Count + 1)
        Next li_Count
        cbo_MediaCode.AddItem ODBCData(ll_Statement, 6)
        Grid.Rows = Grid.Rows + 1
    End If
Loop
Grid.Row = 1
Grid.Col = 0
If Grid.Text <> "" Then Grid.RemoveItem Grid.Rows - 1
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub
Private Sub get_sc_csts()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Field, ls_Text As String
   
ls_Req = "EXEC Screen_Csts 'main_mc','" & QuoteParam(gut_LangLogin.Code) & "'"

On Error GoTo suite

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

Grid.Row = 0
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ls_Field = ODBCData(ll_Statement, 1)
        ls_Text = ODBCData(ll_Statement, 2)
        Select Case ls_Field
            Case "title": Caption = ls_Text
            Case "col0": Grid.Col = 0
                         Grid.Text = ls_Text
            Case "col1": Grid.Col = 1
                         Grid.Text = ls_Text
            Case "col2": Grid.Col = 2
                         Grid.Text = ls_Text
            Case "col3": Grid.Col = 3
                         Grid.Text = ls_Text
            Case "col4": Grid.Col = 4
                         Grid.Text = 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 csp_Language_Click()
'Dim li_SvgSel As Integer

'MouseOff

'gut_LangWork.Code = csp_Language.ListTabText(csp_Language.ListIndex, 1)
'pic_Language.Picture = csp_Language.ListPicture(csp_Language.ListIndex)
'frm_Language.Visible = KO
'def_permission
'ClearGrid
'FillGrid
'MouseOn
'End Sub



'Private Sub csp_Language_LostFocus()
'frm_Language.Visible = KO
'End Sub


Private Sub lvw_Language_Click()
Dim li_SvgSel As Integer
MouseOff

If Not lvw_Language.SelectedItem Is Nothing Then
    gut_LangWork.Code = GetTagValue(lvw_Language.SelectedItem, 0)
    pic_Language.Picture = img_pictList.ListImages(lvw_Language.SelectedItem.SmallIcon).Picture
    frm_Language.Visible = KO
    def_permission
    ClearGrid
    FillGrid
End If

MouseOn
End Sub

Private Sub lvw_Language_LostFocus()
frm_Language.Visible = KO
End Sub


Private Sub Form_Load()

MouseOff

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

gut_LangWork.Code = gut_LangLogin.Code
pic_add.Picture = LoadResPicture(RES_ADD, 1)
pic_delete.Picture = LoadResPicture(RES_DELETE, 1)
pic_upd.Picture = LoadResPicture(RES_MODIFY, 1)
pic_help.Picture = LoadResPicture(RES_HELP, 1)
pic_log.Picture = LoadResPicture(RES_LOG, 1)
pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_refresh.Picture = LoadResPicture(RES_REFRESH, 1)
pic_search.Picture = LoadResPicture(RES_SEARCH, 1)
pic_print.Picture = LoadResPicture(RES_PRINT, 1)
pic_Language.Picture = LoadResPicture(gut_LangLogin.Icon, 1)
pic_media.Picture = LoadResPicture(RES_MEDIA, 1)

    ' NEW remove ListView begin
    Call InitImageList(img_pictList)
    Call InitListView(lvw_Language, img_pictList)
    ' NEW remove ListView end

'FillCspLanguage csp_Language
FillLvwLanguage lvw_Language

mi_Yav = 0
mi_Xav = 0
mi_Yav2 = 0
mi_Xav2 = 0

get_sc_csts
cbo_MediaCode.Clear
ClearGrid
FillGrid
def_permission
mb_Selected = KO
MouseOn

End Sub
Public Sub Grid_Click()

MouseOff
If Grid.Col <> mi_Xav Or Grid.Row <> mi_Yav Then
    Grid.HighLight = flexHighlightAlways
Else
    Grid.HighLight = IIf(Grid.HighLight = flexHighlightNever, flexHighlightAlways, flexHighlightNever)
End If
mi_Xav = Grid.Col
mi_Yav = Grid.Row
If Grid.TextMatrix(Grid.Row, Grid.Col) = "" Or Grid.HighLight = flexHighlightNever Then
    mb_Selected = KO
Else
    mb_Selected = OK
End If
If Grid.HighLight = flexHighlightAlways Then
    Grid.FocusRect = flexFocusNone
'    Grid.Row = 0
Else
    Grid.FocusRect = flexFocusHeavy
End If
MouseOn

End Sub


Private Sub pic_add_Click()

MouseOff
Grid.Row = mi_Yav
gs_Action = "add"
frm_mtnc_mc.show 1
MouseOn

End Sub

Private Sub pic_delete_Click()

MouseOff
If Not mb_Selected Then
    SendMessage 1, "Select record first, please", gut_LangLogin.Code
    MouseOn
    Exit Sub
End If

Grid.Row = mi_Yav
gs_Action = "del"
frm_mtnc_mc.show 1
mb_Selected = KO
MouseOn

End Sub
Private Sub pic_Language_Click()
MouseOff
frm_Language.Visible = Not frm_Language.Visible
'csp_Language.SetFocus
lvw_Language.SetFocus
MouseOn
End Sub

Private Sub pic_media_Click()
On Error GoTo suite
MouseOff
If gs_MediaCode <> "" Then
    
    Media_dsp.ms_Caller = "media"
    Media_dsp.show 1
End If
MouseOn
Exit Sub

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

Private Sub pic_print_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
PrintGrid2 11, Array(70, 70, 70, 70, 70), Array(0, 1, 2, 3, 4)
MouseOn

End Sub
Private Sub pic_quit_Click()
Unload Me
End Sub

Private Sub pic_refresh_Click()

MouseOff
mi_Yav = 0
mi_Xav = 0
mi_Yav2 = 0
mi_Xav2 = 0
get_sc_csts
cbo_MediaCode.Clear
ClearGrid
FillGrid
MouseOn

End Sub

Private Sub pic_search_Click()

MouseOff
gi_SearchGrid = 2
C_search.show 1
MouseOn

End Sub


Private Sub pic_upd_Click()

MouseOff
If Not mb_Selected Then
    SendMessage 1, "Select record first, please", gut_LangLogin.Code
    MouseOn
    Exit Sub
End If

Grid.Row = mi_Yav
gs_Action = "upd"
frm_mtnc_mc.show 1
mb_Selected = KO
MouseOn

End Sub

' NEW Remove ListView begin

Private Function GetTagValue(ByVal ao_lvw As MSComctlLib.ListItem, ByVal al_Index As Long)
    Dim ls_values() As String
    ls_values = Split(ao_lvw.Tag, SEP)

    GetTagValue = ls_values(al_Index)

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 InitListView(ByRef ao_lvw As MSComctlLib.ListView, Optional ByVal ao_imgList As MSComctlLib.ImageList = Nothing)
    ao_lvw.HideSelection = False        ' don't hide selection when lostFocus
    ao_lvw.View = lvwReport
    ao_lvw.LabelEdit = lvwManual       ' disable edit labels
    ao_lvw.Icons = ao_imgList
    ao_lvw.SmallIcons = ao_imgList
End Sub

Private Sub InitImageList(ByRef ao_imgList As MSComctlLib.ImageList)
    ao_imgList.ImageHeight = 32
    ao_imgList.ImageWidth = 32
    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 ListView end

