VERSION 5.00
Begin VB.Form frm_mtnc_mc 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Marketing classification maintenance"
   ClientHeight    =   2865
   ClientLeft      =   1245
   ClientTop       =   2145
   ClientWidth     =   7305
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2865
   ScaleWidth      =   7305
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   612
      Left            =   5520
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   1440
      Width           =   672
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   6300
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   1440
      Width           =   672
   End
   Begin VB.ComboBox cbo_SupportCode 
      Height          =   288
      Left            =   3960
      Style           =   2  'Dropdown List
      TabIndex        =   16
      Top             =   1380
      Visible         =   0   'False
      Width           =   492
   End
   Begin VB.ComboBox cbo_STypeCode 
      Height          =   288
      Left            =   1680
      Style           =   2  'Dropdown List
      TabIndex        =   15
      Top             =   1380
      Visible         =   0   'False
      Width           =   492
   End
   Begin VB.ComboBox cbo_AreaCode 
      Height          =   288
      Left            =   6240
      Style           =   2  'Dropdown List
      TabIndex        =   14
      Top             =   600
      Visible         =   0   'False
      Width           =   492
   End
   Begin VB.ComboBox cbo_ObjCode 
      Height          =   288
      Left            =   3960
      Style           =   2  'Dropdown List
      TabIndex        =   13
      Top             =   600
      Visible         =   0   'False
      Width           =   492
   End
   Begin VB.ComboBox cbo_ViewTypeCode 
      Height          =   288
      Left            =   1680
      Style           =   2  'Dropdown List
      TabIndex        =   12
      Top             =   600
      Visible         =   0   'False
      Width           =   492
   End
   Begin VB.ComboBox Cbo_support 
      Height          =   288
      Left            =   2520
      Style           =   2  'Dropdown List
      TabIndex        =   4
      Top             =   1380
      Width           =   2172
   End
   Begin VB.ComboBox cbo_SType 
      Height          =   288
      Left            =   240
      Style           =   2  'Dropdown List
      TabIndex        =   3
      Top             =   1380
      Width           =   2172
   End
   Begin VB.ComboBox Cbo_area 
      Height          =   300
      Left            =   4800
      Style           =   2  'Dropdown List
      TabIndex        =   2
      Top             =   600
      Width           =   2175
   End
   Begin VB.ComboBox Cbo_obj 
      Height          =   300
      Left            =   2520
      Style           =   2  'Dropdown List
      TabIndex        =   1
      Top             =   600
      Width           =   2175
   End
   Begin VB.ComboBox Cbo_ViewType 
      Height          =   300
      Left            =   240
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   600
      Width           =   2175
   End
   Begin VB.Label Lbl_support 
      Height          =   252
      Left            =   2520
      TabIndex        =   11
      Top             =   1140
      Width           =   2172
   End
   Begin VB.Label Lbl_s_type 
      Height          =   252
      Left            =   240
      TabIndex        =   10
      Top             =   1140
      Width           =   2172
   End
   Begin VB.Label Lbl_area 
      Height          =   255
      Left            =   4800
      TabIndex        =   9
      Top             =   360
      Width           =   2175
   End
   Begin VB.Label Lbl_obj 
      Height          =   255
      Left            =   2520
      TabIndex        =   8
      Top             =   360
      Width           =   2175
   End
   Begin VB.Label Lbl_view_type 
      Height          =   255
      Left            =   240
      TabIndex        =   7
      Top             =   360
      Width           =   2175
   End
End
Attribute VB_Name = "frm_mtnc_mc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mi_iConcurr As Integer
Dim ms_AdvertCode As String
Dim mb_AreaNotLoaded As Boolean
Dim mb_ObjNotLoaded As Boolean
Dim mb_InterestNotLoaded As Boolean
Dim mb_STypeNotLoaded As Boolean
Dim mb_SupportNotLoaded As Boolean
Dim mb_ViewTypeNotLoaded As Boolean
' task 409 JN begin
Private mo_medMan As MediaManager

