VERSION 5.00
Begin VB.Form Plant_cont_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   3885
   ClientLeft      =   1050
   ClientTop       =   1455
   ClientWidth     =   7425
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   3885
   ScaleWidth      =   7425
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   612
      Left            =   6060
      Style           =   1  'Graphical
      TabIndex        =   10
      Top             =   3120
      Width           =   612
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   6720
      Style           =   1  'Graphical
      TabIndex        =   11
      Top             =   3120
      Width           =   612
   End
   Begin VB.CommandButton SSC_dropped 
      Height          =   276
      Left            =   3360
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   3480
      Width           =   252
   End
   Begin VB.CheckBox chk_Int 
      Caption         =   "Check1"
      Height          =   252
      Left            =   2100
      TabIndex        =   14
      Top             =   3120
      Width           =   252
   End
   Begin VB.TextBox txt_dropped 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   2100
      Locked          =   -1  'True
      TabIndex        =   13
      Top             =   3480
      Width           =   1212
   End
   Begin VB.ComboBox Cbo_plant 
      Height          =   288
      Left            =   5400
      Style           =   2  'Dropdown List
      TabIndex        =   4
      Top             =   1140
      Width           =   1812
   End
   Begin VB.TextBox txt_info 
      Height          =   1785
      Left            =   276
      MaxLength       =   240
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   3
      Top             =   1176
      Width           =   4965
   End
   Begin VB.TextBox Txt_tel 
      Height          =   285
      Left            =   3540
      MaxLength       =   40
      TabIndex        =   1
      Top             =   396
      Width           =   1755
   End
   Begin VB.TextBox Txt_name 
      Height          =   285
      Left            =   240
      MaxLength       =   40
      TabIndex        =   0
      Top             =   396
      Width           =   3135
   End
   Begin VB.TextBox Txt_fax 
      Height          =   285
      Left            =   5400
      MaxLength       =   40
      TabIndex        =   2
      Top             =   396
      Width           =   1755
   End
   Begin VB.ComboBox cbo_PlantCode 
      Height          =   288
      Left            =   6600
      Style           =   2  'Dropdown List
      TabIndex        =   5
      Top             =   1140
      Visible         =   0   'False
      Width           =   396
   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            =   300
      TabIndex        =   16
      Top             =   3480
      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            =   300
      TabIndex        =   15
      Top             =   3120
      Width           =   1452
   End
   Begin VB.Label Lbl_plant 
      Alignment       =   2  'Center
      Caption         =   "Plant"
      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            =   5400
      TabIndex        =   12
      Top             =   900
      Width           =   1812
   End
   Begin VB.Label Lbl_info 
      Alignment       =   2  'Center
      Caption         =   "Info"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   312
      Left            =   300
      TabIndex        =   9
      Top             =   900
      Width           =   4968
   End
   Begin VB.Label Lbl_fax 
      Alignment       =   2  'Center
      Caption         =   "Fax"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   228
      Left            =   5436
      TabIndex        =   8
      Top             =   156
      Width           =   1728
   End
   Begin VB.Label Lbl_tel 
      Alignment       =   2  'Center
      Caption         =   "Tel"
      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            =   3540
      TabIndex        =   7
      Top             =   156
      Width           =   1752
   End
   Begin VB.Label lbl_name 
      Alignment       =   2  'Center
      Caption         =   "Name"
      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        =   6
      Top             =   120
      Width           =   3132
   End
End
Attribute VB_Name = "Plant_cont_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim mi_concurrency As Integer

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)

mtnc_plant_cont_cst
Select Case gs_Action
Case "Add":
    FillCbo "Plants", cbo_PlantCode, Cbo_plant
Case "Update":
    FillCbo "Plants", cbo_PlantCode, Cbo_plant
    Set_Description
Case "MoreInfo":
    Set_Description
    spp_save.Visible = KO
    Txt_name.Locked = OK
    Txt_tel.Locked = OK
    Txt_fax.Locked = OK
    txt_info.Locked = OK
    Cbo_plant.Enabled = KO
    Cbo_plant.AddItem gs_TableCode3
    Cbo_plant.ListIndex = 0
    chk_Int.Enabled = KO
    txt_dropped.Locked = OK
    SSC_dropped.Visible = -1
Case "Delete":
    Set_Description
    Txt_name.Enabled = KO
    Txt_tel.Enabled = KO
    Txt_fax.Enabled = KO
    txt_info.Enabled = KO
    Cbo_plant.Enabled = KO
    Cbo_plant.AddItem gs_TableCode3
    Cbo_plant.ListIndex = 0
End Select
MouseOn
Exit Sub

