VERSION 5.00
Begin VB.Form BaseItem_search 
   Caption         =   "Form1"
   ClientHeight    =   1425
   ClientLeft      =   2100
   ClientTop       =   2895
   ClientWidth     =   5490
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   1425
   ScaleWidth      =   5490
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmd_cancel 
      Caption         =   "Cancel"
      Height          =   372
      Left            =   4080
      TabIndex        =   3
      Top             =   840
      Width           =   1212
   End
   Begin VB.CommandButton cmd_next 
      Caption         =   "Find Next"
      Default         =   -1  'True
      Height          =   372
      Left            =   4080
      TabIndex        =   2
      Top             =   360
      Width           =   1212
   End
   Begin VB.TextBox txt_item 
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1320
      TabIndex        =   1
      Top             =   600
      Width           =   2532
   End
   Begin VB.Label lbl_item 
      Caption         =   "Label1"
      Height          =   252
      Left            =   120
      TabIndex        =   0
      Top             =   600
      Width           =   1212
   End
End
Attribute VB_Name = "BaseItem_search"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub GetConstants()
Dim ls_Field As String
Dim ls_Text As String
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer

    On Error GoTo GetConstants_Err
    
    Select Case gs_TableName
    Case "Base_Item"
        ls_Req = "EXEC Screen_Csts 'bi_search', '" _
            & gut_LangLogin.Code & "'"
'    Case "Claim"
'        ls_Req = "EXEC Screen_Csts 'claim_fnd', '" _
'            & gut_LangLogin.Code & "'"
    Case "Quotation"
        ls_Req = "EXEC Screen_Csts 'Quot_Search', '" _
            & gut_LangLogin.Code & "'"
    Case "TestManager"
        ls_Req = "EXEC Screen_Csts 'Test_Search', '" _
            & gut_LangLogin.Code & "'"
    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 = ODBCData(ll_Statement, 2)
            Select Case ls_Field
            Case "title": Caption = ls_Text
            Case "item": lbl_Item.Caption = ls_Text
            Case "Next": cmd_next.Caption = ls_Text
            Case "cancel": cmd_cancel.Caption = ls_Text
            End Select
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
    
GetConstants_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub

Private Sub cmd_Cancel_Click()
    MouseOff
    gs_Path = ""
    Unload Me
    MouseOn
End Sub

Private Sub cmd_next_Click()
    MouseOff
    If txt_Item <> "" Then
        If GetData Then
            Unload Me
        End If
    End If
    MouseOn
End Sub

Private Sub Form_Load()
    MouseOff
    
    If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharSet Me

    GetConstants
    MouseOn
End Sub

Private Function GetData() As Boolean
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_PO As String

    GetData = KO
    gs_Path = ""
    
    On Error GoTo GetData_Err
    
    Select Case gs_TableName
    Case "Base_Item"
'        ls_req = "EXEC Item_Code_Search '" & QuoteParam(txt_Item) & "', '" _
'            & 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
'                gs_Path = ODBCData(ll_Statement, 1) & "\"
'                gs_Path = gs_Path & ODBCData(ll_Statement, 2) & "\"
'                gs_Path = gs_Path & ODBCData(ll_Statement, 3) & "\"
'                gs_Path = gs_Path & ODBCData(ll_Statement, 4) & "\"
'                gs_Path = gs_Path & ODBCData(ll_Statement, 5)
'                GetData = OK
'            Else
'                SendMessage 93, "Item code does not exist !",gut_LangLogin.Code
'            End If
'        Else
'            SendMessage 93, "Item code does not exist !",gut_LangLogin.Code
'        End If
'        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        ls_Req = "EXEC Base_Item_t_sel '" _
            & txt_Item.Text & "','" _
            & gut_LangLogin.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
                gs_Path = ODBCData(ll_Statement, 1)
                gs_Path = txt_Item.Text
                GetData = OK
            Else
                SendMessage 93, "Item code does not exist !", gut_LangLogin.Code
            End If
        Else
            SendMessage 93, "Item code does not exist !", gut_LangLogin.Code
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
'    Case "Claim"
        
'        If Claims_dsp.opt_Plant = OK Then
'            ls_PO = "P"
'        Else
'            ls_PO = "O"
'        End If
'        ls_Req = "EXEC Claim_fnd '" & ls_PO & "', '" & QuoteParam(txt_Item) & "'"
'        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
'                gs_Path = ODBCData(ll_Statement, 1) & "\"
'                gs_Path = gs_Path & ODBCData(ll_Statement, 2) & "\"
'                gs_Path = gs_Path & ODBCData(ll_Statement, 3) & "\"
'                gs_Path = gs_Path & Trim(UCase(txt_Item))
'                GetData = OK
'            Else
'                SendMessage 96, "Claim does not exist !", gut_LangLogin.Code
'            End If
'        Else
'            SendMessage 96, "Claim does not exist !", gut_LangLogin.Code
'        End If
'        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Case "Quotation"
        ls_Req = "EXEC Quotation_sel5 '" & QuoteParam(txt_Item) & "'"
        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
                gs_Path = ODBCData(ll_Statement, 1)
                GetData = OK
            Else
                SendMessage 93, "Item code does not exist !", gut_LangLogin.Code
            End If
        Else
            SendMessage 93, "Item code does not exist !", gut_LangLogin.Code
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Case "TestManager"
        ls_Req = "EXEC Test_sel '" & QuoteParam(txt_Item) & "'"
        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
              gs_Path = ODBCData(ll_Statement, 1)
              GetData = OK
           Else
              SendMessage 93, "Item code does not exist !", gut_LangLogin.Code
           End If
        Else
           SendMessage 93, "Item code does not exist !", gut_LangLogin.Code
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End Select
    Exit Function
    
GetData_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Function
