VERSION 5.00
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form News_mtnc 
   Caption         =   "News maintenance"
   ClientHeight    =   6180
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8010
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6180
   ScaleWidth      =   8010
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   615
      Left            =   6600
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   5460
      Width           =   615
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   615
      Left            =   7260
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   5460
      Width           =   615
   End
   Begin VB.Frame Frame 
      Caption         =   "Countries"
      Height          =   3735
      Left            =   60
      TabIndex        =   6
      Top             =   1500
      Width           =   7875
      Begin VB.CommandButton cmd_Remove 
         Caption         =   "< Remove all"
         Height          =   375
         Left            =   3180
         TabIndex        =   14
         Top             =   2880
         Width           =   1515
      End
      Begin VB.ListBox lst_NotSelected 
         Height          =   2595
         ItemData        =   "News_mntnc.frx":0000
         Left            =   120
         List            =   "News_mntnc.frx":0002
         TabIndex        =   11
         Top             =   720
         Width           =   3012
      End
      Begin VB.ListBox lst_Selected 
         Height          =   2595
         ItemData        =   "News_mntnc.frx":0004
         Left            =   4740
         List            =   "News_mntnc.frx":0006
         TabIndex        =   10
         Top             =   720
         Width           =   3012
      End
      Begin VB.PictureBox pic_In 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   3720
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   9
         Top             =   1500
         Width           =   408
      End
      Begin VB.PictureBox pic_Out 
         AutoSize        =   -1  'True
         Height          =   408
         Left            =   3720
         ScaleHeight     =   345
         ScaleWidth      =   345
         TabIndex        =   8
         Top             =   2220
         Width           =   408
      End
      Begin VB.CommandButton cmd_Add 
         Caption         =   "Add all >"
         Height          =   375
         Left            =   3180
         TabIndex        =   7
         Top             =   960
         Width           =   1515
      End
      Begin VB.Label lbl_NotSelected 
         Alignment       =   2  'Center
         Caption         =   "Not selected"
         Height          =   255
         Left            =   120
         TabIndex        =   13
         Top             =   420
         Width           =   3015
      End
      Begin VB.Label lbl_Selected 
         Alignment       =   2  'Center
         Caption         =   "Selected"
         Height          =   255
         Left            =   4740
         TabIndex        =   12
         Top             =   420
         Width           =   3015
      End
   End
   Begin VB.Label lbl_Language 
      Caption         =   "Language"
      Height          =   315
      Left            =   60
      TabIndex        =   3
      Top             =   840
      Width           =   1575
   End
   Begin MSForms.ComboBox cbo_Language 
      Height          =   315
      Left            =   1620
      TabIndex        =   2
      Top             =   840
      Width           =   2715
      VariousPropertyBits=   679495707
      DisplayStyle    =   7
      Size            =   "4789;556"
      MatchEntry      =   1
      ShowDropButtonWhen=   2
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
   End
   Begin VB.Label lbl_Mediatitle 
      Caption         =   "Media title"
      Height          =   255
      Left            =   60
      TabIndex        =   1
      Top             =   420
      Width           =   1575
   End
   Begin MSForms.ComboBox cbo_MediaTitle 
      Height          =   315
      Left            =   1620
      TabIndex        =   0
      Top             =   420
      Width           =   2715
      VariousPropertyBits=   679495707
      DisplayStyle    =   7
      Size            =   "4789;556"
      MatchEntry      =   1
      ShowDropButtonWhen=   2
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
   End
End
Attribute VB_Name = "News_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public ms_MediaCode As String
Public ms_MediaTitle As String
Public ms_Language As String
Public ms_LangDesc As String
Public mi_Conc As Integer
Public mo_SelectedCode As New Collection
Private mo_lst_SelectedCode As New Collection
Private mo_lst_UnselectedCode As New Collection
Private mo_AllCode As New Collection
Public mb_AllCode As Boolean
Private Sub cbo_MediaTitle_DropButtonClick()
Dim ls_Req As String
Dim lv_ActualCode
    
