VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form BaseItem_Special 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Bi_Special"
   ClientHeight    =   6795
   ClientLeft      =   60
   ClientTop       =   330
   ClientWidth     =   9480
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6795
   ScaleWidth      =   9480
   ShowInTaskbar   =   0   'False
   Begin MSFlexGridLib.MSFlexGrid grid 
      Height          =   855
      Left            =   6720
      TabIndex        =   22
      Top             =   1440
      Visible         =   0   'False
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   1508
      _Version        =   393216
   End
   Begin MSFlexGridLib.MSFlexGrid Gridvisible 
      Height          =   3615
      Left            =   0
      TabIndex        =   21
      Top             =   2400
      Width           =   9495
      _ExtentX        =   16748
      _ExtentY        =   6376
      _Version        =   393216
      AllowBigSelection=   0   'False
      AllowUserResizing=   1
   End
   Begin VB.TextBox ssp_code 
      Alignment       =   2  'Center
      BackColor       =   &H0080FFFF&
      Height          =   300
      Left            =   2640
      TabIndex        =   20
      Top             =   6240
      Width           =   765
   End
   Begin VB.TextBox txt_shape 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   285
      Left            =   5940
      Locked          =   -1  'True
      TabIndex        =   17
      Top             =   1560
      Width           =   2355
   End
   Begin VB.TextBox txt_surface 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   285
      Left            =   5940
      Locked          =   -1  'True
      TabIndex        =   16
      Top             =   1200
      Width           =   2355
   End
   Begin VB.TextBox txt_Group 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   285
      Left            =   5940
      Locked          =   -1  'True
      TabIndex        =   15
      Top             =   840
      Width           =   2355
   End
   Begin VB.TextBox txt_basemat 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   2760
      Locked          =   -1  'True
      TabIndex        =   9
      Top             =   840
      Width           =   1512
   End
   Begin VB.TextBox txt_family 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1380
      Locked          =   -1  'True
      TabIndex        =   8
      Top             =   1200
      Width           =   2892
   End
   Begin VB.TextBox txt_pattern 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1380
      Locked          =   -1  'True
      TabIndex        =   7
      Top             =   1560
      Width           =   2892
   End
   Begin VB.TextBox txt_psegm 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1380
      Locked          =   -1  'True
      TabIndex        =   6
      Top             =   1920
      Width           =   2892
   End
   Begin VB.TextBox txt_SupBaseMat 
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1380
      Locked          =   -1  'True
      TabIndex        =   5
      Top             =   840
      Width           =   1332
   End
   Begin VB.PictureBox pic_next25 
      AutoSize        =   -1  'True
      Height          =   480
      Left            =   3720
      ScaleHeight     =   420
      ScaleWidth      =   420
      TabIndex        =   3
      Top             =   6180
      Width           =   480
   End
   Begin VB.PictureBox ButtonBox 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ClipControls    =   0   'False
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   665
      Left            =   0
      ScaleHeight     =   630
      ScaleWidth      =   9450
      TabIndex        =   0
      Top             =   0
      Width           =   9480
      Begin VB.PictureBox pic_exit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_SPC.frx":0000
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   660
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   2
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_print 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   1
         Top             =   60
         Width           =   480
      End
   End
   Begin VB.Label Lbl_Shape 
      Caption         =   "Shape"
      Height          =   255
      Left            =   4500
      TabIndex        =   19
      Top             =   1560
      Width           =   1395
   End
   Begin VB.Label Lbl_Surface 
      Caption         =   "Surface"
      Height          =   255
      Left            =   4500
      TabIndex        =   18
      Top             =   1200
      Width           =   1395
   End
   Begin VB.Label Lbl_group 
      Caption         =   "Group-Edge detail"
      Height          =   255
      Left            =   4500
      TabIndex        =   14
      Top             =   840
      Width           =   1395
   End
   Begin VB.Label lbl_baseMat 
      Caption         =   "Base material"
      Height          =   255
      Left            =   120
      TabIndex        =   13
      Top             =   840
      Width           =   1275
   End
   Begin VB.Label lbl_family 
      Caption         =   "Family"
      Height          =   255
      Left            =   120
      TabIndex        =   12
      Top             =   1200
      Width           =   1275
   End
   Begin VB.Label lbl_pattern 
      Caption         =   "Pattern"
      Height          =   255
      Left            =   120
      TabIndex        =   11
      Top             =   1560
      Width           =   1290
   End
   Begin VB.Label lbl_psegm 
      Caption         =   "Product segm"
      Height          =   255
      Left            =   120
      TabIndex        =   10
      Top             =   1920
      Width           =   1290
   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          =   315
      Left            =   1080
      TabIndex        =   4
      Top             =   6240
      Width           =   1485
   End
