VERSION 5.00
Begin VB.Form Plants_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   6375
   ClientLeft      =   975
   ClientTop       =   420
   ClientWidth     =   7515
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6375
   ScaleWidth      =   7515
   ShowInTaskbar   =   0   'False
   Begin Project1.ArmCombobox cbo_PurchManager 
      Height          =   345
      Left            =   4140
      TabIndex        =   34
      Top             =   2880
      Width           =   3105
      _ExtentX        =   5477
      _ExtentY        =   609
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   6660
      Style           =   1  'Graphical
      TabIndex        =   31
      Top             =   5520
      Width           =   612
   End
   Begin VB.CommandButton spp_save 
      Height          =   612
      Left            =   6000
      Style           =   1  'Graphical
      TabIndex        =   32
      Top             =   5520
      Width           =   612
   End
   Begin VB.CommandButton SSC_dropped 
      Height          =   276
      Left            =   3240
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   5760
      Width           =   252
   End
   Begin VB.TextBox txt_code 
      Height          =   285
      Left            =   1920
      MaxLength       =   15
      TabIndex        =   0
      Top             =   120
      Width           =   1875
   End
   Begin VB.TextBox Txt_name 
      Height          =   285
      Left            =   1920
      MaxLength       =   80
      TabIndex        =   2
      Top             =   480
      Width           =   5295
   End
   Begin VB.TextBox Txt_adr1 
      Height          =   285
      Left            =   1920
      MaxLength       =   80
      TabIndex        =   3
      Top             =   840
      Width           =   5295
   End
   Begin VB.TextBox Txt_adr2 
      Height          =   285
      Left            =   1920
      MaxLength       =   80
      TabIndex        =   4
      Top             =   1200
      Width           =   5295
   End
   Begin VB.TextBox Txt_town 
      Height          =   285
      Left            =   1920
      MaxLength       =   80
      TabIndex        =   6
      Top             =   1920
      Width           =   2295
   End
   Begin VB.TextBox Txt_zcode 
      Height          =   285
      Left            =   5400
      MaxLength       =   40
      TabIndex        =   7
      Top             =   1920
      Width           =   1815
   End
   Begin VB.TextBox Txt_phone 
      Height          =   285
      Left            =   1920
      MaxLength       =   20
      TabIndex        =   10
      Top             =   3360
      Width           =   1935
   End
   Begin VB.TextBox Txt_fax 
      Height          =   285
      Left            =   5160
      MaxLength       =   20
      TabIndex        =   11
      Top             =   3360
      Width           =   2055
   End
   Begin VB.TextBox Txt_info 
      Height          =   1152
      Left            =   240
      MaxLength       =   240
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   12
      Top             =   4140
      Width           =   6972
   End
   Begin VB.ComboBox Cbo_country 
      Height          =   315
      Left            =   1920
      Style           =   2  'Dropdown List
      TabIndex        =   8
      Top             =   2400
      Width           =   1932
   End
   Begin VB.TextBox Txt_adr3 
      Height          =   285
      Left            =   1920
      MaxLength       =   80
      TabIndex        =   5
      Top             =   1560
      Width           =   5295
   End
   Begin VB.ComboBox Cbo_currenc 
      Height          =   315
      Left            =   1920
      Style           =   2  'Dropdown List
      TabIndex        =   9
      Top             =   2880
      Width           =   1932
   End
   Begin VB.TextBox txt_ID 
      Height          =   288
      Left            =   4620
      MaxLength       =   2
      TabIndex        =   1
      Top             =   120
      Width           =   600
   End
   Begin VB.ComboBox cbo_CountryCode 
      Height          =   288
      Left            =   3240
      Style           =   2  'Dropdown List
      TabIndex        =   16
      Top             =   2400
      Visible         =   0   'False
      Width           =   396
   End
   Begin VB.ComboBox cbo_CurrencyCode 
      Height          =   288
      Left            =   3240
      Style           =   2  'Dropdown List
      TabIndex        =   15
      Top             =   2880
      Visible         =   0   'False
      Width           =   396
   End
   Begin VB.TextBox txt_dropped 
      ForeColor       =   &H00FF0000&
      Height          =   288
      Left            =   2040
      Locked          =   -1  'True
      TabIndex        =   14
      Top             =   5760
      Width           =   1212
   End
   Begin VB.CheckBox chk_Int 
      Caption         =   "Check1"
      Height          =   252
      Left            =   2040
      TabIndex        =   13
      Top             =   5400
      Width           =   252
   End
   Begin VB.Label Lbl_purch_manager 
      Caption         =   "Purchasing manager:"
      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            =   4200
      TabIndex        =   33
      Top             =   2520
      Width           =   3015
   End
   Begin VB.Label Lbl_code 
      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        =   30
      Top             =   120
      Width           =   1572
   End
   Begin VB.Label Lbl_name 
      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        =   29
      Top             =   480
      Width           =   1572
   End
   Begin VB.Label Lbl_adr1 
      Caption         =   "Address :"
      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        =   28
      Top             =   840
      Width           =   1572
   End
   Begin VB.Label Lbl_town 
      Caption         =   "Town :"
      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        =   27
      Top             =   1920
      Width           =   1572
   End
   Begin VB.Label Lbl_code_country 
      Caption         =   "Country :"
      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        =   26
      Top             =   2400
      Width           =   1572
   End
   Begin VB.Label Lbl_phone 
      Caption         =   "Phone :"
      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        =   25
      Top             =   3360
      Width           =   1572
   End
   Begin VB.Label Lbl_fax 
      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          =   252
      Left            =   4200
      TabIndex        =   24
      Top             =   3360
      Width           =   912
   End
   Begin VB.Label Lbl_info 
      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          =   252
      Left            =   240
      TabIndex        =   23
      Top             =   3840
      Width           =   5388
   End
   Begin VB.Label Lbl_zip_code 
      Caption         =   "Zip 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            =   4260
      TabIndex        =   22
      Top             =   1956
      Width           =   1152
   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          =   252
      Left            =   240
      TabIndex        =   21
      Top             =   2880
      Width           =   1572
   End
   Begin VB.Label lbl_ID 
      Caption         =   "ID :"
      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            =   3912
      TabIndex        =   20
      Top             =   120
      Width           =   492
   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            =   240
      TabIndex        =   19
      Top             =   5400
      Width           =   1452
   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            =   240
      TabIndex        =   18
      Top             =   5760
      Width           =   1452
   End
