VERSION 5.00
Begin VB.Form Query_Excel 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   6720
   ClientLeft      =   75
   ClientTop       =   390
   ClientWidth     =   9420
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6720
   ScaleWidth      =   9420
   ShowInTaskbar   =   0   'False
   Begin VB.CheckBox chk_cat 
      Height          =   192
      Index           =   0
      Left            =   120
      TabIndex        =   4
      Top             =   480
      Width           =   3000
   End
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   612
      Left            =   8100
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   6060
      Width           =   612
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   8820
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   6060
      Width           =   612
   End
   Begin VB.Label lbl_Info 
      Caption         =   "lbl_Info"
      Height          =   192
      Left            =   120
      TabIndex        =   3
      Top             =   6420
      Width           =   7812
   End
   Begin VB.Label lbl_Cat 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   192
      Index           =   0
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Visible         =   0   'False
      Width           =   3000
   End
End
Attribute VB_Name = "Query_Excel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Load()
Dim i As Integer
Dim li_Left As Integer
Dim li_top As Integer
Dim ls_GroupName As String
Dim ls_msg As String

MouseOff

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

ssp_quit.Picture = LoadResPicture(RES_QUIT, 1)
spp_save.Picture = LoadResPicture(RES_OK, 1)

GetCriteria
Select Case UCase(gut_Param.Str1)
Case "BASE_ITEM"
    ls_msg = MsgText(114, gut_LangLogin.Code)
    If ls_msg = "" Then
        ls_msg = "Remark -> CLS item number and CLS description are automatically included into the excel file."
    End If
End Select

lbl_Info.Caption = ls_msg
li_Left = 120
li_top = 120
ls_GroupName = ""
For i = 1 To UBound(gut_Excel)
    If gut_Excel(i).GroupName <> ls_GroupName Then
        If i <> 1 Then
            Load Lbl_Cat(i - 1)
        End If
        Lbl_Cat(i - 1).Top = li_top
        Lbl_Cat(i - 1).Left = li_Left
        Lbl_Cat(i - 1).Visible = OK
        ls_GroupName = gut_Excel(i).GroupName
        Lbl_Cat(i - 1).Caption = gut_Excel(i).GroupName
        li_top = li_top + 250
        If li_top > 6000 Then
            li_top = 120
            li_Left = li_Left + 3000
        End If
    End If
    If i <> 1 Then
        Load chk_cat(i - 1)
    End If
    chk_cat(i - 1).Top = li_top
    chk_cat(i - 1).Left = li_Left
    chk_cat(i - 1).Visible = OK
    chk_cat(i - 1).Caption = gut_Excel(i).Criteria
    li_top = li_top + 250
    If li_top > 6000 Then
        li_top = 120
        li_Left = li_Left + 3000
    End If
Next i
MouseOn

End Sub



Private Sub GetCriteria()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_Index As Integer

On Error GoTo suite

ReDim gut_Excel(0)

Select Case UCase(gut_Param.Str1)
    Case "CLAIM"
        ls_Req = "EXEC Query_Excel_lst 'Query Claim','QryXLS_Claim','" & gut_LangLogin.Code & "'"
    Case "BASE_ITEM"
        ls_Req = "EXEC Query_Excel_lst 'Query Product','Query_Excel','" & 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
        ReDim Preserve gut_Excel(UBound(gut_Excel) + 1)
        li_Index = UBound(gut_Excel)
        gut_Excel(li_Index).Criteria = ODBCData(ll_Statement, 1)
        gut_Excel(li_Index).BaseName = ODBCData(ll_Statement, 2)
        gut_Excel(li_Index).GroupName = ODBCData(ll_Statement, 3)
        gut_Excel(li_Index).DataType = ODBCData(ll_Statement, 4)
        gut_Excel(li_Index).ReqUpdate = ODBCMemoGet(ll_Statement, 5)
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

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

Private Sub spp_save_Click()
Dim i As Integer

ReDim gi_CritExcel(0)
For i = 1 To UBound(gut_Excel)
    If chk_cat(i - 1).value = 1 Then
        ReDim Preserve gi_CritExcel(UBound(gi_CritExcel) + 1)
        gi_CritExcel(UBound(gi_CritExcel)) = i
    End If
Next

MouseOff
Unload Me
End Sub

Private Sub ssp_quit_Click()

ReDim gi_CritExcel(1)
gi_CritExcel(1) = -1
MouseOff
Unload Me
End Sub


