VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFlxGrd.ocx"
Begin VB.Form Item_sel 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   6810
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9525
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6810
   ScaleWidth      =   9525
   ShowInTaskbar   =   0   'False
   Begin MSFlexGridLib.MSFlexGrid grid 
      Height          =   795
      Left            =   3720
      TabIndex        =   58
      Top             =   2940
      Visible         =   0   'False
      Width           =   2235
      _ExtentX        =   3942
      _ExtentY        =   1402
      _Version        =   393216
      Cols            =   14
   End
   Begin MSFlexGridLib.MSFlexGrid GridVisible 
      Height          =   3135
      Left            =   0
      TabIndex        =   57
      Top             =   3180
      Width           =   9555
      _ExtentX        =   16854
      _ExtentY        =   5530
      _Version        =   393216
      Cols            =   14
      FixedCols       =   0
      SelectionMode   =   1
      AllowUserResizing=   1
   End
   Begin VB.TextBox ssp_code 
      Alignment       =   2  'Center
      BackColor       =   &H0080FFFF&
      Height          =   300
      Left            =   1560
      TabIndex        =   56
      Top             =   6360
      Width           =   765
   End
   Begin VB.TextBox Txt_Short 
      Height          =   285
      Left            =   7620
      TabIndex        =   55
      Top             =   1440
      Width           =   1815
   End
   Begin VB.TextBox txt_ShortCode 
      BackColor       =   &H00C0C0C0&
      Height          =   288
      Left            =   7320
      Locked          =   -1  'True
      TabIndex        =   54
      Top             =   1140
      Visible         =   0   'False
      Width           =   1680
   End
   Begin VB.PictureBox pic_next25 
      AutoSize        =   -1  'True
      Height          =   408
      Left            =   2520
      ScaleHeight     =   345
      ScaleWidth      =   345
      TabIndex        =   52
      Top             =   6300
      Visible         =   0   'False
      Width           =   408
   End
   Begin VB.ComboBox cbo_DimensionCode 
      Height          =   300
      Left            =   9000
      Style           =   2  'Dropdown List
      TabIndex        =   47
      Top             =   2820
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_ShapeCode 
      Height          =   300
      Left            =   9000
      Style           =   2  'Dropdown List
      TabIndex        =   46
      Top             =   2460
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_GroupCode 
      Height          =   300
      Left            =   8940
      Style           =   2  'Dropdown List
      TabIndex        =   45
      Top             =   1740
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_SurfaceCode 
      Height          =   300
      Left            =   8940
      Style           =   2  'Dropdown List
      TabIndex        =   44
      Top             =   2100
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_Dimension 
      Enabled         =   0   'False
      Height          =   300
      Left            =   7680
      Style           =   2  'Dropdown List
      TabIndex        =   43
      Top             =   2820
      Visible         =   0   'False
      Width           =   1815
   End
   Begin VB.ComboBox cbo_Shape 
      Enabled         =   0   'False
      Height          =   300
      Left            =   7680
      Style           =   2  'Dropdown List
      TabIndex        =   42
      Top             =   2460
      Width           =   1815
   End
   Begin VB.ComboBox cbo_Group 
      Enabled         =   0   'False
      Height          =   300
      Left            =   7680
      Style           =   2  'Dropdown List
      TabIndex        =   41
      Top             =   1740
      Width           =   1815
   End
   Begin VB.ComboBox cbo_Surface 
      Enabled         =   0   'False
      Height          =   300
      Left            =   7680
      Style           =   2  'Dropdown List
      TabIndex        =   40
      Top             =   2100
      Width           =   1815
   End
   Begin VB.ComboBox cbo_PsegmCode 
      Height          =   300
      Left            =   5700
      Style           =   2  'Dropdown List
      TabIndex        =   39
      Top             =   2460
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_PatternCode 
      Height          =   300
      Left            =   5700
      Style           =   2  'Dropdown List
      TabIndex        =   38
      Top             =   2100
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_ColourCode 
      Height          =   300
      Left            =   5700
      Style           =   2  'Dropdown List
      TabIndex        =   37
      Top             =   1740
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_Psegm 
      Enabled         =   0   'False
      Height          =   300
      Left            =   4440
      Style           =   2  'Dropdown List
      TabIndex        =   36
      Top             =   2460
      Width           =   1815
   End
   Begin VB.ComboBox cbo_Pattern 
      Enabled         =   0   'False
      Height          =   300
      Left            =   4440
      Style           =   2  'Dropdown List
      TabIndex        =   35
      Top             =   2100
      Width           =   1815
   End
   Begin VB.ComboBox cbo_Colour 
      Enabled         =   0   'False
      Height          =   300
      Left            =   4440
      Style           =   2  'Dropdown List
      TabIndex        =   34
      Top             =   1740
      Width           =   1815
   End
   Begin VB.Frame Frm_dropped 
      Height          =   1095
      Left            =   4260
      TabIndex        =   27
      Top             =   600
      Width           =   1875
      Begin VB.OptionButton Option1 
         Caption         =   "All"
         Height          =   255
         Index           =   0
         Left            =   60
         TabIndex        =   30
         Top             =   180
         Value           =   -1  'True
         Width           =   1635
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Dropped"
         Height          =   255
         Index           =   1
         Left            =   60
         TabIndex        =   29
         Top             =   480
         Width           =   1635
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Non dropped"
         Height          =   255
         Index           =   2
         Left            =   60
         TabIndex        =   28
         Top             =   780
         Width           =   1635
      End
   End
   Begin VB.Frame Frm_special 
      Height          =   1095
      Left            =   2340
      TabIndex        =   23
      Top             =   600
      Width           =   1875
      Begin VB.OptionButton Option3 
         Caption         =   "All"
         Height          =   255
         Index           =   0
         Left            =   60
         TabIndex        =   26
         Top             =   180
         Value           =   -1  'True
         Width           =   1635
      End
      Begin VB.OptionButton Option3 
         Caption         =   "Standard"
         Height          =   255
         Index           =   1
         Left            =   60
         TabIndex        =   25
         Top             =   480
         Width           =   1635
      End
      Begin VB.OptionButton Option3 
         Caption         =   "Special"
         Height          =   255
         Index           =   2
         Left            =   60
         TabIndex        =   24
         Top             =   780
         Width           =   1635
      End
   End
   Begin VB.Frame frm_code_level 
      Height          =   795
      Left            =   60
      TabIndex        =   20
      Top             =   600
      Visible         =   0   'False
      Width           =   2235
      Begin VB.OptionButton Opt_Code_Level 
         Caption         =   "Marketing code level"
         Height          =   255
         Index           =   1
         Left            =   60
         TabIndex        =   22
         Top             =   480
         Width           =   1995
      End
      Begin VB.OptionButton Opt_Code_Level 
         Caption         =   "SAP code level"
         Height          =   255
         Index           =   0
         Left            =   60
         TabIndex        =   21
         Top             =   180
         Value           =   -1  'True
         Width           =   1995
      End
   End
   Begin VB.ComboBox cbo_plant2 
      Enabled         =   0   'False
      ForeColor       =   &H00FF0000&
      Height          =   300
      ItemData        =   "GETITEM.frx":0000
      Left            =   8760
      List            =   "GETITEM.frx":0002
      Style           =   2  'Dropdown List
      TabIndex        =   17
      Top             =   6420
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_Plant 
      Enabled         =   0   'False
      ForeColor       =   &H00000000&
      Height          =   300
      ItemData        =   "GETITEM.frx":0004
      Left            =   7620
      List            =   "GETITEM.frx":0006
      Style           =   2  'Dropdown List
      TabIndex        =   18
      Top             =   6420
      Width           =   1800
   End
   Begin VB.ComboBox cbo_FamilyCode 
      Enabled         =   0   'False
      ForeColor       =   &H00FF0000&
      Height          =   300
      ItemData        =   "GETITEM.frx":0008
      Left            =   2520
      List            =   "GETITEM.frx":000A
      Style           =   2  'Dropdown List
      TabIndex        =   16
      Top             =   2460
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_BasematCode 
      Enabled         =   0   'False
      ForeColor       =   &H00FF0000&
      Height          =   300
      ItemData        =   "GETITEM.frx":000C
      Left            =   2520
      List            =   "GETITEM.frx":000E
      Style           =   2  'Dropdown List
      TabIndex        =   15
      Top             =   2100
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_CategoryCode 
      ForeColor       =   &H00FF0000&
      Height          =   300
      ItemData        =   "GETITEM.frx":0010
      Left            =   2520
      List            =   "GETITEM.frx":0012
      Style           =   2  'Dropdown List
      TabIndex        =   14
      Top             =   1740
      Visible         =   0   'False
      Width           =   390
   End
   Begin VB.ComboBox cbo_Category 
      ForeColor       =   &H00000000&
      Height          =   300
      ItemData        =   "GETITEM.frx":0014
      Left            =   1260
      List            =   "GETITEM.frx":0016
      Style           =   2  'Dropdown List
      TabIndex        =   13
      Top             =   1740
      Width           =   1815
   End
   Begin VB.PictureBox pic_pic 
      BackColor       =   &H00FFFFFF&
      Height          =   540
      Left            =   -60
      ScaleHeight     =   480
      ScaleWidth      =   9510
      TabIndex        =   8
      Top             =   0
      Width           =   9570
      Begin VB.PictureBox pic_search 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "GETITEM.frx":0018
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   1080
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   12
         Top             =   0
         Width           =   384
      End
      Begin VB.PictureBox pic_Save 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "GETITEM.frx":0322
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   60
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   11
         Top             =   0
         Width           =   384
      End
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "GETITEM.frx":062C
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   1740
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   10
         Top             =   30
         Width           =   384
      End
      Begin VB.PictureBox pic_UnDo 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   600
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   9
         Top             =   0
         Width           =   384
      End
   End
   Begin VB.TextBox txt_SAP 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   7320
      Locked          =   -1  'True
      MaxLength       =   40
      TabIndex        =   7
      Top             =   780
      Width           =   1680
   End
   Begin VB.TextBox txt_Like 
      BackColor       =   &H00FFFFFF&
      ForeColor       =   &H00000000&
      Height          =   285
      Left            =   7620
      TabIndex        =   0
      Top             =   1260
      Width           =   1815
   End
   Begin VB.ComboBox cbo_Family 
      Enabled         =   0   'False
      ForeColor       =   &H00000000&
      Height          =   300
      ItemData        =   "GETITEM.frx":0936
      Left            =   1260
      List            =   "GETITEM.frx":0938
      Style           =   2  'Dropdown List
      TabIndex        =   4
      Top             =   2460
      Width           =   1815
   End
   Begin VB.ComboBox cbo_Basemat 
      Enabled         =   0   'False
      ForeColor       =   &H00000000&
      Height          =   300
      ItemData        =   "GETITEM.frx":093A
      Left            =   1260
      List            =   "GETITEM.frx":093C
      Style           =   2  'Dropdown List
      TabIndex        =   2
      Top             =   2100
      Width           =   1815
   End
   Begin VB.Label lbl_rcd 
      Caption         =   "Nb of rows:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   60
      TabIndex        =   53
      Top             =   6360
      Width           =   1485
   End
   Begin VB.Label lbl_Dimension 
      Caption         =   "Dimension"
      Enabled         =   0   'False
      Height          =   255
      Left            =   6360
      TabIndex        =   51
      Top             =   2820
      Visible         =   0   'False
      Width           =   1395
   End
   Begin VB.Label lbl_Shape 
      Caption         =   "Shape"
      Enabled         =   0   'False
      Height          =   255
      Left            =   6360
      TabIndex        =   50
      Top             =   2460
      Width           =   1335
   End
   Begin VB.Label lbl_Group 
      Caption         =   "Group/edge detail"
      Enabled         =   0   'False
      Height          =   255
      Left            =   6360
      TabIndex        =   49
      Top             =   1740
      Width           =   1335
   End
   Begin VB.Label lbl_Surface 
      Caption         =   "Surface"
      Enabled         =   0   'False
      Height          =   255
      Left            =   6360
      TabIndex        =   48
      Top             =   2100
      Width           =   1335
   End
   Begin VB.Label lbl_psegm 
      Caption         =   "Product range"
      Enabled         =   0   'False
      Height          =   255
      Left            =   3120
      TabIndex        =   33
      Top             =   2460
      Width           =   1335
   End
   Begin VB.Label lbl_Pattern 
      Caption         =   "Pattern"
      Enabled         =   0   'False
      Height          =   255
      Left            =   3120
      TabIndex        =   32
      Top             =   2100
      Width           =   1335
   End
   Begin VB.Label lbl_Colour 
      Caption         =   "Colour"
      Enabled         =   0   'False
      Height          =   255
      Left            =   3120
      TabIndex        =   31
      Top             =   1740
      Width           =   1335
   End
   Begin VB.Label lbl_Plant 
      Caption         =   "Default Plant/Supplier"
      Enabled         =   0   'False
      Height          =   255
      Left            =   5880
      TabIndex        =   19
      Top             =   6480
      Width           =   1710
   End
   Begin VB.Label lbl_Like 
      Caption         =   "SAP like"
      Height          =   255
      Left            =   6360
      TabIndex        =   6
      Top             =   1320
      Width           =   1350
   End
   Begin VB.Label lbl_Family 
      Caption         =   "Family"
      Enabled         =   0   'False
      Height          =   255
      Left            =   60
      TabIndex        =   5
      Top             =   2460
      Width           =   1350
   End
   Begin VB.Label lbl_BaseMat 
      Caption         =   "Base material"
      Enabled         =   0   'False
      Height          =   255
      Left            =   60
      TabIndex        =   3
      Top             =   2100
      Width           =   1350
   End
   Begin VB.Label lbl_Category 
      Caption         =   "Category"
      Height          =   255
      Left            =   60
      TabIndex        =   1
      Top             =   1740
      Width           =   1350
   End
