VERSION 5.00
Begin VB.Form BI_Estimate 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   7725
   ClientLeft      =   1050
   ClientTop       =   1335
   ClientWidth     =   8625
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   7725
   ScaleWidth      =   8625
   ShowInTaskbar   =   0   'False
   Begin VB.Frame frm_AccGrid 
      BorderStyle     =   0  'None
      Height          =   1335
      Left            =   100
      TabIndex        =   22
      Top             =   3360
      Width           =   4695
      Begin VB.TextBox txt_MinLength 
         ForeColor       =   &H00000000&
         Height          =   315
         Left            =   1716
         Locked          =   -1  'True
         TabIndex        =   24
         TabStop         =   0   'False
         Top             =   405
         Width           =   2000
      End
      Begin VB.TextBox txt_MaxLength 
         ForeColor       =   &H00000000&
         Height          =   315
         Left            =   1716
         Locked          =   -1  'True
         TabIndex        =   23
         TabStop         =   0   'False
         Top             =   0
         Width           =   2000
      End
      Begin VB.Label lbl_MinLength 
         Caption         =   "Min. length :"
         Height          =   255
         Left            =   0
         TabIndex        =   26
         Top             =   465
         Width           =   1575
      End
      Begin VB.Label lbl_MaxLength 
         Caption         =   "Max. length :"
         Height          =   255
         Left            =   0
         TabIndex        =   25
         Top             =   60
         Width           =   1575
      End
   End
   Begin VB.Frame frm_Grid 
      BorderStyle     =   0  'None
      Height          =   1335
      Left            =   100
      TabIndex        =   15
      Top             =   1750
      Width           =   4695
      Begin VB.TextBox txt_LastSlot 
         ForeColor       =   &H00000000&
         Height          =   315
         Left            =   1716
         Locked          =   -1  'True
         TabIndex        =   18
         TabStop         =   0   'False
         Top             =   420
         Width           =   2000
      End
      Begin VB.TextBox txt_FirstSlot 
         ForeColor       =   &H00000000&
         Height          =   315
         Left            =   1716
         Locked          =   -1  'True
         TabIndex        =   17
         TabStop         =   0   'False
         Top             =   0
         Width           =   2000
      End
      Begin VB.TextBox txt_SlotSpacing 
         ForeColor       =   &H00000000&
         Height          =   315
         Left            =   1716
         Locked          =   -1  'True
         TabIndex        =   16
         TabStop         =   0   'False
         Top             =   795
         Width           =   2000
      End
      Begin VB.Label lbl_FirstSlot 
         Caption         =   "First slot :"
         Height          =   255
         Left            =   0
         TabIndex        =   21
         Top             =   60
         Width           =   1575
      End
      Begin VB.Label lbl_LastSlot 
         Caption         =   "Last slot :"
         Height          =   255
         Left            =   0
         TabIndex        =   20
         Top             =   465
         Width           =   1575
      End
      Begin VB.Label lbl_SlotSpacing 
         Caption         =   "Slot spacing :"
         Height          =   255
         Left            =   0
         TabIndex        =   19
         Top             =   855
         Width           =   1575
      End
   End
   Begin VB.TextBox txt_Desc 
      ForeColor       =   &H00000000&
      Height          =   315
      Left            =   1836
      Locked          =   -1  'True
      TabIndex        =   13
      TabStop         =   0   'False
      Top             =   540
      Width           =   5300
   End
   Begin VB.PictureBox pic_pics 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ClipControls    =   0   'False
      ForeColor       =   &H80000008&
      Height          =   4800
      Left            =   7920
      ScaleHeight     =   4770
      ScaleWidth      =   630
      TabIndex        =   6
      Top             =   2880
      Width           =   665
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_est.frx":0000
         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        =   12
         TabStop         =   0   'False
         Top             =   3000
         Width           =   480
      End
      Begin VB.PictureBox pic_upd 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_est.frx":030A
         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        =   11
         TabStop         =   0   'False
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_Print 
         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            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   10
         TabStop         =   0   'False
         Top             =   1200
         Width           =   480
      End
      Begin VB.PictureBox pic_Log 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_est.frx":0614
         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        =   9
         TabStop         =   0   'False
         Top             =   1800
         Width           =   480
      End
      Begin VB.PictureBox pic_refresh 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   8
         TabStop         =   0   'False
         Top             =   2400
         Width           =   480
      End
      Begin VB.PictureBox pic_help 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_est.frx":091E
         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        =   7
         TabStop         =   0   'False
         Top             =   3600
         Width           =   480
      End
   End
   Begin VB.TextBox txt_Measurement 
      ForeColor       =   &H00000000&
      Height          =   315
      Left            =   1836
      Locked          =   -1  'True
      TabIndex        =   1
      TabStop         =   0   'False
      Top             =   1335
      Width           =   2000
   End
   Begin VB.TextBox txt_Type 
      ForeColor       =   &H00000000&
      Height          =   315
      Left            =   1836
      Locked          =   -1  'True
      TabIndex        =   0
      TabStop         =   0   'False
      Text            =   " "
      Top             =   945
      Width           =   2892
   End
   Begin VB.TextBox txt_SAP 
      ForeColor       =   &H00000000&
      Height          =   315
      Left            =   1836
      Locked          =   -1  'True
      TabIndex        =   5
      TabStop         =   0   'False
      Top             =   140
      Width           =   1092
   End
   Begin VB.Label lbl_Desc 
      Caption         =   "Description :"
      Height          =   252
      Left            =   120
      TabIndex        =   14
      Top             =   600
      Width           =   1575
   End
   Begin VB.Label lbl_SAP 
      Caption         =   "SAP Code :"
      Height          =   252
      Left            =   120
      TabIndex        =   4
      Top             =   200
      Width           =   1575
   End
   Begin VB.Label lbl_Measurement 
      Caption         =   "Measurement system :"
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   1395
      Width           =   1575
   End
   Begin VB.Label lbl_Type 
      Caption         =   "Grid / Accessory type"
      Height          =   255
      Left            =   120
      TabIndex        =   2
      Top             =   1005
      Width           =   1575
   End