End
Attribute VB_Name = "BaseItem_Special"
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/07/99 by JC
'--------------------------------------------------
' Params:
'   gut_Param.Str1: Language
'   gut_Param.Str2: Category
'   gut_Param.Str3: Base material
'   gut_Param.Str4: Super base material
'   gut_Param.Str5: Family
'   gut_Param.Str6: Pattern
'   gut_Param.Str7: Product segmentation
'   gut_Param.Str8: Group/edge detail
'   gut_Param.Str9: Surface
'   gut_Param.Str10: Shape
'
'  gs_param2req1:   request for screen constants
'  gs_param2req2:   request for filling the grid of special products
' --------------------------------------------------

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

Public mb_Load As Boolean   ' Is the form need to be load?

Private Sub get_values()
'---------------------------------------------
' GET VALUES
' Get the common values from Base_item
'---------------------------------------------
' Created Sept/07/99 by JC
'---------------------------------------------
    txt_basemat = gut_Param.Str3     ' Base material
    txt_SupBaseMat = gut_Param.Str4    ' Super Base material
    txt_family = gut_Param.Str5    ' Family
    txt_pattern = gut_Param.Str6     ' Pattern
    txt_psegm = gut_Param.Str7    ' Product range
    txt_Group = gut_Param.Str8    ' Edge detail
    txt_surface = gut_Param.Str9    ' Surface
    txt_shape = gut_Param.Str10     ' Shape
End Sub
'---------------------------------------------
' FILL GRID
' Fill the grid with the specials
'---------------------------------------------
' Created Sept/09/99 by JC
'---------------------------------------------
Private Sub FillGrid()
Dim li_Count As Integer

    On Error GoTo FillGrid_Err
    
    'Dimension the grid and fill the first row with the captions
    grid.Cols = gi_GridNbColumns
    For li_Count = 0 To gi_GridNbColumns - 1
        grid.Col = li_Count
        grid.ColWidth(li_Count) = gi_GridWidth2(li_Count)
        grid.Row = 0
        grid.Text = gs_GridColumn2(li_Count, 0)
    Next li_Count
    
    'Execute the request to get the data
    If mo_Fetch.ExecuteQry(gs_Param2Req2, gb_UseServerCursor) Then
        mi_Status = SQL_SUCCESS
        'Request for the 25 first records
        pic_next25.Visible = Next25
    Else
        mi_Status = SQL_ERROR
    End If
    
    Exit Sub
    
FillGrid_Err:
    StdError