End
Attribute VB_Name = "Item_sel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'--------------------------------------------------
' BASEITEM_SPECIAL
' That form display a list of special products
'--------------------------------------------------
' Created Sept/15/99 by JC
'--------------------------------------------------
' Params: ms_TypeCodeReturn    Type of code to return: 0=SAP  1=Marketting 2=none
' Return gs_photo                        Code
'--------------------------------------------------

Option Explicit

Public ms_TypeCodeReturn As String           ' Type of code to return 0=SAP  1=Marketting 2=none

Dim ml_ResultIndex As Long  ' Number of row in the grid

Dim ml_Hstmt As Long       ' Statement for queries
Dim mi_Status As Integer     ' Status of the queries
Dim mo_Fetch As Fetch      ' Fetch object

Dim mi_CodeLevel As Integer          ' Code level
Dim ms_TypeCode As String           ' Type
Dim ms_DropCode As String           ' Drop
Dim ms_CategoryCode As String       ' Category
Dim ms_BasematCode As String        ' Base material
Dim ms_FamilyCode As String         ' Family
Dim ms_ColourCode As String         ' Colour
Dim ms_PatternCode As String        ' Pattern
Dim ms_PsegmCode As String          ' Product range
Dim ms_GroupCode As String          ' Group/edge detail
Dim ms_SurfaceCode As String        ' Surface
Dim ms_ShapeCode As String          ' Shape
Dim ms_DimensionCode As String     ' Dimension