End
Attribute VB_Name = "BI_Estimate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim mb_DelVisible As Boolean
Dim mb_Perm As Boolean
Dim mb_Led As Boolean
Dim mi_Concurr As Integer

Private Function Control() As Boolean
Dim i As Integer

Control = KO
Control = OK

End Function

Private Sub Form_Load()
MouseOff

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

pic_help.Picture = LoadResPicture(RES_HELP, 1)
pic_log.Picture = LoadResPicture(RES_LOG, 1)
pic_Print.Picture = LoadResPicture(RES_PRINT, 1)
pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_refresh.Picture = LoadResPicture(RES_REFRESH, 1)
pic_upd.Picture = LoadResPicture(RES_MODIFY, 1)
Top = 1580 + frmMain.Top
Left = 3280 + frmMain.Left
Width = 8650
Height = 7750
FillCsts
FillForm
Permission
pic_log.Visible = KO

'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 = 1750
    frm_AccGrid.Left = 100
End Select

MouseOn
End Sub

Private Sub FillCsts()
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 FillCsts_Err

ls_req = "EXEC Screen_Csts 'm_Estimate','" & 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 LCase(ls_Field)
        Case "lbl_sap": lbl_SAP = ls_Text
        Case "lbl_desc": lbl_Desc = ls_Text
        Case "lbl_type": lbl_type = ls_Text
        Case "lbl_measurement": lbl_Measurement = ls_Text
        Case "lbl_firstslot": lbl_FirstSlot = ls_Text
        Case "lbl_lastslot": lbl_LastSlot = ls_Text
        Case "lbl_slotspacing": lbl_SlotSpacing = ls_Text
        Case "lbl_maxlength": lbl_MaxLength = ls_Text
        Case "lbl_minlength": lbl_MinLength = ls_Text
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub
    
FillCsts_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub
Private Sub FillForm()
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 FillCsts_Err
    
