VERSION 5.00
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form Bi_Estimate_mtnc 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Estimate"
   ClientHeight    =   7380
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9810
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7380
   ScaleWidth      =   9810
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame frm_Grid 
      BorderStyle     =   0  'None
      Height          =   1215
      Left            =   100
      TabIndex        =   19
      Top             =   3360
      Width           =   4815
      Begin VB.Label lbl_FirstSlot 
         Caption         =   "First slot"
         Height          =   255
         Left            =   0
         TabIndex        =   25
         Top             =   0
         Width           =   1575
      End
      Begin MSForms.ComboBox cbo_LastSlot 
         Height          =   315
         Left            =   1680
         TabIndex        =   24
         Top             =   400
         Width           =   2715
         VariousPropertyBits=   679495707
         DisplayStyle    =   7
         Size            =   "4789;556"
         MatchEntry      =   1
         ShowDropButtonWhen=   2
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
      End
      Begin VB.Label lbl_LastSlot 
         Caption         =   "Last slot"
         Height          =   255
         Left            =   0
         TabIndex        =   23
         Top             =   400
         Width           =   1575
      End
      Begin MSForms.ComboBox cbo_FirstSlot 
         Height          =   315
         Left            =   1680
         TabIndex        =   22
         Top             =   0
         Width           =   2715
         VariousPropertyBits=   679479323
         DisplayStyle    =   7
         Size            =   "4789;556"
         MatchEntry      =   1
         ShowDropButtonWhen=   2
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
      End
      Begin VB.Label lbl_SlotSpacing 
         Caption         =   "Slot spacing"
         Height          =   255
         Left            =   0
         TabIndex        =   21
         Top             =   800
         Width           =   1575
      End
      Begin MSForms.ComboBox cbo_SlotSpacing 
         Height          =   315
         Left            =   1680
         TabIndex        =   20
         Top             =   800
         Width           =   2715
         VariousPropertyBits=   679495707
         DisplayStyle    =   7
         Size            =   "4789;556"
         MatchEntry      =   1
         ShowDropButtonWhen=   2
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
      End
   End
   Begin VB.Frame frm_AccGrid 
      BorderStyle     =   0  'None
      Height          =   1215
      Left            =   100
      TabIndex        =   14
      Top             =   4680
      Width           =   4815
      Begin VB.Label lbl_MaxLength 
         Caption         =   "Max. length"
         Height          =   255
         Left            =   0
         TabIndex        =   18
         Top             =   0
         Width           =   1575
      End
      Begin VB.Label lbl_MinLength 
         Caption         =   "Min. length"
         Height          =   255
         Left            =   0
         TabIndex        =   17
         Top             =   400
         Width           =   1575
      End
      Begin MSForms.ComboBox cbo_MaxLength 
         Height          =   315
         Left            =   1680
         TabIndex        =   16
         Top             =   0
         Width           =   2715
         VariousPropertyBits=   679495707
         DisplayStyle    =   7
         Size            =   "4789;556"
         MatchEntry      =   1
         ShowDropButtonWhen=   2
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
      End
      Begin MSForms.ComboBox cbo_MinLength 
         Height          =   315
         Left            =   1680
         TabIndex        =   15
         Top             =   400
         Width           =   2715
         VariousPropertyBits=   679495707
         DisplayStyle    =   7
         Size            =   "4789;556"
         MatchEntry      =   1
         ShowDropButtonWhen=   2
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
      End
   End
   Begin VB.ListBox lst_ToolBox 
      ForeColor       =   &H00000000&
      Height          =   2010
      ItemData        =   "Bi_est_m.frx":0000
      Left            =   1680
      List            =   "Bi_est_m.frx":0002
      TabIndex        =   6
      Top             =   600
      Visible         =   0   'False
      Width           =   1932
   End
   Begin VB.TextBox txt_Desc 
      ForeColor       =   &H00000000&
      Height          =   315
      Left            =   1716
      Locked          =   -1  'True
      TabIndex        =   12
      TabStop         =   0   'False
      Top             =   1260
      Width           =   5300
   End
   Begin VB.TextBox Txt_Code 
      Height          =   315
      Left            =   1716
      TabIndex        =   2
      TabStop         =   0   'False
      Top             =   840
      Width           =   1935
   End
   Begin VB.PictureBox ToolBar 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ClipControls    =   0   'False
      ForeColor       =   &H80000008&
      Height          =   665
      Left            =   0
      ScaleHeight     =   630
      ScaleWidth      =   9780
      TabIndex        =   8
      Top             =   0
      Width           =   9810
      Begin VB.PictureBox pic_ToolBox 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   1680
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   5
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_Quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   2220
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   7
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_Undo 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   600
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   4
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_Save 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            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        =   3
         Top             =   60
         Width           =   480
      End
   End
   Begin MSForms.ComboBox cbo_Type 
      Height          =   315
      Left            =   1716
      TabIndex        =   0
      Top             =   2000
      Width           =   2715
      VariousPropertyBits=   679479323
      DisplayStyle    =   7
      Size            =   "4789;556"
      MatchEntry      =   1
      ShowDropButtonWhen=   2
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
   End
   Begin VB.Label lbl_Desc 
      Caption         =   "Description :"
      Height          =   252
      Left            =   60
      TabIndex        =   13
      Top             =   1300
      Width           =   1575
   End
   Begin VB.Label lbl_type 
      Caption         =   "Grid / Acc. type"
      Height          =   252
      Left            =   60
      TabIndex        =   11
      Top             =   2000
      Width           =   1575
   End
   Begin VB.Label lbl_Measurement 
      Caption         =   "Measurement system"
      Height          =   255
      Left            =   60
      TabIndex        =   10
      Top             =   2700
      Width           =   1575
   End
   Begin MSForms.ComboBox cbo_Measurement 
      Height          =   315
      Left            =   1740
      TabIndex        =   1
      Top             =   2700
      Width           =   2715
      VariousPropertyBits=   679479323
      DisplayStyle    =   7
      Size            =   "4789;556"
      MatchEntry      =   1
      ShowDropButtonWhen=   2
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
   End
   Begin VB.Label lbl_Code 
      Caption         =   "Code"
      Height          =   252
      Left            =   60
      TabIndex        =   9
      Top             =   900
      Width           =   1575
   End