End
Attribute VB_Name = "Plants_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 Cbo_country_Click()
MouseOff
If Cbo_country.ListIndex <> -1 And Cbo_country.Visible = -1 Then
    If cbo_CountryCode.ItemData(Cbo_country.ListIndex) = 1 Then
        SendMessage 70, "Inactive item", gut_LangLogin.Code
    End If
End If
MouseOn
End Sub

Private Sub cbo_PurchManager_ComboItemSelected()
MouseOff
If Not cbo_PurchManager.SelectedItem Is Nothing Then
    If cbo_PurchManager.SelectedItem.Key <> "" And cbo_PurchManager.SelectedItem.GetData(2) = 0 Then
        SendMessage 7549, "Selected Manager does not have email address!", gut_LangLogin.Code
    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)

mtnc_Plants_cst
FillCbo "Countries", cbo_CountryCode, Cbo_country
FillCbo "Currencies", cbo_CurrencyCode, Cbo_currenc

Call cbo_PurchManager.Load_A_Com
Call cbo_PurchManager.Clear
Set cbo_PurchManager.ArmDb = aDb
cbo_PurchManager.Request = "exec Purchasing_Manager_cbo"
cbo_PurchManager.DisplayColumnsCount = 1
cbo_PurchManager.FirstBlankItem = True
cbo_PurchManager.Enabled = True
cbo_PurchManager.Visible = True

Select Case gs_Action
Case "Update":
    Set_Description
    txt_code.Enabled = KO
    txt_ID.Enabled = KO