ls_req = "EXEC Estimate_t_lst '" & gs_SAPCode & "','" & 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
        txt_SAP = gs_SAPCode
        txt_Desc = ODBCData(ll_Statement, 1)
        Bi_Estimate_mtnc.mi_Conc = ODBCData(ll_Statement, 2)
        Bi_Estimate_mtnc.ms_EGTcode = ODBCData(ll_Statement, 3)
        txt_Type = ODBCData(ll_Statement, 4)
        Bi_Estimate_mtnc.ms_MScode = ODBCData(ll_Statement, 5)
        txt_Measurement = ODBCData(ll_Statement, 6)
        Bi_Estimate_mtnc.ms_FirstSlot = ODBCData(ll_Statement, 7)
        txt_FirstSlot = ODBCData(ll_Statement, 8)
        Bi_Estimate_mtnc.ms_LastSlot = ODBCData(ll_Statement, 9)
        txt_LastSlot = ODBCData(ll_Statement, 10)
        Bi_Estimate_mtnc.ms_SlotSpacing = ODBCData(ll_Statement, 11)
        txt_SlotSpacing = ODBCData(ll_Statement, 12)
        Bi_Estimate_mtnc.ms_MaxLength = ODBCData(ll_Statement, 13)
        txt_MaxLength = ODBCData(ll_Statement, 14)
        Bi_Estimate_mtnc.ms_MinLength = ODBCData(ll_Statement, 15)
        txt_MinLength = ODBCData(ll_Statement, 16)
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub
    
FillCsts_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub

Private Sub Permission()
Dim ls_Perm As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_req As String
Dim ll_lngrows As Long

On Error GoTo Permission_Err
    
ls_req = "EXEC Check_Security Estimate " & ", " & prg.LoginName
pic_upd.Visible = KO
mb_Perm = KO

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_Perm = ODBCData(ll_Statement, 1)
        If ls_Perm = "Update" Then
            pic_upd.Visible = OK
        End If
    End If
Loop

ls_req = "EXEC Estimate_Category_sel '" & gs_CGCode & "'"
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
            pic_upd.Visible = KO
    End If
Else
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    pic_upd.Visible = KO
End If


DoEvents
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub
    
Permission_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub

Private Sub pic_help_Click()

MouseOff
gs_TableName = "Base_Item"
frm_help.show 1
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

MouseOff
InitPrinter 1

'title
Printer.Font.Italic = 0
SetBold -1
SetFontSize 12
Printer.Print Date;
Printer.Print " - ";
Printer.Print Time
SetFontSize 36
Printer.Print "Armstrong Ceiling Solutions"
SetFontSize 24
Printer.Print BaseItem_main.Caption & " - " & BaseItem_main.cmd_Estimate.Caption
SetFontSize 12
Printer.Print Tab(100 - 5);
Printer.Print Printer.Page
Printer.Print ""
SetFontSize 18
Printer.Print ""
SetFontSize 12
Printer.Print ""
        
'fields
PrintField lbl_SAP, txt_SAP
PrintField lbl_Desc, txt_Desc
PrintField lbl_type, txt_Type
PrintField lbl_Measurement, txt_Measurement
PrintField lbl_FirstSlot, txt_FirstSlot
PrintField lbl_LastSlot, txt_LastSlot
PrintField lbl_SlotSpacing, txt_SlotSpacing
PrintField lbl_MaxLength, txt_MaxLength
PrintField lbl_MinLength, txt_MinLength

Printer.EndDoc

'ExPrintGrid 1, 10, "ARMSTRONG", BaseItem_main.Caption, ""
Printer.EndDoc
MouseOn

End Sub

Private Sub pic_quit_Click()

MouseOff
Unload Me
MouseOn

End Sub

Private Sub pic_refresh_Click()

MouseOff
FillForm
MouseOn

End Sub

Private Sub pic_upd_Click()

MouseOff
gs_Action = "upd"
gb_Return = KO
Bi_Estimate_mtnc.show 1
If gb_Return Then FillForm
MouseOn

End Sub