Dim lbl_SAPCode As String               ' Label for SAP code
Dim lbl_ShortCode As String            ' Label for marketting code
Dim lbl_Edge As String                      'Label for edge detail
Dim lbl_pgroup As String                ' Label for product group

Dim mb_CalledFromSPA As Boolean         ' special behaviour when called from SPA

Dim mi_gridwidth(13) As Integer      ' Default size from grids

Dim Changed As Integer                  ' Num of last changed combo

Public Property Let CalledFromSPA(ByVal ab_CalledFromSPA As Boolean)
       
    mb_CalledFromSPA = ab_CalledFromSPA
    Exit Property
End Property

Private Sub ClearAll()
' Clear all the combo and set them disabled
ClearFamily
ClearColour
ClearPattern
ClearPSegm
ClearGroup
ClearSurface
ClearShape
ClearDimension
End Sub

Private Sub ClearBasemat()
' Clear the combo and set it disabled
    cbo_Basemat.Clear
    cbo_BasematCode.Clear
    cbo_Basemat.Enabled = KO
    lbl_BaseMat.Enabled = KO
    ms_BasematCode = ""
    ClearAll
End Sub

Private Sub ClearColour()
' Clear the combo and set it disabled
      cbo_Colour.Clear
    cbo_ColourCode.Clear
    cbo_Colour.Enabled = KO
    lbl_Colour.Enabled = KO
    ms_ColourCode = ""
End Sub

Private Sub ClearPlant()
' Clear the combo and set it disabled
     cbo_Plant.Clear
   cbo_plant2.Clear
    cbo_Plant.Enabled = KO
    lbl_Plant.Enabled = KO
End Sub

Private Sub ClearPattern()
' Clear the combo and set it disabled
     cbo_Pattern.Clear
    cbo_PatternCode.Clear
    cbo_Pattern.Enabled = KO
    lbl_Pattern.Enabled = KO
    ms_PatternCode = ""
End Sub

Private Sub ClearPSegm()
' Clear the combo and set it disabled
      cbo_Psegm.Clear
    cbo_PsegmCode.Clear
    cbo_Psegm.Enabled = KO
    lbl_psegm.Enabled = KO
    ms_PsegmCode = ""
End Sub
  
Private Sub ClearGroup()
' Clear the combo and set it disabled
    cbo_Group.Clear
    cbo_GroupCode.Clear
    cbo_Group.Enabled = KO
    Lbl_group.Enabled = KO
    ms_GroupCode = ""
End Sub
Private Sub ClearSurface()
' Clear the combo and set it disabled
    cbo_surface.Clear
    cbo_SurfaceCode.Clear
    cbo_surface.Enabled = KO
    lbl_Surface.Enabled = KO
    ms_SurfaceCode = ""
End Sub
Private Sub ClearShape()
' Clear the combo and set it disabled
    cbo_Shape.Clear
    cbo_ShapeCode.Clear
    cbo_Shape.Enabled = KO
    lbl_Shape.Enabled = KO
    ms_ShapeCode = ""
End Sub

Private Sub ClearDimension()
' Clear the combo and set it disabled
    cbo_Dimension.Clear
    cbo_DimensionCode.Clear
    cbo_Dimension.Enabled = KO
    lbl_Dimension.Enabled = KO
    ms_DimensionCode = ""
End Sub

Private Sub ClearFamily()
' Clear the combo and set it disabled
    cbo_family.Clear
    cbo_FamilyCode.Clear
    cbo_family.Enabled = KO
    lbl_Family.Enabled = KO
    ms_FamilyCode = ""
End Sub

Private Sub ClearGrid()

' Clear all the record of the grid
Grid.AddItem ""             ' Add an empty row
While Grid.Rows > 2      ' Remove all
    Grid.RemoveItem (1)