If cbo_MediaTitle.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_MediaTitle)
    cbo_MediaTitle.Clear
    
    ls_Req = "EXEC Media_News_cbo"
    MCombo_Fill cbo_MediaTitle, ls_Req
    
    MCombo_CodeSelect(cbo_MediaTitle) = lv_ActualCode
    
    cbo_MediaTitle.Tag = Loaded
    MouseOn
End If
End Sub

Private Sub cmd_Add_Click()
Dim i As Integer
Dim ls_Code As String
Dim ls_Desc As String

For i = lst_NotSelected.ListCount - 1 To i = 1 Step -1
    ls_Code = mo_lst_UnselectedCode.Item(i + 1)
    lst_NotSelected.ListIndex = i
    ls_Desc = lst_NotSelected.Text
    
    lst_Selected.AddItem ls_Desc
    mo_lst_SelectedCode.Add ls_Code

    mo_lst_UnselectedCode.Remove i + 1
    lst_NotSelected.RemoveItem i
Next

End Sub

Private Sub cmd_Remove_Click()
Dim i As Integer
Dim ls_Code As String
Dim ls_Desc As String

For i = lst_Selected.ListCount - 1 To i = 1 Step -1
    ls_Code = mo_lst_SelectedCode.Item(i + 1)
    lst_Selected.ListIndex = i
    ls_Desc = lst_Selected.Text
            
    lst_NotSelected.AddItem ls_Desc
    mo_lst_UnselectedCode.Add ls_Code
    
    mo_lst_SelectedCode.Remove i + 1
    lst_Selected.RemoveItem i
Next
End Sub

Private Sub pic_In_Click()
Dim lo_code
Dim lo_desc
    
If lst_NotSelected.ListIndex <> -1 Then
    lo_code = mo_lst_UnselectedCode.Item(lst_NotSelected.ListIndex + 1)
    lo_desc = lst_NotSelected.Text
    
    lst_Selected.AddItem lo_desc
    mo_lst_SelectedCode.Add lo_code

    mo_lst_UnselectedCode.Remove lst_NotSelected.ListIndex + 1
    lst_NotSelected.RemoveItem lst_NotSelected.ListIndex
End If
End Sub
Private Sub Form_Load()
On Error GoTo Err_NewsMtncLoad

MouseOff

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

gb_Return = KO
mb_AllCode = KO
spp_save.Picture = LoadResPicture(RES_OK, 1)
ssp_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_In.Picture = LoadResPicture(RES_RIGHT, 1)
pic_Out.Picture = LoadResPicture(RES_LEFT, 1)

cbo_MediaTitle.Tag = UNLOADED
cbo_Language.Tag = UNLOADED

GetConstants

If LCase(gs_Action) <> "add" Then
    MCombo_AddItemCode cbo_MediaTitle, ms_MediaCode, ms_MediaTitle, OK
    MCombo_AddItemCode cbo_Language, ms_Language, ms_LangDesc, OK
    cbo_MediaTitle.Enabled = KO
    cbo_Language.Enabled = KO
End If
If LCase(gs_Action) = "moreinfo" Then
    cmd_Add.Visible = KO
    cmd_Remove.Visible = KO
    pic_In.Visible = KO
    pic_Out.Visible = KO
End If

FillSelected
FillUnSelected

MouseOn
Exit Sub

Err_NewsMtncLoad:
StdError
End Sub

Private Sub cbo_Language_DropButtonClick()
Dim ls_Req As String
Dim lv_ActualCode
    
If cbo_Language.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_Language)
    cbo_Language.Clear
    
    ls_Req = "EXEC language_cbo"
    MCombo_Fill cbo_Language, ls_Req
    
    MCombo_CodeSelect(cbo_Language) = lv_ActualCode
    
    cbo_Language.Tag = Loaded
    MouseOn
