VERSION 5.00
Begin VB.Form Country_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   3705
   ClientLeft      =   2175
   ClientTop       =   2640
   ClientWidth     =   5175
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   3705
   ScaleWidth      =   5175
   ShowInTaskbar   =   0   'False
   Begin VB.TextBox txt_EndDate 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   1800
      Locked          =   -1  'True
      TabIndex        =   18
      Top             =   1440
      Width           =   1212
   End
   Begin VB.CommandButton cmd_EndDate 
      Height          =   276
      Left            =   3000
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   1440
      Width           =   252
   End
   Begin VB.TextBox txt_StartDate 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   1800
      Locked          =   -1  'True
      TabIndex        =   15
      Top             =   960
      Width           =   1212
   End
   Begin VB.CommandButton cmd_StartDate 
      Height          =   276
      Left            =   3000
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   960
      Width           =   252
   End
   Begin VB.CommandButton spp_save 
      Height          =   612
      Left            =   3600
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   2880
      Width           =   612
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   4320
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   2880
      Width           =   612
   End
   Begin VB.CommandButton SSC_dropped 
      Height          =   276
      Left            =   3000
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   3060
      Width           =   252
   End
   Begin VB.TextBox Txt_descr 
      Enabled         =   0   'False
      Height          =   288
      Left            =   1080
      MaxLength       =   40
      TabIndex        =   1
      Top             =   360
      Width           =   3852
   End
   Begin VB.ComboBox Cbo_curr 
      Height          =   315
      Left            =   1800
      Style           =   2  'Dropdown List
      TabIndex        =   2
      Top             =   2040
      Width           =   2292
   End
   Begin VB.TextBox Txt_code 
      Height          =   285
      Left            =   240
      MaxLength       =   4
      TabIndex        =   0
      Top             =   360
      Width           =   735
   End
   Begin VB.ComboBox cbo_CurrencyCode 
      Height          =   315
      Left            =   4200
      Style           =   2  'Dropdown List
      TabIndex        =   5
      Top             =   2040
      Visible         =   0   'False
      Width           =   396
   End
   Begin VB.CheckBox chk_Int 
      Caption         =   "Check1"
      Height          =   252
      Left            =   1800
      TabIndex        =   3
      Top             =   2700
      Width           =   252
   End
   Begin VB.TextBox txt_dropped 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   1800
      Locked          =   -1  'True
      TabIndex        =   4
      Top             =   3060
      Width           =   1212
   End
   Begin VB.Label lbl_EndDate 
      Caption         =   "End 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          =   255
      Left            =   240
      TabIndex        =   19
      Top             =   1440
      Width           =   1455
   End
   Begin VB.Label lbl_StartDate 
      Caption         =   "Start 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          =   255
      Left            =   240
      TabIndex        =   16
      Top             =   960
      Width           =   1455
   End
   Begin VB.Label lbl_descr 
      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            =   1080
      TabIndex        =   11
      Top             =   120
      Width           =   3852
   End
   Begin VB.Label Lbl_code 
      Alignment       =   2  'Center
      Caption         =   "Code"
      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            =   240
      TabIndex        =   10
      Top             =   120
      Width           =   732
   End
   Begin VB.Label Lbl_curr 
      Caption         =   "Currency"
      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            =   240
      TabIndex        =   9
      Top             =   2100
      Width           =   1455
   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          =   255
      Left            =   240
      TabIndex        =   7
      Top             =   3060
      Width           =   1455
   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          =   255
      Left            =   240
      TabIndex        =   6
      Top             =   2700
      Width           =   1455
   End
End
Attribute VB_Name = "Country_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private mb_ToDate As Boolean
Private mb_FromDate As Boolean

Private Sub cmd_StartDate_Click()
On Error GoTo Err_cmd_StartDate

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

Exit Sub

Err_cmd_StartDate:
    StdError
End Sub

Private Sub cmd_EndDate_Click()
On Error GoTo Err_cmd_EndDate

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