Wend
Gridvisible.AddItem ""             ' Add an empty row
While Gridvisible.Rows > 2      ' Remove all
    Gridvisible.RemoveItem (1)
Wend

Gridvisible.Row = 0
Gridvisible.HighLight = flexHighlightNever

pic_next25.Visible = KO
' Clear the other fields
txt_SAP = ""
txt_shortcode = ""
ssp_code = ""
ClearPlant
Set mo_Fetch = Nothing
Set mo_Fetch = New Fetch
mo_Fetch.EnvironmentIdentifier = gl_Environment
mo_Fetch.DatabaseIdentifier = gl_Database
End Sub

Private Sub FillGridVisible()
' copy the values from the hidden grid into the visible grid
Dim li_Count As Integer
Dim li_Count2 As Integer
Dim li_NbRowsPrev As Integer

li_NbRowsPrev = Gridvisible.Rows
If li_NbRowsPrev = 2 Then li_NbRowsPrev = 1

Gridvisible.Col = 0
Gridvisible.Rows = Grid.Rows

For li_Count = 0 To 13
    If Grid.ColWidth(li_Count) > 1 Then
        'Gridvisible.Cols = Gridvisible.Cols + 1   ' Add a column
        Gridvisible.Col = Gridvisible.Col + 1
        'Gridvisible.ColWidth(Gridvisible.col) = mi_gridwidth(li_Count) ' Resize the new column
        Grid.Col = li_Count
        Grid.Row = 0
        Gridvisible.Row = 0
        Gridvisible.Text = Grid.Text   ' Copy the values
        
        For li_Count2 = li_NbRowsPrev To Grid.Rows - 1  'For each row
            Gridvisible.Row = li_Count2
            Grid.Row = li_Count2
            Grid.Col = li_Count
            Gridvisible.Text = Grid.Text   ' Copy the values
        Next li_Count2
End If
Next li_Count
Gridvisible.ColWidth(0) = 1
End Sub


Private Sub FillGrid() ' Fill the grid with the item found
Dim li_Count As Integer
Dim ls_req As String
On Error GoTo suite

'Show or hide the columns
Grid.ColWidth(2) = 1
For li_Count = 4 To 13
    Grid.ColWidth(li_Count) = 1
Next
If ms_TypeCode = "" Then Grid.ColWidth(2) = mi_gridwidth(2)
If ms_BasematCode = "" Then Grid.ColWidth(4) = mi_gridwidth(4)
If ms_FamilyCode = "" Then Grid.ColWidth(5) = mi_gridwidth(5)
If ms_ColourCode = "" Then Grid.ColWidth(6) = mi_gridwidth(6)
If ms_PatternCode = "" Then Grid.ColWidth(7) = mi_gridwidth(7)
If ms_PsegmCode = "" Then Grid.ColWidth(8) = mi_gridwidth(8)
If ms_GroupCode = "" Then Grid.ColWidth(9) = mi_gridwidth(9)
If ms_DropCode = "" Then Grid.ColWidth(13) = mi_gridwidth(13)
If ms_SurfaceCode = "" And (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006") Then Grid.ColWidth(10) = mi_gridwidth(10)
If ms_ShapeCode = "" And (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006") Then Grid.ColWidth(11) = mi_gridwidth(11)
If ms_DimensionCode = "" And (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006") And ms_TypeCode = "STD" Then Grid.ColWidth(12) = mi_gridwidth(12)

If mb_CalledFromSPA = False Then
ls_req = "Base_Item_lst2 " & mi_CodeLevel & ",'" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "','" & txt_like & "','" & Txt_Short & "'"
Else
    ls_req = "Base_Item_lst2 " & "0" & ",'" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                    ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                    ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                    ms_ShapeCode & "','" & ms_DimensionCode & "','" & txt_like & "','" & Txt_Short & "'"
End If

ml_ResultIndex = 0

Gridvisible.Cols = 1
Gridvisible.Rows = 2
For li_Count = 0 To 13
    If Grid.ColWidth(li_Count) > 1 Then
        Gridvisible.Cols = Gridvisible.Cols + 1   ' Add a column
        Gridvisible.Col = Gridvisible.Cols - 1
        Gridvisible.ColWidth(Gridvisible.Col) = Grid.ColWidth(li_Count) ' Resize the new column
    End If
Next li_Count
Gridvisible.ColWidth(0) = 1

'Execute the request to get the data
If mo_Fetch.ExecuteQry(ls_req, OK) Then
    mi_Status = SQL_SUCCESS
        'Request for the 25 first records
    pic_next25.Visible = Next25
Else
    mi_Status = SQL_ERROR
End If
Exit Sub
suite:
StdError
End Sub

Private Sub GetFamilies()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 2) Then
    cbo_family.Clear
    cbo_FamilyCode.Clear
    ls_req = "EXEC Products_Families_cbo4 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_FamilyCode, cbo_family
    Changed = 2
End If
Exit Sub
suite:
StdError
End Sub
Private Sub GetColour()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 3) Then
    cbo_Colour.Clear
    cbo_ColourCode.Clear
    ls_req = "EXEC colours_cbo3 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_ColourCode, cbo_Colour
    Changed = 3
End If
Exit Sub
suite:
StdError
End Sub
Private Sub GetPattern()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 4) Then
    cbo_Pattern.Clear
    cbo_PatternCode.Clear
    ls_req = "EXEC Products_Patterns_cbo3 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_PatternCode, cbo_Pattern
    Changed = 4
End If
Exit Sub
suite:
StdError
End Sub
Private Sub GetPsegm()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 5) Then
    cbo_Psegm.Clear
    cbo_PsegmCode.Clear
    ls_req = "EXEC Products_Segmentation_cbo3 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_PsegmCode, cbo_Psegm
    Changed = 5
End If
Exit Sub
suite:
StdError
End Sub


Private Sub GetGroup()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 6) Then
    cbo_Group.Clear
    cbo_GroupCode.Clear
    ls_req = "EXEC Products_Edges_cbo3 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_GroupCode, cbo_Group
    Changed = 6
End If
Exit Sub
suite:
StdError
End Sub

Private Sub GetSurface()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 7) Then
    cbo_surface.Clear
    cbo_SurfaceCode.Clear
    ls_req = "EXEC Surfaces_cbo3 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_SurfaceCode, cbo_surface
    Changed = 7