End
Attribute VB_Name = "Bi_Estimate_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' MultiComboBox: The parameter Tag says if the information have been loaded from the Database or not
' Text: The code is not stored in a text object but in a module variable

Public mi_Conc As Integer
Public ms_EGTcode As String
Public ms_MScode As String
Public ms_FirstSlot As String
Public ms_LastSlot As String
Public ms_SlotSpacing As String
Public ms_MaxLength As String
Public ms_MinLength As String

Private Sub cbo_MinLength_DropButtonClick()
Dim ls_req As String
Dim lv_ActualCode

If cbo_MinLength.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_MinLength)
    cbo_MinLength.Clear
            
    ls_req = "EXEC Estimate_Length_cbo 'Min','" & gut_LangLogin.Code & "'"
    
    MCombo_Fill cbo_MinLength, ls_req
    MCombo_CodeSelect(cbo_MinLength) = lv_ActualCode
    
    cbo_MinLength.Tag = LOADED
    MouseOn
End If

End Sub


Private Sub cbo_MaxLength_DropButtonClick()
Dim ls_req As String
Dim lv_ActualCode

If cbo_MaxLength.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_MaxLength)
    cbo_MaxLength.Clear
            
    ls_req = "EXEC Estimate_Length_cbo 'Max','" & gut_LangLogin.Code & "'"
    
    MCombo_Fill cbo_MaxLength, ls_req
    MCombo_CodeSelect(cbo_MaxLength) = lv_ActualCode
    
    cbo_MaxLength.Tag = LOADED
    MouseOn