Exit Sub

Err_cmd_EndDate:
    StdError
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)
SSC_dropped.Picture = LoadResPicture(RES_DOWN2, vbResIcon)
cmd_StartDate.Picture = LoadResPicture(RES_DOWN2, vbResIcon)
cmd_EndDate.Picture = LoadResPicture(RES_DOWN2, vbResIcon)

mtnc_Country_cst
Select Case gs_Action
Case "Add"
    FillCbo "Currencies", cbo_CurrencyCode, Cbo_curr
    Txt_descr.Enabled = False
'P516 dates management
    txt_EndDate = ""
    txt_startdate = ""
'P516
Case "Update"
    txt_Code.Enabled = KO
    txt_Code = gs_TableCode
    Txt_descr = gs_TableCode3
    If gs_TableCode6 = "X" Then
        chk_Int.Value = 1
    End If
    txt_dropped = gs_TableCode7
    FillCbo "Currencies", cbo_CurrencyCode, Cbo_curr
    Cbo_curr.ListIndex = ComboFindItem(cbo_CurrencyCode, gs_TableCode4)
'P516 dates management
    Txt_descr.Enabled = False
    InitDates
'P516
Case "Delete"
    txt_Code.Enabled = KO
    Txt_descr.Enabled = KO
    Cbo_curr.Enabled = KO
    txt_dropped.Enabled = KO
    chk_Int.Enabled = KO
    SSC_dropped.Visible = KO
    txt_Code = gs_TableCode
    Txt_descr = gs_TableCode3
    Cbo_curr.AddItem gs_TableCode5
    Cbo_curr.ListIndex = 0
    If gs_TableCode6 = "X" Then
        chk_Int.Value = 1
    End If
    txt_dropped = gs_TableCode7
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 Add_Table Then
        txt_Code = ""
        Txt_descr = ""
        txt_dropped = ""
        chk_Int.Value = 0
        Cbo_curr.ListIndex = -1
        txt_Code.SetFocus
    End If
Case "Update"
    If Upd_Table Then

'P516 SPA date range
        If txt_EndDate <> "" Then
            If mb_ToDate Then
                If Not Config_Upd("SPA_VALIDTODATE_??", txt_EndDate) Then
                    MouseOn
                    SendMessage 3, "Update failed", gut_LangLogin.Code
                    Exit Sub
                End If
            Else
                If Not Config_Add("SPA_VALIDTODATE_??", txt_EndDate) Then
                    MouseOn
                    SendMessage 4, "Insert failed", gut_LangLogin.Code
                    Exit Sub
                End If
            End If
        Else
'            If mb_ToDate Then
'                If Not Config_Del("SPA_VALIDTODATE_??") Then
'                    MouseOn
'                    SendMessage 7, "Delete failed.", gut_LangLogin.Code
'                    Exit Sub
'                End If
'            End If
        End If
        
        If txt_startdate <> "" Then
            If mb_FromDate Then
                If Not Config_Upd("SPA_VALIDFROMDATE_??", txt_startdate) Then
                    MouseOn
                    SendMessage 3, "Update failed", gut_LangLogin.Code
                    Exit Sub
                End If
            Else
                If Not Config_Add("SPA_VALIDFROMDATE_??", txt_startdate) Then
                    MouseOn
                    SendMessage 4, "Insert failed", gut_LangLogin.Code
                    Exit Sub
                End If
            End If
        Else
            If mb_FromDate Then
                If Not Config_Del("SPA_VALIDFROMDATE_??") Then
                    MouseOn
                    SendMessage 7, "Delete failed.", gut_LangLogin.Code
                    Exit Sub
                End If
            End If
        End If
    Else
        MouseOn
        Exit Sub
    End If
    
Case "Delete"
    If Dlt_Table Then
        Unload Me
        MouseOn
        Exit Sub
    End If
End Select


Unload Me
MouseOn

End Sub
Private Sub SSC_dropped_Click()

On Error GoTo suite

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

Exit Sub

