VERSION 5.00
Begin VB.Form Test_Standard_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   2385
   ClientLeft      =   1410
   ClientTop       =   2775
   ClientWidth     =   6240
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2385
   ScaleWidth      =   6240
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   615
      Left            =   4800
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   1620
      Width           =   615
   End
   Begin VB.CommandButton SSC_dropped 
      Height          =   270
      Left            =   2940
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   1920
      Width           =   255
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   615
      Left            =   5520
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   1620
      Width           =   615
   End
   Begin VB.ComboBox cbo_Categ2 
      Height          =   300
      Left            =   2100
      Style           =   2  'Dropdown List
      TabIndex        =   11
      TabStop         =   0   'False
      Top             =   360
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.CheckBox chk_Int 
      Caption         =   "Check1"
      Height          =   252
      Left            =   1680
      TabIndex        =   2
      Top             =   1560
      Width           =   252
   End
   Begin VB.TextBox txt_dropped 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   1680
      Locked          =   -1  'True
      TabIndex        =   8
      TabStop         =   0   'False
      Top             =   1920
      Width           =   1212
   End
   Begin VB.TextBox txt_Desc 
      Height          =   285
      Left            =   120
      MaxLength       =   79
      TabIndex        =   0
      Top             =   1020
      Width           =   6045
   End
   Begin VB.ComboBox cbo_Categ 
      Height          =   300
      Left            =   120
      Style           =   2  'Dropdown List
      TabIndex        =   1
      Top             =   360
      Width           =   2655
   End
   Begin VB.Label lbl_Drop 
      Caption         =   "Drop date"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   10
      Top             =   1920
      Width           =   1452
   End
   Begin VB.Label lbl_Int 
      Caption         =   "Internet flag"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   9
      Top             =   1560
      Width           =   1452
   End
   Begin VB.Label lbl_Desc 
      Alignment       =   2  'Center
      Caption         =   "Description"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   7
      Top             =   780
      Width           =   2652
   End
   Begin VB.Label lbl_Categ 
      Alignment       =   2  'Center
      Caption         =   "Test category"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   120
      Width           =   2655
   End
End
Attribute VB_Name = "Test_Standard_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'Dim mb_MarketNotLoaded As Boolean
Dim mb_CategNotLoaded As Boolean
'Dim mb_TypeNotLoaded As Boolean


Private Sub cbo_Categ_DropDown()

Dim ls_Categ As String
Dim ls_Req As String

MouseOff
If mb_CategNotLoaded Then
    mb_CategNotLoaded = KO
    If cbo_Categ.ListIndex <> -1 Then
        ls_Categ = cbo_Categ2.List(cbo_Categ.ListIndex)
    Else
        ls_Categ = ""
    End If
    cbo_Categ2.Clear
    cbo_Categ.Clear
    
    'start change
    Select Case gs_TableName
        Case "Test_Standard"
            ls_Req = "Exec Test_Category_cbo3 '" & gut_LangWork.Code & "'"
        Case "Test_Dtl_Result"
            ls_Req = "EXEC Test_Typ_result_cbo " _
              & "'" & gut_LangWork.Code & "'"
    End Select
    FillCbo ls_Req, cbo_Categ2, cbo_Categ
    'end change
    
    If ls_Categ <> "" Then
        cbo_Categ.ListIndex = ComboFindItem(cbo_Categ2, ls_Categ)
    End If
End If
MouseOn

End Sub



Private Sub Form_Load()

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)
SSC_dropped.Picture = LoadResPicture(RES_DOWN2, vbResIcon)

Getcsts

Select Case gs_Action
Case "Add"
    Select Case gs_TableName
    Case "Test_Standard"
'        mb_MarketNotLoaded = OK
        mb_CategNotLoaded = OK
'        mb_TypeNotLoaded = OK
'        Cbo_type.Enabled = KO
    
    Case "Test_Dtl_Result"
