VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form C_GridDetail 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "C_GridDetail"
   ClientHeight    =   5580
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8115
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5580
   ScaleWidth      =   8115
   StartUpPosition =   1  'CenterOwner
   Begin MSFlexGridLib.MSFlexGrid Grid 
      Height          =   4635
      Left            =   120
      TabIndex        =   2
      Top             =   120
      Width           =   7215
      _ExtentX        =   12726
      _ExtentY        =   8176
      _Version        =   393216
      Cols            =   1
      FixedCols       =   0
      AllowUserResizing=   1
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   615
      Left            =   7380
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   4860
      Width           =   615
   End
   Begin VB.PictureBox pic_next25 
      AutoSize        =   -1  'True
      Height          =   480
      Left            =   7500
      ScaleHeight     =   420
      ScaleWidth      =   420
      TabIndex        =   1
      Top             =   4260
      Visible         =   0   'False
      Width           =   480
   End
End
Attribute VB_Name = "C_GridDetail"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 0

Public s_GridReq As String              ' (E) Define the request to fill the grid
Public s_ScreenConstantsReq As String   ' (E) Define the request to get translated label for the screen
Public e_Action As TAction              ' (E) Inform the screen on what action must be done (Add,Update,Delete or moreinfo) (Only Moreinfo is supported Yet)
Public i_NumColumn As Integer           ' (E) Define the number of columns to display in the grid (Only tested with 1 column, i think some code must be add to support more)

'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Dim mo_Fetch As Fetch
Dim ml_TotCount As Long
Dim mi_NbRows As Integer
Dim ms_GridColumn(29) As String

Private Sub Form_Load()
Dim li_Status As Integer
Dim li_Count As Integer
On Error GoTo suite

MouseOff
' the pictures for the buttons
ssp_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_next25.Picture = LoadResPicture(RES_DOWN, 1)

' get transleted label
Getcsts

pic_next25.Visible = KO

' insert Columns header
Grid.Rows = 2
For li_Count = 1 To i_NumColumn
    Grid.Col = li_Count - 1
    Grid.Row = 0
    Grid.Text = ms_GridColumn(li_Count - 1)
    Grid.Row = 1
    Grid.Text = ""
Next li_Count

'execute the query to fill the grid
Set mo_Fetch = New Fetch
mo_Fetch.EnvironmentIdentifier = gl_Environment
mo_Fetch.DatabaseIdentifier = gl_Database
li_Status = mo_Fetch.ExecuteQry(s_GridReq, OK)

Grid.ColWidth(0) = Grid.Width
If li_Status Then
    ml_TotCount = mo_Fetch.RowCount
End If

' Fills grid / by 25
mi_NbRows = 1

FillGrid
MouseOn
Exit Sub

suite:
StdError
End Sub




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

Private Sub pic_next25_Click()
Dim li_Count As Integer
Dim li_Count2 As Integer
Dim li_Grid2Col As Integer
Dim li_NbRowsPrev As Integer
Dim li_LastRow As Integer
Dim li_TopRow As Integer

MouseOff
    li_NbRowsPrev = Grid.Rows
    FillGrid
MouseOn

End Sub



Private Sub FillGrid()
' Fills grid / by 25
Dim li_Count, li_Count25 As Integer
Dim lb_Exit As Boolean
Dim i As Integer
Dim j As Integer
Dim li_NBcol As Integer

On Error GoTo suite

lb_Exit = False

li_NBcol = mo_Fetch.NbCol

'Get 25 records
Do While lb_Exit = False
    li_Count = mo_Fetch.FillMore
    If li_Count = 0 Then Exit Do
    For i = 1 To li_Count
        Grid.Rows = mi_NbRows + 1
        Grid.Row = mi_NbRows
        For j = 1 To li_NBcol
            Grid.Col = j - 1
            Grid.Text = mo_Fetch.GetData(i, j)
        Next
        mi_NbRows = mi_NbRows + 1
    Next
    lb_Exit = True
Loop

'we must make the "more 25" image visible or not
If li_Count = mo_Fetch.MaxRowCount And mi_NbRows <> ml_TotCount + 1 Then
    pic_next25.Visible = OK
Else
    pic_next25.Visible = KO
End If

Exit Sub

suite:
pic_next25.Visible = KO
StdError
End Sub

Private Sub ssp_quit_Click()
MouseOff

Unload Me
End Sub


Private Sub Getcsts()

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

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, s_ScreenConstantsReq) 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 e_Action = vbAdd Then Caption = Caption & " - " & ls_text
'        Case "titleU": If e_Action = vbUpdate Then Caption = Caption & " - " & ls_text
'        Case "titleD": If e_Action = vbDelete Then Caption = Caption & " - " & ls_text
        Case "titleI": If e_Action = vbMoreInfo Then Caption = Caption & " - " & ls_Text
        Case "c0": ms_GridColumn(0) = ls_Text
        Case "c1": ms_GridColumn(1) = ls_Text
        Case "c2": ms_GridColumn(2) = ls_Text
        Case "c3": ms_GridColumn(3) = ls_Text
        Case "c4": ms_GridColumn(4) = ls_Text
        Case "c5": ms_GridColumn(5) = ls_Text
        Case "c6": ms_GridColumn(6) = 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