End If

End Sub
Private Sub pic_Out_Click()
Dim i As Integer
Dim ls_Code As String
Dim ls_Desc As String
    
If lst_Selected.ListIndex <> -1 Then
    ls_Code = mo_lst_SelectedCode.Item(lst_Selected.ListIndex + 1)
    ls_Desc = lst_Selected.Text
            
    lst_NotSelected.AddItem ls_Desc
    mo_lst_UnselectedCode.Add ls_Code
    
    mo_lst_SelectedCode.Remove lst_Selected.ListIndex + 1
    lst_Selected.RemoveItem lst_Selected.ListIndex
End If
End Sub
Private Sub FillUnSelected()
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Req As String
Dim i As Integer
Dim lb_Found As Boolean
Dim ls_Code As String

On Error GoTo Err_FillUnSelected

ls_Req = "exec Country_link_cbo '" & gut_LangWork.Code & "'"
lst_NotSelected.Clear
For i = mo_lst_UnselectedCode.Count To 1 Step -1
    mo_lst_UnselectedCode.Remove i
Next

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    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)
            lb_Found = KO
            For i = 1 To mo_lst_SelectedCode.Count
                If mo_lst_SelectedCode.Item(i) = ls_Code Then
                    lb_Found = OK
                    Exit For
                End If
            Next
            If lb_Found = KO Then
                mo_lst_UnselectedCode.Add ls_Code
                lst_NotSelected.AddItem ODBCData(ll_Statement, 2)
            End If
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End If
Exit Sub

Err_FillUnSelected:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError

End Sub
Private Sub FillAll()
Dim ls_Req As String
Dim ls_Code As String
Dim ls_Desc As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim i As Integer

On Error GoTo Err_FillAll
If mb_AllCode Then Exit Sub
MouseOff

For i = mo_lst_SelectedCode.Count To 1 Step -1
    mo_AllCode.Remove i
Next

ls_Req = "Exec Country_Link_t_lst2 '" & ms_MediaCode & "','" & gut_LangWork.Code & "'"

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
    'Get the row of data
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Code = ODBCData(ll_Statement, 1)
            ls_Desc = ODBCData(ll_Statement, 2)
            mo_AllCode.Add ls_Code
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End If

mb_AllCode = OK
MouseOn
Exit Sub

Err_FillAll:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
MouseOn
End Sub
Private Sub FillSelected()
Dim ls_Req As String
Dim ls_Code As String
Dim ls_Desc As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim i As Integer

On Error GoTo Err_FillSelected

MouseOff
lst_Selected.Clear

For i = mo_lst_SelectedCode.Count To 1 Step -1
    mo_lst_SelectedCode.Remove i
Next

For i = mo_SelectedCode.Count To 1 Step -1
    mo_SelectedCode.Remove i
Next

ls_Req = "Exec Media_CountriesLanguage_cbo '" & ms_MediaCode & "','" & MCombo_GetCode(cbo_Language) & "'"

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
    'Get the row of data
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Code = ODBCData(ll_Statement, 1)
            ls_Desc = ODBCData(ll_Statement, 2)
            mo_SelectedCode.Add ls_Code
            mo_lst_SelectedCode.Add ls_Code
            lst_Selected.AddItem ls_Desc
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End If

MouseOn
Exit Sub

Err_FillSelected:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
MouseOn
End Sub
Private Sub GetConstants()

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

On Error GoTo suite

ls_Req = "EXEC Screen_Csts 'news_mtnc', '" & gut_LangLogin.Code & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ls_Field = ODBCData(ll_Statement, 1)
        ls_Text = left(ODBCData(ll_Statement, 2), 30)
        Select Case ls_Field
        Case "title": Caption = ls_Text
        Case "lbl_mediatitle": lbl_Mediatitle = ls_Text
        Case "lbl_language": lbl_Language = ls_Text
        Case "lbl_notsel": lbl_NotSelected = ls_Text
        Case "lbl_sel": lbl_Selected = ls_Text
        Case "frame": Frame = ls_Text
        Case "cmd_add": cmd_Add = ls_Text
        Case "cmd_remove": cmd_Remove = 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 Validate_Manager()
