VERSION 5.00
Begin VB.Form Test_MarketA_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   1725
   ClientLeft      =   2505
   ClientTop       =   2835
   ClientWidth     =   4305
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   1725
   ScaleWidth      =   4305
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   612
      Left            =   2880
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   960
      Width           =   612
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   3540
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   960
      Width           =   612
   End
   Begin VB.ComboBox cbo_Market2 
      Height          =   288
      Left            =   2040
      Style           =   2  'Dropdown List
      TabIndex        =   10
      TabStop         =   0   'False
      Top             =   420
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_Category2 
      Enabled         =   0   'False
      Height          =   288
      Left            =   3600
      Style           =   2  'Dropdown List
      TabIndex        =   9
      TabStop         =   0   'False
      Top             =   420
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_Market 
      Height          =   288
      Left            =   180
      Style           =   2  'Dropdown List
      TabIndex        =   1
      Top             =   420
      Width           =   2592
   End
   Begin VB.VScrollBar vsb_Priority 
      Height          =   435
      Left            =   1380
      Max             =   99
      TabIndex        =   2
      Top             =   1140
      Value           =   99
      Width           =   255
   End
   Begin VB.TextBox txt_Priority 
      Height          =   315
      Left            =   720
      Locked          =   -1  'True
      MaxLength       =   4
      TabIndex        =   5
      TabStop         =   0   'False
      Text            =   "1"
      Top             =   1200
      Width           =   615
   End
   Begin VB.ComboBox cbo_Category 
      Enabled         =   0   'False
      Height          =   288
      Left            =   2400
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   420
      Visible         =   0   'False
      Width           =   1812
   End
   Begin VB.Label lbl_Market 
      Alignment       =   2  'Center
      Caption         =   "Market"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   238
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   180
      TabIndex        =   8
      Top             =   120
      Width           =   1812
   End
   Begin VB.Label lbl_Categ 
      Alignment       =   2  'Center
      Caption         =   "Category"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   238
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   180
      TabIndex        =   7
      Top             =   120
      Visible         =   0   'False
      Width           =   1812
   End
   Begin VB.Label lbl_Priority 
      Alignment       =   2  'Center
      Caption         =   "Priority"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   238
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   180
      TabIndex        =   6
      Top             =   960
      Width           =   1812
   End
End
Attribute VB_Name = "Test_MarketA_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


Dim mb_CategoryNotLoaded As Boolean

Dim mb_MarketNotLoaded As Boolean

Private Sub Cbo_category_DropDown()

Dim ls_Category As String
Dim ls_req As String

MouseOff
If mb_CategoryNotLoaded Then
    mb_CategoryNotLoaded = KO
    If cbo_Category.ListIndex <> -1 Then
        ls_Category = cbo_Category2.List(cbo_Category.ListIndex)
    Else
        ls_Category = ""
    End If
    cbo_Category2.Clear
    cbo_Category.Clear
    FillCbo "Test_Category", cbo_Category2, cbo_Category
    If ls_Category <> "" Then
        cbo_Category.ListIndex = ComboFindItem(cbo_Category2, ls_Category)
    End If
End If
MouseOn

End Sub
Private Sub Cbo_market_DropDown()

Dim ls_Market As String
Dim ls_req As String
Dim li_Count As Integer

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
    '/* Debut Modif */
    FillCbo "EXEC Test_Market_cbo " & Test_Market_mtnc.cbo_Category2.List(Test_Market_mtnc.cbo_Category.ListIndex) & ",'" & gut_LangWork.Code & "'", cbo_Market2, cbo_Market
    '/* Fin Modif */
    For li_Count = 0 To cbo_Market.ListCount - 1
        If cbo_Market2.List(li_Count) = gut_Param2.Str1 Then
            cbo_Market2.RemoveItem li_Count
            cbo_Market.RemoveItem li_Count
            Exit For
        End If
    Next li_Count
    If ls_Market <> "" Then
        cbo_Market.ListIndex = ComboFindItem(cbo_Market2, ls_Market)
    End If
End If
MouseOn

End Sub
Private Sub Form_Load()

Dim li_Count As Integer

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)

Getcsts
Select Case gut_Param2.action
Case "Add"
    '/* debut modif */
'    mb_CategoryNotLoaded = OK
    '/* fin modif */
    mb_MarketNotLoaded = OK
    