End If
Exit Sub
suite:
StdError
End Sub
Private Sub GetShape()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 8) Then
    cbo_Shape.Clear
    cbo_ShapeCode.Clear
    ls_req = "EXEC Shapes_cbo2 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_ShapeCode, cbo_Shape
    Changed = 8
End If
Exit Sub
suite:
StdError
End Sub

Private Sub GetDimension()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
If (Changed <> 9) Then
    cbo_Dimension.Clear
    cbo_DimensionCode.Clear
    ls_req = "EXEC Product_Dimension_cbo4 '" & gut_LangWork.Code & "','" & ms_TypeCode & "','" & ms_DropCode & "','" & _
                ms_CategoryCode & "','" & ms_BasematCode & "','" & ms_FamilyCode & "','" & ms_ColourCode & "','" & _
                ms_PatternCode & "','" & ms_PsegmCode & "','" & ms_GroupCode & "','" & ms_SurfaceCode & "','" & _
                ms_ShapeCode & "','" & ms_DimensionCode & "'"
    FillCbo ls_req, cbo_DimensionCode, cbo_Dimension
    Changed = 9
End If
Exit Sub
suite:
StdError
End Sub
Private Sub GetBasemat()
'Fill the combo with new values
Dim ls_req As String
On Error GoTo suite
    ls_req = "EXEC Base_Material_Link_cbo '" _
        & cbo_CategoryCode.List(cbo_Category.ListIndex) & "','" _
        & gut_LangLogin.Code & "'"
    FillCbo ls_req, cbo_BasematCode, cbo_Basemat
Exit Sub
suite:
StdError
End Sub
Private Sub GetPlant()
Dim ls_req As String

On Error GoTo suite

If gs_TableName <> "Test_Link_Products" Then Exit Sub
lbl_Plant.Enabled = KO
cbo_Plant.Enabled = KO
cbo_Plant.Clear
cbo_plant2.Clear
If txt_SAP <> "" Then
    ls_req = "EXEC Plants_cbo4 '" _
        & txt_SAP & "', '" & gut_LangWork.Code & "'"
    FillCbo ls_req, cbo_plant2, cbo_Plant
End If
Exit Sub

suite:
StdError
End Sub

Private Sub cbo_basemat_Click()
' A base material is chosen
ms_BasematCode = cbo_BasematCode.List(cbo_Basemat.ListIndex)    ' New code
MouseOff
 ' Clear all combos fields and grid
txt_SAP = ""
ClearAll
ClearGrid
Changed = 1
 ' Set all the combos enabled
cbo_family.Enabled = OK
lbl_Family.Enabled = OK
cbo_Colour.Enabled = OK
lbl_Colour.Enabled = OK
cbo_Pattern.Enabled = OK
lbl_Pattern.Enabled = OK
cbo_Psegm.Enabled = OK
lbl_psegm.Enabled = OK
cbo_Group.Enabled = OK
Lbl_group.Enabled = OK
cbo_surface.Enabled = OK
lbl_Surface.Enabled = OK
cbo_Shape.Enabled = OK
lbl_Shape.Enabled = OK
cbo_Dimension.Enabled = OK
lbl_Dimension.Enabled = OK
MouseOn
End Sub