'        mb_MarketNotLoaded = OK
        mb_CategNotLoaded = OK
'        mb_TypeNotLoaded = OK
'        Cbo_type.Enabled = KO
    End Select

Case "Update"
    Select Case gs_TableName
    Case "Test_Standard"
        cbo_Categ.Enabled = KO
'        Cbo_type.Enabled = KO
    '/* debut modif */
'    mb_MarketNotLoaded = OK
 '   cbo_Market2.AddItem gs_TableCode
  '  Cbo_market.AddItem gs_TableCode2
   ' Cbo_market.ListIndex = 0
        mb_CategNotLoaded = OK
        cbo_Categ2.AddItem gs_TableCode2
        cbo_Categ.AddItem gs_TableCode3
        cbo_Categ.ListIndex = 0
'    mb_TypeNotLoaded = OK
'    cbo_Type2.AddItem gs_TableCode4
'    Cbo_type.AddItem gs_TableCode5
'    Cbo_type.ListIndex = 0
        txt_Desc = gs_TableCode5
        If gs_TableCode6 = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = gs_TableCode7
    
    Case "Test_Dtl_Result"
        cbo_Categ.Enabled = KO
'        Cbo_type.Enabled = KO
        mb_CategNotLoaded = OK
        cbo_Categ2.AddItem gs_TableCode2
        cbo_Categ.AddItem gs_TableCode4
        cbo_Categ.ListIndex = 0
        txt_Desc = gs_TableCode5
        If gs_TableCode6 = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = gs_TableCode8
        
    End Select

Case "Delete"
    Select Case gs_TableName
    Case "Test_Standard"
    '/* debut modif */
'    Cbo_market.Enabled = KO
        cbo_Categ.Enabled = KO
'        Cbo_type.Visible = OK
'        Cbo_type.Enabled = KO
        chk_Int.Enabled = KO
        txt_Desc.Enabled = KO
'        txt_dropped.Enabled = KO
        SSC_dropped.Visible = KO
'    Cbo_market.AddItem gs_TableCode2
'    Cbo_market.ListIndex = 0
        cbo_Categ.AddItem gs_TableCode3
        cbo_Categ.ListIndex = 0
'    Cbo_type.AddItem gs_TableCode5
'    Cbo_type.ListIndex = 0
        txt_Desc = gs_TableCode5
        If gs_TableCode6 = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = gs_TableCode7

    Case "Test_Dtl_Result"
        cbo_Categ.Enabled = KO
'        Cbo_type.Visible = KO
'        Cbo_type.Enabled = KO
        chk_Int.Enabled = KO
        txt_Desc.Enabled = KO
'        txt_dropped.Enabled = KO
        SSC_dropped.Visible = KO
        cbo_Categ.AddItem gs_TableCode4
        cbo_Categ.ListIndex = 0
        txt_Desc = gs_TableCode5
        If gs_TableCode6 = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = gs_TableCode8

    End Select
'start change
Case "MoreInfo"
    Select Case gs_TableName
    Case "Test_Standard"
        cbo_Categ.Enabled = KO
'        Cbo_type.Enabled = KO
        chk_Int.Enabled = KO
        txt_Desc.Enabled = KO
'        txt_dropped.Enabled = KO
        SSC_dropped.Visible = KO
        spp_save.Visible = KO
        cbo_Categ.AddItem gs_TableCode3
        cbo_Categ.ListIndex = 0
        txt_Desc = gs_TableCode5
        If gs_TableCode6 = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = gs_TableCode7
        
    Case "Test_Dtl_Result"
        cbo_Categ.Enabled = KO
'        Cbo_type.Enabled = KO
        chk_Int.Enabled = KO
        txt_Desc.Enabled = KO
'        txt_dropped.Enabled = KO
        SSC_dropped.Visible = KO
        spp_save.Visible = KO
        cbo_Categ.AddItem gs_TableCode4
        cbo_Categ.ListIndex = 0
        txt_Desc = gs_TableCode5
        If gs_TableCode6 = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = gs_TableCode8
        
    End Select