suite:
    StdError
End Sub
Private Sub ssp_quit_Click()

MouseOn
Unload Me

End Sub
Private Function Upd_Table() 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

Upd_Table = KO

On Error GoTo suite

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
If Control Then
    ls_req = "EXEC Countries_upd '" _
        & QuoteParam(gs_TableCode) & "', '" _
        & QuoteParam(Txt_descr) & "', '" _
        & QuoteParam(cbo_CurrencyCode.List(Cbo_curr.ListIndex)) & "', " _
        & gs_TableCode2 & ",'" _
        & ls_IntFlag & "','" _
        & ls_DropFlag & "','" _
        & ls_DropDate & "'"
    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
            Upd_Table = OK
            C_main.Grid.RemoveItem C_main.Grid.Row
            ls_Line = gs_TableCode & Chr(9) & CInt(gs_TableCode2) + 1 & Chr(9) & Txt_descr & Chr(9) & cbo_CurrencyCode.List(Cbo_curr.ListIndex) & Chr(9) & Cbo_curr & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
            C_main.Grid.AddItem ls_Line, C_main.Grid.Row
        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 Add_Table() 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

Add_Table = 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
    ls_req = "EXEC Countries_ins '" _
        & QuoteParam(UCase(txt_Code)) & "', '" _
        & QuoteParam(Txt_descr) & "', '" _
        & QuoteParam(cbo_CurrencyCode.List(Cbo_curr.ListIndex)) & "', '" _
        & ls_IntFlag & "','" _
        & ls_DropFlag & "','" _
        & ls_DropDate & "'"
    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
            C_main.FillGrid
        Else
            Add_Table = OK
            ls_Line = UCase(txt_Code) & Chr(9) & 1 & Chr(9) & Txt_descr & Chr(9) & cbo_CurrencyCode.List(Cbo_curr.ListIndex) & Chr(9) & Cbo_curr & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
            C_main.Grid.AddItem ls_Line
            C_main.Grid.Row = C_main.Grid.Rows - 1
        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 Dlt_Table() As Boolean

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

Dlt_Table = KO

On Error GoTo suite

MouseOn
If SendMessage(5, "Delete record ?", gut_LangLogin.Code, vbQuestion + vbYesNo, "Delete ") = vbYes Then
    ls_req = "EXEC Countries_del '" _
      & QuoteParam(gs_TableCode) & "', " _
      & gs_TableCode2
    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
            Dlt_Table = 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
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 mtnc_Country_cst()

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

ls_req = "EXEC Screen_Csts 'mtnc_Country', '" & 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 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 "lbl_code": lbl_Code = ls_Text
        Case "lbl_descr": lbl_descr = ls_Text
        Case "lbl_curr": Lbl_curr = ls_Text
        Case "lbl_int": lbl_Int = ls_Text
        Case "lbl_drop": lbl_Drop = ls_Text
        Case "lbl_StartDate": lbl_StartDate = ls_Text
        Case "lbl_EndDate": lbl_EndDate = 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_Code.Text = "" Then
    txt_Code.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Txt_descr.Text = "" Then
    Txt_descr.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Len(Txt_descr) < 4 Then
    Txt_descr.SetFocus
    SendMessage 11, "Value must be more than 3 characters long", gut_LangLogin.Code
    Exit Function
End If
If Cbo_curr.ListIndex = -1 Then
    Cbo_curr.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If

'P516 SPA dates
'Is A_Config table OK ?
If Not ConfigOK Then
    txt_EndDate.SetFocus
    SendMessage 122, "Contact your IT support; problem in A_Config table", gut_LangLogin.Code
    Exit Function
End If
If txt_EndDate.Text = "" Then
    txt_EndDate.SetFocus
    SendMessage 8690, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If txt_startdate.Text <> "" Then
    If Not DateGreaterOrEqual(txt_EndDate, txt_startdate) Then
        txt_startdate.SetFocus
        SendMessage 8680, "Ending date must be greather than starting date", gut_LangLogin.Code
        Exit Function
    End If