End If

End Sub


Private Sub cbo_SlotSpacing_DropButtonClick()
Dim ls_req As String
Dim lv_ActualCode

If cbo_SlotSpacing.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_SlotSpacing)
    cbo_SlotSpacing.Clear
            
    ls_req = "EXEC Estimate_Slot_cbo 'Spacing','" & gut_LangLogin.Code & "'"
    
    MCombo_Fill cbo_SlotSpacing, ls_req
    MCombo_CodeSelect(cbo_SlotSpacing) = lv_ActualCode
    
    cbo_SlotSpacing.Tag = LOADED
    MouseOn
End If

End Sub


Private Sub cbo_FirstSlot_DropButtonClick()
Dim ls_req As String
Dim lv_ActualCode

If cbo_FirstSlot.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_FirstSlot)
    cbo_FirstSlot.Clear
            
    ls_req = "EXEC Estimate_Slot_cbo 'First','" & gut_LangLogin.Code & "'"
    
    MCombo_Fill cbo_FirstSlot, ls_req
    MCombo_CodeSelect(cbo_FirstSlot) = lv_ActualCode
    
    cbo_FirstSlot.Tag = LOADED
    MouseOn
End If

End Sub

Private Sub cbo_LastSlot_DropButtonClick()
Dim ls_req As String
Dim lv_ActualCode

If cbo_LastSlot.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_LastSlot)
    cbo_LastSlot.Clear
            
    ls_req = "EXEC Estimate_Slot_cbo 'Last','" & gut_LangLogin.Code & "'"
    
    MCombo_Fill cbo_LastSlot, ls_req
    MCombo_CodeSelect(cbo_LastSlot) = lv_ActualCode
    
    cbo_LastSlot.Tag = LOADED
    MouseOn
End If

End Sub

Private Sub cbo_measurement_DropButtonClick()
Dim ls_req As String
Dim lv_ActualCode

If cbo_measurement.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_measurement)
    cbo_measurement.Clear
            
    ls_req = "EXEC Measurement_system_cbo '" & gut_LangLogin.Code & "'"
    
    MCombo_Fill cbo_measurement, ls_req
    MCombo_CodeSelect(cbo_measurement) = lv_ActualCode
    
    cbo_measurement.Tag = LOADED
    MouseOn
End If

End Sub

Private Sub cbo_Type_DropButtonclick()
Dim ls_req As String
Dim lv_ActualCode

If cbo_Type.Tag = UNLOADED Then
    MouseOff
    
    lv_ActualCode = MCombo_GetCode(cbo_Type)
    cbo_Type.Clear
            
    ls_req = "EXEC Estimate_Gridtype_cbo '" & gs_CGCode & "','" & gut_LangLogin.Code & "'"
    
    MCombo_Fill cbo_Type, ls_req
    MCombo_CodeSelect(cbo_Type) = lv_ActualCode
    
    cbo_Type.Tag = LOADED
    MouseOn
End If

End Sub

Private Sub Form_Click()
    lst_ToolBox.Visible = KO
End Sub

Private Sub Form_Load()

MouseOff
If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharSet Me

'Initialize the pictures
Pic_Save.Picture = LoadResPicture(RES_OK, 1)
Pic_Undo.Picture = LoadResPicture(RES_CANCEL, 1)
Pic_ToolBox.Picture = LoadResPicture(RES_TOOL, 1)
pic_quit.Picture = LoadResPicture(RES_QUIT, 1)

'Initialize the combobox to unloaded status
cbo_Type.Tag = UNLOADED
cbo_measurement.Tag = UNLOADED
cbo_FirstSlot.Tag = UNLOADED
cbo_LastSlot.Tag = UNLOADED
cbo_SlotSpacing.Tag = UNLOADED
cbo_MaxLength.Tag = UNLOADED
cbo_MinLength.Tag = UNLOADED