Dim i As Integer
Dim j As Integer
Dim ls_Code As String

'On Error GoTo Err_Validate_Manager

For i = mo_lst_SelectedCode.Count To 1 Step -1
    ls_Code = mo_lst_SelectedCode.Item(i)
    
    For j = mo_SelectedCode.Count To 1 Step -1
        If mo_SelectedCode.Item(j) = ls_Code Then
            mo_lst_SelectedCode.Remove i
            mo_SelectedCode.Remove j
        End If
    Next
Next

Validate_Add
For i = mo_lst_SelectedCode.Count To 1 Step -1
    mo_lst_SelectedCode.Remove i
Next

Validate_Del
For i = mo_SelectedCode.Count To 1 Step -1
    mo_SelectedCode.Remove i
Next

Exit Sub

Err_Validate_Manager:
StdError
End Sub

Private Function Validate_Add() As Boolean
Dim i As Integer
Dim ls_Code As String
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long

On Error GoTo Err_Validate_Add

Validate_Add = KO
gs_MediaCode = MCombo_GetCode(cbo_MediaTitle)
For i = 0 To lst_Selected.ListCount - 1
    ls_Code = mo_lst_SelectedCode.Item(i + 1)
    ls_Req = "Exec Media_CountriesLanguage_ins '" & MCombo_GetCode(cbo_MediaTitle) & "','" _
    & ls_Code & "','" & MCombo_GetCode(cbo_Language) & "'"

    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQLRowCount(ll_Statement, ll_lngrows)
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        If ll_lngrows = 0 Then
            SendMessage 4, "Insert failed", gut_LangLogin.Code
        Else
            Validate_Add = OK
            gb_Return = OK
            C_main.FillGrid
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Insert failed", gut_LangLogin.Code
    End If
Next

Exit Function

Err_Validate_Add:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
MouseOn
End Function
Private Function Validate_Del() As Boolean
Dim i As Integer
Dim ls_Code As String
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_lngrows As Long

On Error GoTo Err_Validate_Del

Validate_Del = KO
gs_MediaCode = MCombo_GetCode(cbo_MediaTitle)
For i = mo_SelectedCode.Count To 1 Step -1
    ls_Code = mo_SelectedCode.Item(i)
    ls_Req = "Exec Media_CountriesLanguage_del '" & MCombo_GetCode(cbo_MediaTitle) & "','" _
    & ls_Code & "','" & MCombo_GetCode(cbo_Language) & "'," & mi_Conc

    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQLRowCount(ll_Statement, ll_lngrows)
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        If ll_lngrows = 0 Then
            SendMessage 4, "Delete failed", gut_LangLogin.Code
        Else
            Validate_Del = OK
            gb_Return = OK
            C_main.FillGrid
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Delete failed", gut_LangLogin.Code
    End If
Next

Exit Function

Err_Validate_Del:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
MouseOn
End Function
Private Sub spp_save_Click()

MouseOff
If cbo_MediaTitle.ListIndex = -1 Then
    cbo_MediaTitle.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    MouseOn
    Exit Sub
End If
If cbo_Language.ListIndex = -1 Then
    cbo_Language.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    MouseOn
    Exit Sub
End If
If gs_Action = "add" And lst_Selected.ListCount = 0 Then
    cbo_Language.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    MouseOn
    Exit Sub
End If

If gs_Action = "add" Then
    Validate_Add
Else
    Validate_Manager
End If
Unload Me
MouseOn

End Sub

Private Sub ssp_quit_Click()

MouseOff
Unload Me
MouseOn

End Sub