'end change

End Select
MouseOn
Exit Sub

suite:
StdError
End Sub
Private Sub spp_save_Click()

MouseOff
gb_Return = OK
Select Case gs_Action
Case "Add"
    If AddTable Then
        txt_Desc = ""
        '/* debut modif */
       ' Cbo_market.ListIndex = -1
        '/* fin modif */
        cbo_Categ.ListIndex = -1
'        Cbo_type.Clear
'        Cbo_type.Enabled = KO
        chk_Int.value = 0
        txt_dropped = ""
        txt_Desc.SetFocus
    End If
Case "Update"
    If UpdTable Then
        Unload Me
        Exit Sub
    End If
Case "Delete"
    If DltTable Then
        Unload Me
        Exit Sub
    End If
End Select
MouseOn

End Sub
Private Sub SSC_dropped_Click()

MouseOff
gb_Return = KO
gs_Date = txt_dropped
Dates.show 1
If gb_Return Then
    txt_dropped = gs_Date
End If
MouseOn

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
Dim ls_Line As String
Dim ls_IntFlag As String
Dim ls_DropFlag As String
Dim ls_DropDate As String

UpdTable = KO

On Error GoTo suite

If Control Then
    If chk_Int.value = 1 Then ls_IntFlag = "X"
    If txt_dropped <> "" Then
        ls_DropFlag = "X"
        ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
    End If
    '/* debut modif */
    Select Case gs_TableName
    Case "Test_Standard"
        ls_Req = "EXEC Test_Standard_upd " _
          & gs_TableCode & ", '" _
          & QuoteParam(txt_Desc) & "', " _
          & cbo_Categ2.List(cbo_Categ.ListIndex) & ", '" _
          & ls_IntFlag & "', '" _
          & ls_DropFlag & "', '" _
          & ls_DropDate & "', " _
          & gs_TableCode4
    Case "Test_Dtl_Result"
        ls_Req = "EXEC Test_dtl_result_upd " _
          & gs_TableCode & ", '" _
          & QuoteParam(txt_Desc) & "', '" _
          & ls_IntFlag & "', '" _
          & ls_DropFlag & "', '" _
          & ls_DropDate & "', " _
          & gs_TableCode2
    End Select
    
    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
            C_main.FillGrid
        Else
            UpdTable = OK
            Select Case gs_TableName
                Case "Test_Standard"
                    C_main.Grid.RemoveItem C_main.Grid.Row
                    ls_Line = gs_TableCode & Chr(9) _
                      & cbo_Categ2.List(cbo_Categ.ListIndex) & Chr(9) & cbo_Categ & Chr(9) _
                      & CInt(gs_TableCode4) + 1 & Chr(9) & txt_Desc & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
                  '/* fin modif */
                    C_main.Grid.AddItem ls_Line, C_main.Grid.Row
                Case "Test_Dtl_Result"
                    C_main.FillGrid
            End Select
        End If
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 3, "Update failed", gut_LangLogin.Code
    End If
End If
Exit Function

suite:
Select Case Err
Case 30015
    C_main.FillGrid
Case Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Select
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
Dim ls_Line As String
Dim ls_Code As String
Dim ls_IntFlag As String
Dim ls_DropFlag As String
Dim ls_DropDate As String

AddTable = KO

On Error GoTo suite

