VERSION 5.00
Begin VB.Form Test_House_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   4965
   ClientLeft      =   945
   ClientTop       =   915
   ClientWidth     =   7365
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4965
   ScaleWidth      =   7365
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   612
      Left            =   5940
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   4200
      Width           =   612
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   6600
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   4200
      Width           =   612
   End
   Begin VB.CommandButton SSC_dropped 
      Height          =   276
      Left            =   3060
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   4500
      Width           =   252
   End
   Begin VB.TextBox txt_memo 
      Height          =   1032
      Left            =   1860
      MaxLength       =   80
      MultiLine       =   -1  'True
      TabIndex        =   10
      Top             =   3000
      Width           =   5292
   End
   Begin VB.TextBox txt_Address3 
      Height          =   285
      Left            =   1860
      MaxLength       =   80
      TabIndex        =   3
      Top             =   1320
      Width           =   5295
   End
   Begin VB.ComboBox cbo_CountryCode 
      Height          =   288
      Left            =   3180
      Style           =   2  'Dropdown List
      TabIndex        =   6
      TabStop         =   0   'False
      Top             =   2160
      Visible         =   0   'False
      Width           =   396
   End
   Begin VB.TextBox txt_dropped 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   1860
      Locked          =   -1  'True
      TabIndex        =   22
      TabStop         =   0   'False
      Top             =   4500
      Width           =   1212
   End
   Begin VB.CheckBox chk_Int 
      Caption         =   "Check1"
      Height          =   252
      Left            =   1860
      TabIndex        =   11
      Top             =   4140
      Width           =   252
   End
   Begin VB.TextBox txt_Name 
      Height          =   285
      Left            =   1860
      MaxLength       =   80
      TabIndex        =   0
      Top             =   180
      Width           =   5295
   End
   Begin VB.TextBox txt_Address1 
      Height          =   285
      Left            =   1860
      MaxLength       =   80
      TabIndex        =   1
      Top             =   600
      Width           =   5295
   End
   Begin VB.TextBox txt_Address2 
      Height          =   285
      Left            =   1860
      MaxLength       =   80
      TabIndex        =   2
      Top             =   960
      Width           =   5295
   End
   Begin VB.TextBox txt_Town 
      Height          =   285
      Left            =   4860
      MaxLength       =   80
      TabIndex        =   5
      Top             =   1740
      Width           =   2295
   End
   Begin VB.TextBox txt_Tel 
      Height          =   285
      Left            =   1860
      MaxLength       =   20
      TabIndex        =   8
      Top             =   2580
      Width           =   1935
   End
   Begin VB.TextBox txt_Fax 
      Height          =   285
      Left            =   5100
      MaxLength       =   20
      TabIndex        =   9
      Top             =   2580
      Width           =   2055
   End
   Begin VB.TextBox txt_Zip 
      Height          =   288
      Left            =   1860
      MaxLength       =   15
      TabIndex        =   4
      Top             =   1740
      Width           =   1512
   End
   Begin VB.ComboBox cbo_Country 
      Height          =   288
      Left            =   1860
      Style           =   2  'Dropdown List
      TabIndex        =   7
      Top             =   2160
      Width           =   1932
   End
   Begin VB.Label lbl_memo 
      Caption         =   "Memo"
      Height          =   252
      Left            =   180
      TabIndex        =   25
      Top             =   3000
      Width           =   1692
   End
   Begin VB.Label lbl_Int 
      Caption         =   "Internet flag"
      Height          =   252
      Left            =   180
      TabIndex        =   24
      Top             =   4140
      Width           =   1692
   End
   Begin VB.Label lbl_Drop 
      Caption         =   "Drop date"
      Height          =   252
      Left            =   180
      TabIndex        =   23
      Top             =   4500
      Width           =   1692
   End
   Begin VB.Label lbl_Name 
      Caption         =   "Name"
      Height          =   252
      Left            =   180
      TabIndex        =   21
      Top             =   180
      Width           =   1692
   End
   Begin VB.Label lbl_Address 
      Caption         =   "Address"
      Height          =   252
      Left            =   180
      TabIndex        =   20
      Top             =   600
      Width           =   1692
   End
   Begin VB.Label lbl_Town 
      Caption         =   "Town"
      Height          =   252
      Left            =   3420
      TabIndex        =   19
      Top             =   1740
      Width           =   1452
   End
   Begin VB.Label lbl_Country 
      Caption         =   "Country"
      Height          =   252
      Left            =   180
      TabIndex        =   18
      Top             =   2160
      Width           =   1692
   End
   Begin VB.Label lbl_Tel 
      Caption         =   "Phone"
      Height          =   252
      Left            =   180
      TabIndex        =   17
      Top             =   2580
      Width           =   1692
   End
   Begin VB.Label lbl_Fax 
      Caption         =   "Fax"
      Height          =   252
      Left            =   4140
      TabIndex        =   16
      Top             =   2580
      Width           =   972
   End
   Begin VB.Label lbl_zip 
      Caption         =   "Zip code"
      Height          =   252
      Left            =   180
      TabIndex        =   15
      Top             =   1740
      Width           =   1692
   End