End If
'P516 SPA dates

Control = OK

End Function

Private Function ConfigOK() As Boolean
'P516 for date range by countries management
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ll_Rows As Long
Const C_REQ As String = "EXEC A_Config_sel '$CFG_key$'"
Const C_SPAFROM As String = "SPA_VALIDFROMDATE_??"
Const C_SPATO As String = "SPA_VALIDTODATE_??"

On Error GoTo Err_Config

ConfigOK = False
mb_ToDate = False
mb_FromDate = False

'Does a record exist in A_Config for to date
ls_req = C_REQ
ls_req = Replace(ls_req, "$CFG_key$", C_SPATO)
ls_req = Replace(ls_req, "??", gs_TableCode)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        If ODBCData(ll_Statement, 1) <> "" Then
            mb_ToDate = True
        End If
    End If
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

'Does a record exist in A_Config for from date

ls_req = C_REQ
ls_req = Replace(ls_req, "$CFG_key$", C_SPAFROM)
ls_req = Replace(ls_req, "??", gs_TableCode)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        If ODBCData(ll_Statement, 1) <> "" Then
            mb_FromDate = True
        End If
    End If
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

If mb_FromDate = True Then
    If mb_ToDate = True Then ConfigOK = True
Else
    ConfigOK = True
End If

Exit Function

Err_Config:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Function

Private Function Config_Add(ByVal as_Key As String, ByVal as_Date As String) As Boolean

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

On Error GoTo Err_ConfigAdd

Config_Add = False

ls_req = "EXEC A_Config_ins '$Key$','$Value$','Range date by Country for SPA'"
ls_req = Replace(ls_req, "$Key$", as_Key)
ls_req = Replace(ls_req, "$Value$", as_Date)
ls_req = Replace(ls_req, "??", gs_TableCode)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLRowCount(ll_Statement, ll_Rows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_Rows <> 1 Then
        Exit Function
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If

Config_Add = True
Exit Function

Err_ConfigAdd:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Function

Private Sub InitDates()

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
Const C_REQ As String = "EXEC A_Config_sel '$Key$'"

On Error GoTo Err_InitDate

ls_req = C_REQ
ls_req = Replace(ls_req, "$Key$", "SPA_VALIDFROMDATE_??")
ls_req = Replace(ls_req, "??", gs_TableCode)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        txt_startdate = ODBCData(ll_Statement, 1)
    End If
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

ls_req = C_REQ
ls_req = Replace(ls_req, "$Key$", "SPA_VALIDTODATE_??")
ls_req = Replace(ls_req, "??", gs_TableCode)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        txt_EndDate = ODBCData(ll_Statement, 1)
    End If
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

Exit Sub

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

Private Function Config_Upd(ByVal as_Key As String, ByVal as_Date As String) As Boolean

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

On Error GoTo Err_ConfigUpd

Config_Upd = False

ls_req = "EXEC A_Config_upd '$Key$','$Value$','Range date by Country for SPA'"
ls_req = Replace(ls_req, "$Key$", as_Key)
ls_req = Replace(ls_req, "$Value$", as_Date)
ls_req = Replace(ls_req, "??", gs_TableCode)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLRowCount(ll_Statement, ll_Rows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_Rows <> 1 Then
        Exit Function
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If

Config_Upd = True
Exit Function

Err_ConfigUpd:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Function


Private Function Config_Del(ByVal as_Key As String) As Boolean

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

On Error GoTo Err_ConfigDel

Config_Del = False

ls_req = "EXEC A_Config_del '$Key$'"
ls_req = Replace(ls_req, "$Key$", as_Key)
ls_req = Replace(ls_req, "??", gs_TableCode)

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
    li_Status = SQLRowCount(ll_Statement, ll_Rows)
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    If ll_Rows <> 1 Then
        Exit Function
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Function
End If

Config_Del = True
Exit Function

Err_ConfigDel:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Function