Private Sub Cbo_category_Click()
' The category as change
MouseOff
ms_CategoryCode = cbo_CategoryCode.List(cbo_Category.ListIndex) ' new value
ClearBasemat    ' Clear and disabled all the combos
ClearGrid           ' Clear the grid
cbo_Basemat.Enabled = OK
lbl_BaseMat.Enabled = OK
' Show some combo for "ceilings" and "walls"
lbl_Surface.Visible = (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006")
cbo_surface.Visible = (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006")
lbl_Shape.Visible = (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006")
cbo_Shape.Visible = (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006")
If (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006") Then
    If ms_TypeCode = "STD" Then
        cbo_Dimension.Visible = OK
        lbl_Dimension.Visible = OK
    End If
    cbo_Dimension.Top = 2820:   lbl_Dimension.Top = 2820
    Lbl_group = lbl_Edge
    If cbo_Dimension.Visible Then
        Gridvisible.Top = 3180
        Gridvisible.Height = 3135
    Else
        Gridvisible.Top = 2820
        Gridvisible.Height = 3495
    End If
Else
    cbo_Dimension.Visible = KO
    lbl_Dimension.Visible = KO
    Lbl_group = lbl_pgroup
    Gridvisible.Top = 2820
    Gridvisible.Height = 3495
End If
Grid.Col = 8:    Grid.Row = 0:    Grid.Text = Lbl_group
MouseOn

End Sub



Private Sub cbo_colour_Click()
' The value change
MouseOff
txt_SAP = ""
ms_ColourCode = cbo_ColourCode.List(cbo_Colour.ListIndex) ' New value
MouseOn
End Sub

Private Sub cbo_Dimension_DropDown()
' Load the new values for the combo
MouseOff
GetDimension
ms_DimensionCode = ""
MouseOn
End Sub

Private Sub cbo_pattern_Click()
MouseOff
txt_SAP = ""
ms_PatternCode = cbo_PatternCode.List(cbo_Pattern.ListIndex)
MouseOn
End Sub

Private Sub cbo_psegm_Click()
MouseOff
txt_SAP = ""
ms_PsegmCode = cbo_PsegmCode.List(cbo_Psegm.ListIndex)
MouseOn
End Sub
Private Sub cbo_group_Click()
MouseOff
txt_SAP = ""
ms_GroupCode = cbo_GroupCode.List(cbo_Group.ListIndex)
MouseOn
End Sub




Private Sub cbo_shape_Click()
MouseOff
txt_SAP = ""
ms_ShapeCode = cbo_ShapeCode.List(cbo_Shape.ListIndex)
MouseOn
End Sub
Private Sub cbo_dimension_Click()
MouseOff
txt_SAP = ""
ms_DimensionCode = cbo_DimensionCode.List(cbo_Dimension.ListIndex)
MouseOn
End Sub
Private Sub cbo_colour_DropDown()
' Load the new values for the combo
MouseOff
ClearGrid
GetColour
ms_ColourCode = ""
MouseOn
End Sub


Private Sub cbo_pattern_DropDown()
' Load the new values for the combo
MouseOff
ClearGrid
GetPattern
ms_PatternCode = ""
MouseOn
End Sub
Private Sub cbo_psegm_DropDown()
' Load the new values for the combo
MouseOff
ClearGrid
GetPsegm
ms_PsegmCode = ""
MouseOn
End Sub
Private Sub cbo_group_DropDown()
' Load the new values for the combo
MouseOff
ClearGrid
GetGroup
ms_GroupCode = ""
MouseOn
End Sub
Private Sub cbo_shape_DropDown()
' Load the new values for the combo
MouseOff
ClearGrid
GetShape
ms_ShapeCode = ""
MouseOn
End Sub

Private Sub cbo_Surface_Click()
MouseOff
txt_SAP = ""
ms_SurfaceCode = cbo_SurfaceCode.List(cbo_surface.ListIndex)
MouseOn
End Sub

Private Sub cbo_surface_DropDown()
' Load the new values for the combo
MouseOff
ClearGrid
GetSurface
ms_SurfaceCode = ""
MouseOn
End Sub
Private Sub cbo_family_DropDown()
' Load the new values for the combo
MouseOff
ClearGrid
GetFamilies
ms_FamilyCode = ""
MouseOn
End Sub
Private Sub cbo_basemat_DropDown()
' Load the new values for the combo
If cbo_Basemat.ListCount > 0 Then Exit Sub
MouseOff
ClearGrid
GetBasemat
MouseOn
End Sub

Private Sub cbo_family_Click()
MouseOff
txt_SAP = ""
ms_FamilyCode = cbo_FamilyCode.List(cbo_family.ListIndex)
MouseOn
End Sub



Private Sub Form_Activate()

If ms_TypeCodeReturn = 0 Then
    mi_CodeLevel = 0
Else
    mi_CodeLevel = 1
End If
' show and place the radio buttons
' special and dropped
If ms_TypeCodeReturn = 2 Then
    frm_code_level.Visible = OK
    pic_Save.Visible = KO
    Frm_special.Left = 2340
    Frm_dropped.Left = 4260
ElseIf ms_TypeCodeReturn = 3 Then
    frm_code_level.Visible = OK
    Opt_Code_Level(0).Enabled = False
    
    Frm_special.Left = 2340
    Frm_dropped.Left = 4260
Else
    Frm_special.Left = 60
    Frm_dropped.Left = 2340
End If
' code level
Opt_Code_Level(mi_CodeLevel) = OK
txt_shortcode.Top = txt_SAP.Top

If mb_CalledFromSPA = False Then
Grid.ColWidth(0) = 1
Grid.ColWidth(1) = 1
Grid.ColWidth(mi_CodeLevel) = mi_gridwidth(mi_CodeLevel)
Else
    ' if called from SPA, show both codes
    Grid.ColWidth(0) = mi_gridwidth(0)
    Grid.ColWidth(1) = 900
End If

txt_SAP.Visible = (mi_CodeLevel = 0)
txt_shortcode.Visible = (mi_CodeLevel = 1)
txt_like.Visible = (mi_CodeLevel = 0)
Txt_Short.Visible = (mi_CodeLevel = 1)
If mi_CodeLevel = 0 Then lbl_Like = lbl_SAPCode
If mi_CodeLevel = 1 Then lbl_Like = lbl_ShortCode
End Sub

Private Sub Form_Load()

On Error GoTo suite

MouseOff

If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me

pic_Save.Picture = LoadResPicture(RES_OK, 1)
pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_search.Picture = LoadResPicture(RES_SEARCH, 1)
pic_Undo.Picture = LoadResPicture(RES_CANCEL, 1)
pic_next25.Picture = LoadResPicture(RES_DOWN, 1)

Set mo_Fetch = New Fetch
mo_Fetch.EnvironmentIdentifier = gl_Environment
mo_Fetch.DatabaseIdentifier = gl_Database

'Default values
ms_TypeCodeReturn = 0
ms_CategoryCode = gs_CGCode
ms_TypeCode = "STD"
ms_DropCode = "N"
mb_CalledFromSPA = False

GetCategories
FillCsts

' Use by module test
lbl_Plant.Visible = KO
cbo_Plant.Visible = KO
cbo_Plant.Enabled = KO
Grid.HighLight = flexHighlightNever

Select Case gs_TableName
Case "Test_Link_Products":
    lbl_Plant.Visible = OK
    cbo_Plant.Visible = OK
End Select

MouseOn
Exit Sub
   
suite:
StdError
End Sub

Private Sub FillCsts()

Dim ls_req As String, ls_Field As String, ls_Text As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Count As Integer
   
On Error GoTo suite
   
' Default size of the grid:
mi_gridwidth(0) = 1400  ' SAP code
mi_gridwidth(1) = 600  ' Marketing code
mi_gridwidth(2) = 430  ' Special
mi_gridwidth(3) = 2500  ' Description
mi_gridwidth(4) = 1500  ' Base material
mi_gridwidth(5) = 1200  ' Product Families
mi_gridwidth(6) = 700  ' Colour
mi_gridwidth(7) = 800  ' Pattern
mi_gridwidth(8) = 1100  ' Product segmentation
mi_gridwidth(9) = 900  ' Edge detail
mi_gridwidth(10) = 900  ' Surface
mi_gridwidth(11) = 1000 ' Shape
mi_gridwidth(12) = 1500 'Dimension
mi_gridwidth(13) = 370  ' Drop
' Set the columns visible or no
Grid.ColWidth(0) = 1            ' SAP code
Grid.ColWidth(1) = 1            ' Marketting code
Grid.ColWidth(2) = 1            ' special
Grid.ColWidth(12) = 1          ' Dimension
Grid.ColWidth(13) = 1           ' Drop
For li_Count = 3 To 11          ' All others visibles (default size)
    Grid.ColWidth(li_Count) = mi_gridwidth(li_Count)
Next li_Count


' Get the label from table screen constants
Grid.Row = 0
ls_req = "EXEC Screen_Csts 'ItemSearch', '" & 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 = ODBCData(ll_Statement, 2)
        Select Case ls_Field
        Case "title": Caption = ls_Text
        Case "lbl_rcd": lbl_Rcd = ls_Text
        Case "lbl_category": lbl_Category = ls_Text
        Case "lbl_baseMat": lbl_BaseMat = ls_Text:  Grid.Col = 4: Grid.Text = ls_Text
        Case "lbl_family": lbl_Family = ls_Text:       Grid.Col = 5: Grid.Text = ls_Text
        Case "lbl_colour": lbl_Colour = ls_Text:         Grid.Col = 6: Grid.Text = ls_Text
        Case "lbl_pattern": lbl_Pattern = ls_Text:      Grid.Col = 7: Grid.Text = ls_Text
        Case "lbl_psegm": lbl_psegm = ls_Text:         Grid.Col = 8: Grid.Text = ls_Text
        Case "lbl_edge": lbl_Edge = ls_Text:               Grid.Col = 9: Grid.Text = ls_Text
        Case "lbl_group": lbl_pgroup = ls_Text
        Case "lbl_surface": lbl_Surface = ls_Text:       Grid.Col = 10: Grid.Text = ls_Text
        Case "lbl_shape": lbl_Shape = ls_Text:           Grid.Col = 11: Grid.Text = ls_Text
        Case "lbl_dimension": lbl_Dimension = ls_Text: Grid.Col = 12: Grid.Text = ls_Text
        Case "lbl_SAP": lbl_SAPCode = ls_Text:          Grid.Col = 0: Grid.Text = ls_Text
        Case "lbl_ShortCode": lbl_ShortCode = ls_Text: Grid.Col = 1: Grid.Text = ls_Text
        Case "lbl_plant": lbl_Plant = ls_Text
        Case "description":     Grid.Col = 3: Grid.Text = ls_Text
        Case "drop":               Grid.Col = 13: Grid.Text = ls_Text
        Case "special":             Grid.Col = 2: Grid.Text = ls_Text
        Case "lbl_codelevel1": Opt_Code_Level(0).Caption = ls_Text
        Case "lbl_codelevel2": Opt_Code_Level(1).Caption = ls_Text
        Case "lbl_special1": Option3(0).Caption = ls_Text
        Case "lbl_special2": Option3(1).Caption = ls_Text
          Case "lbl_special3": Option3(2).Caption = ls_Text
        Case "lbl_drop1": Option1(0).Caption = ls_Text
        Case "lbl_drop2": Option1(1).Caption = ls_Text
        Case "lbl_drop3": Option1(2).Caption = ls_Text
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Lbl_group = lbl_Edge

' default setting for radio button
' standard
Option3(0) = (ms_TypeCode = "")
Option3(1) = (ms_TypeCode = "STD")
Option3(2) = (ms_TypeCode = "SPC")
' dropped
Option1(0) = (ms_DropCode = "")
Option1(1) = (ms_DropCode = "Y")
Option1(2) = (ms_DropCode = "N")

' repositition cbo dimension
cbo_Dimension.Top = 2820
lbl_Dimension.Top = 2820
If ms_TypeCode = "STD" And (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006") Then
        cbo_Dimension.Visible = OK
        lbl_Dimension.Visible = OK
        Gridvisible.Top = 3180
        Gridvisible.Height = 3135
   Else
        cbo_Dimension.Visible = KO
        lbl_Dimension.Visible = KO
        Gridvisible.Top = 2820
        Gridvisible.Height = 3495
    End If
Txt_Short.Top = txt_like.Top

Gridvisible.Cols = 1
Gridvisible.Rows = 2
For li_Count = 0 To 13
    If Grid.ColWidth(li_Count) > 1 Then
        Gridvisible.Cols = Gridvisible.Cols + 1   ' Add a column
        Gridvisible.Col = Gridvisible.Cols - 1
        Gridvisible.ColWidth(Gridvisible.Col) = Grid.ColWidth(li_Count) ' Resize the new column
    End If
Next li_Count
Gridvisible.ColWidth(0) = 1

' Size and label the visible grid
FillGridVisible
Exit Sub

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

Private Sub Form_Unload(Cancel As Integer)
    Set mo_Fetch = Nothing
    MouseOn
End Sub

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_Code As String
Dim ls_Line As String
Dim ls_IntFlag As String
Dim ls_DropFlag As String
Dim ls_DropDate As String

On Error GoTo suite

Add_Table = KO

'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 = gs_ParamReqIns & " " _
    & gut_Param.Str22 & ", '" _
    & QuoteParam(gs_Photo) & "','" & QuoteParam(cbo_plant2.List(cbo_Plant.ListIndex)) & "'"

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
        Add_Table = OK
        ' Find the code
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Code = ODBCData(ll_Statement, 1)
        End If
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
'            ls_Line = ls_Code & Chr(9) & 1 & Chr(9) & "c1" & Chr(9) & "c2" & Chr(9) & "c3"
            C_main.Grid.AddItem ls_Line
            C_main.Grid.Row = C_main.Grid.Rows - 1
        Else
            C_main.FillGrid
        End If
            
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    SendMessage 4, "Insert failed", gut_LangLogin.Code
End If

Exit Function

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



Private Sub GridVisible_SelChange()
Dim ll_SelectedRow As Long
ll_SelectedRow = Gridvisible.Row
' Module Test
If gs_TableName = "Test_Link_Products" And pic_next25.Visible Then
    Do While Next25 = OK
    Loop
    pic_next25.Visible = KO
End If
 If ml_ResultIndex >= 1 And ll_SelectedRow > 0 Then
        Gridvisible.HighLight = flexHighlightAlways
        Grid.Row = ll_SelectedRow
        txt_SAP = Grid.TextMatrix(ll_SelectedRow, 0)  '.Text
        txt_shortcode = Grid.TextMatrix(ll_SelectedRow, 1)
        If gs_TableName = "Test_Link_Products" Then
            GetPlant
            lbl_Plant.Enabled = OK
            cbo_Plant.Enabled = OK
        End If
Else
    Gridvisible.HighLight = flexHighlightNever
End If
End Sub

Private Sub Opt_Code_Level_Click(Index As Integer)
mi_CodeLevel = Index
Grid.ColWidth(0) = 1
Grid.ColWidth(1) = 1
Grid.ColWidth(mi_CodeLevel) = mi_gridwidth(mi_CodeLevel)
txt_SAP.Visible = (Index = 0)
txt_shortcode.Visible = (Index = 1)
txt_like.Visible = (Index = 0)
Txt_Short.Visible = (Index = 1)
txt_like = ""
Txt_Short = ""
If mi_CodeLevel = 0 Then lbl_Like = lbl_SAPCode
If mi_CodeLevel = 1 Then lbl_Like = lbl_ShortCode
ClearGrid
End Sub

Private Sub Option1_Click(Index As Integer)
ClearGrid
Select Case Index
Case 0: ms_DropCode = ""
Case 1: ms_DropCode = "Y"
Case 2: ms_DropCode = "N"
End Select
End Sub

'---------------------------------------------
' NEXT 25
' Get the 25 next rows
'---------------------------------------------
' Created sept/04/99 by JC
'---------------------------------------------
Private Function Next25() As Boolean

Dim li_Count, li_NBcol As Integer
Dim i As Integer 'Use to scan rows
Dim j As Integer 'Use to scan columns
Dim ls_Date As String ' Use to store the lauch date

On Error GoTo suite

'At least one record left
Next25 = OK
'Number of columns returned by the query
li_NBcol = mo_Fetch.NbCol
'get 25 new records
li_Count = mo_Fetch.FillMore

For i = 1 To li_Count
    
    ml_ResultIndex = ml_ResultIndex + 1

    'Add a row into the grid
    Grid.Rows = ml_ResultIndex + 1

    'Select the last row and the first column
    Grid.Row = ml_ResultIndex

    Grid.Col = 0
    For j = 0 To li_NBcol - 1
        'select the good column and fill it with data
        Grid.Col = j
        Grid.Text = mo_Fetch.GetData(i, j + 1)
    Next j
 Next i
'No more record left
If li_Count < 25 Then
    Next25 = KO
End If

'Number of row to display in the bottom on the screen
ssp_code = ml_ResultIndex
FillGridVisible
Gridvisible.RowSel = Gridvisible.Row
Gridvisible.HighLight = flexHighlightNever
Exit Function

suite:
Next25 = KO
StdError
End Function




Private Sub Option3_Click(Index As Integer)
ClearGrid
ClearDimension
lbl_Dimension.Visible = (Index = 1) And (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006")
cbo_Dimension.Visible = (Index = 1) And (ms_CategoryCode = "C001" Or ms_CategoryCode = "C006")
lbl_Dimension.Enabled = (Index = 1 And ms_BasematCode <> "")
cbo_Dimension.Enabled = (Index = 1 And ms_BasematCode <> "")
If cbo_Dimension.Visible Then
        Gridvisible.Top = 3180
        Gridvisible.Height = 3135
    Else
        Gridvisible.Top = 2820
        Gridvisible.Height = 3495
    End If
If Index = 1 Then
        Grid.ColWidth(13) = mi_gridwidth(13)
Else
   Grid.ColWidth(13) = 1
End If
Select Case Index
Case 0: ms_TypeCode = ""
Case 1: ms_TypeCode = "STD"
Case 2: ms_TypeCode = "SPC"
End Select
End Sub

Private Sub pic_next25_Click()
Dim li_TopRow As Integer

' Download and display the 25 next rows of the grid
    MouseOff
    
    li_TopRow = Gridvisible.TopRow
    txt_SAP = ""
    txt_shortcode = ""
    pic_next25.Visible = Next25
    Gridvisible.TopRow = li_TopRow
    MouseOn
End Sub

Private Sub pic_search_Click()

On Error GoTo suite
If ms_CategoryCode = "" And txt_like = "" And Txt_Short = "" Then
        cbo_Category.SetFocus
        SendMessage 8, lbl_Category & " must be filled in", gut_LangLogin.Code
        MouseOn
Exit Sub
End If
MouseOff
txt_SAP = ""
txt_shortcode = ""
'GetPlant
FillGrid
MouseOn
Exit Sub

suite:
StdError
End Sub
Private Sub pic_UnDo_Click()
ClearBasemat
If cbo_Category.Enabled Then
    cbo_Category.ListIndex = -1
    cbo_Basemat.Enabled = KO
    lbl_BaseMat.Enabled = KO
Else
    cbo_Basemat.Enabled = OK
    lbl_BaseMat.Enabled = OK
End If
txt_like = ""
Txt_Short = ""
txt_SAP = ""
ClearGrid

End Sub
Private Sub pic_quit_Click()

MouseOff
Unload Me
gb_Return = KO
MouseOn

End Sub

Private Sub pic_Save_Click()

MouseOff
gs_Photo = ""
If mb_CalledFromSPA = False Then
If txt_shortcode <> "" And (ms_TypeCodeReturn = 1 Or ms_TypeCodeReturn = 3) Then gs_Photo = txt_shortcode    ' return an Short code
If txt_SAP <> "" And (ms_TypeCodeReturn = 0) Then gs_Photo = txt_SAP        ' return an SAP code
Else
    gs_Photo = txt_SAP.Text        ' return an SAP code
End If

' Add the link between the product and the test
If gs_TableName = "Test_Link_Products" Then
    'control
    If (txt_SAP = "") Then
        SendMessage 8, lbl_Like.Caption & " must be filled in", gut_LangLogin.Code
        MouseOn
        Exit Sub
    End If
    
    If (cbo_Plant = "") Then
        SendMessage 154, "Please complete the Plant / Supplier field", gut_LangLogin.Code
        cbo_Plant.SetFocus
        MouseOn
        Exit Sub
    End If
    Add_Table
    txt_SAP = ""
    cbo_Plant.Clear
    cbo_plant2.Clear
    cbo_Plant.Enabled = KO
    lbl_Plant.Enabled = KO
    
    C_main.FillGrid
    
Else
Unload Me
gb_Return = OK
End If

MouseOn

End Sub
Private Sub GetCategories()

Dim ls_req As String

On Error GoTo suite

If gs_CGCode = "" Then
    ls_req = "EXEC Categories_cbo '" _
        & gut_LangLogin.Code & "'"
    FillCbo ls_req, cbo_CategoryCode, cbo_Category
Else
    ls_req = "EXEC Categories_cbo2 '" _
        & gs_CGCode & "','" _
        & gut_LangLogin.Code & "'"
    FillCbo ls_req, cbo_CategoryCode, cbo_Category
    cbo_Category.ListIndex = 0
    cbo_Category.Enabled = KO
End If

Changed = 0
lbl_Surface.Visible = (gs_CGCode = "C001" Or gs_CGCode = "C006")
cbo_surface.Visible = (gs_CGCode = "C001" Or gs_CGCode = "C006")
lbl_Shape.Visible = (gs_CGCode = "C001" Or gs_CGCode = "C006")
cbo_Shape.Visible = (gs_CGCode = "C001" Or gs_CGCode = "C006")
Exit Sub


suite:
StdError
End Sub

Private Sub txt_Like_Change()

ClearGrid
txt_SAP = ""

End Sub


Private Sub txt_short_Change()
ClearGrid
End Sub