End
Attribute VB_Name = "Test_House_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim mb_CountryNotLoaded As Boolean
Private Sub Cbo_country_DropDown()

Dim ls_Country As String

MouseOff
If mb_CountryNotLoaded Then
    mb_CountryNotLoaded = KO
    If cbo_Country.ListIndex <> -1 Then
        ls_Country = cbo_CountryCode.List(cbo_Country.ListIndex)
    Else
        ls_Country = ""
    End If
    cbo_CountryCode.Clear
    cbo_Country.Clear
    FillCbo "Countries", cbo_CountryCode, cbo_Country
    If ls_Country <> "" Then
        cbo_Country.ListIndex = ComboFindItem(cbo_CountryCode, ls_Country)
    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"
    mb_CountryNotLoaded = OK
Case "Update"
    Set_Description
'Txt_name = gs_TableCode3
'txt_Address1 = gs_TableCode4
'    txt_Address2 = gs_TableCode5
'    txt_Address3 = gs_TableCode6
'    txt_Zip = gs_TableCode7
'    Txt_town = gs_TableCode8
'    mb_CountryNotLoaded = OK
'    cbo_CountryCode.AddItem gs_TableCode9
'    Cbo_country.AddItem gs_TableCode10
'    Cbo_country.ListIndex = 0
'    Txt_tel = gs_TableCode11
'    Txt_fax = gs_TableCode12
    
'    If gs_TableCode14 = "X" Then
'        chk_Int.Value = 1
'    End If
'    txt_dropped = gs_TableCode14

Case "Delete"
    txt_Name.Enabled = KO
    txt_Address1.Enabled = KO
    txt_Address2.Enabled = KO
    txt_Address3.Enabled = KO
    txt_Zip.Enabled = KO
    txt_Town.Enabled = KO
    cbo_Country.Enabled = KO
    txt_Tel.Enabled = KO
    txt_Fax.Enabled = KO
    txt_memo.Enabled = KO
    txt_dropped.Enabled = KO
    chk_Int.Enabled = KO
    SSC_dropped.Visible = KO
    Set_Description
'    Txt_name = gs_TableCode3
'    txt_Address1 = gs_TableCode4
'    txt_Address2 = gs_TableCode5
'    txt_Zip = gs_TableCode6
'    Txt_town = gs_TableCode7
'    Cbo_country.AddItem gs_TableCode9
'    Cbo_country.ListIndex = 0
'    Txt_tel = gs_TableCode10
'    Txt_fax = gs_TableCode11
'    If gs_TableCode12 = "X" Then
'        chk_Int.Value = 1
'    End If
'    txt_dropped = gs_TableCode13

'start change
Case "MoreInfo"
    txt_Name.Enabled = KO
    txt_Address1.Enabled = KO
    txt_Address2.Enabled = KO
    txt_Address3.Enabled = KO
    txt_Zip.Enabled = KO
    txt_Town.Enabled = KO
    cbo_Country.Enabled = KO
    txt_Tel.Enabled = KO
    txt_Fax.Enabled = KO
    txt_memo.Enabled = KO
    chk_Int.Enabled = KO
    txt_dropped.Enabled = KO
    SSC_dropped.Visible = KO
    spp_save.Visible = KO
    Set_Description
'end change

End Select
MouseOn
Exit Sub

suite:
StdError
End Sub

Private Sub Label1_Click()

End Sub

Private Sub spp_save_Click()

MouseOff
gb_Return = OK
Select Case gs_Action
Case "Add"
    If AddTable Then
        txt_Name = ""
        txt_Address1 = ""
        txt_Address2 = ""
        txt_Address3 = ""
        txt_Zip = ""
        txt_Town = ""
        cbo_Country.ListIndex = -1
        txt_Tel = ""
        txt_Fax = ""
        txt_memo = ""
        chk_Int.value = 0
        txt_dropped = ""
        txt_Name.SetFocus
        If gl_NbLineDisplay < 2 Then
            C_main.FillGrid
        End If
    End If
Case "Update"
    If UpdTable Then
        Unload Me
    End If
Case "Delete"
    If DltTable Then
        Unload Me
    End If