Public Property Set MediaManager(ByRef ao_medMan As MediaManager)
    Set mo_medMan = ao_medMan
End Property
' task 409 end

Private Function Control() As Boolean
Control = KO
If Cbo_ViewType = "" Then
    Cbo_ViewType.SetFocus
    SendMessage 73, "You must fill every field", gut_LangLogin.Code
    MouseOn
    Exit Function
End If
If Cbo_obj = "" Then
    Cbo_obj.SetFocus
    SendMessage 73, "You must fill every field", gut_LangLogin.Code
    MouseOn
    Exit Function
End If
If Cbo_area = "" Then
    Cbo_area.SetFocus
    SendMessage 73, "You must fill every field", gut_LangLogin.Code
    MouseOn
    Exit Function
End If
If cbo_SType = "" Then
    cbo_SType.SetFocus
    SendMessage 73, "You must fill every field", gut_LangLogin.Code
    MouseOn
    Exit Function
End If
If Cbo_support = "" Then
    Cbo_support.SetFocus
    SendMessage 73, "You must fill every field", gut_LangLogin.Code
    MouseOn
    Exit Function
End If
Control = OK
End Function

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

On Error GoTo suite

ls_Req = "EXEC media_advert_classif_upd '"
ls_Req = ls_Req & QuoteParam(ms_AdvertCode) & "','"
ls_Req = ls_Req & QuoteParam(cbo_ViewTypeCode.List(Cbo_ViewType.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_ObjCode.List(Cbo_obj.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_AreaCode.List(Cbo_area.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_STypeCode.List(cbo_SType.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_SupportCode.List(Cbo_support.ListIndex)) & "','','',''," & mi_iConcurr

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQLRowCount(ll_Statement, ll_lngrows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_lngrows = 0 Then
        SendMessage 2, "Another user change the record", gut_LangLogin.Code
        Exit Sub
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
End If

' task 408 JN
Call mo_medMan.Item_Marketing_Upd(ms_AdvertCode, Array(ms_AdvertCode, Cbo_ViewType.Text, Cbo_obj.Text, Cbo_area.Text, cbo_SType.Text, Cbo_support.Text))

Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub
Private Sub Validate_Add_Advert()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim lS_Code As String

On Error GoTo suite

ls_Req = "EXEC media_advert_classif_ins '"
ls_Req = ls_Req & QuoteParam(gs_MediaCode) & "','"
ls_Req = ls_Req & QuoteParam(cbo_ViewTypeCode.List(Cbo_ViewType.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_ObjCode.List(Cbo_obj.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_AreaCode.List(Cbo_area.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_STypeCode.List(cbo_SType.ListIndex)) & "','"
ls_Req = ls_Req & QuoteParam(cbo_SupportCode.List(Cbo_support.ListIndex)) & "','','',''"

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQL_SUCCESS
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            lS_Code = ODBCData(ll_Statement, 1)
        End If
    Loop
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

' task 408 JN
Call mo_medMan.Item_Marketing_Add(Array(lS_Code, Cbo_ViewType.Text, Cbo_obj.Text, Cbo_area.Text, cbo_SType.Text, Cbo_support.Text))

Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub
Private Sub Validate_Del_Advert()
Dim ls_Req As String
Dim ll_Statement As Long
Dim ll_LngID As Long
Dim li_Status As Integer
Dim ll_lngrows As Long
Dim i As Integer

On Error GoTo suite

If SendMessage(5, "Delete record ?", gut_LangLogin.Code, vbQuestion + vbYesNo, "Delete ") = vbNo Then
    Exit Sub
End If

ls_Req = "EXEC media_advert_classif_del '"
ls_Req = ls_Req & QuoteParam(ms_AdvertCode) & "'," & mi_iConcurr

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQLRowCount(ll_Statement, ll_lngrows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_lngrows = 0 Then
        SendMessage 2, "Another user change the record", gut_LangLogin.Code
        Exit Sub
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
End If

' task 408 JN
Call mo_medMan.Item_Marketing_Del(ms_AdvertCode)

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
   
On Error GoTo suite

ls_Req = "EXEC Screen_Csts 'mtnc_mc','" & QuoteParam(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": Me.Caption = ls_Text
        End Select
    End If
Loop

li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

suite:
StdError
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub
Private Sub Cbo_area_DropDown()
Dim ls_Area As String

MouseOff
If mb_AreaNotLoaded Then
    mb_AreaNotLoaded = KO
    If Cbo_area.ListIndex <> -1 Then
        ls_Area = cbo_AreaCode.List(Cbo_area.ListIndex)
    Else
        ls_Area = ""
    End If
    cbo_AreaCode.Clear
    Cbo_area.Clear
    FillCbo "Market_Segmentation", cbo_AreaCode, Cbo_area
    If ls_Area <> "" Then
        Cbo_area.ListIndex = ComboFindItem(cbo_AreaCode, ls_Area)
    End If
End If
MouseOn

End Sub


Private Sub Cbo_obj_DropDown()

Dim ls_Obj As String

MouseOff
If mb_ObjNotLoaded Then
    mb_ObjNotLoaded = KO
    If Cbo_obj.ListIndex <> -1 Then
        ls_Obj = cbo_ObjCode.List(Cbo_obj.ListIndex)
    Else
        ls_Obj = ""
    End If
    cbo_ObjCode.Clear
    Cbo_obj.Clear
    FillCbo "Media_Market_Objectives", cbo_ObjCode, Cbo_obj
    If ls_Obj <> "" Then
        Cbo_obj.ListIndex = ComboFindItem(cbo_ObjCode, ls_Obj)
    End If
End If
MouseOn

End Sub


Private Sub cbo_SType_DropDown()

Dim ls_SType As String

MouseOff
If mb_STypeNotLoaded Then
    mb_STypeNotLoaded = KO
    If cbo_SType.ListIndex <> -1 Then
        ls_SType = cbo_STypeCode.List(cbo_SType.ListIndex)
    Else
        ls_SType = ""
    End If
    cbo_STypeCode.Clear
    cbo_SType.Clear
    FillCbo "Media_Area_Type", cbo_STypeCode, cbo_SType
    If ls_SType <> "" Then
        cbo_SType.ListIndex = ComboFindItem(cbo_STypeCode, ls_SType)
    End If
End If
MouseOn

End Sub


Private Sub Cbo_Support_DropDown()

Dim ls_Support As String

MouseOff
If mb_SupportNotLoaded Then
    mb_SupportNotLoaded = KO
    If Cbo_support.ListIndex <> -1 Then
        ls_Support = cbo_SupportCode.List(Cbo_support.ListIndex)
    Else
        ls_Support = ""
    End If
    cbo_SupportCode.Clear
    Cbo_support.Clear
    FillCbo "Media_Source_Support", cbo_SupportCode, Cbo_support
    If ls_Support <> "" Then
        Cbo_support.ListIndex = ComboFindItem(cbo_SupportCode, ls_Support)
    End If
End If
MouseOn

End Sub


Private Sub cbo_ViewType_DropDown()

Dim ls_ViewType As String

MouseOff
If mb_ViewTypeNotLoaded Then
    mb_ViewTypeNotLoaded = KO
    If Cbo_ViewType.ListIndex <> -1 Then
        ls_ViewType = cbo_ViewTypeCode.List(Cbo_ViewType.ListIndex)
    Else
        ls_ViewType = ""
    End If
    cbo_ViewTypeCode.Clear
    Cbo_ViewType.Clear
    FillCbo "Media_Type_Of_View", cbo_ViewTypeCode, Cbo_ViewType
    If ls_ViewType <> "" Then
        Cbo_ViewType.ListIndex = ComboFindItem(cbo_ViewTypeCode, ls_ViewType)
    End If
End If
MouseOn

End Sub


Private Sub Form_Load()
Dim li_Pos As Integer
Dim lv_Data As Variant      ' task 409 JN
Dim lv_labels As Variant    ' task 409 JN

On Error GoTo suite

MouseOff

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

spp_save.Picture = LoadResPicture(RES_OK, 1)
ssp_quit.Picture = LoadResPicture(RES_QUIT, 1)

get_sc_csts

Select Case gs_Action
    Case "add":
        mb_AreaNotLoaded = OK
        mb_ObjNotLoaded = OK
        mb_STypeNotLoaded = OK
        mb_SupportNotLoaded = OK
        mb_ViewTypeNotLoaded = OK
    Case "upd":
        mb_AreaNotLoaded = OK
        mb_ObjNotLoaded = OK
        mb_STypeNotLoaded = OK
        mb_SupportNotLoaded = OK
        mb_ViewTypeNotLoaded = OK

' task 409 JN   begin
        ms_AdvertCode = mo_medMan.Item_Marketing_Code
        mi_iConcurr = GetConcurrency("EXEC media_adv_clas_iconc_sel '" & QuoteParam(ms_AdvertCode) & "'")
        lv_Data = mo_medMan.Item_Marketing_GridLine
        Cbo_ViewType.AddItem lv_Data(1) ' frm_main_mc.Grid.Text
        Cbo_ViewType.ListIndex = 0
        Cbo_obj.AddItem lv_Data(2)      'frm_main_mc.Grid.Text
        Cbo_obj.ListIndex = 0
        Cbo_area.AddItem lv_Data(3)     'frm_main_mc.Grid.Text
        Cbo_area.ListIndex = 0
        cbo_SType.AddItem lv_Data(4)    'frm_main_mc.Grid.Text
        cbo_SType.ListIndex = 0
        Cbo_support.AddItem lv_Data(5)  'frm_main_mc.Grid.Text
        Cbo_support.ListIndex = 0
    Case "del":
        ms_AdvertCode = mo_medMan.Item_Marketing_Code
        mi_iConcurr = GetConcurrency("EXEC media_adv_clas_iconc_sel '" & QuoteParam(ms_AdvertCode) & "'")
        lv_Data = mo_medMan.Item_Marketing_GridLine
        Cbo_ViewType.AddItem lv_Data(1) ' frm_main_mc.Grid.Text
        Cbo_ViewType.ListIndex = 0
        Cbo_obj.AddItem lv_Data(2)      'frm_main_mc.Grid.Text
        Cbo_obj.ListIndex = 0
        Cbo_area.AddItem lv_Data(3)     'frm_main_mc.Grid.Text
        Cbo_area.ListIndex = 0
        cbo_SType.AddItem lv_Data(4)    'frm_main_mc.Grid.Text
        cbo_SType.ListIndex = 0
        Cbo_support.AddItem lv_Data(5)  'frm_main_mc.Grid.Text
        Cbo_support.ListIndex = 0
' task 409 JN end
        Cbo_ViewType.Enabled = KO
        Cbo_obj.Enabled = KO
        Cbo_area.Enabled = KO
        cbo_SType.Enabled = KO
        Cbo_support.Enabled = KO
End Select

' task 409 JN begin
lv_labels = mo_medMan.Item_Marketing_GridColumnLabels
Lbl_view_type.Caption = lv_labels(1)
Lbl_obj.Caption = lv_labels(2)
Lbl_area.Caption = lv_labels(3)
Lbl_s_type.Caption = lv_labels(4)
Lbl_support.Caption = lv_labels(5)
' task 409 JN end
MouseOn
Exit Sub

suite:
'frm_main_mc.ClearGrid
'frm_main_mc.FillGrid
Resume
End Sub

Private Sub Form_Unload(Cancel As Integer)
gs_TableCode = ""
'frm_main_mc.Grid.HighLight = flexHighlightNever
End Sub


Private Sub spp_save_Click()

MouseOff
gb_Return = OK
Select Case gs_Action
    Case "add":
        If Control Then
            Validate_Add_Advert
        End If
    Case "del":
        Validate_Del_Advert
        Unload Me
    Case "upd":
        Validate_Upd_Advert
        Unload Me
End Select
MouseOn

End Sub
Private Sub ssp_quit_Click()
Unload Me
End Sub