'Hide frame
Select Case gs_CGCode
Case "C002"
    frm_Grid.Visible = OK
    frm_AccGrid.Visible = KO
Case "C004"
    frm_Grid.Visible = KO
    frm_AccGrid.Visible = OK
    frm_AccGrid.Top = 3360
    frm_AccGrid.Left = 100
End Select


GetCaptions
FillForm
FillToolBox
 
MouseOn

End Sub

Private Sub lst_toolbox_Click()
Dim li_Count As Integer
Dim ls_req As String
Dim ls_codeSOS As String

On Error GoTo suite
If lst_ToolBox.ListIndex = -1 Then Exit Sub
MouseOff
lst_ToolBox.Visible = KO

BeforeToolbox

ls_codeSOS = gs_CGCode
Select Case lst_ToolBox
Case "Grid Type"
    OptGridType
    cbo_Type.ListIndex = -1
    cbo_Type.Tag = UNLOADED
Case "First slot"
    gs_CGCode = "First"
    OptSlot
    cbo_FirstSlot.ListIndex = -1
    cbo_FirstSlot.Tag = UNLOADED
Case "Last slot"
    gs_CGCode = "Last"
    OptSlot
    cbo_LastSlot.ListIndex = -1
    cbo_LastSlot.Tag = UNLOADED
Case "Slot spacing"
    gs_CGCode = "Spacing"
    OptSlot
    cbo_SlotSpacing.ListIndex = -1
    cbo_SlotSpacing.Tag = UNLOADED
Case "Max length"
    gs_CGCode = "Max"
    OptLength
    cbo_MaxLength.ListIndex = -1
    cbo_MaxLength.Tag = UNLOADED
Case "Min length"
    gs_CGCode = "Min"
    OptLength
    cbo_MinLength.ListIndex = -1
    cbo_MinLength.Tag = UNLOADED
End Select
gs_CGCode = ls_codeSOS

AfterToolbox

MouseOn
Exit Sub
    
suite:
    StdError
End Sub

Private Sub pic_quit_Click()
    Unload Me
End Sub

Private Sub pic_Save_Click()
    
MouseOff
UpdateItem
MouseOn
Unload Me

End Sub

Private Sub pic_ToolBox_Click()

If lst_ToolBox.Visible = OK Then
    lst_ToolBox.Visible = KO
Else
    lst_ToolBox.Visible = OK
    lst_ToolBox.ListIndex = -1
    lst_ToolBox.SetFocus
End If

End Sub

Private Sub pic_UnDo_Click()

MouseOff
FillForm
MouseOn

End Sub

Private Sub FillToolBox()
Dim ls_req As String
Dim ll_statement As Long
Dim li_status As Integer
   
On Error GoTo Toolbox_Err

ls_req = "EXEC Estimate_Toolbox_lst"
If SQLSubmit(gl_Environment, gl_Database, ll_statement, ls_req) Then
    li_status = SQL_SUCCESS
Else
    li_status = SQL_ERROR
End If

lst_ToolBox.Clear
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_ToolBox.AddItem ODBCData(ll_statement, 1)
    End If
Loop
li_status = SQLFreeStatement(ll_statement, SQL_DROP)
Exit Sub
    
Toolbox_Err:
    li_status = SQLFreeStatement(ll_statement, SQL_DROP)
    StdError
End Sub

Private Sub FillForm()

Txt_Code = gs_SAPCode
txt_Desc = BI_Estimate.txt_Desc
MCombo_AddItemCode cbo_Type, ms_EGTcode, BI_Estimate.txt_Type
MCombo_AddItemCode cbo_Measurement, ms_MScode, BI_Estimate.txt_Measurement
MCombo_AddItemCode cbo_FirstSlot, ms_FirstSlot, BI_Estimate.txt_FirstSlot
MCombo_AddItemCode cbo_LastSlot, ms_LastSlot, BI_Estimate.txt_LastSlot
MCombo_AddItemCode cbo_SlotSpacing, ms_SlotSpacing, BI_Estimate.txt_SlotSpacing
MCombo_AddItemCode cbo_MaxLength, ms_MaxLength, BI_Estimate.txt_MaxLength
MCombo_AddItemCode cbo_MinLength, ms_MinLength, BI_Estimate.txt_MinLength