Case "Update"
    '/* debut modif */
   ' Cbo_category.Enabled = KO
    cbo_Market.Enabled = KO
    
    'mb_CategoryNotLoaded = OK
    'cbo_Category2.AddItem gut_Param2.Str2
    'Cbo_category.AddItem gut_Param2.Str3
    'Cbo_category.ListIndex = 0
    mb_MarketNotLoaded = OK
    cbo_Market2.AddItem gut_Param2.Str2
    cbo_Market.AddItem gut_Param2.Str3
    cbo_Market.ListIndex = 0
    txt_Priority = gut_Param2.Str4
    '/* fin modif */
Case "Delete"
    cbo_Category.Enabled = KO
    cbo_Market.Enabled = KO
    vsb_Priority.Enabled = KO
    '/* debut modif */
   ' Cbo_category.AddItem gut_Param2.Str3
   ' Cbo_category.ListIndex = 0
    cbo_Market.AddItem gut_Param2.Str3
    cbo_Market.ListIndex = 0
    txt_Priority = gut_Param2.Str4
    '/* fin modif */
End Select
MouseOn
Exit Sub

suite:
StdError
End Sub
Private Sub spp_save_Click()

On Error GoTo suite

MouseOff
gut_Param2.Return = OK
Select Case gut_Param2.action
Case "Add"
    If AddTable Then
    ' /* debut modif */
'        Cbo_category.ListIndex = -1
        cbo_Market.ListIndex = -1
'        Cbo_category.SetFocus
        cbo_Market.SetFocus
    '/* fin modif */
      End If
Case "Update"
    If UpdTable Then
        Unload Me
    End If
Case "Delete"
    If DltTable Then
        Unload Me
    End If
End Select
MouseOn
Exit Sub

suite:
MouseOn
StdError
End Sub
Private Sub ssp_quit_Click()

MouseOff
Unload Me

End Sub
Private Function UpdTable() As Boolean

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

UpdTable = KO

On Error GoTo suite

If Control Then
    '/* debut modif */
    ls_req = "EXEC Test_Market_Accepts_upd " _
     & gut_Param2.Str1 & ", " _
     & gut_Param2.Str2 & ", " _
     & txt_Priority & ", " _
     & gut_Param2.Str5
    '/* fin modif */
    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
        Else
            UpdTable = OK
        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 AddTable() As Boolean

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

AddTable = KO

On Error GoTo suite

If Control Then
    '/* debut modif */
    ls_req = "EXEC Test_Market_Accepts_ins " _
     & gut_Param2.Str1 & ", " _
     & cbo_Market2.List(cbo_Market.ListIndex) & ", " _
     & txt_Priority
     '/* fin modif */
    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
            AddTable = OK
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Insert failed", gut_LangLogin.Code
    End If
End If
Exit Function

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

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

DltTable = KO

On Error GoTo suite

MouseOn
If SendMessage(5, "Delete record ?", gut_LangLogin.Code, vbQuestion + vbYesNo, "Delete ") = vbYes Then
    MouseOff
    '/* debut modif */
     ls_req = "EXEC Test_Market_Accepts_del " _
     & gut_Param2.Str1 & ", " _
     & gut_Param2.Str2 & ", " _
     & gut_Param2.Str5
     ' /* fin modif */
    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 7, "Delete failed : concurrency problem ?", gut_LangLogin.Code
        Else
            DltTable = 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 Getcsts()

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 'mtnc_Test_mka', '" & 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 "titleA": If gut_Param2.action = "Add" Then Caption = Caption & " - " & ls_Text
        Case "titleU": If gut_Param2.action = "Update" Then Caption = Caption & " - " & ls_Text
        Case "titleD": If gut_Param2.action = "Delete" Then Caption = Caption & " - " & ls_Text
        Case "lbl_Categ": lbl_Categ = ls_Text
        Case "lbl_Market": lbl_Market = ls_Text
        Case "lbl_Priority": lbl_Priority = 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 Control() As Boolean

Control = KO
'/* debut modif */
'If Cbo_category.ListIndex = -1 Then
'    Cbo_category.SetFocus
'    SendMessage 8, "Value must be filled in",gut_LangLogin.Code
'    Exit Function
'End If
'/* fin modif */
If cbo_Market.ListIndex = -1 Then
    cbo_Market.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
Control = OK

End Function

Private Sub vsb_Priority_Change()

txt_Priority = Abs(CInt(vsb_Priority) - 100)

End Sub