End Sub
'---------------------------------------------
' BASE_ITEM_SPECIAL_CSTS
' Get the constants for the screen
'---------------------------------------------
'Created sept/07/99 by JC
'--------------------------------------------
Private Sub Base_Item_Special_cst()
Dim ls_Field As String    ' Name of the field
Dim ls_Text As String    ' Text of the field
Dim ls_Req As String      ' Request to execute

    On Error GoTo Base_Item_Special_cst_Err
    
    If SQLSubmit(gl_Environment, gl_Database, ml_Hstmt, gs_Param2Req1) Then ' Request for the screen_constants
        mi_Status = SQL_SUCCESS
    Else
        mi_Status = SQL_ERROR
    End If
    Do While mi_Status = SQL_SUCCESS Or mi_Status = SQL_SUCCESS_WITH_INFO
        mi_Status = SQLFetch(ml_Hstmt)
        If mi_Status = SQL_SUCCESS Or mi_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Field = ODBCData(ml_Hstmt, 1)
            ls_Text = left(ODBCData(ml_Hstmt, 2), 30)
            Select Case ls_Field
            Case "title": Caption = ls_Text                         ' Title of the form
            Case "lbl_record": lbl_rcd = ls_Text                  ' Number of rows displayed
            
            Case "lbl_basemat": lbl_baseMat = ls_Text       ' Label of common values
            Case "lbl_family": lbl_family = ls_Text
            Case "lbl_pattern": lbl_pattern = ls_Text
            Case "lbl_psegm": lbl_psegm = ls_Text
            Case "lbl_group": If (gs_CGCode <> "C001" And gs_CGCode <> "C006") Then Lbl_group = ls_Text
            Case "lbl_edgedetail": If (gs_CGCode = "C001" Or gs_CGCode = "C006") Then Lbl_group = ls_Text
            Case "lbl_surface": Lbl_Surface = ls_Text
            Case "lbl_shape": Lbl_Shape = ls_Text
            Case "lbl_corrosive": lbl_corrosive = ls_Text
            
            Case "c0": gs_GridColumn2(0, 0) = ls_Text      ' Title of the grid columns
            Case "c1": gs_GridColumn2(1, 0) = ls_Text
            Case "c2": gs_GridColumn2(2, 0) = ls_Text
            Case "c3": gs_GridColumn2(3, 0) = ls_Text
            Case "c4": gs_GridColumn2(4, 0) = ls_Text
            Case "c5": gs_GridColumn2(5, 0) = ls_Text
            Case "c6": gs_GridColumn2(6, 0) = ls_Text
            Case "c7": gs_GridColumn2(7, 0) = ls_Text
            Case "c8": gs_GridColumn2(8, 0) = ls_Text
            Case "c9": gs_GridColumn2(9, 0) = ls_Text
            Case "c10": gs_GridColumn2(10, 0) = ls_Text
            Case "c11": gs_GridColumn2(11, 0) = ls_Text
            Case "c12": gs_GridColumn2(12, 0) = ls_Text
            Case "c13": gs_GridColumn2(13, 0) = ls_Text
            Case "c14": gs_GridColumn2(14, 0) = ls_Text
            Case "c15": gs_GridColumn2(15, 0) = ls_Text
            Case "c16": gs_GridColumn2(16, 0) = ls_Text
            Case "c17": gs_GridColumn2(17, 0) = ls_Text
            Case "c18": gs_GridColumn2(18, 0) = ls_Text
            Case "c19": gs_GridColumn2(19, 0) = ls_Text
            Case "c20": gs_GridColumn2(20, 0) = ls_Text
            Case "c21": gs_GridColumn2(21, 0) = ls_Text
            Case "c22": gs_GridColumn2(22, 0) = ls_Text
            Case "c23": gs_GridColumn2(23, 0) = ls_Text
            Case "c24": gs_GridColumn2(24, 0) = ls_Text
            Case "c25": gs_GridColumn2(25, 0) = ls_Text
            Case "c26": gs_GridColumn2(26, 0) = ls_Text
            Case "c27": gs_GridColumn2(27, 0) = ls_Text
            Case "c28": gs_GridColumn2(28, 0) = ls_Text
            Case "c29": gs_GridColumn2(29, 0) = ls_Text
            Case "c30": gs_GridColumn2(30, 0) = ls_Text
            End Select
        End If
    Loop
    mi_Status = SQLFreeStatement(ml_Hstmt, SQL_DROP)
    Exit Sub
    
Base_Item_Special_cst_Err:
    mi_Status = SQLFreeStatement(ml_Hstmt, SQL_DROP)
    StdError
End Sub

Private Sub Form_Load()

    On Error GoTo Form_Load_Err
    MouseOff
    
    If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me

    pic_print.Picture = LoadResPicture(RES_PRINT, 1)    ' Load the icons
    pic_exit.Picture = LoadResPicture(RES_QUIT, 1)
    pic_next25.Picture = LoadResPicture(RES_DOWN, 1)
    
    Set mo_Fetch = New Fetch ' Create a new fetch
    mo_Fetch.EnvironmentIdentifier = gl_Environment
    mo_Fetch.DatabaseIdentifier = gl_Database
    
    y = 0
    Base_Item_Special_cst   ' Get the screen constants
    
    Select Case gs_CGCode
        Case "C001", "C006":  txt_surface.Visible = OK
                                            Lbl_Surface.Visible = OK
                                            txt_shape.Visible = OK
                                            Lbl_Shape.Visible = OK
        Case Else:                     txt_surface.Visible = KO
                                            Lbl_Surface.Visible = KO
                                            txt_shape.Visible = KO
                                            Lbl_Shape.Visible = KO
    End Select
    
    ' Display the value in the grid (if value="" (all))  or in the textbox (if use as criteria)
    If gut_Param.Str2 <> "" Then gi_GridWidth2(2) = 1   ' Category
    lbl_baseMat.Visible = gut_Param.Str3 <> ""      ' Base material
    txt_basemat.Visible = gut_Param.Str3 <> ""
    If gut_Param.Str3 <> "" Then gi_GridWidth2(3) = 1
    txt_SupBaseMat.Visible = gut_Param.Str4 <> ""    ' Super base material
    If gut_Param.Str4 <> "" Then gi_GridWidth2(4) = 1
    lbl_family.Visible = gut_Param.Str5 <> ""        ' Family
    txt_family.Visible = gut_Param.Str5 <> ""
    If gut_Param.Str5 <> "" Then gi_GridWidth2(5) = 1
    lbl_pattern.Visible = gut_Param.Str6 <> ""      ' Pattern
    txt_pattern.Visible = gut_Param.Str6 <> ""
    If gut_Param.Str6 <> "" Then gi_GridWidth2(6) = 1
    lbl_psegm.Visible = gut_Param.Str7 <> ""         ' Product segmentation
    txt_psegm.Visible = gut_Param.Str7 <> ""
    If gut_Param.Str7 <> "" Then gi_GridWidth2(7) = 1
    Lbl_group.Visible = gut_Param.Str8 <> ""        ' Group/edge detail
    txt_Group.Visible = gut_Param.Str8 <> ""
    If gut_Param.Str8 <> "" Then gi_GridWidth2(8) = 1
    Lbl_Surface.Visible = gut_Param.Str9 <> ""      ' Surface
    txt_surface.Visible = gut_Param.Str9 <> ""
    If gut_Param.Str9 <> "" Then gi_GridWidth2(9) = 1
    Lbl_Shape.Visible = gut_Param.Str10 <> ""       ' Shape
    txt_shape.Visible = gut_Param.Str10 <> ""
    If gut_Param.Str10 <> "" Then gi_GridWidth2(10) = 1
    
    FillGrid                           ' Fill the grid with all the specials
    If y = 0 Then
        SendMessage 119, "No special product found", gut_LangLogin.Code
        mb_Load = KO
        Set mo_Fetch = Nothing      ' Free the fetch object
    Else
        mb_Load = OK
        get_values                      ' Get the common values for the item
    End If
    MouseOn
    Exit Sub
    