If Control Then
    If chk_Int.value = 1 Then ls_IntFlag = "X"
    If txt_dropped <> "" Then
        ls_DropFlag = "X"
        ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
    End If
    '/* debut modif */
    Select Case gs_TableName
    Case "Test_Standard"
        ls_Req = "EXEC Test_Standard_ins '" _
          & QuoteParam(txt_Desc) & "', " _
          & cbo_Categ2.List(cbo_Categ.ListIndex) & ", '" _
          & ls_IntFlag & "', '" _
          & ls_DropFlag & "', '" _
          & ls_DropDate & "'"
    Case "Test_Dtl_Result"
        ls_Req = "EXEC Test_Dtl_Result_ins " _
          & cbo_Categ2.List(cbo_Categ.ListIndex) & ", '" _
          & QuoteParam(txt_Desc) & "', '" _
          & ls_IntFlag & "', '" _
          & ls_DropFlag & "', '" _
          & ls_DropDate & "'"
    End Select
    '/* fin modif */
    
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQLRowCount(ll_Statement, ll_lngrows)
        If ll_lngrows = 0 Then
            li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
            SendMessage 4, "Insert failed", gut_LangLogin.Code
            C_main.FillGrid
        Else
            AddTable = OK
            li_Status = SQLFetch(ll_Statement)
            If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
                ls_Code = ODBCData(ll_Statement, 1)
                li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
                '/* debut modif */
                Select Case gs_TableName
                Case "Test_Standard"
                    ls_Line = ls_Code & Chr(9) _
                        & cbo_Categ2.List(cbo_Categ.ListIndex) & Chr(9) & cbo_Categ & Chr(9) _
                        & 1 & Chr(9) & txt_Desc & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
                '/* fin modif */
                    C_main.Grid.AddItem ls_Line
                    C_main.Grid.Row = C_main.Grid.Rows - 1
                Case "Test_Dtl_Result"
                    C_main.FillGrid
                End Select
            Else
                li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
                C_main.FillGrid
            End If
        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
    Select Case gs_TableName
        Case "Test_Standard"
            ls_Req = "EXEC Test_Standard_del " _
              & gs_TableCode & ", " _
              & gs_TableCode4
        Case "Test_Dtl_Result"
            ls_Req = "EXEC Test_Dtl_Result_del " _
              & gs_TableCode & ", " _
              & gs_TableCode2
    End Select
    
    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
            C_main.FillGrid
        Else
            DltTable = OK
            C_main.Grid.RemoveItem C_main.Grid.Row
        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:
Select Case Err
Case 30015
    C_main.FillGrid
Case Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Select
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
Dim ls_Text As String

On Error GoTo suite

Select Case gs_TableName
    Case "Test_Standard"
        ls_Req = "EXEC Screen_Csts 'mtnc_Test_Stand', '" & gut_LangLogin.Code & "'"
    'start change
    Case "Test_Dtl_Result"
        ls_Req = "EXEC Screen_Csts 'mtnc_Test_res', '" & gut_LangLogin.Code & "'"
    'end change
End Select

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 gs_Action = "Add" Then Caption = Caption & " - " & ls_Text
        Case "titleU": If gs_Action = "Update" Then Caption = Caption & " - " & ls_Text
        Case "titleD": If gs_Action = "Delete" Then Caption = Caption & " - " & ls_Text
        Case "titleI": If gs_Action = "MoreInfo" Then Caption = Caption & " - " & ls_Text
        Case "lbl_Desc": lbl_Desc = ls_Text
        Case "lbl_Categ": lbl_Categ = ls_Text
'        Case "lbl_Type": Lbl_type = ls_Text
'        Case "lbl_Market": Lbl_market = ls_Text
        Case "lbl_Int": lbl_Int = ls_Text
        Case "lbl_Drop": lbl_Drop = 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
If txt_Desc.Text = "" Then
    txt_Desc.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
' /* debut modif */
'If Cbo_market.ListIndex = -1 Then
'    Cbo_market.SetFocus
'    SendMessage 8, "Value must be filled in",gut_LangLogin.Code
'    Exit Function
'End If
'/* fin modif */
If cbo_Categ.ListIndex = -1 Then
    cbo_Categ.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
' /* debut modif */
'If Cbo_type.ListIndex = -1 Then
'    Cbo_type.SetFocus
'    SendMessage 8, "Value must be filled in",gut_LangLogin.Code
'    Exit Function
'End If
'/* fin modif */
Control = OK

End Function