Case "Delete":
    Set_Description
    txt_code.Enabled = KO
    txt_ID.Enabled = KO
    Txt_name.Enabled = KO
    Txt_adr1.Enabled = KO
    Txt_adr2.Enabled = KO
    Txt_adr3.Enabled = KO
    Txt_zcode.Enabled = KO
    Txt_town.Enabled = KO
    Cbo_country.Enabled = KO
    Cbo_currenc.Enabled = KO
    cbo_PurchManager.Enabled = KO
    Txt_phone.Enabled = KO
    Txt_fax.Enabled = KO
    Txt_info.Enabled = KO
    txt_dropped.Enabled = KO
    SSC_dropped.Visible = KO
    chk_Int.Enabled = KO
Case "MoreInfo":
    Set_Description
    spp_save.Visible = KO
    txt_code.Locked = OK
    txt_ID.Locked = OK
    Txt_name.Locked = OK
    Txt_info.Locked = OK
    Txt_adr1.Locked = OK
    Txt_adr2.Locked = OK
    Txt_adr3.Locked = OK
    Txt_town.Locked = OK
    Txt_zcode.Locked = OK
    Txt_fax.Locked = OK
    Txt_phone.Locked = OK
    Cbo_currenc.Enabled = KO
    Cbo_country.Enabled = KO
    cbo_PurchManager.Enabled = KO
    txt_dropped.Enabled = KO
    SSC_dropped.Visible = KO
    chk_Int.Enabled = KO
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_ID = ""
        Txt_name = ""
        Txt_adr1 = ""
        Txt_adr2 = ""
        Txt_adr3 = ""
        Txt_zcode = ""
        Txt_town = ""
        Cbo_country.ListIndex = -1
        Cbo_currenc.ListIndex = -1
        Set cbo_PurchManager.SelectedItem = Nothing
        Txt_phone = ""
        Txt_fax = ""
        Txt_info = ""
        txt_code.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

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
Call cbo_PurchManager.Unload_A_Com
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 ls_Field2 As String
Dim ls_U_code As String
Dim ls_PurchManager As String
Dim li_Count As Integer

On Error GoTo suite
 