suite:
StdError
End Sub
Private Sub spp_save_Click()

On Error GoTo suite

MouseOff
gb_Return = OK
Select Case gs_Action
Case "Add":
    If Add_Table Then
        Txt_name = ""
        Txt_tel = ""
        Txt_fax = ""
        txt_info = ""
        Cbo_plant.ListIndex = -1
        txt_dropped = ""
        chk_Int.value = 0
        Txt_name.SetFocus
        If gl_NbLineDisplay < 2 Then
            C_main.FillGrid
        End If
    End If
Case "Update":
    If Upd_Table Then
        Unload Me
    End If
Case "Delete":
    If Dlt_Table Then
        Unload Me
    End If
End Select
MouseOn
Exit Sub

suite:
MouseOn
StdError
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 Sub Set_Description()

Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Field As String
Dim li_Count As Integer
   
On Error GoTo suite
   
ls_Req = "EXEC Claim_Contact_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)
        ls_Field = ODBCData(ll_Statement, 2)
        Txt_tel = ODBCData(ll_Statement, 3)
        Txt_fax = ODBCData(ll_Statement, 4)
        txt_info = ODBCData(ll_Statement, 5)
        If ODBCData(ll_Statement, 6) = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = ODBCData(ll_Statement, 7)
        mi_concurrency = ODBCData(ll_Statement, 8)
        For li_Count = 0 To cbo_PlantCode.ListCount - 1
            If cbo_PlantCode.List(li_Count) = ls_Field Then
                Cbo_plant.ListIndex = li_Count
                Exit For
            End If
        Next li_Count
    End If
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
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_DropDate As String
Dim ls_DropFlag As String

Upd_Table = KO

On Error GoTo suite
If chk_Int.value = 1 Then
    ls_IntFlag = "X"
Else
    ls_IntFlag = ""
End If
If txt_dropped <> "" Then
    ls_DropFlag = "X"
    ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
End If
If Control Then
    ls_Req = "EXEC Claim_Contact_upd " _
     & gs_TableCode & ", '" _
     & QuoteParam(Txt_name) & "', '" _
     & QuoteParam(cbo_PlantCode.List(Cbo_plant.ListIndex)) & "', '" _
     & QuoteParam(Txt_tel) & "', '" _
     & QuoteParam(Txt_fax) & "', '" _
     & QuoteParam(txt_info) & "', '" _
     & ls_IntFlag & "', '" & ls_DropFlag & "', '" & ls_DropDate & "', " _
     & mi_concurrency
    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) & Txt_name & Chr(9) & Cbo_plant.Text & Chr(9) & Txt_tel & Chr(9) & Txt_fax & Chr(9) & ls_IntFlag & Chr(9) & ls_DropDate
            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_IntFlag As String
Dim ls_DropDate As String
Dim ls_DropFlag As String

Add_Table = KO

On Error GoTo suite
If chk_Int.value = 1 Then
    ls_IntFlag = "X"
Else
    ls_IntFlag = ""
End If
If txt_dropped <> "" Then
    ls_DropFlag = "X"
    ls_DropDate = FormatD(txt_dropped, "mm/dd/yyyy")
End If
If Control Then
    ls_Req = "EXEC Claim_Contact_ins '" _
     & QuoteParam(Txt_name) & "', '" _
     & QuoteParam(cbo_PlantCode.List(Cbo_plant.ListIndex)) & "', '" _
     & QuoteParam(Txt_tel) & "', '" _
     & QuoteParam(Txt_fax) & "', '" _
     & QuoteParam(txt_info) & "', '" _
     & 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
            SendMessage 4, "Insert failed", gut_LangLogin.Code
        Else
            Add_Table = OK
        End If
        C_main.FillGrid
    Else
        SendMessage 4, "Insert failed", gut_LangLogin.Code
    End If
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
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
    MouseOff
    ls_Req = "EXEC Claim_Contact_del " & gs_TableCode & ", " & mi_concurrency
    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
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 mtnc_plant_cont_cst()

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_Claim_Cont, '" & 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.Caption = ls_Text
        Case "lbl_phone": Lbl_tel = ls_Text
        Case "lbl_fax": Lbl_fax = ls_Text
        Case "lbl_info": Lbl_info = ls_Text
        Case "lbl_plant": Lbl_plant = 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 Cbo_plant = "" Then
    Cbo_plant.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Txt_name.Text = "" Then
    Txt_name.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Txt_tel.Text = "" Then
    Txt_tel.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Len(Txt_name) < 4 Then
    Txt_name.SetFocus
    SendMessage 11, "Value must be more than 3 characters long", gut_LangLogin.Code
    Exit Function
End If
Control = OK

End Function

