VERSION 5.00
Begin VB.Form C_Order 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Titre"
   ClientHeight    =   5145
   ClientLeft      =   1350
   ClientTop       =   1155
   ClientWidth     =   5805
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   5145
   ScaleWidth      =   5805
   ShowInTaskbar   =   0   'False
   Begin VB.TextBox ssp_code 
      Alignment       =   2  'Center
      BackColor       =   &H0080FFFF&
      Height          =   300
      Left            =   1440
      TabIndex        =   12
      Top             =   4440
      Width           =   765
   End
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   612
      Left            =   4440
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   4440
      Width           =   612
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   5100
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   4440
      Width           =   612
   End
   Begin VB.ComboBox cbo_Combo2Code 
      Height          =   288
      Left            =   5040
      TabIndex        =   11
      Text            =   "Combo1"
      Top             =   600
      Visible         =   0   'False
      Width           =   372
   End
   Begin VB.ComboBox cbo_Combo2 
      Height          =   288
      Left            =   4140
      TabIndex        =   10
      Text            =   "cbo_Combo1"
      Top             =   600
      Width           =   1572
   End
   Begin VB.ComboBox cbo_Combo1Code 
      Height          =   288
      Left            =   2160
      TabIndex        =   8
      Text            =   "Combo1"
      Top             =   600
      Visible         =   0   'False
      Width           =   372
   End
   Begin VB.ComboBox cbo_Combo1 
      Height          =   288
      Left            =   1260
      TabIndex        =   7
      Text            =   "cbo_Combo1"
      Top             =   600
      Width           =   1572
   End
   Begin VB.ListBox lst_OrderCode 
      Height          =   840
      Left            =   2460
      TabIndex        =   5
      Top             =   4140
      Visible         =   0   'False
      Width           =   1515
   End
   Begin VB.ListBox lst_Order 
      Height          =   2985
      Left            =   60
      TabIndex        =   4
      Top             =   1080
      Width           =   5652
   End
   Begin VB.Label lbl_Combo2 
      Caption         =   "Label1"
      Height          =   252
      Left            =   3000
      TabIndex        =   9
      Top             =   600
      Width           =   1092
   End
   Begin VB.Label lbl_Combo1 
      Caption         =   "Label1"
      Height          =   252
      Left            =   120
      TabIndex        =   6
      Top             =   600
      Width           =   1092
   End
   Begin VB.Label lbl_Rcd 
      Height          =   312
      Left            =   120
      TabIndex        =   3
      Top             =   4440
      Width           =   1212
   End
   Begin VB.Label lbl_Info 
      Height          =   312
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5532
   End
End
Attribute VB_Name = "C_Order"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public ms_parameter As String   ' Parameters to give to the request
Public mb_Return As Boolean

Dim mi_DragIndex
Dim ms_DragText As String
Dim ms_DragTextCode As String
Dim ms_Category As String
Dim ms_CodeType As String
Dim mi_Combo As Integer

Private Sub cbo_Combo1_Click()
Dim ls_Req As String

MouseOff
If cbo_Combo1.Visible Then
    Select Case mi_Combo
    Case 1
        lst_Order.Clear
        lst_OrderCode.Clear
        FillList
    Case 2
        Cbo_Combo2.Clear
        cbo_Combo2Code.Clear
        ls_Req = gs_TableName & "_o_cbo2 " & cbo_Combo1Code.List(cbo_Combo1.ListIndex)
        FillCbo ls_Req, cbo_Combo2Code, Cbo_Combo2
        Cbo_Combo2.ListIndex = 0
        lst_Order.Clear
        lst_OrderCode.Clear
        FillList
    End Select
End If
MouseOn

End Sub

Private Sub cbo_Combo2_Click()
Dim ls_Req As String

MouseOff
If Cbo_Combo2.Visible Then
    lst_Order.Clear
    lst_OrderCode.Clear
    FillList
End If
MouseOn

End Sub

Private Sub Form_Load()
On Error GoTo suite

MouseOff

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

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

mb_Return = KO
Order_Constants
GetInfo
Show_Combo
FillList
MouseOn

Exit Sub

suite:
StdError
End Sub
Private Sub Form_Unload(Cancel As Integer)
ms_parameter = ""
End Sub

Private Sub lst_Order_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 1 And lst_Order.ListIndex <> -1 Then
    mi_DragIndex = lst_Order.ListIndex
    ms_DragText = lst_Order
    lst_OrderCode.ListIndex = mi_DragIndex
    ms_DragTextCode = lst_OrderCode
End If

End Sub


Private Sub lst_Order_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim li_Index As Integer

If Button = 1 And lst_Order.ListIndex <> -1 Then
    li_Index = lst_Order.ListIndex
    If li_Index <> mi_DragIndex Then
        If li_Index < mi_DragIndex Then
            lst_Order.RemoveItem mi_DragIndex
            lst_OrderCode.RemoveItem mi_DragIndex
            lst_Order.AddItem ms_DragText, li_Index
            lst_OrderCode.AddItem ms_DragTextCode, li_Index
        Else
            lst_Order.RemoveItem mi_DragIndex
            lst_OrderCode.RemoveItem mi_DragIndex
            lst_Order.AddItem ms_DragText, li_Index - 1
            lst_OrderCode.AddItem ms_DragTextCode, li_Index - 1
        End If
    End If
End If

End Sub