End Sub

Private Sub GetCaptions()

lbl_Code = BI_Estimate.lbl_SAP
lbl_Desc = BI_Estimate.lbl_Desc
lbl_Type = BI_Estimate.lbl_Type
lbl_Measurement = BI_Estimate.lbl_Measurement
lbl_FirstSlot = BI_Estimate.lbl_FirstSlot
lbl_LastSlot = BI_Estimate.lbl_LastSlot
lbl_SlotSpacing = BI_Estimate.lbl_SlotSpacing
lbl_MaxLength = BI_Estimate.lbl_MaxLength
lbl_MinLength = BI_Estimate.lbl_MinLength

End Sub
Private Function UpdateItem() As Boolean
Dim ls_req As String
Dim ll_statement As Long
Dim ll_Lngrows As Long
Dim li_status As Integer

On Error GoTo UpdEstimate_Err
UpdateItem = KO
gb_Return = KO

ls_req = "exec estimate_upd '" & gs_SAPCode & "'"

If cbo_Type.ListIndex <> -1 And cbo_Type.Value <> "" Then
    ls_req = ls_req & ",'" & MCombo_GetCode(cbo_Type) & "'"
Else
    ls_req = ls_req & ",NULL"
End If
If cbo_measurement.ListIndex <> -1 And cbo_measurement.Value <> "" Then
    ls_req = ls_req & ",'" & MCombo_GetCode(cbo_measurement) & "'"
Else
    ls_req = ls_req & ",NULL"
End If
If cbo_FirstSlot.ListIndex <> -1 And cbo_FirstSlot.Value <> "" Then
    ls_req = ls_req & ",'" & MCombo_GetCode(cbo_FirstSlot) & "'"
Else
    ls_req = ls_req & ",NULL"
End If
If cbo_LastSlot.ListIndex <> -1 And cbo_LastSlot.Value <> "" Then
    ls_req = ls_req & ",'" & MCombo_GetCode(cbo_LastSlot) & "'"
Else
    ls_req = ls_req & ",NULL"
End If
If cbo_SlotSpacing.ListIndex <> -1 And cbo_SlotSpacing.Value <> "" Then
    ls_req = ls_req & ",'" & MCombo_GetCode(cbo_SlotSpacing) & "'"
Else
    ls_req = ls_req & ",NULL"
End If
If cbo_MaxLength.ListIndex <> -1 And cbo_MaxLength.Value <> "" Then
    ls_req = ls_req & ",'" & MCombo_GetCode(cbo_MaxLength) & "'"
Else
    ls_req = ls_req & ",NULL"
End If
If cbo_MinLength.ListIndex <> -1 And cbo_MinLength.Value <> "" Then
    ls_req = ls_req & ",'" & MCombo_GetCode(cbo_MinLength) & "'"
Else
    ls_req = ls_req & ",NULL"
End If
ls_req = ls_req & "," & mi_Conc

If SQLSubmit(gl_Environment, gl_Database, ll_statement, ls_req) Then
    li_status = SQLRowCount(ll_statement, ll_Lngrows)
    li_status = SQLFreeStatement(ll_statement, SQL_DROP)
    If ll_Lngrows = 0 Then
        SendMessage 2, "Update failed", gut_LangLogin.Code
    Else
        UpdateItem = OK
        gb_Return = OK
    End If
Else
    li_status = SQLFreeStatement(ll_statement, SQL_DROP)
    SendMessage 2, "Update failed", gut_LangLogin.Code
End If
Exit Function
    
UpdEstimate_Err:
    SQLFreeStatement ll_statement, SQL_DROP
End Function