Form_Load_Err:
    StdError
End Sub

Private Sub Form_Unload(Cancel As Integer)
    MouseOff
    Set mo_Fetch = Nothing      ' Free the fetch object
    MouseOn
End Sub

'---------------------------------------------
' NEXT 25
' Get the 25 next rows of the specials
'---------------------------------------------
' Created sept/07/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 Next25_Err
    
    '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
        y = y + 1
        'Add a row into the grid
        grid.Rows = y + 1
        'Select the last row and the first column
        grid.Row = grid.Rows - 1
        grid.Col = 0
        'Get the action date from the audit and convert it into a date format
        ls_Date = mo_Fetch.GetData(i, 1)
        grid.Text = FormatDate(Mid$(ls_Date, 1, 10))
        For j = 1 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
    FillGridVisible
    
    'Number of row to display in the bottom on the screen
    ssp_code = y
    Exit Function
    
Next25_Err:
    Next25 = KO
    StdError
End Function



Private Sub pic_exit_Click()
    MouseOn
    Unload Me
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

    Gridvisible.Cols = 1
    Gridvisible.Rows = grid.Rows
    For li_Count = 0 To gi_GridNbColumns - 1
        If grid.ColWidth(li_Count) > 1 Then
            Gridvisible.Cols = Gridvisible.Cols + 1     ' Add a column
            Gridvisible.Col = Gridvisible.Cols - 1
            Gridvisible.ColWidth(Gridvisible.Col) = gi_GridWidth2(li_Count) ' Resize the new column
            For li_Count2 = 0 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 pic_next25_Click()
    ' Download and display the 25 next rows of the grid
    MouseOff
    pic_next25.Visible = Next25
    MouseOn
End Sub

Private Sub pic_print_Click()
    
    If Printers.Count = 0 Then
        SendMessage 135, "No printer is installed on your computer. Please, contact your system administrator.", gut_LangLogin.Code
        Exit Sub
    End If
        
    InitPrinter (1)
    Print (lbl_baseMat + ":" + Chr$(9) + txt_SupBaseMat.Text + "/" + txt_basemat.Text)  ' Print the base material
    Print (lbl_family + ":" + Chr$(9) + txt_family.Text)    ' Print the family
    Print (lbl_pattern + ":" + Chr$(9) + txt_pattern.Text)  '
    Print (lbl_psegm + ":" + Chr$(9) + txt_psegm.Text)
    Print (Lbl_group + ":" + Chr$(9) + txt_Group.Text)
    Select Case gs_CGCode
    Case "C001", "C006":
        Print (Lbl_Surface + ":" + Chr$(9) + txt_surface.Text)
        Print (Lbl_Shape + ":" + Chr$(9) + txt_shape.Text)
        Print (lbl_Corrosion + ":" + Chr$(9) + txt_Corrosion.Text)
        PrintGrid 1, 10, Array(30, 30, 50, 50, 50)
    Case Else
        PrintGrid 1, 10, Array(30, 30, 50, 50, 50, 30)
    End Select
End Sub