ls_req = "EXEC Plants_dtl2 '" & QuoteParam(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_code = gs_TableCode
        Txt_name = ODBCData(ll_Statement, 1)
        Txt_adr1 = ODBCData(ll_Statement, 2)
        Txt_adr2 = ODBCData(ll_Statement, 3)
        Txt_adr3 = ODBCData(ll_Statement, 4)
        Txt_town = ODBCData(ll_Statement, 5)
        Txt_zcode = ODBCData(ll_Statement, 6)
        ls_Field = ODBCData(ll_Statement, 7)
        ls_Field2 = ODBCData(ll_Statement, 8)
        Txt_phone = ODBCData(ll_Statement, 9)
        Txt_fax = ODBCData(ll_Statement, 10)
        Txt_info = ODBCData(ll_Statement, 11)
        txt_ID = ODBCData(ll_Statement, 12)
        If ODBCData(ll_Statement, 13) = "X" Then
            chk_Int.value = 1
        End If
        txt_dropped = ODBCData(ll_Statement, 14)
        mi_concurrency = ODBCData(ll_Statement, 15)
        
        ls_U_code = ODBCData(ll_Statement, 16)
        ls_PurchManager = ODBCData(ll_Statement, 17)
        
        Cbo_country.ListIndex = ComboFindItem(cbo_CountryCode, ls_Field)
        Cbo_currenc.ListIndex = ComboFindItem(cbo_CurrencyCode, ls_Field2)
        
        If ls_U_code <> "" Then
            Call cbo_PurchManager.AddItem(Array(CStr(ls_U_code), ls_PurchManager), True)
        End If
  
    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_DropFlag As String
Dim ls_DropDate As String
Dim ls_PurchasingManagerCode As String

If cbo_PurchManager.SelectedItem Is Nothing Then
    ls_PurchasingManagerCode = "NULL"
Else
    ls_PurchasingManagerCode = cbo_PurchManager.SelectedItem.Key
    If ls_PurchasingManagerCode = "" Then
        ls_PurchasingManagerCode = "NULL"
    End If
End If

Upd_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 Plants_upd '" _
        & QuoteParam(UCase(txt_code)) & "', '" _
        & QuoteParam(Txt_name) & "', '" & QuoteParam(Txt_adr1) & "', '" & QuoteParam(Txt_adr2) & "', '" & QuoteParam(Txt_adr3) & "', '" _
        & QuoteParam(Txt_town) & "', '" & QuoteParam(Txt_zcode) & "', '" & QuoteParam(cbo_CountryCode.List(Cbo_country.ListIndex)) & "', '" _
        & QuoteParam(cbo_CurrencyCode.List(Cbo_currenc.ListIndex)) & "', " & ls_PurchasingManagerCode & ", '" & QuoteParam(Txt_phone) & "', '" & QuoteParam(Txt_fax) & "', '" _
        & QuoteParam(Txt_info) & "', '" & QuoteParam(txt_ID) & "', " & mi_concurrency & ",'" _
        & 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 = UCase(txt_code) & Chr(9) & Txt_name & Chr(9) & Txt_town & Chr(9) & Txt_zcode & Chr(9) & Txt_adr1 & Chr(9) _
            & txt_ID & 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
Dim ls_PurchasingManagerCode As String

If cbo_PurchManager.SelectedItem Is Nothing Then
    ls_PurchasingManagerCode = "NULL"
Else
    ls_PurchasingManagerCode = cbo_PurchManager.SelectedItem.Key
    If ls_PurchasingManagerCode = "" Then
        ls_PurchasingManagerCode = "NULL"
    End If
End If

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 Plants_ins '" _
        & QuoteParam(UCase(txt_code)) & "', '" _
        & QuoteParam(Txt_name) & "', '" & QuoteParam(Txt_adr1) & "', '" & QuoteParam(Txt_adr2) & "', '" & QuoteParam(Txt_adr3) & "', '" _
        & QuoteParam(Txt_town) & "', '" & QuoteParam(Txt_zcode) & "', '" & QuoteParam(cbo_CountryCode.List(Cbo_country.ListIndex)) & "', '" _
        & QuoteParam(cbo_CurrencyCode.List(Cbo_currenc.ListIndex)) & "', " & ls_PurchasingManagerCode & ", '" & QuoteParam(Txt_phone) & "', '" & QuoteParam(Txt_fax) & "', '" _
        & QuoteParam(Txt_info) & "', '" & QuoteParam(txt_ID) & "', '" _
        & 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
            C_main.FillGrid
        Else
            Add_Table = OK
            ls_Line = UCase(txt_code) & Chr(9) & Txt_name & Chr(9) & Txt_town & Chr(9) & Txt_zcode & Chr(9) & Txt_adr1 & Chr(9) _
            & txt_ID & 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
        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 ") = vbNo Then
    MouseOff
    Exit Function
End If
MouseOff
ls_req = "EXEC Plants_del '" & QuoteParam(txt_code) & "', " & 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
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_Plants_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_Plants, '" & 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_code": Lbl_code.Caption = ls_Text
            Case "lbl_name": Lbl_name = ls_Text
            Case "lbl_adr1": Lbl_adr1 = ls_Text
            Case "lbl_town": Lbl_town = ls_Text
            Case "lbl_zip_code": Lbl_zip_code = ls_Text
            Case "lbl_code_country": Lbl_code_country = ls_Text
            Case "lbl_curr": Lbl_curr = ls_Text
            Case "lbl_phone": Lbl_phone.Caption = ls_Text
            Case "lbl_fax": Lbl_fax = ls_Text
            Case "lbl_info": Lbl_info = ls_Text
            Case "lbl_ID": lbl_ID = ls_Text
            Case "lbl_int": lbl_Int = ls_Text
            Case "lbl_drop": lbl_Drop = ls_Text
            Case "lbl_purch_manager": Lbl_purch_manager = 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 = "" Then
    txt_code.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If txt_ID = "" Or txt_ID < "01" Or txt_ID > "99" Then
    txt_ID.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 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
If Txt_adr1 = "" Then
    Txt_adr1.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Txt_town = "" Then
    Txt_town.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Txt_zcode = "" Then
    Txt_zcode.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Cbo_country = "" Then
    Cbo_country.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Cbo_currenc = "" Then
    Cbo_currenc.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If Txt_phone = "" Then
    Txt_phone.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
Control = OK

End Function