Private Sub spp_save_Click()
Dim li_Comp As Integer
Dim ls_Req As String

MouseOff

For li_Comp = 0 To lst_OrderCode.ListCount - 1
    lst_OrderCode.ListIndex = li_Comp
    If ms_Category = "Y" Then
        If ms_CodeType = "C" Then
            ls_Req = gs_TableName & "_o_upd '" & gs_CGCode & "', '" & _
                     lst_OrderCode & "', " & li_Comp + 1
        Else
            ls_Req = gs_TableName & "_o_upd '" & gs_CGCode & "', " & _
                     lst_OrderCode & ", " & li_Comp + 1
        End If
    Else
        If ms_CodeType = "C" Then
            ls_Req = gs_TableName & "_o_upd '" & _
                     lst_OrderCode & "', " & li_Comp + 1
        Else
            ls_Req = gs_TableName & "_o_upd " & _
                     lst_OrderCode & ", " & li_Comp + 1
        End If
    End If
    If Not Order_upd(ls_Req) Then
        Exit For
    End If
Next li_Comp
mb_Return = OK
MouseOn
Unload Me
End Sub

Private Sub ssp_quit_Click()
Unload Me
End Sub



Public Sub Order_Constants()
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 suite
ls_Req = "EXEC Screen_Csts 'ord_" & gs_TableName & "', '" & 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 "lbl_Title": Caption = ls_Text
        Case "lbl_Info": lbl_Info = ls_Text
        Case "lbl_Record": lbl_Rcd = ls_Text
        Case "lbl_Combo1": lbl_Combo1 = ls_Text
        Case "lbl_Combo2": lbl_Combo2 = ls_Text
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
If gs_CGCode <> "" Then
    lbl_Info = lbl_Info & " for " & gs_MenuChoice
End If
Exit Sub

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

Public Sub FillList()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer

On Error GoTo suite

Select Case mi_Combo
Case 0
    If ms_Category = "Y" Then
        ls_Req = gs_TableName & "_o_lst '" & gs_CGCode & "'" & ms_parameter
    Else
        ls_Req = gs_TableName & "_o_lst " & ms_parameter
    End If
Case 1
    If ms_Category = "Y" Then
        ls_Req = gs_TableName & "_o_lst '" & gs_CGCode & "', " _
                & cbo_Combo1Code.List(cbo_Combo1.ListIndex) & ms_parameter
    Else
        ls_Req = gs_TableName & "_o_lst " _
                & cbo_Combo1Code.List(cbo_Combo1.ListIndex) & ms_parameter
    End If
Case 2
    If ms_Category = "Y" Then
        ls_Req = gs_TableName & "_o_lst '" & gs_CGCode & "'" _
                & cbo_Combo1Code.List(cbo_Combo1.ListIndex) & ", " _
                & cbo_Combo2Code.List(Cbo_Combo2.ListIndex) & ms_parameter
    Else
        ls_Req = gs_TableName & "_o_lst " _
                & cbo_Combo1Code.List(cbo_Combo1.ListIndex) & ", " _
                & cbo_Combo2Code.List(Cbo_Combo2.ListIndex) & ms_parameter
    End If
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
        lst_OrderCode.AddItem ODBCData(ll_Statement, 1)
        lst_Order.AddItem ODBCData(ll_Statement, 2)
    End If
Loop
ssp_code = lst_Order.ListCount
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

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



Public Function Order_upd(ls_Req As String) As Boolean
Dim ll_Statement As Long
Dim li_Status As Integer

On Error GoTo suite
Order_upd = KO

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQL_SUCCESS
    Order_upd = OK
Else
    li_Status = SQL_ERROR
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Function

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

Public Sub GetInfo()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer

On Error GoTo suite

ls_Req = "TableSortedShow '" & gs_TableName & "', '" & prg.LoginName & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    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
            ms_Category = ODBCData(ll_Statement, 1)
            ms_CodeType = ODBCData(ll_Statement, 2)
            mi_Combo = ODBCData(ll_Statement, 3)
        End If
    Loop
End If
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

suite:
StdError
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

End Sub

Private Sub Show_Combo()
Dim ls_Req As String

On Error GoTo suite

Select Case mi_Combo
Case 0
    cbo_Combo1.Visible = KO
    lbl_Combo1.Visible = KO
    Cbo_Combo2.Visible = KO
    lbl_Combo2.Visible = KO
    Me.Height = 5200
    lst_Order.Top = 650
    ssp_code.Top = 4010
    lbl_Rcd.Top = 4010
    spp_save.Top = 4010
    ssp_quit.Top = 4010
    lst_OrderCode.Top = 3950
Case 1
    Cbo_Combo2.Visible = KO
    lbl_Combo2.Visible = KO
    ls_Req = gs_TableName & "_o_cbo1 "
    FillCbo ls_Req, cbo_Combo1Code, cbo_Combo1
    cbo_Combo1.ListIndex = 0
Case 2
    ls_Req = gs_TableName & "_o_cbo1 "
    FillCbo ls_Req, cbo_Combo1Code, cbo_Combo1
    cbo_Combo1.ListIndex = 0
    ls_Req = gs_TableName & "_o_cbo2 " & cbo_Combo1Code.List(cbo_Combo1.ListIndex)
    FillCbo ls_Req, cbo_Combo2Code, Cbo_Combo2
    Cbo_Combo2.ListIndex = 0
End Select
Exit Sub

suite:
StdError
End Sub