End Select
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()

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_CountryCode As String
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 cbo_Country.ListIndex = -1 Then
        ls_CountryCode = ""
    Else
        ls_CountryCode = QuoteParam(cbo_CountryCode.List(cbo_Country.ListIndex))
    End If
    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 Test_House_upd " _
      & gs_TableCode & ", '" & QuoteParam(txt_Name) & "', '" _
      & QuoteParam(txt_Address1) & "', '" & QuoteParam(txt_Address2) & "', '" & QuoteParam(txt_Address3) & "', '" _
      & QuoteParam(txt_Zip) & "', '" & QuoteParam(txt_Town) & "', '" & ls_CountryCode & "', '" _
      & QuoteParam(txt_Tel) & "', '" & QuoteParam(txt_Fax) & "', '" & QuoteParam(txt_memo) & "', '" _
      & ls_IntFlag & "', '" & ls_DropFlag & "', '" & ls_DropDate & "', " & 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 2, "Another user change the record", gut_LangLogin.Code
            C_main.FillGrid
        Else
            UpdTable = OK
            C_main.Grid.RemoveItem C_main.Grid.Row
            ls_Line = gs_TableCode & Chr(9) & CInt(gs_TableCode2 + 1) & Chr(9) & txt_Name & Chr(9) _
                & txt_Town & Chr(9) & cbo_Country & 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 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_CountryCode As String
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 cbo_Country.ListIndex = -1 Then
        ls_CountryCode = ""
    Else
        ls_CountryCode = QuoteParam(cbo_CountryCode.List(cbo_Country.ListIndex))
    End If
    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 Test_House_ins '" _
      & QuoteParam(txt_Name) & "', '" & QuoteParam(txt_Address1) & "', '" & QuoteParam(txt_Address2) & "', '" _
      & QuoteParam(txt_Address3) & "', '" & QuoteParam(txt_Zip) & "', '" & QuoteParam(txt_Town) & "', '" _
      & ls_CountryCode & "', '" & QuoteParam(txt_Tel) & "', '" & QuoteParam(txt_Fax) & "', '" _
      & QuoteParam(txt_memo) & "', '" & ls_IntFlag & "','" & ls_DropFlag & "','" & ls_DropDate & "'"
    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)
                ls_Line = ls_Code & Chr(9) & 1 & Chr(9) & txt_Name & Chr(9) _
                    & txt_Town & Chr(9) & cbo_Country & Chr(9) & ls_IntFlag & Chr(9) & txt_dropped
                C_main.Grid.AddItem ls_Line
                C_main.Grid.Row = C_main.Grid.Rows - 1
            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 ") = vbNo Then
    MouseOff
    Exit Function
End If
MouseOff
ls_Req = "EXEC Test_House_del " & 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
        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
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, ls_Text As String

On Error GoTo suite

ls_Req = "EXEC Screen_Csts 'mtnc_Test_House', '" & 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 "titleI": If gs_Action = "MoreInfo" Then Caption = Caption & " - " & ls_Text
        Case "lbl_Name": lbl_Name = ls_Text
        Case "lbl_Address": lbl_Address = ls_Text
        Case "lbl_Town": lbl_Town = ls_Text
        Case "lbl_Zip": lbl_zip = ls_Text
        Case "lbl_Country": lbl_Country = ls_Text
        Case "lbl_Tel": lbl_Tel.Caption = ls_Text
        Case "lbl_Fax": lbl_Fax = 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_Name.Text = "" Then
    txt_Name.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
Control = OK

End Function


Private Sub Set_Description()

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Count As Integer

On Error GoTo suite

ls_Req = "EXEC Test_House_dtl " & gs_TableCode & ",'" & gut_LangWork.Code & "'"
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_Name = ODBCData(ll_Statement, 1)
        txt_Address1 = ODBCData(ll_Statement, 2)
        txt_Address2 = ODBCData(ll_Statement, 3)
        txt_Address3 = ODBCData(ll_Statement, 4)
        txt_Zip = ODBCData(ll_Statement, 5)
        txt_Town = ODBCData(ll_Statement, 6)
        mb_CountryNotLoaded = OK
        cbo_CountryCode.AddItem ODBCData(ll_Statement, 7)
        cbo_Country.AddItem ODBCData(ll_Statement, 8)
        cbo_Country.ListIndex = 0
        txt_Tel = ODBCData(ll_Statement, 9)
        txt_Fax = ODBCData(ll_Statement, 10)
        txt_memo = ODBCMemoGet(ll_Statement, 11)
        If ODBCData(ll_Statement, 12) = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = ODBCData(ll_Statement, 14)
    End If
End If

li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

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

