VERSION 5.00
Begin VB.UserControl SOM_Quote 
   ClientHeight    =   10005
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   15090
   ScaleHeight     =   10005
   ScaleWidth      =   15090
   Begin VB.Frame fra_invalidate 
      Height          =   2265
      Left            =   3180
      TabIndex        =   145
      Top             =   5910
      Width           =   7425
      Begin VB.CommandButton btn_OK 
         Caption         =   "OK"
         Height          =   615
         Left            =   3000
         Style           =   1  'Graphical
         TabIndex        =   147
         Top             =   1410
         Width           =   1395
      End
      Begin VB.Label lbl_info 
         Alignment       =   2  'Center
         Caption         =   "#The data has been modified and became invalide. This screen will be closed."
         Height          =   825
         Left            =   240
         TabIndex        =   146
         Top             =   450
         Width           =   6975
      End
   End
   Begin VB.TextBox txt_ProjNumber 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   10770
      TabIndex        =   144
      Tag             =   "ProjectNumber®©Text"
      Text            =   "ProjectNumber®©Text"
      Top             =   0
      Width           =   2055
   End
   Begin VB.TextBox txt_TOT_SS_desc 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   90
      TabIndex        =   143
      Tag             =   "TOT_SS_desc®©Text"
      Text            =   "TOT_SS_desc®©Text"
      Top             =   2130
      Width           =   1845
   End
   Begin VB.TextBox txt_TOT_area 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   10770
      TabIndex        =   142
      Tag             =   "TOT_Quote_Area®©Text"
      Text            =   "TOT_Quote_Area®©Text"
      Top             =   2070
      Width           =   2115
   End
   Begin VB.TextBox txt_TOT_UM 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   12930
      TabIndex        =   141
      Tag             =   "TOT_UM_System®©Text"
      Text            =   "TOT_UM_System®©Text"
      Top             =   2070
      Width           =   2115
   End
   Begin VB.TextBox txt_QuoteRef 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   12960
      TabIndex        =   140
      Tag             =   "Quote_Ref®©Text"
      Text            =   "Quote_Ref®©Text"
      Top             =   0
      Width           =   1575
   End
   Begin VB.TextBox txt_FreightCostCHF 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   3090
      TabIndex        =   139
      Tag             =   "Quote_FRGHTCost_CHF®©Text"
      Text            =   "Quote_FRGHTCost_CHF®©Text"
      Top             =   4650
      Width           =   2505
   End
   Begin VB.TextBox txt_Status 
      ForeColor       =   &H000000FF&
      Height          =   285
      Left            =   8040
      TabIndex        =   138
      Tag             =   "Status®©Text"
      Text            =   "Status®©Text"
      Top             =   720
      Width           =   2295
   End
   Begin VB.Frame fra_ModifInfo 
      BorderStyle     =   0  'None
      Height          =   375
      Left            =   30
      TabIndex        =   133
      Top             =   9570
      Width           =   15030
      Begin VB.TextBox txt_CreationDate 
         Alignment       =   2  'Center
         BackColor       =   &H8000000F&
         Height          =   330
         Left            =   1590
         Locked          =   -1  'True
         TabIndex        =   63
         Tag             =   "Z_creation®©Text"
         Text            =   "Text1"
         Top             =   0
         Width           =   1095
      End
      Begin VB.TextBox txt_Creator 
         Alignment       =   2  'Center
         BackColor       =   &H8000000F&
         Height          =   330
         Left            =   3255
         Locked          =   -1  'True
         TabIndex        =   64
         Tag             =   "U_login_creator®©Text"
         Text            =   "Text1"
         Top             =   0
         Width           =   1995
      End
      Begin VB.TextBox txt_LastUpdDate 
         Alignment       =   2  'Center
         BackColor       =   &H8000000F&
         Height          =   330
         Left            =   10140
         Locked          =   -1  'True
         TabIndex        =   65
         Tag             =   "Z_last_upd®©Text"
         Text            =   "Text1"
         Top             =   0
         Width           =   1095
      End
      Begin VB.TextBox txt_UpdUser 
         Alignment       =   2  'Center
         BackColor       =   &H8000000F&
         Height          =   330
         Left            =   11850
         Locked          =   -1  'True
         TabIndex        =   66
         Tag             =   "U_login_lastupd®©Text"
         Text            =   "Text1"
         Top             =   0
         Width           =   1995
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#By"
         Height          =   240
         Index           =   58
         Left            =   11400
         TabIndex        =   137
         Tag             =   "lbl_UpdUserBy"
         Top             =   45
         Width           =   375
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Last Updated"
         Height          =   240
         Index           =   53
         Left            =   8880
         TabIndex        =   136
         Tag             =   "lbl_LastUpdateDate"
         Top             =   45
         Width           =   1185
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#By"
         Height          =   240
         Index           =   52
         Left            =   2760
         TabIndex        =   135
         Tag             =   "lbl_CreatorBy"
         Top             =   45
         Width           =   420
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Date Entered"
         Height          =   240
         Index           =   37
         Left            =   420
         TabIndex        =   134
         Tag             =   "lbl_CreationDate"
         Top             =   45
         Width           =   1095
      End
   End
   Begin VB.TextBox txt_LinkID 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   7215
      TabIndex        =   68
      Tag             =   "ProjCustLink_ID®©Text"
      Text            =   "ProjCustLink_ID®©Text"
      Top             =   1095
      Width           =   2055
   End
   Begin VB.Frame fra_Customer 
      Appearance      =   0  'Flat
      ForeColor       =   &H80000008&
      Height          =   1695
      Left            =   30
      TabIndex        =   124
      Top             =   7860
      Width           =   15045
      Begin VB.TextBox txt_custSales 
         Height          =   285
         Left            =   11280
         TabIndex        =   148
         Tag             =   "Cust_SSR_Desc®©Text"
         Text            =   "Cust_SSR_Desc®©Text"
         Top             =   450
         Width           =   3645
      End
      Begin VB.TextBox txt_CustTown 
         Height          =   285
         Left            =   1620
         MaxLength       =   80
         TabIndex        =   57
         Tag             =   "Cust_town®©Text"
         Text            =   "Cust_town®©Text"
         Top             =   1050
         Width           =   7515
      End
      Begin VB.TextBox txt_Cust_addr2 
         Height          =   285
         Left            =   1620
         MaxLength       =   80
         TabIndex        =   56
         Tag             =   "Cust_addr2®©Text"
         Text            =   "Cust_addr2®©Text"
         Top             =   750
         Width           =   7515
      End
      Begin VB.TextBox txt_CustName 
         Height          =   285
         Left            =   1620
         MaxLength       =   80
         TabIndex        =   54
         Tag             =   "Cust_name®©Text"
         Text            =   "Cust_name®©Text"
         Top             =   150
         Width           =   7515
      End
      Begin VB.TextBox txt_CustAddr1 
         Height          =   285
         Left            =   1620
         MaxLength       =   80
         TabIndex        =   55
         Tag             =   "Cust_addr1®©Text"
         Text            =   "Cust_addr1®©Text"
         Top             =   450
         Width           =   7515
      End
      Begin VB.TextBox txt_CustZip 
         Height          =   285
         Left            =   1620
         MaxLength       =   15
         TabIndex        =   58
         Tag             =   "Cust_zip®©Text"
         Text            =   "Cust_zip®©Text"
         Top             =   1350
         Width           =   1515
      End
      Begin VB.TextBox txt_CustCountry 
         Height          =   285
         Index           =   12
         Left            =   3150
         MaxLength       =   80
         TabIndex        =   59
         Tag             =   "CustCT_desc®©Text"
         Text            =   "CustCT_desc®©Text"
         Top             =   1350
         Width           =   5985
      End
      Begin VB.TextBox txt_CustType 
         Height          =   285
         Left            =   11280
         MaxLength       =   80
         TabIndex        =   60
         Tag             =   "SCT_desc®©Text"
         Text            =   "SCT_desc®©Text"
         Top             =   150
         Width           =   3645
      End
      Begin VB.TextBox txt_CustTel 
         Height          =   285
         Left            =   11280
         MaxLength       =   20
         TabIndex        =   61
         Tag             =   "Cust_tel®©Text"
         Text            =   "Cust_tel®©Text"
         Top             =   1050
         Width           =   2175
      End
      Begin VB.TextBox txt_CustFax 
         Height          =   285
         Left            =   11280
         MaxLength       =   20
         TabIndex        =   62
         Tag             =   "Cust_fax®©Text"
         Text            =   "Cust_fax®©Text"
         Top             =   1350
         Width           =   2175
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Sales Person"
         Height          =   225
         Index           =   59
         Left            =   9210
         TabIndex        =   149
         Tag             =   "lbl_SalesPerson"
         Top             =   510
         Width           =   2025
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Town"
         Height          =   225
         Index           =   51
         Left            =   90
         TabIndex        =   132
         Tag             =   "lbl_CustTown"
         Top             =   1110
         Width           =   1485
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Customer"
         Height          =   225
         Index           =   57
         Left            =   90
         TabIndex        =   130
         Tag             =   "lbl_CustomerName"
         Top             =   210
         Width           =   1485
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Address"
         Height          =   225
         Index           =   56
         Left            =   90
         TabIndex        =   129
         Tag             =   "lbl_CustAddress"
         Top             =   510
         Width           =   1485
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#ZipCode"
         Height          =   225
         Index           =   55
         Left            =   90
         TabIndex        =   128
         Tag             =   "lbl_CustZipCode"
         Top             =   1410
         Width           =   1485
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Type"
         Height          =   225
         Index           =   54
         Left            =   9210
         TabIndex        =   127
         Tag             =   "lbl_CustType"
         Top             =   210
         Width           =   2025
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Telephone"
         Height          =   225
         Index           =   50
         Left            =   9210
         TabIndex        =   126
         Tag             =   "lbl_CustTel"
         Top             =   1110
         Width           =   2025
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Fax"
         Height          =   225
         Index           =   49
         Left            =   9210
         TabIndex        =   125
         Tag             =   "lbl_CustFax"
         Top             =   1410
         Width           =   2025
      End
   End
   Begin VB.Frame fra_project 
      Appearance      =   0  'Flat
      ForeColor       =   &H80000008&
      Height          =   1695
      Left            =   30
      TabIndex        =   112
      Top             =   6150
      Width           =   15045
      Begin VB.TextBox txt_projTown 
         Height          =   285
         Left            =   1590
         MaxLength       =   80
         TabIndex        =   43
         Tag             =   "Proj_Town®©Text"
         Text            =   "Proj_Town®©Text"
         Top             =   750
         Width           =   7515
      End
      Begin VB.TextBox txt_projduration 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   11280
         TabIndex        =   48
         Tag             =   "Proj_duration®©Num®©0"
         Text            =   "Proj_duration®©Num®©0"
         Top             =   1350
         Width           =   1065
      End
      Begin VB.TextBox txt_ProjExporderdate 
         Height          =   285
         Left            =   6930
         MaxLength       =   50
         TabIndex        =   47
         Tag             =   "Proj_Exporderdate®©Text"
         Text            =   "Proj_Exporderdate®©Text"
         Top             =   1350
         Width           =   2175
      End
      Begin VB.TextBox txt_projFollowup 
         Height          =   285
         Left            =   2100
         MaxLength       =   50
         TabIndex        =   46
         Tag             =   "Proj_Followupdate®©Text"
         Text            =   "Proj_Followupdate®©Text"
         Top             =   1350
         Width           =   2175
      End
      Begin VB.TextBox txt_projMKS 
         Height          =   285
         Left            =   11280
         TabIndex        =   53
         Tag             =   "MKS_desc®©Text"
         Text            =   "MKS_desc®©Text"
         Top             =   1050
         Width           =   3645
      End
      Begin VB.TextBox txt_projUM 
         Height          =   285
         Left            =   13260
         TabIndex        =   52
         Tag             =   "UM_Code®©Text"
         Text            =   "UM_Code®©Text"
         Top             =   750
         Width           =   1665
      End
      Begin VB.TextBox txt_projSize 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   11280
         TabIndex        =   51
         Tag             =   "Proj_Size®©Num®©0"
         Text            =   "Proj_Size®©Num®©0"
         Top             =   750
         Width           =   1965
      End
      Begin VB.TextBox txt_ProjStatus 
         Height          =   285
         Left            =   11280
         TabIndex        =   50
         Tag             =   "PS_desc®©Text"
         Text            =   "PS_desc®©Text"
         Top             =   450
         Width           =   3645
      End
      Begin VB.TextBox txt_projSales 
         Height          =   285
         Left            =   11280
         TabIndex        =   49
         Tag             =   "Proj_SSR_Desc®©Text"
         Text            =   "Proj_SSR_Desc®©Text"
         Top             =   150
         Width           =   3645
      End
      Begin VB.TextBox txt_projCountry 
         Height          =   285
         Left            =   3120
         MaxLength       =   80
         TabIndex        =   45
         Tag             =   "ProjCT_desc®©Text"
         Text            =   "ProjCT_desc®©Text"
         Top             =   1050
         Width           =   5985
      End
      Begin VB.TextBox txt_projZip 
         Height          =   285
         Left            =   1590
         MaxLength       =   15
         TabIndex        =   44
         Tag             =   "Proj_Zip®©Text"
         Text            =   "Proj_Zip®©Text"
         Top             =   1050
         Width           =   1515
      End
      Begin VB.TextBox txt_projaddr1 
         Height          =   285
         Left            =   1590
         MaxLength       =   80
         TabIndex        =   42
         Tag             =   "Proj_Addr1®©Text"
         Text            =   "Proj_Addr1®©Text"
         Top             =   450
         Width           =   7515
      End
      Begin VB.TextBox txt_project 
         Height          =   285
         Left            =   1590
         MaxLength       =   80
         TabIndex        =   41
         Tag             =   "Proj_Name®©Text"
         Text            =   "Proj_Name®©Text"
         Top             =   150
         Width           =   7515
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Town"
         Height          =   225
         Index           =   48
         Left            =   90
         TabIndex        =   131
         Tag             =   "lbl_ProjTown"
         Top             =   810
         Width           =   1455
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Weeks"
         Height          =   225
         Index           =   47
         Left            =   12390
         TabIndex        =   123
         Tag             =   "lbl_ProjectWeeks"
         Top             =   1410
         Width           =   975
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Duration"
         Height          =   225
         Index           =   46
         Left            =   9150
         TabIndex        =   122
         Tag             =   "lbl_ProjectDuration"
         Top             =   1410
         Width           =   2085
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Exp order date"
         Height          =   225
         Index           =   45
         Left            =   4380
         TabIndex        =   121
         Tag             =   "lbl_ExpOrder"
         Top             =   1410
         Width           =   2475
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Follow up date"
         Height          =   225
         Index           =   44
         Left            =   90
         TabIndex        =   120
         Tag             =   "lbl_FollowUp"
         Top             =   1410
         Width           =   1965
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Mkt Segment"
         Height          =   225
         Index           =   43
         Left            =   9150
         TabIndex        =   119
         Tag             =   "lbl_MktSegment"
         Top             =   1110
         Width           =   2085
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Size"
         Height          =   225
         Index           =   42
         Left            =   9150
         TabIndex        =   118
         Tag             =   "lbl_Size"
         Top             =   810
         Width           =   2085
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Status"
         Height          =   225
         Index           =   41
         Left            =   9150
         TabIndex        =   117
         Tag             =   "lbl_ProjStatus"
         Top             =   510
         Width           =   2085
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Sales Person"
         Height          =   225
         Index           =   40
         Left            =   9150
         TabIndex        =   116
         Tag             =   "lbl_SalesPerson"
         Top             =   210
         Width           =   2085
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#ZipCode"
         Height          =   225
         Index           =   39
         Left            =   90
         TabIndex        =   115
         Tag             =   "lbl_ProjZipCode"
         Top             =   1110
         Width           =   1455
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Address"
         Height          =   225
         Index           =   38
         Left            =   90
         TabIndex        =   114
         Tag             =   "lbl_ProjAddress"
         Top             =   510
         Width           =   1455
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Project"
         Height          =   225
         Index           =   36
         Left            =   90
         TabIndex        =   113
         Tag             =   "lbl_ProjectName"
         Top             =   210
         Width           =   1455
      End
   End
   Begin VB.TextBox txt_FreightCost 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   4170
      MaxLength       =   11
      TabIndex        =   36
      Tag             =   "Quote_FRGHTCostLC®©Num®©0"
      Text            =   "99,999,999"
      Top             =   5160
      Width           =   1215
   End
   Begin VB.TextBox txt_comment 
      Height          =   615
      Left            =   1410
      MaxLength       =   5000
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   40
      Tag             =   "Quote_Comment®©Text"
      Text            =   "SOM_Quote.ctx":0000
      Top             =   5490
      Width           =   13665
   End
   Begin Project1.A_calocx cal_ValidUntil 
      Height          =   345
      Left            =   1170
      TabIndex        =   35
      Tag             =   "Quote_ValidToDate"
      Top             =   5100
      Width           =   1845
      _ExtentX        =   3254
      _ExtentY        =   609
   End
   Begin VB.Frame fra_TOT 
      Appearance      =   0  'Flat
      Caption         =   "#Total"
      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          =   495
      Left            =   30
      TabIndex        =   102
      Tag             =   "fra_TOT"
      Top             =   4560
      Width           =   15045
      Begin VB.TextBox txt_TOT_ValueLC 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   2580
         TabIndex        =   153
         Tag             =   "TOT_Quote_Value_LC®©Num®©0"
         Text            =   "TOT_Quote_Value_LC®©Num®©0"
         Top             =   150
         Width           =   1065
      End
      Begin VB.TextBox txt_TOT_DB 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   4860
         TabIndex        =   32
         Tag             =   "TOT_Quote_DB®©Num®©0"
         Text            =   "TOT_Quote_DB®©Num®©0"
         Top             =   150
         Width           =   795
      End
      Begin VB.TextBox txt_TOT_ValueCHF 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   7680
         TabIndex        =   33
         Tag             =   "TOT_Quote_Value_CHF®©Num®©0"
         Text            =   "TOT_Quote_Value_CHF®©Num®©0"
         Top             =   120
         Width           =   2475
      End
      Begin VB.TextBox txt_TOT_PrimeMarg 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   12180
         TabIndex        =   34
         Tag             =   "TOT_Quote_PrimeMargin®©Num®©0.00"
         Text            =   "TOT_Quote_PrimeMargin®©Num®©0.00"
         Top             =   150
         Width           =   2475
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Total value quotation currency"
         Height          =   225
         Index           =   61
         Left            =   90
         TabIndex        =   152
         Tag             =   "lbl_CUS_ValueLC"
         Top             =   210
         Width           =   2445
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#DB %"
         Height          =   225
         Index           =   29
         Left            =   3720
         TabIndex        =   105
         Tag             =   "lbl_TOT_DB"
         Top             =   210
         Width           =   1095
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Value CHF"
         Height          =   225
         Index           =   28
         Left            =   5580
         TabIndex        =   104
         Tag             =   "lbl_TOT_ValueCHF"
         Top             =   210
         Width           =   2055
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Prime margin"
         Height          =   225
         Index           =   27
         Left            =   10230
         TabIndex        =   103
         Tag             =   "lbl_TOT_PrimeMargin"
         Top             =   210
         Width           =   1905
      End
   End
   Begin VB.Frame fra_CUS 
      Appearance      =   0  'Flat
      Caption         =   "#Custom"
      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          =   855
      Left            =   30
      TabIndex        =   94
      Tag             =   "fra_CUS"
      Top             =   3690
      Width           =   15045
      Begin VB.TextBox txt_CUS_PrimeMarg 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   12180
         TabIndex        =   31
         Tag             =   "CUS_Quote_PrimeMargin®©Num®©0.00"
         Text            =   "CUS_Quote_PrimeMargin®©Num®©0.00"
         Top             =   510
         Width           =   2475
      End
      Begin VB.TextBox txt_CUS_ValueCHF 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   7680
         TabIndex        =   30
         Tag             =   "CUS_Quote_Value_CHF®©Num®©0"
         Text            =   "CUS_Quote_Value_CHF®©Num®©0"
         Top             =   510
         Width           =   2475
      End
      Begin VB.TextBox txt_CUS_DB 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   4860
         MaxLength       =   8
         TabIndex        =   29
         Tag             =   "CUS_Quote_DB®©Num®©0"
         Text            =   "1000"
         Top             =   540
         Width           =   795
      End
      Begin VB.TextBox txt_CUS_ValueLC 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   2580
         MaxLength       =   10
         TabIndex        =   28
         Tag             =   "CUS_Quote_ValueLC®©Num®©0"
         Text            =   "99,999,999"
         Top             =   510
         Width           =   1065
      End
      Begin VB.TextBox txt_CUS_Area 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   6150
         MaxLength       =   9
         TabIndex        =   26
         Tag             =   "CUS_Quote_Area®©Num®©0"
         Text            =   "9,999,999"
         Top             =   210
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_CUS_System 
         Height          =   345
         Left            =   2580
         TabIndex        =   25
         Tag             =   "CUS_SS_code"
         Top             =   150
         Width           =   2505
         _ExtentX        =   4419
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_CUS_UM 
         Height          =   345
         Left            =   8250
         TabIndex        =   27
         Tag             =   "CUS_UM_code"
         Top             =   150
         Width           =   2475
         _ExtentX        =   4366
         _ExtentY        =   609
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Prime margin"
         Height          =   225
         Index           =   26
         Left            =   10230
         TabIndex        =   101
         Tag             =   "lbl_CUS_PrimeMargin"
         Top             =   570
         Width           =   1905
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Value CHF"
         Height          =   225
         Index           =   25
         Left            =   5580
         TabIndex        =   100
         Tag             =   "lbl_CUS_ValueCHF"
         Top             =   540
         Width           =   2055
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#DB %"
         Height          =   225
         Index           =   24
         Left            =   3720
         TabIndex        =   99
         Tag             =   "lbl_CUS_DB"
         Top             =   570
         Width           =   1095
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Value quotation currency"
         Height          =   225
         Index           =   23
         Left            =   90
         TabIndex        =   98
         Tag             =   "lbl_CUS_ValueLC"
         Top             =   540
         Width           =   2445
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#in"
         Height          =   225
         Index           =   22
         Left            =   7320
         TabIndex        =   97
         Tag             =   "lbl_CUS_in"
         Top             =   240
         Width           =   885
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Area"
         Height          =   225
         Index           =   21
         Left            =   5160
         TabIndex        =   96
         Tag             =   "lbl_CUS_Area"
         Top             =   240
         Width           =   945
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#System"
         Height          =   225
         Index           =   20
         Left            =   90
         TabIndex        =   95
         Tag             =   "lbl_CUS_system"
         Top             =   240
         Width           =   2445
      End
   End
   Begin VB.Frame fra_SEM 
      Appearance      =   0  'Flat
      Caption         =   "#Semi Standard"
      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          =   855
      Left            =   30
      TabIndex        =   82
      Tag             =   "fra_SEM"
      Top             =   2820
      Width           =   15045
      Begin VB.TextBox txt_SEM_Area 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   6150
         MaxLength       =   9
         TabIndex        =   19
         Tag             =   "SEM_Quote_Area®©Num®©0"
         Text            =   "9,999,999"
         Top             =   210
         Width           =   1095
      End
      Begin VB.TextBox txt_SEM_ValueLC 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   2580
         MaxLength       =   10
         TabIndex        =   21
         Tag             =   "SEM_Quote_ValueLC®©Num®©0"
         Text            =   "99,999,999"
         Top             =   510
         Width           =   1065
      End
      Begin VB.TextBox txt_SEM_DB 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   4860
         MaxLength       =   8
         TabIndex        =   22
         Tag             =   "SEM_Quote_DB®©Num®©0"
         Text            =   "1,000.00"
         Top             =   510
         Width           =   795
      End
      Begin VB.TextBox txt_SEM_ValueCHF 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   7680
         TabIndex        =   23
         Tag             =   "SEM_Quote_Value_CHF®©Num®©0"
         Text            =   "SEM_Quote_Value_CHF®©Num®©0"
         Top             =   510
         Width           =   2475
      End
      Begin VB.TextBox txt_SEM_PrimeMarg 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   12180
         TabIndex        =   24
         Tag             =   "SEM_Quote_PrimeMargin®©Num®©0.00"
         Text            =   "SEM_Quote_PrimeMargin®©Num®©0.00"
         Top             =   510
         Width           =   2475
      End
      Begin Project1.ArmCombobox cbo_SEM_System 
         Height          =   345
         Left            =   2580
         TabIndex        =   18
         Tag             =   "SEM_SS_code"
         Top             =   150
         Width           =   2505
         _ExtentX        =   4419
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_SEM_UM 
         Height          =   345
         Left            =   8250
         TabIndex        =   20
         Tag             =   "SEM_UM_code"
         Top             =   150
         Width           =   2475
         _ExtentX        =   4366
         _ExtentY        =   609
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#System"
         Height          =   225
         Index           =   19
         Left            =   90
         TabIndex        =   89
         Tag             =   "lbl_SEM_system"
         Top             =   240
         Width           =   2445
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Area"
         Height          =   225
         Index           =   18
         Left            =   5160
         TabIndex        =   88
         Tag             =   "lbl_SEM_Area"
         Top             =   240
         Width           =   945
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#in"
         Height          =   225
         Index           =   17
         Left            =   7320
         TabIndex        =   87
         Tag             =   "lbl_SEM_in"
         Top             =   240
         Width           =   885
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Value quotation currency"
         Height          =   225
         Index           =   16
         Left            =   90
         TabIndex        =   86
         Tag             =   "lbl_SEM_ValueLC"
         Top             =   540
         Width           =   2445
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#DB %"
         Height          =   225
         Index           =   15
         Left            =   3720
         TabIndex        =   85
         Tag             =   "lbl_SEM_DB"
         Top             =   540
         Width           =   1095
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Value CHF"
         Height          =   225
         Index           =   14
         Left            =   5580
         TabIndex        =   84
         Tag             =   "lbl_SEM_ValueCHF"
         Top             =   570
         Width           =   2055
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Prime margin"
         Height          =   225
         Index           =   13
         Left            =   10230
         TabIndex        =   83
         Tag             =   "lbl_SEM_PrimeMargin"
         Top             =   570
         Width           =   1905
      End
   End
   Begin VB.Frame fra_STD 
      Appearance      =   0  'Flat
      Caption         =   "#Standard"
      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          =   855
      Left            =   30
      TabIndex        =   78
      Tag             =   "fra_STD"
      Top             =   1950
      Width           =   15045
      Begin VB.TextBox txt_STD_PrimeMarg 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   12180
         TabIndex        =   17
         Tag             =   "STD_Quote_PrimeMargin®©Num®©0.00"
         Text            =   "STD_Quote_PrimeMargin®©Num®©0.00"
         Top             =   510
         Width           =   2475
      End
      Begin VB.TextBox txt_STD_ValueCHF 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         Height          =   285
         Left            =   7680
         TabIndex        =   16
         Tag             =   "STD_Quote_Value_CHF®©Num®©0"
         Text            =   "STD_Quote_Value_CHF®©Num®©0"
         Top             =   510
         Width           =   2475
      End
      Begin VB.TextBox txt_STD_DB 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   4860
         MaxLength       =   8
         TabIndex        =   15
         Tag             =   "STD_Quote_DB®©Num®©0"
         Text            =   "1000"
         Top             =   510
         Width           =   795
      End
      Begin VB.TextBox txt_STD_ValueLC 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   2580
         MaxLength       =   10
         TabIndex        =   14
         Tag             =   "STD_Quote_ValueLC®©Num®©0"
         Text            =   "99,999,999"
         Top             =   510
         Width           =   1095
      End
      Begin VB.TextBox txt_STD_Area 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   6150
         MaxLength       =   9
         TabIndex        =   12
         Tag             =   "STD_Quote_Area®©Num®©0"
         Text            =   "9,999,999"
         Top             =   210
         Width           =   1065
      End
      Begin Project1.ArmCombobox cbo_STD_System 
         Height          =   345
         Left            =   2580
         TabIndex        =   11
         Tag             =   "STD_SS_code"
         Top             =   150
         Width           =   2505
         _ExtentX        =   4419
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_STD_UM 
         Height          =   345
         Left            =   8250
         TabIndex        =   13
         Tag             =   "STD_UM_code"
         Top             =   150
         Width           =   2475
         _ExtentX        =   4366
         _ExtentY        =   609
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Prime margin"
         Height          =   225
         Index           =   12
         Left            =   10230
         TabIndex        =   93
         Tag             =   "lbl_STD_PrimeMargin"
         Top             =   570
         Width           =   1905
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Value CHF"
         Height          =   225
         Index           =   11
         Left            =   5580
         TabIndex        =   92
         Tag             =   "lbl_STD_ValueCHF"
         Top             =   570
         Width           =   2055
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#DB %"
         Height          =   225
         Index           =   10
         Left            =   3750
         TabIndex        =   91
         Tag             =   "lbl_STD_DB"
         Top             =   570
         Width           =   1065
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Value quotation currency"
         Height          =   225
         Index           =   9
         Left            =   90
         TabIndex        =   90
         Tag             =   "lbl_STD_ValueLC"
         Top             =   540
         Width           =   2445
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#in"
         Height          =   225
         Index           =   8
         Left            =   7290
         TabIndex        =   81
         Tag             =   "lbl_STD_in"
         Top             =   240
         Width           =   885
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#Area"
         Height          =   225
         Index           =   7
         Left            =   5160
         TabIndex        =   80
         Tag             =   "lbl_STD_Area"
         Top             =   240
         Width           =   945
      End
      Begin VB.Label lbl_label 
         Alignment       =   1  'Right Justify
         Caption         =   "#System"
         Height          =   225
         Index           =   6
         Left            =   90
         TabIndex        =   79
         Tag             =   "lbl_STD_system"
         Top             =   240
         Width           =   2445
      End
   End
   Begin VB.TextBox txt_StatusDate 
      Height          =   285
      Left            =   13410
      TabIndex        =   2
      Tag             =   "StatusDate®©Date"
      Text            =   "StatusDate®©Date"
      Top             =   720
      Width           =   1635
   End
   Begin VB.TextBox txt_StatusDesc 
      Height          =   285
      Left            =   11130
      TabIndex        =   1
      Tag             =   "StatusDesc®©Text"
      Text            =   "StatusDesc®©Text"
      Top             =   720
      Width           =   2235
   End
   Begin VB.Frame fra_include 
      Caption         =   "#Include"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   525
      Left            =   7680
      TabIndex        =   75
      Tag             =   "fra_include"
      Top             =   1410
      Width           =   2625
      Begin VB.OptionButton opt_include 
         Caption         =   "#Multiple"
         Height          =   195
         Index           =   1
         Left            =   1350
         TabIndex        =   9
         Tag             =   "Quote_Include®©True®©??"
         Top             =   240
         Width           =   1095
      End
      Begin VB.OptionButton opt_include 
         Caption         =   "#Active"
         Height          =   195
         Index           =   0
         Left            =   210
         TabIndex        =   8
         Tag             =   "Quote_Include®©False®©??"
         Top             =   240
         Width           =   1095
      End
   End
   Begin VB.Frame fra_type 
      Caption         =   "#Type"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   525
      Left            =   3150
      TabIndex        =   74
      Tag             =   "fra_type"
      Top             =   1410
      Width           =   4485
      Begin VB.OptionButton opt_type 
         Caption         =   "#Material and installation"
         Height          =   255
         Index           =   1
         Left            =   1890
         TabIndex        =   7
         Tag             =   "Quote_Type®©False®©??"
         Top             =   210
         Width           =   2505
      End
      Begin VB.OptionButton opt_type 
         Caption         =   "#Material"
         Height          =   255
         Index           =   0
         Left            =   180
         TabIndex        =   6
         Tag             =   "Quote_Type®©True®©??"
         Top             =   210
         Value           =   -1  'True
         Width           =   1515
      End
   End
   Begin Project1.ArmCombobox cbo_customer 
      Height          =   345
      Left            =   9270
      TabIndex        =   4
      Tag             =   "Cust_ID"
      Top             =   1095
      Width           =   5805
      _ExtentX        =   10239
      _ExtentY        =   609
   End
   Begin VB.TextBox txt_key 
      ForeColor       =   &H000000FF&
      Height          =   315
      Left            =   8610
      TabIndex        =   67
      Tag             =   "Quote_ID®©Text"
      Text            =   "Quote_ID®©Text"
      Top             =   0
      Width           =   2025
   End
   Begin VB.TextBox txt_Ref 
      Height          =   285
      Left            =   1620
      TabIndex        =   0
      Tag             =   "Reference®©Text"
      Text            =   "Reference®©Text"
      Top             =   720
      Width           =   2595
   End
   Begin Project1.ArmCombobox cbo_project 
      Height          =   345
      Left            =   1590
      TabIndex        =   3
      Tag             =   "Proj_ID"
      Top             =   1050
      Width           =   5805
      _ExtentX        =   10239
      _ExtentY        =   609
   End
   Begin Project1.ArmCombobox cbo_quote_curr 
      Height          =   345
      Left            =   1980
      TabIndex        =   5
      Tag             =   "Quote_CURR_Code"
      Top             =   1500
      Width           =   1065
      _ExtentX        =   1879
      _ExtentY        =   609
   End
   Begin Project1.ToolbarControl tbl_Main 
      Height          =   690
      Left            =   0
      TabIndex        =   71
      Top             =   0
      Width           =   8475
      _ExtentX        =   14949
      _ExtentY        =   1217
   End
   Begin Project1.ArmCombobox cbo_SalesRep 
      Height          =   345
      Left            =   11640
      TabIndex        =   10
      Tag             =   "SSR_code"
      Top             =   1500
      Width           =   3435
      _ExtentX        =   6059
      _ExtentY        =   609
   End
   Begin Project1.ArmCombobox cbo_FreightCurr 
      Height          =   345
      Left            =   6000
      TabIndex        =   37
      Tag             =   "FRGHT_CURR_code"
      Top             =   5100
      Width           =   1065
      _ExtentX        =   1879
      _ExtentY        =   609
   End
   Begin Project1.ArmCombobox cbo_realisation 
      Height          =   345
      Left            =   8820
      TabIndex        =   38
      Tag             =   "RL_code"
      Top             =   5100
      Width           =   795
      _ExtentX        =   1402
      _ExtentY        =   609
   End
   Begin Project1.ArmCombobox cbo_BO 
      Height          =   345
      Left            =   11640
      TabIndex        =   39
      Tag             =   "BO_SSR_code"
      Top             =   5100
      Width           =   3435
      _ExtentX        =   6059
      _ExtentY        =   609
   End
   Begin Project1.A_calocx cal_OfferDate 
      Height          =   345
      Left            =   6000
      TabIndex        =   151
      Tag             =   "Quote_ValidToDate"
      Top             =   700
      Width           =   1845
      _ExtentX        =   3254
      _ExtentY        =   609
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Offer date"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   60
      Left            =   4400
      TabIndex        =   150
      Tag             =   "lbl_OfferDate"
      Top             =   750
      Width           =   1515
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Back office person"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   35
      Left            =   9690
      TabIndex        =   111
      Tag             =   "lbl_BO"
      Top             =   5190
      Width           =   1905
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Realisation %"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   34
      Left            =   7140
      TabIndex        =   110
      Tag             =   "lbl_Realisation"
      Top             =   5190
      Width           =   1635
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#in"
      Height          =   225
      Index           =   33
      Left            =   5460
      TabIndex        =   109
      Tag             =   "lbl_Freight_in"
      Top             =   5190
      Width           =   495
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Freight cost"
      Height          =   225
      Index           =   32
      Left            =   3090
      TabIndex        =   108
      Tag             =   "lbl_FreightCostLC"
      Top             =   5190
      Width           =   1035
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Valid until"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   31
      Left            =   60
      TabIndex        =   107
      Tag             =   "lbl_ValidUntil"
      Top             =   5190
      Width           =   1065
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Comments"
      Height          =   225
      Index           =   30
      Left            =   60
      TabIndex        =   106
      Tag             =   "lbl_Quote_Comment"
      Top             =   5490
      Width           =   1305
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Status"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   5
      Left            =   9210
      TabIndex        =   77
      Tag             =   "lbl_Status"
      Top             =   750
      Width           =   1875
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Sales rep"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   4
      Left            =   10350
      TabIndex        =   76
      Tag             =   "lbl_SalesRep"
      Top             =   1590
      Width           =   1245
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Quotation currency"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   3
      Left            =   60
      TabIndex        =   73
      Tag             =   "lbl_currency"
      Top             =   1590
      Width           =   1875
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Project"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   2
      Left            =   60
      TabIndex        =   72
      Tag             =   "lbl_project"
      Top             =   1110
      Width           =   1485
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Customer"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   1
      Left            =   7710
      TabIndex        =   70
      Tag             =   "lbl_customer"
      Top             =   1110
      Width           =   1515
   End
   Begin VB.Label lbl_label 
      Alignment       =   1  'Right Justify
      Caption         =   "#Reference"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   0
      Left            =   60
      TabIndex        =   69
      Tag             =   "lbl_Reference"
      Top             =   750
      Width           =   1515
   End
End
Attribute VB_Name = "SOM_Quote"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public Event OnExit(ByVal ab_ByUser As Boolean)
Public Event OnItemAdd(ByVal ae_CptType As eComponent, ByVal al_Key As Long, ByVal as_SrzFields As String)
Public Event OnItemDelete(ByVal ae_CptType As eComponent, ByVal al_Key As Long)

Public Event OnItemUpdate(ByVal ae_CptType As eComponent, ByVal al_Key As Long, ByVal as_SrzFields As String)
Public Event OnValidate(ByVal as_Request As String, ByVal as_SrzFields As String, ByRef ab_StopProcess As Boolean)

Public Event OnItemNext()
Public Event OnItemPrevious()


Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwnd As Long) As Long

Private Const SCREEN_NAME As String = "SOM_QUOT"

Private Const SEP As String = "®©"
Private Const SEP1 As String = "®"
Private Const SEP2 As String = "©"

Private Const LOCALE_USER_DEFAULT = &H400
Private ms_DecimalSeparator  As String
Private ms_ThousandSeparator As String
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long

Private Const LOCALE_SDECIMAL = &HE ' Decimal separator
Private Const LOCALE_STHOUSAND = &HF ' Thousand separator

Const C_ERRORRAISE As Long = 3000

Private Enum ArmErr
    DBCnxFailed = C_ERRORRAISE + 1             ' Unable to connect to the database
    CPTAlreadyInitialized = C_ERRORRAISE + 2   ' We try to initialize a component that is already initialized
    CPTNotInitialized = C_ERRORRAISE + 3       ' We try to use or free that is not initialized yet
    InvalidArgument = C_ERRORRAISE + 4
    PropertyNotSet = C_ERRORRAISE + 5
    SQLFailure = C_ERRORRAISE + 6               ' A SQL runtime error has occured : syntax wrong....
    SQLBadRowAffectedCount = C_ERRORRAISE + 7   ' A SQL request has not affected the expected rowcount (ex: one Update do nothing)
    SQLBadRowExpectedCount = C_ERRORRAISE + 8   ' A SQL request does not return the expected rowcount : select an item return nothing...
    DrivingError = C_ERRORRAISE + 9
    CompFncFailed = C_ERRORRAISE + 10           ' when component function fail
    GridLoadFailed = C_ERRORRAISE + 11          ' load function failed ... bad sql
End Enum

Private Enum ArmCusErr
    DuplicityDetected = C_ERRORRAISE + 2301                ' detected row with same unique id
End Enum


#If LIVE Then
    Private mo_Db                   As Object
#Else
    Private mo_Db                   As ArmDb
#End If

Private mb_Initialized              As Boolean
Private ms_LoginName                As String
Private ms_FullUserName             As String
Private ms_Language_Code            As String
Private ml_UCode                    As Long

Private mb_IsFullAccess As Boolean

Private me_Mode As eMode
Private me_OldMode As eMode

Private mb_Internal As Boolean

Private ml_Driver As eComponent

Private ml_LocalID As Long

Private mb_IsVisible As Boolean

Private Type TConfigRecord
    RequestView As String
    RequestAdd As String
    RequestUpd As String
    RequestDel As String
    ListFieldsToDisable             As Variant
    ListFieldsMandatory             As Variant
    ListFieldsDefaultValue          As Variant
End Type

Private mt_ClassInfoLst() As TConfigRecord


Private ms_SrzStrFromWLD As String

Dim ml_Cursor As Long

#If LIVE Then
Public Property Set DB(ByRef aDb As Object)
#Else
Public Property Set DB(ByRef aDb As ArmDb)
#End If
    Set mo_Db = aDb
End Property

Public Property Let A_Visible(ByVal aVisible As Boolean)
    UserControl.Extender.Visible = aVisible
    mb_IsVisible = aVisible
    If mb_IsVisible Then
        If cbo_Project.Enabled Then
            cbo_Project.SetFocus
        ElseIf cbo_Customer.Enabled Then
            cbo_Customer.SetFocus
        ElseIf cbo_quote_curr.Enabled Then
            cbo_quote_curr.SetFocus
        End If
    End If
End Property

Public Property Get IsVisible() As Boolean
    IsVisible = mb_IsVisible
End Property

Public Property Get A_Visible() As Boolean
    A_Visible = UserControl.Extender.Visible
End Property

Public Property Get Initialized() As Boolean
    Initialized = mb_Initialized
End Property

Public Property Let LoginName(ByVal aLoginName As String)
    ms_LoginName = aLoginName
End Property

Public Property Let FullUserName(ByVal aFullUserName As String)
    ms_FullUserName = aFullUserName
End Property

Public Property Let Ucode(ByVal aUcode As Long)
    ml_UCode = aUcode
End Property


Public Property Let Language_Code(ByVal aLanguage_Code As String)
    ms_Language_Code = aLanguage_Code
End Property


Public Sub Move(ByVal aLeft As Single, ByVal aTop As Single, ByVal aWidth As Single, ByVal aHeight As Single)
    Call UserControl.Extender.Move(aLeft, aTop, aWidth, aHeight)
End Sub

Public Property Let DrivenBy(ByVal al_CptType As Long)
    ml_Driver = al_CptType
End Property

Public Sub Run(ByVal ae_ScrMode As eMode, ByVal al_Key As Long, ByVal as_SrzFields As String)
On Error GoTo ErrHandler

    Debug.Assert (mb_Initialized = True)
    
    mb_Internal = True
    
    Call LockScreen(True)
    
    fra_invalidate.Visible = False
    
    Select Case ae_ScrMode
        Case eMode.emView
            Call Item_ViewInit(al_Key)
        
        Case eMode.emAdd
            Call Item_AddInit(as_SrzFields)
                    
        Case eMode.emUpdate
            Call Item_UpdateInit(al_Key, as_SrzFields)
                    
        Case eMode.emCopy
            Call Item_CopyInit(al_Key)
        
        Case eMode.emRevision
            Call Item_RevisionInit(al_Key)
        
        Case eMode.emDelete
            Call Item_DeleteInit(al_Key)
            
    End Select
    
    Call LockScreen(False)
    
    mb_Internal = False
    
    Exit Sub
ErrHandler:
    Call LockScreen(False)
    Call ErrorHandler("Run")
End Sub
Private Function GetFieldValueFromSrz(ByVal as_SrzFields As String, ByVal as_Param As String) As String
On Error GoTo ErrHandler
    
    Dim lv_SrzFields As Variant
    Dim lv_Values
    Dim ll_Count As Long
    Dim ll_Nb As Long
    
    If right(as_SrzFields, 2) <> SEP Then as_SrzFields = as_SrzFields & SEP
       
    lv_SrzFields = Split(as_SrzFields, SEP)
    ll_Nb = UBound(lv_SrzFields) - 1

    For ll_Count = 0 To ll_Nb
        lv_Values = Split(lv_SrzFields(ll_Count), SEP1)
         If UCase(as_Param) = UCase(lv_Values(0)) Then
           GetFieldValueFromSrz = lv_Values(1)
           Exit For
         End If
    Next ll_Count
    
    Exit Function
ErrHandler:
    Call ErrorHandler("GetFieldValueFromSrz")
End Function
Public Sub Notify(ByVal ae_CptType As eComponent, ByVal ae_Mode As eMode, ByVal al_Key As Long, ByVal as_SrzFields As String)
 On Error GoTo ErrHandler
       
    Dim ls_Desc As String

    If Not mb_Initialized Then Exit Sub
    
    Debug.Assert (mb_Initialized = True)
        
    Select Case ae_CptType
        Case eCustomer
                    
            Select Case ae_Mode
            
                Case eMode.emUpdate
                    
                    If Not cbo_IsFilled(cbo_Customer) Then Exit Sub
                
                    If cbo_Customer.SelectedItem.Key <> al_Key Then Exit Sub
                                        
                    ls_Desc = GetFieldValueFromSrz(as_SrzFields, "CUST_NAME") & " / " & GetFieldValueFromSrz(as_SrzFields, "CUST_TOWN") & " / " & GetFieldValueFromSrz(as_SrzFields, "CT_DESC")
                    
                    mb_Internal = True
                    cbo_Customer.SelectedItem.DisplayText = ls_Desc
                    DoEvents
                    mb_Internal = False
                    
                    If me_Mode Like eMode.emView Or me_Mode = eMode.emDelete Then
                        Call LoadDataToFormFromSrzString(UserControl.Controls, fra_Customer, as_SrzFields)
                    End If
                    
                Case eMode.emDelete
                
                    If Not cbo_IsFilled(cbo_Customer) Then Exit Sub
                
                    If cbo_Customer.SelectedItem.Key <> al_Key Then Exit Sub
                                                            
                    Lbl_info.Caption = MsgText(3056, ms_Language_Code, "#You have deleted the customer from an other place. This action will be terminated.")
                                                            
                    Call EnableFrame(UserControl.Controls, Me, False)
                    Call EnableFrame(UserControl.Controls, fra_invalidate, True)
                    
                    fra_invalidate.ZOrder
                    fra_invalidate.Visible = True
                    
            End Select
                
         Case eProject
                   
            Select Case ae_Mode
            
                Case eMode.emUpdate
                    
                    If Not cbo_IsFilled(cbo_Project) Then Exit Sub
                
                    If cbo_Project.SelectedItem.Key <> al_Key Then Exit Sub


                    ls_Desc = GetFieldValueFromSrz(as_SrzFields, "PROJ_NAME") & " / " & GetFieldValueFromSrz(as_SrzFields, "PROJ_TOWN") & " / " & GetFieldValueFromSrz(as_SrzFields, "CT_DESC")
                    
                    cbo_Project.SelectedItem.DisplayText = ls_Desc
                                       
                    Dim ll_ps_code
                    ll_ps_code = CLng(GetFieldValueFromSrz(as_SrzFields, "PS_CODE"))
                                      
                    If ll_ps_code <> eProjSpecification And ll_ps_code <> eProjQuoteTender Then
                        Select Case me_Mode
                            Case eMode.emView
                                tbl_main.ButtonEnabled("R") = False
                                tbl_main.ButtonEnabled("Z") = False
                                tbl_main.ButtonEnabled("B") = False
                        Case Else
                            Lbl_info.Caption = MsgText(3060, ms_Language_Code, "#You have change the status of the project. This action will be terminated.")
                                                                    
                            Call EnableFrame(UserControl.Controls, Me, False)
                            Call EnableFrame(UserControl.Controls, fra_invalidate, True)
                                                                    
                            fra_invalidate.ZOrder
                            fra_invalidate.Visible = True
                        End Select
                    Else
                        Select Case me_Mode
                            Case eMode.emView
                                tbl_main.ButtonEnabled("R") = True
                                tbl_main.ButtonEnabled("Z") = True
                                tbl_main.ButtonEnabled("B") = True
                                
                        End Select
                    End If
                    
                    If me_Mode Like eMode.emView Or me_Mode = eMode.emDelete Then
                        Call LoadDataToFormFromSrzString(UserControl.Controls, fra_project, as_SrzFields)
                    End If
                    
                Case eMode.emDelete
                    If Not cbo_IsFilled(cbo_Project) Then Exit Sub

                    If cbo_Project.SelectedItem.Key <> al_Key Then Exit Sub
                    
                    Lbl_info.Caption = MsgText(3057, ms_Language_Code, "#You have deleted the project from an other place. This action will be terminated.")
                                                            
                    Call EnableFrame(UserControl.Controls, Me, False)
                    Call EnableFrame(UserControl.Controls, fra_invalidate, True)
                                                            
                    fra_invalidate.ZOrder
                    fra_invalidate.Visible = True
            End Select
         
         Case eLink
           
            Select Case ae_Mode
                                
                Case eMode.emDelete
                    If Val(txt_LinkID.Text) <> al_Key Then Exit Sub
                    
                    Lbl_info.Caption = MsgText(3058, ms_Language_Code, "#You have deleted the link between the project and the customer from an other place. This action will be terminated.")
                                                            
                    Call EnableFrame(UserControl.Controls, Me, False)
                    Call EnableFrame(UserControl.Controls, fra_invalidate, True)
                                                            
                    fra_invalidate.ZOrder
                    fra_invalidate.Visible = True
            End Select
            
        Case eQuote
        
            If me_Mode <> eMode.emView And me_Mode <> eMode.emDelete And me_Mode <> eMode.emUpdate Then Exit Sub
        
        
            Select Case ae_Mode
                Case eMode.emDelete
                    If Val(txt_key.Text) <> al_Key Then Exit Sub
                    
                    Lbl_info.Caption = MsgText(3059, ms_Language_Code, "#You have deleted the quote from an other place. This action will be terminated.")
                                                            
                    Call EnableFrame(UserControl.Controls, Me, False)
                    Call EnableFrame(UserControl.Controls, fra_invalidate, True)
                                                            
                    fra_invalidate.ZOrder
                    fra_invalidate.Visible = True
                    
                Case eMode.emUpdate
                    If al_Key <> 0 Then
                        If Val(txt_key.Text) <> al_Key Then Exit Sub
                        
                        Select Case me_Mode
                            Case eMode.emView, eMode.emDelete
                               Call LoadDataToFormFromSrzString(UserControl.Controls, Me, as_SrzFields)
                                txt_LastUpdDate.Text = Format(Now, "dd\/mm\/yyyy")
                                txt_UpdUser.Text = ms_FullUserName
                               
                            Case Else
                            
                                Lbl_info.Caption = MsgText(3067, ms_Language_Code, "#You have updated this quote from an other place. This action will be terminated.")
                                                                        
                                Call EnableFrame(UserControl.Controls, Me, False)
                                Call EnableFrame(UserControl.Controls, fra_invalidate, True)
                                                                        
                                fra_invalidate.ZOrder
                                fra_invalidate.Visible = True
                        End Select
                    Else
                        If cbo_Project.SelectedItem.Key <> GetFieldValueFromSrz(as_SrzFields, "Proj_id") Then Exit Sub
                    
                        Call LoadDataToFormFromSrzString(UserControl.Controls, Me, as_SrzFields)
                        txt_LastUpdDate.Text = Format(Now, "dd\/mm\/yyyy")
                    txt_UpdUser.Text = ms_FullUserName
                        
                    End If
                    
            End Select
        
    End Select
        
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Notify")
End Sub

Public Function Load_A_Com() As Boolean

On Error GoTo ErrHandler

    If mb_Initialized Then Exit Function
    
    Call LockScreen(True)


'to handle Decimal with the local settings
    Dim sBuffer As String
    Dim nBufferLen As Long
    Dim LCID As Long

    LCID = GetSystemDefaultLCID

    ms_DecimalSeparator = Format(0, ".")

    nBufferLen = 255
    sBuffer = String$(nBufferLen, vbNullChar)
    nBufferLen = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, sBuffer, nBufferLen)
    If nBufferLen > 0 Then
        ms_ThousandSeparator = Left$(sBuffer, nBufferLen - 1)
    End If

    mb_IsFullAccess = SOM_lib.IsFullAccess

    Call Load_ClassInfo

    Call Components_Settings
    
    Call InitComponents
    
    Call LoadAllLabels

    Call LockScreen(False)
    
    mb_Initialized = True
    
    Load_A_Com = True
    
    Exit Function

ErrHandler:
    Call LockScreen(False)
    Call ErrorHandler("Load_A_Com")
End Function
Private Sub LoadAllLabels()
    
On Error GoTo ErrHandler
    
    Call LoadLabels(UserControl.Controls, Me, SCREEN_NAME, ms_Language_Code)
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("LoadAllLabels")
 
End Sub
Public Sub LoadLabels(ByRef aControls As Variant, ByRef av_Container As Object, ByVal as_ScreenName As String, ByVal as_Language As String)

On Error GoTo ErrHandler
    Dim lIdx As Long, lCount As Long, lLabels As Long, lb_Apply As Boolean, lv_Iter As Object, ls_Buffer As String
    Dim lControl As Control, ll_Idx2 As Long, ll_Count2 As Long, ll_IdxGrd As Long
    
    'lLabels = mo_Db.OpenSQL("exec Screen_Csts '" & as_ScreenName & "','" & as_Language & "'")
    lLabels = OpenSQLSafe(mo_Db, "exec Screen_Csts '" & as_ScreenName & "','" & as_Language & "'")
    lCount = aControls.Count - 1
    
    For lIdx = 0 To lCount
        Set lControl = aControls.Item(lIdx)
        
        If Not av_Container Is Nothing Then
            lb_Apply = HasContainer(lControl, av_Container)
        Else
            lb_Apply = True
        End If
        If lb_Apply Then
            Select Case UCase(TypeName(lControl))
                Case "LABEL", "FRAME", "COMMANDBUTTON"
                    If lControl.Tag <> "" Then
                        If mo_Db.Find(lLabels, "FIELD_NAME", lControl.Tag, , 1) >= 0 Then
                            lControl.Caption = mo_Db.GetFields(lLabels, "LOCAL_TEXT")
                        End If
                    End If
                Case "CHECKBOX"
                    If lControl.Tag <> "" Then
                        ls_Buffer = Split(lControl.Tag, SEP, , vbTextCompare)(0)
                        If mo_Db.Find(lLabels, "FIELD_NAME", ls_Buffer, , 1) >= 0 Then
                            lControl.Caption = mo_Db.GetFields(lLabels, "LOCAL_TEXT")
                        End If
                    End If
                Case "TEXTBOX"
                    If lControl.Tag <> "" Then
                        If mo_Db.Find(lLabels, "FIELD_NAME", lControl.Tag, , 1) >= 0 Then
                            lControl.Text = mo_Db.GetFields(lLabels, "LOCAL_TEXT")
                        End If
                    End If
                Case "TABSTRIP"
                    If lControl.Tag <> "" Then
                        For Each lv_Iter In lControl.Tabs
                            If mo_Db.Find(lLabels, "FIELD_NAME", lControl.Tag & "_" & lv_Iter.Tag, , 1) >= 0 Then
                                lv_Iter.Caption = mo_Db.GetFields(lLabels, "LOCAL_TEXT")
                            End If
                        Next
                    End If
                
                Case "OPTIONBUTTON"
                    If lControl.Tag <> "" Then
                        ls_Buffer = Split(lControl.Tag, SEP, , vbTextCompare)(0)
                        On Error Resume Next
                        ls_Buffer = ls_Buffer & lControl.Index
                        On Error GoTo 0
                        If mo_Db.Find(lLabels, "FIELD_NAME", ls_Buffer, , 1) >= 0 Then
                            lControl.Caption = mo_Db.GetFields(lLabels, "LOCAL_TEXT")
                        End If
                    End If
                
                Case "ARMGRID"
                    If lControl.Tag <> "" Then
                        If mo_Db.Find(lLabels, "FIELD_NAME", lControl.Tag, , 1) >= 0 Then
                            Dim ls_Text As String
                            Dim ls_Title As String
                                                       
                            ls_Text = mo_Db.GetFields(lLabels, "LOCAL_TEXT")
                            
                            If ls_Text <> "" And InStr(1, ls_Text, SEP) <> 0 Then
                                ls_Title = Mid(ls_Text, 1, InStr(1, ls_Text, SEP) - 1)
                                
                                lControl.Title = ls_Title
                                
                                ls_Text = Mid(ls_Text, InStr(1, ls_Text, SEP) + 2)
                                Call lControl.LoadConstants(ptStatic, ls_Text, ctColumns)
                            End If
                        End If
                    End If
                    
                Case "FRAME", "MSFLEXGRID", "TOOLBARCONTROL", "COMMANDBUTTON", "ARMCHECKVIEW", "ARMCOMBOBOX", "A_CALOCX", "ARMTREEVIEW", "LISTBOX", "PICTUREBOX"
                   ' NOTHING
                
            End Select
        End If
        Set lControl = Nothing
    Next
    
CleanUp:
    mo_Db.Close (lLabels)
    Exit Sub
            
ErrHandler:
    mo_Db.Close (lLabels)
    If Not lControl Is Nothing Then Set lControl = Nothing
    Call ErrorHandler("LoadLabels")
            
End Sub

Private Sub Item_AddInit(ByVal as_SrzFields As String)
On Error GoTo ErrHandler
    
    Dim ls_SrzFields As String
    
    
    Call SetMode(eMode.emAdd)
    
    
    'visuel
    Call ClearForm(UserControl.Controls, Me)
    Call EnableFrame(UserControl.Controls, Me, True)
    
    Call DisableFrameParts(0)
    Call HandleToolbar(tbl_main, 1, mb_IsFullAccess)
    
    fra_project.Visible = False
    fra_Customer.Visible = False
    
    Call EnableFrame(UserControl.Controls, fra_ModifInfo, False)
     
     
    Call EnableFrame(UserControl.Controls, fra_STD, False)
    cbo_STD_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_SEM, False)
    cbo_SEM_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_CUS, False)
    cbo_CUS_System.Enabled = True
    
    
    txt_key.Text = 0
     
    'Default values
    Call Item_LoadDefaultValue(0)
    
    Dim lv_Data As Variant
    Dim lv_Temp As Variant
    Dim ll_Count As Long
    Dim ll_Nb As Long
    Dim ll_ID As Long
    Dim ls_Desc As String
'    Dim ls_name As String
'    Dim ls_Town As String
'    Dim ls_Country As String
    
    Dim ll_ProjCustLink As Long
    
    Select Case ml_Driver
        Case eProject
            
            txt_ProjNumber.Text = GetFieldValueFromSrz(as_SrzFields, "ProjectNumber")
            
            cbo_Project.Enabled = False
            ls_SrzFields = Trim(as_SrzFields)
                                    
            ll_ID = CLng(GetFieldValueFromSrz(ls_SrzFields, "PROJ_ID"))
            ls_Desc = GetFieldValueFromSrz(ls_SrzFields, "PROJ_NAME") & " / " & GetFieldValueFromSrz(ls_SrzFields, "PROJ_TOWN") & " / " & GetFieldValueFromSrz(ls_SrzFields, "CT_DESC")
           
            If Not cbo_Project.SearchItem(ll_ID) Then
                Call cbo_Project.AddItem(Array(ll_ID, ls_Desc), True)
            End If
                        
        Case eCustomer
            cbo_Customer.Enabled = False
            
            ls_SrzFields = Trim(as_SrzFields)
            ll_ID = CLng(GetFieldValueFromSrz(ls_SrzFields, "CUST_ID"))
            ls_Desc = GetFieldValueFromSrz(ls_SrzFields, "CUST_NAME") & " / " & GetFieldValueFromSrz(ls_SrzFields, "CUST_TOWN") & " / " & GetFieldValueFromSrz(ls_SrzFields, "CT_DESC")
            If Not cbo_Customer.SearchItem(ll_ID) Then
                Call cbo_Customer.AddItem(Array(ll_ID, ls_Desc), True)
            End If
        
        
    End Select
    

    txt_CreationDate.Text = Format(Now, "dd\/mm\/yyyy")
    txt_Creator.Text = ms_FullUserName
    txt_LastUpdDate.Text = Format(Now, "dd\/mm\/yyyy")
    txt_UpdUser.Text = ms_FullUserName
   
   Exit Sub
    
ErrHandler:
    Call ErrorHandler("Item_AddInit")
End Sub




Private Function Item_CheckMandatory(ByVal al_Index As Long) As Boolean

On Error GoTo ErrHandler
    Dim lIdx As Long, lCount As Long
    Dim lValues As Variant
    Dim ls_TempTag As String
    Dim ls_Str As String
    Dim lControl As Control
    
    Dim lv_MsgReplaceInfo(0, 1) As String
    
    'lecture du tableau des valeurs par defaut en prmeier car + petit
    lCount = UBound(mt_ClassInfoLst(al_Index).ListFieldsMandatory)
    For lIdx = 0 To lCount
         
        Set lControl = mt_ClassInfoLst(al_Index).ListFieldsMandatory(lIdx, 0)
            
        Select Case UCase(TypeName(lControl))
            Case "TEXTBOX"
                If Trim(lControl.Text) = "" Then
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = lbl_label(mt_ClassInfoLst(al_Index).ListFieldsMandatory(lIdx, 1)).Caption
                    Call MsgBox(MsgText(2120, ms_Language_Code, "The field " & lv_MsgReplaceInfo(0, 1) & " is mandatory.", lv_MsgReplaceInfo), vbInformation)
                    lControl.SetFocus
                    
                    Exit Function
                End If
                
            Case "ARMCOMBOBOX"
                If lControl.SelectedItem Is Nothing Then
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = lbl_label(mt_ClassInfoLst(al_Index).ListFieldsMandatory(lIdx, 1)).Caption
                    Call MsgBox(MsgText(2120, ms_Language_Code, "The field " & lv_MsgReplaceInfo(0, 1) & " is mandatory.", lv_MsgReplaceInfo), vbInformation)
                    lControl.SetFocus
                    
                    Exit Function
                End If
                
            Case "A_CALOCX"
                If lControl.date_courte = "" Then
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = lbl_label(mt_ClassInfoLst(al_Index).ListFieldsMandatory(lIdx, 1)).Caption
                    Call MsgBox(MsgText(2120, ms_Language_Code, "The field " & lv_MsgReplaceInfo(0, 1) & " is mandatory.", lv_MsgReplaceInfo), vbInformation)
                    lControl.SetFocus
                    
                    Exit Function
               End If
                
            Case "OPTIONBUTTON", "CHECKBOX", "ARMGRID", "LABEL", "FRAME", "DIRLISTBOX", "FILELISTBOX", "DRIVELISTBOX", "TOOLBARCONTROL"
                'Nothing to do
            Case Else
                Debug.Print "Item_CheckMandatory " & UCase(TypeName(mt_ClassInfoLst(al_Index).ListFieldsMandatory(lIdx, 0)))
        End Select
        Set lControl = Nothing
    
    Next
    
    
    Item_CheckMandatory = True
    Exit Function
    
ErrHandler:
    Call ErrorHandler("Item_CheckMandatory")
    
End Function
Private Sub DisableFrameParts(ByVal al_InfoArrayIndex As Long)
On Error GoTo ErrHandler
    Dim lIdx As Long, lCount As Long
    Dim lParams As Variant
    
    lCount = UBound(mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsToDisable)
    
    For lIdx = 0 To lCount
            Select Case UCase(TypeName(mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsToDisable(lIdx)))
                Case "FRAME", "LABEL", "MSFLEXGRID", "TOOLBARCONTROL"
                    ' Do nothing !
                
                Case "TEXTBOX"
                        mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsToDisable(lIdx).Locked = True
                        mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsToDisable(lIdx).BackColor = CL_COLOR_DISABLED
                        
                Case "ARMGRID", "ARMCHECKVIEW"
                                    
                Case "OPTIONBUTTON", "COMMANDBUTTON", "ARMCOMBOBOX", "A_CALOCX", "ARMTREEVIEW", "LISTBOX", "PICTUREBOX", "TABSTRIP", "CHECKBOX"
                    mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsToDisable(lIdx).Enabled = False
                    
                Case Else
                    Debug.Print "DisableFrameParts " & UCase(TypeName(mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsToDisable(lIdx)))
            End Select
    Next
    Exit Sub
ErrHandler:
    Call ErrorHandler("DisableFrameParts")
End Sub


Private Function cbo_IsFilled(ByVal ao_Combo As ArmCombobox) As Boolean
On Error GoTo ErrHandler

    If ao_Combo.SelectedItem Is Nothing Then Exit Function
    
    If ao_Combo.SelectedItem.Key = "" Then Exit Function
    
    cbo_IsFilled = True
    Exit Function
ErrHandler:
    Call ErrorHandler("cbo_IsFilled")

End Function


Private Function Item_Add() As Boolean
On Error GoTo ErrHandler
    
    'check the data validity -> Item_Check
    If Not Item_CheckMandatory(0) Then Exit Function
    
    If Not cbo_IsFilled(cbo_STD_System) And _
        Not cbo_IsFilled(cbo_SEM_System) And _
        Not cbo_IsFilled(cbo_CUS_System) Then
        MsgBox MsgText(0, ms_Language_Code, "#At least one of the Standard, Semi standard or Custom block must be field."), vbInformation
        cbo_STD_System.SetFocus
        Exit Function
    End If
    
    
    If cbo_IsFilled(cbo_STD_System) Then
        If Not Item_CheckMandatory(1) Then Exit Function
    End If
    
    If cbo_IsFilled(cbo_SEM_System) Then
        If Not Item_CheckMandatory(2) Then Exit Function
    End If
    
    If cbo_IsFilled(cbo_CUS_System) Then
        If Not Item_CheckMandatory(3) Then Exit Function
    End If
    
    If Not Item_Check Then Exit Function
    
    'update data on the db ->
    If Not Item_AddDB(0) Then Exit Function  'GoTo BackToGrid
        
    RaiseEvent OnItemAdd(eQuote, CLng(txt_key.Text), Build_SrzString(UserControl.Controls, Me))
    
    Call Item_Exit
    
    Item_Add = True
    
    Exit Function

ErrHandler:
    Call ErrorHandler("Item_Add")

End Function
Private Function Item_AddDB(ByVal al_InfoArrayIndex As Long) As Boolean

On Error GoTo ErrHandler

    Dim lb_TranOpened As Boolean

    Dim ls_ADD_Request As String
    Dim lv_ADD_Request As Variant
    
    Dim ll_curs As Long
    Dim ll_Ref As Long
    Dim ll_Tot_Area As Long
    Dim ls_UM_system As String
    Dim ls_SS_desc As String
    
    Dim ll_NextID As Long
    ll_NextID = mo_Db.SQLNextID("SOM_Quote")
    
    txt_key.Text = ll_NextID
    
    
    
    ls_ADD_Request = ReplaceALLHolders(UserControl.Controls, Me, mt_ClassInfoLst(0).RequestAdd)
    
    If me_Mode <> emRevision Then
        lv_ADD_Request = Split(ls_ADD_Request, SEP)
        
        ll_curs = OpenSQLSafe(mo_Db, lv_ADD_Request(0), 1)
        ll_Ref = mo_Db.GetFields(ll_curs, "Id_Value")
        mo_Db.Close (ll_curs)
        
        txt_QuoteRef.Text = ll_Ref
    
        ls_ADD_Request = ReplaceHolders(UserControl.Controls, Me, mt_ClassInfoLst(0).RequestAdd)
        
    End If
    
    ls_ADD_Request = Replace(ls_ADD_Request, "$Mode$", me_Mode)
    
    lv_ADD_Request = Split(ls_ADD_Request, SEP)
    
    
    lv_ADD_Request(1) = Replace(lv_ADD_Request(1), "$Quote_Ref$", ll_Ref)


    If Not BeginTran("AddQuoteDB") Then
        Err.Raise C_ERRORRAISE + 3, SCREEN_NAME, "Transaction Failure." & vbCrLf & "Enable to Start the transaction." & vbCrLf & Join(mo_Db.SQLErrorMessages, vbCrLf)
    End If
    
    lb_TranOpened = True
    
    
    ExecuteSQLSafe mo_Db, lv_ADD_Request(1), 1
    
    ExecuteSQLSafe mo_Db, lv_ADD_Request(2)
    
    ExecuteSQLSafe mo_Db, lv_ADD_Request(3)
    
'close the transaction
    If Not CommitTran("AddQuoteDB") Then
        Err.Raise C_ERRORRAISE + 4, SCREEN_NAME, "Transaction Failure." & vbCrLf & "Enable to commit the transaction." & vbCrLf & Join(mo_Db.SQLErrorMessages, vbCrLf)
    End If
    lb_TranOpened = False
    
    If me_Mode = emRevision Then
        ll_curs = OpenSQLSafe(mo_Db, lv_ADD_Request(4), 1)
        txt_Ref.Text = mo_Db.GetFields(ll_curs, "Reference")
        mo_Db.Close (ll_curs)
    Else
        txt_Ref.Text = txt_ProjNumber.Text & "." & txt_QuoteRef
    End If
    
    
    Item_AddDB = True

    Exit Function
    
ErrHandler:
    Item_AddDB = False
    If lb_TranOpened Then
         Call RollbackTran("AddQuoteDB")
    End If
    
    mo_Db.Close (ll_curs)
    Call ErrorHandler("Item_AddDB")
    
End Function

Private Function CheckNumericField(ByVal ao_value As TextBox, ByVal ai_NbDecimal As Integer, ByVal av_Min As Variant, ByVal av_Max As Variant) As Long
On Error GoTo ErrHandler
    Dim ls_Value As Variant
    
    ls_Value = Replace(ao_value.Text, ".", ms_DecimalSeparator, , , vbTextCompare)
    
    
    On Error Resume Next
    Dim ld_Number As Double
    Dim ll_errnum As Long
    ld_Number = CDbl(ls_Value)
    ll_errnum = Err.Number
    Err.Clear
    On Error GoTo ErrHandler
    If ll_errnum <> 0 Then
        CheckNumericField = 2131
        GoTo BackToControl
    End If

    If InStr(1, ls_Value, "e", vbTextCompare) Or InStr(1, ls_Value, ms_ThousandSeparator, vbTextCompare) Then
        CheckNumericField = 2131
        GoTo BackToControl
    End If
    
    
    If ai_NbDecimal = 0 And InStr(1, ls_Value, ms_DecimalSeparator) Then
        CheckNumericField = 2134
        GoTo BackToControl
    End If
    
    If Not (ld_Number >= av_Min And ld_Number <= av_Max) Then
        CheckNumericField = 2132
        GoTo BackToControl
    End If

    CheckNumericField = 0
    
    Exit Function

BackToControl:
    ao_value.SelStart = 0
    ao_value.SelLength = Len(ao_value.Text)
    If ao_value.Visible Then
        ao_value.SetFocus
        DoEvents
    End If
    
    Exit Function

ErrHandler:
    Call ErrorHandler("CheckNumericField")
   
End Function

Private Function Item_Check() As Boolean
On Error GoTo ErrHandler
    Dim lv_MsgReplaceInfo() As String
    Dim ll_IsNum As Long 'if 0 then ok
    
    'select case to manage the different records
            ll_IsNum = 0
            If opt_include(0).value = False And opt_include(1).value = False Then
                ReDim lv_MsgReplaceInfo(0, 1)
                lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                lv_MsgReplaceInfo(0, 1) = fra_include.Caption
                Call MsgBox(MsgText(2120, ms_Language_Code, "The field " & lv_MsgReplaceInfo(0, 1) & " is mandatory.", lv_MsgReplaceInfo), vbInformation)
                opt_include(0).SetFocus
                opt_include(0).value = False
                Exit Function
            End If
            
            If cbo_IsFilled(cbo_STD_System) Then
                ll_IsNum = CheckNumericField(txt_STD_Area, 0, 1, 9999999)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_STD.Caption & " " & lbl_label(7).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(9999999, 0)
                    GoTo errMessage
                End If
                
                ll_IsNum = CheckNumericField(txt_STD_ValueLC, 0, 1, 99999999)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_STD.Caption & " " & lbl_label(9).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(99999999, 0)
                    GoTo errMessage
                End If
                
                ll_IsNum = CheckNumericField(txt_STD_DB, 0, 1, 1000)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_STD.Caption & " " & lbl_label(10).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(1000, 0)
                    GoTo errMessage
                End If
            End If
            
            If cbo_IsFilled(cbo_SEM_System) Then
                ll_IsNum = CheckNumericField(txt_SEM_Area, 0, 1, 9999999)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_SEM.Caption & " " & lbl_label(18).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(9999999, 0)
                    GoTo errMessage
                End If
                
                ll_IsNum = CheckNumericField(txt_SEM_ValueLC, 0, 1, 99999999)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_SEM.Caption & " " & lbl_label(16).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(99999999, 0)
                    GoTo errMessage
                End If
                
                ll_IsNum = CheckNumericField(txt_SEM_DB, 0, 1, 1000)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_SEM.Caption & " " & lbl_label(15).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(1000, 0)
                    GoTo errMessage
                End If
            End If

            If cbo_IsFilled(cbo_CUS_System) Then
                ll_IsNum = CheckNumericField(txt_CUS_Area, 0, 1, 9999999)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_CUS.Caption & " " & lbl_label(21).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(9999999, 0)
                    GoTo errMessage
                End If
                
                ll_IsNum = CheckNumericField(txt_CUS_ValueLC, 0, 1, 99999999)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_CUS.Caption & " " & lbl_label(23).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(99999999, 0)
                    GoTo errMessage
                End If
                
                ll_IsNum = CheckNumericField(txt_CUS_DB, 0, 1, 1000)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = fra_CUS.Caption & " " & lbl_label(24).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(1000, 0)
                    GoTo errMessage
                End If
            End If
            
            If cbo_IsFilled(cbo_FreightCurr) Then
                ll_IsNum = CheckNumericField(txt_FreightCost, 0, 1, 99999999)
                If ll_IsNum <> 0 Then
                    ReDim lv_MsgReplaceInfo(2, 1)
                    lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                    lv_MsgReplaceInfo(0, 1) = lbl_label(32).Caption
                    lv_MsgReplaceInfo(1, 0) = "$Min$"
                    lv_MsgReplaceInfo(1, 1) = 1
                    lv_MsgReplaceInfo(2, 0) = "$Max$"
                    lv_MsgReplaceInfo(2, 1) = FormatNumber(99999999, 0)
                    GoTo errMessage
                End If
            End If
            
            If txt_FreightCost.Text <> "0" And txt_FreightCost.Text <> "" And Not cbo_IsFilled(cbo_FreightCurr) Then
                ll_IsNum = 10000
                ReDim lv_MsgReplaceInfo(2, 1)
                lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                lv_MsgReplaceInfo(0, 1) = lbl_label(32).Caption
                GoTo errMessage
            End If
            
            ll_IsNum = CheckNumericField(txt_TOT_ValueCHF, 0, 1, 999999999)
            If ll_IsNum <> 0 Then
                ReDim lv_MsgReplaceInfo(2, 1)
                lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
                lv_MsgReplaceInfo(0, 1) = fra_TOT.Caption & " " & lbl_label(28).Caption
                lv_MsgReplaceInfo(1, 0) = "$Min$"
                lv_MsgReplaceInfo(1, 1) = 1
                lv_MsgReplaceInfo(2, 0) = "$Max$"
                lv_MsgReplaceInfo(2, 1) = FormatNumber(999999999, 0)
                GoTo errMessage
            End If
            
            If cbo_IsFilled(cbo_quote_curr) Then
                If cbo_quote_curr.SelectedItem.GetData(2) = 0 Then
                    cbo_quote_curr.SetFocus
                    ll_IsNum = 3064
                    GoTo errMessage
                End If
            End If
            
            If cbo_IsFilled(cbo_FreightCurr) Then
                If cbo_FreightCurr.SelectedItem.GetData(2) = 0 Then
                    cbo_FreightCurr.SetFocus
                    ll_IsNum = 3064
                    GoTo errMessage
                End If
            End If
            
errMessage:
    Select Case ll_IsNum
        Case 2131
            Call MsgBox(MsgText(ll_IsNum, ms_Language_Code, "#The field " & lv_MsgReplaceInfo(0, 1) & " must be numeric.", lv_MsgReplaceInfo), vbInformation)
            Exit Function
            
        Case 2134
            Call MsgBox(MsgText(ll_IsNum, ms_Language_Code, "#The field " & lv_MsgReplaceInfo(0, 1) & " does not accept decimal number.", lv_MsgReplaceInfo), vbInformation)
            Exit Function
            
        Case 2132
            Call MsgBox(MsgText(ll_IsNum, ms_Language_Code, "#The field " & lv_MsgReplaceInfo(0, 1) & " must be a number between " & lv_MsgReplaceInfo(1, 1) & " and " & lv_MsgReplaceInfo(2, 1) & ".", lv_MsgReplaceInfo), vbInformation)
            Exit Function
            
        Case 3064
            Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
            Exit Function
            
            
        Case 10000
            Call MsgBox(MsgText(ll_IsNum, ms_Language_Code, "#The field " & lv_MsgReplaceInfo(0, 1) & " is not 0 please select  a currencie or set the " & lv_MsgReplaceInfo(0, 1) & " to 0."), vbInformation)
            txt_FreightCost.SetFocus
            Exit Function
    End Select
    
    Item_Check = True
    Exit Function
    
ErrHandler:
    Call ErrorHandler("Item_Check")


End Function

Private Sub Components_Settings()
On Error GoTo ErrHandler

    Call Component_SetUp(tbl_main, "", 79)
    
    Call Component_SetUp(lbl_label(61), "lbl_TTL_ValueLC")
    Call Component_SetUp(txt_TOT_ValueLC, "TOT_Quote_Value_LC" & SEP & "Num" & SEP & "0", 78)
    
    Call Component_SetUp(lbl_label(60), "lbl_OfferDate")
    Call Component_SetUp(cal_OfferDate, "Quote_OfferDate", 77)
    
    
    Call Component_SetUp(txt_ProjNumber, "ProjectNumber" & SEP & "Text", 76)
    Call Component_SetUp(txt_TOT_SS_desc, "TOT_SS_desc" & SEP & "Text", 75)
    Call Component_SetUp(txt_TOT_area, "TOT_Quote_Area" & SEP & "Text", 74)
    Call Component_SetUp(txt_TOT_UM, "TOT_UM_System" & SEP & "Text", 73)
    Call Component_SetUp(txt_Status, "Status" & SEP & "Text", 72)
    Call Component_SetUp(txt_QuoteRef, "Quote_Ref" & SEP & "Text", 71)
    Call Component_SetUp(txt_LinkID, "ProjCustLink_ID" & SEP & "Text", 70)
    Call Component_SetUp(txt_FreightCostCHF, "Quote_FRGHTCost_CHF" & SEP & "Text", 69)
    Call Component_SetUp(txt_key, "Quote_ID" & SEP & "Text", 68)
            
'--------

    Call Component_SetUp(fra_ModifInfo, "")
    
    Call Component_SetUp(lbl_label(58), "lbl_UpdUserBy")
    Call Component_SetUp(txt_UpdUser, "U_login_lastupd" & SEP & "Text", 67)
    
    Call Component_SetUp(lbl_label(53), "lbl_LastUpdateDate")
    Call Component_SetUp(txt_LastUpdDate, "Z_last_upd" & SEP & "Text", 66)
    
    Call Component_SetUp(lbl_label(52), "lbl_CreatorBy")
    Call Component_SetUp(txt_Creator, "U_login_creator" & SEP & "Text", 65)
    
    Call Component_SetUp(lbl_label(37), "lbl_CreationDate")
    Call Component_SetUp(txt_CreationDate, "Z_creation" & SEP & "Text", 64)

'---------
    
    Call Component_SetUp(lbl_label(49), "lbl_CustFax")
    Call Component_SetUp(txt_CustFax, "Cust_fax" & SEP & "Text", 63)
    
    Call Component_SetUp(lbl_label(50), "lbl_CustTel")
    Call Component_SetUp(txt_CustTel, "Cust_tel" & SEP & "Text", 62)
    
    Call Component_SetUp(lbl_label(59), "lbl_SalesPerson")
    Call Component_SetUp(txt_custSales, "Cust_SSR_desc" & SEP & "Text", 61)
    
    Call Component_SetUp(lbl_label(54), "lbl_CustType")
    Call Component_SetUp(txt_CustType, "SCT_desc" & SEP & "Text", 60)
    
    Call Component_SetUp(lbl_label(55), "lbl_CustZipCode")
    Call Component_SetUp(txt_CustCountry(12), "CustCT_desc" & SEP & "Text", 59)
    Call Component_SetUp(txt_CustZip, "Cust_zip" & SEP & "Text", 58)
    
    Call Component_SetUp(fra_Customer, "")
    Call Component_SetUp(lbl_label(51), "lbl_CustTown")
    Call Component_SetUp(txt_CustTown, "Cust_town" & SEP & "Text", 57)
    
    Call Component_SetUp(lbl_label(56), "lbl_CustAddress")
    Call Component_SetUp(txt_Cust_addr2, "Cust_addr2" & SEP & "Text", 56)
    Call Component_SetUp(txt_CustAddr1, "Cust_addr1" & SEP & "Text", 55)
    
    Call Component_SetUp(lbl_label(57), "lbl_CustomerName")
    Call Component_SetUp(txt_CustName, "Cust_name" & SEP & "Text", 54)
    
'---------
    Call Component_SetUp(fra_project, "")
            
    Call Component_SetUp(lbl_label(46), "lbl_ProjectDuration")
    Call Component_SetUp(txt_projduration, "Proj_duration" & SEP & "Num" & SEP & "0", 53)
    Call Component_SetUp(lbl_label(47), "lbl_ProjectWeeks")
    
    Call Component_SetUp(lbl_label(45), "lbl_ExpOrder")
    Call Component_SetUp(txt_ProjExporderdate, "Proj_Exporderdate" & SEP & "Text", 52)
    
    Call Component_SetUp(lbl_label(44), "lbl_FollowUp")
    Call Component_SetUp(txt_projFollowup, "Proj_Followupdate" & SEP & "Text", 51)
    
    Call Component_SetUp(lbl_label(43), "lbl_MktSegment")
    Call Component_SetUp(txt_projMKS, "MKS_desc" & SEP & "Text", 50)
    
    Call Component_SetUp(lbl_label(42), "lbl_Size")
    Call Component_SetUp(txt_projUM, "UM_desc" & SEP & "Text", 49)
    Call Component_SetUp(txt_projSize, "Proj_Size" & SEP & "Num" & SEP & "0", 48)
    
    Call Component_SetUp(lbl_label(41), "lbl_ProjStatus")
    Call Component_SetUp(txt_ProjStatus, "PS_desc" & SEP & "Text", 47)
    
    Call Component_SetUp(lbl_label(40), "lbl_SalesPerson")
    Call Component_SetUp(txt_projSales, "Proj_SSR_Desc" & SEP & "Text", 46)
    
    Call Component_SetUp(lbl_label(39), "lbl_ProjZipCode")
    Call Component_SetUp(txt_projCountry, "ProjCT_desc" & SEP & "Text", 45)
    Call Component_SetUp(txt_projZip, "Proj_Zip" & SEP & "Text", 44)
    
    Call Component_SetUp(lbl_label(48), "lbl_ProjTown")
    Call Component_SetUp(txt_projTown, "Proj_Town" & SEP & "Text", 43)
    
    Call Component_SetUp(lbl_label(38), "lbl_ProjAddress")
    Call Component_SetUp(txt_projaddr1, "Proj_Addr1" & SEP & "Text", 42)
    
    Call Component_SetUp(lbl_label(36), "lbl_ProjectName")
    Call Component_SetUp(txt_project, "Proj_Name" & SEP & "Text", 41)


'--------

    Call Component_SetUp(lbl_label(30), "lbl_Quote_Comment")
    Call Component_SetUp(txt_comment, "Quote_Comment" & SEP & "Text", 40)

    Call Component_SetUp(lbl_label(35), "lbl_BO")
    Call Component_SetUp(cbo_BO, "BO_SSR_code" & SEP & "BO_SSR_desc", 39)
    
    Call Component_SetUp(lbl_label(34), "lbl_Realisation")
    Call Component_SetUp(cbo_realisation, "RL_code" & SEP & "RL_desc", 38)
    
    Call Component_SetUp(lbl_label(33), "lbl_Freight_in")
    Call Component_SetUp(cbo_FreightCurr, "FRGHT_CURR_code" & SEP & "FRGHT_CURR_desc", 37)
    
    Call Component_SetUp(lbl_label(32), "lbl_FreightCostLC")
    Call Component_SetUp(txt_FreightCost, "Quote_FRGHTCostLC" & SEP & "Num" & SEP & "0", 36)
    
    Call Component_SetUp(lbl_label(31), "lbl_ValidUntil")
    Call Component_SetUp(cal_ValidUntil, "Quote_ValidToDate", 35)
    
'--------
   
    Call Component_SetUp(lbl_label(27), "lbl_TOT_PrimeMargin")
    Call Component_SetUp(txt_TOT_PrimeMarg, "TOT_Quote_PrimeMargin" & SEP & "Num" & SEP & "2", 34)
    
    Call Component_SetUp(lbl_label(28), "lbl_TOT_ValueCHF")
    Call Component_SetUp(txt_TOT_ValueCHF, "TOT_Quote_Value_CHF" & SEP & "Num" & SEP & "0", 33)
    
    Call Component_SetUp(fra_TOT, "fra_TOT")
    Call Component_SetUp(lbl_label(29), "lbl_TOT_DB")
    Call Component_SetUp(txt_TOT_DB, "TOT_Quote_DB" & SEP & "Num" & SEP & "0", 32)
    
'--------
    Call Component_SetUp(fra_CUS, "fra_CUS")
    
    Call Component_SetUp(lbl_label(26), "lbl_CUS_PrimeMargin")
    Call Component_SetUp(txt_CUS_PrimeMarg, "CUS_Quote_PrimeMargin" & SEP & "Num" & SEP & "2", 31)
      
    Call Component_SetUp(lbl_label(25), "lbl_CUS_ValueCHF")
    Call Component_SetUp(txt_CUS_ValueCHF, "CUS_Quote_Value_CHF" & SEP & "Num" & SEP & "0", 30)
    
    Call Component_SetUp(lbl_label(24), "lbl_CUS_DB")
    Call Component_SetUp(txt_CUS_DB, "CUS_Quote_DB" & SEP & "Num" & SEP & "0", 29)
    
    Call Component_SetUp(lbl_label(23), "lbl_CUS_ValueLC")
    Call Component_SetUp(txt_CUS_ValueLC, "CUS_Quote_ValueLC" & SEP & "Num" & SEP & "0", 28)
    
    Call Component_SetUp(lbl_label(22), "lbl_CUS_in")
    Call Component_SetUp(cbo_CUS_UM, "CUS_UM_code" & SEP & "CUS_UM_desc", 27)
    
    Call Component_SetUp(lbl_label(21), "lbl_CUS_Area")
    Call Component_SetUp(txt_CUS_Area, "CUS_Quote_Area" & SEP & "Num" & SEP & "0", 26)
    
    Call Component_SetUp(lbl_label(20), "lbl_CUS_system")
    Call Component_SetUp(cbo_CUS_System, "CUS_SS_code" & SEP & "CUS_SS_desc", 25)

'--------
    Call Component_SetUp(fra_SEM, "fra_SEM")
    
    Call Component_SetUp(lbl_label(13), "lbl_SEM_PrimeMargin")
    Call Component_SetUp(txt_SEM_PrimeMarg, "SEM_Quote_PrimeMargin" & SEP & "Num" & SEP & "2", 24)
    
    Call Component_SetUp(lbl_label(14), "lbl_SEM_ValueCHF")
    Call Component_SetUp(txt_SEM_ValueCHF, "SEM_Quote_Value_CHF" & SEP & "Num" & SEP & "0", 23)
    
    Call Component_SetUp(lbl_label(15), "lbl_SEM_DB")
    Call Component_SetUp(txt_SEM_DB, "SEM_Quote_DB" & SEP & "Num" & SEP & "0", 22)
    
    Call Component_SetUp(lbl_label(16), "lbl_SEM_ValueLC")
    Call Component_SetUp(txt_SEM_ValueLC, "SEM_Quote_ValueLC" & SEP & "Num" & SEP & "0", 21)
    
    Call Component_SetUp(lbl_label(17), "lbl_SEM_in")
    Call Component_SetUp(cbo_SEM_UM, "SEM_UM_code" & SEP & "SEM_UM_desc", 20)
    
    Call Component_SetUp(lbl_label(18), "lbl_SEM_Area")
    Call Component_SetUp(txt_SEM_Area, "SEM_Quote_Area" & SEP & "Num" & SEP & "0", 19)
    
    Call Component_SetUp(lbl_label(19), "lbl_SEM_system")
    Call Component_SetUp(cbo_SEM_System, "SEM_SS_code" & SEP & "SEM_SS_desc", 18)
 
 '--------
    Call Component_SetUp(fra_STD, "fra_STD")
    
    Call Component_SetUp(lbl_label(12), "lbl_STD_PrimeMargin")
    Call Component_SetUp(txt_STD_PrimeMarg, "STD_Quote_PrimeMargin" & SEP & "Num" & SEP & "2", 17)
    
    Call Component_SetUp(lbl_label(11), "lbl_STD_ValueCHF")
    Call Component_SetUp(txt_STD_ValueCHF, "STD_Quote_Value_CHF" & SEP & "Num" & SEP & "0", 16)
    
    Call Component_SetUp(lbl_label(10), "lbl_STD_DB")
    Call Component_SetUp(txt_STD_DB, "STD_Quote_DB" & SEP & "Num" & SEP & "0", 15)
    
    Call Component_SetUp(lbl_label(9), "lbl_STD_ValueLC")
    Call Component_SetUp(txt_STD_ValueLC, "STD_Quote_ValueLC" & SEP & "Num" & SEP & "0", 14)
    
    Call Component_SetUp(lbl_label(8), "lbl_STD_in")
    Call Component_SetUp(cbo_STD_UM, "STD_UM_code" & SEP & "STD_UM_desc", 13)
    
    Call Component_SetUp(lbl_label(7), "lbl_STD_Area")
    Call Component_SetUp(txt_STD_Area, "STD_Quote_Area" & SEP & "Num" & SEP & "0", 12)
    
    Call Component_SetUp(lbl_label(6), "lbl_STD_system")
    Call Component_SetUp(cbo_STD_System, "STD_SS_code" & SEP & "STD_SS_desc", 11)

'---------
       
    Call Component_SetUp(lbl_label(4), "lbl_SalesRep")
    Call Component_SetUp(cbo_SalesRep, "Q_SSR_code" & SEP & "Q_SSR_desc", 10)
    Call Component_SetUp(lbl_label(5), "lbl_Status")
    
    Call Component_SetUp(fra_include, "fra_include")
    Call Component_SetUp(opt_include(1), "Quote_Include" & SEP & "False" & SEP & "2" & SEP & "Include_desc", 9)
    Call Component_SetUp(opt_include(0), "Quote_Include" & SEP & "False" & SEP & "1" & SEP & "Include_desc", 8)
    
    Call Component_SetUp(fra_type, "fra_type")
    Call Component_SetUp(opt_type(1), "Quote_Type" & SEP & "False" & SEP & "2" & SEP & "Type_desc", 7)
    Call Component_SetUp(opt_type(0), "Quote_Type" & SEP & "True" & SEP & "1" & SEP & "Type_desc", 6)
    
    Call Component_SetUp(lbl_label(3), "lbl_currency")
    Call Component_SetUp(cbo_quote_curr, "Quote_CURR_Code" & SEP & "Quote_CURR_desc", 5)
    
    Call Component_SetUp(lbl_label(1), "lbl_customer")
    Call Component_SetUp(cbo_Customer, "Cust_ID" & SEP & "Cust_desc", 4)
    
    Call Component_SetUp(lbl_label(2), "lbl_project")
    Call Component_SetUp(cbo_Project, "Proj_ID" & SEP & "Proj_desc", 3)
    
    Call Component_SetUp(txt_StatusDate, "StatusDate" & SEP & "Date", 2)
    Call Component_SetUp(txt_StatusDesc, "Status_desc" & SEP & "Text", 1)
    
    Call Component_SetUp(lbl_label(0), "lbl_Reference")
    Call Component_SetUp(txt_Ref, "Reference" & SEP & "Text", 0)
    
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Components_Settings")
End Sub


Private Sub Component_SetUp(ByVal ao_cpt As Object, ByVal as_Tag As String, Optional ai_TabIndex As Integer)

On Error GoTo ErrHandler
    
    ao_cpt.Tag = as_Tag
    ao_cpt.TabIndex = ai_TabIndex
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("Component_SetUp")
End Sub
Private Sub HandleToolbar(ByVal atlb_Toolbar As Object, ByVal as_face As String, ByVal ab_ButtonsVisible As Boolean)
On Error GoTo ErrHandler

    atlb_Toolbar.Visible = False
    atlb_Toolbar.DisplayFace (as_face)
    If Not ab_ButtonsVisible Then
        atlb_Toolbar.Redraw = False
        atlb_Toolbar.ButtonVisible("C") = False
        atlb_Toolbar.Redraw = True
    End If
    atlb_Toolbar.Visible = True
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("HandleToolbar")
    
End Sub
Private Sub InitComponents()

On Error GoTo ErrHandler
    
    Const CL_REQUEST_TB As String = "SELECT Toolbar_Info FROM Toolbars_Users WHERE User_Code=$user_id$"

    Dim ls_Toolbar_Info As String
    Dim lCursTB As Long
    Dim ll_Charset As Long
    
    lCursTB = OpenSQLSafe(mo_Db, Replace(CL_REQUEST_TB, "$user_id$", 0))
    
    ls_Toolbar_Info = mo_Db.GetFields(lCursTB, "toolbar_info")
    Call mo_Db.Close(lCursTB)
    
    Call tbl_main.Load_A_Com
    tbl_main.Language = "E" 'ms_Language_Code
    
    Call tbl_main.SetToolbarInfoStringParameters(ls_Toolbar_Info, "050")
    Call HandleToolbar(tbl_main, "0", mb_IsFullAccess)
    
    ll_Charset = GetCharSetFromCodePage(Get_Code_Page)
    
    Dim lo_Control As Control

    For Each lo_Control In UserControl.Controls
        Select Case UCase(TypeName(lo_Control))
            Case "ARMGRID"
                Set lo_Control.ArmDb = mo_Db
                lo_Control.Font.Name = "Arial"
                lo_Control.Font.Charset = ll_Charset
                lo_Control.LocalID = ml_LocalID
                lo_Control.Codepage = Get_Code_Page
                lo_Control.Load_A_Com
                
            Case "ARMCOMBOBOX"
                Set lo_Control.ArmDb = mo_Db
                lo_Control.Font.Name = "Arial"
                lo_Control.Font.Charset = ll_Charset
                lo_Control.Load_A_Com
                
            Case "CHECKBOX", "LABEL", "COMMANDBUTTON", "FRAME", "TEXTBOX"
                lo_Control.Font.Name = "Arial"
                lo_Control.Font.Charset = ll_Charset
                Select Case UCase(lo_Control.Name)
                    Case "TXT_KEY", "TXT_LINKID", "TXT_PROJNUMBER", "TXT_QUOTEREF", "TXT_STATUS", "TXT_TOT_AREA", "TXT_TOT_UM", "TXT_TOT_SS_DESC", "TXT_FREIGHTCOSTCHF"
                        lo_Control.Visible = False
                End Select
        End Select
    Next
    
    
    
    Dim ll_curs As Long
    ll_curs = OpenSQLSafe(mo_Db, "SELECT RF_desc FROM A_references_ML WHERE gr_code = 53 and rf_code = 5 and Language_code = '" & ms_Language_Code & "'")
    If mo_Db.RowCount(ll_curs) <> 0 Then
        mt_ClassInfoLst(0).ListFieldsDefaultValue(22, 1) = Trim(mo_Db.GetFields(ll_curs, "RF_desc"))
    End If
    mo_Db.Close (ll_curs)
    
    
    
    
    cbo_FreightCurr.Request = "exec  SOM_Currencies_cbo '" & ms_Language_Code & "'"
    cbo_quote_curr.Request = "exec  SOM_Currencies_cbo '" & ms_Language_Code & "'"
    cbo_realisation.Request = "exec SOM_Realisation_cbo '" & ms_Language_Code & "'"
    
    cbo_SalesRep.Request = "exec SOM_Sales_Reps_cbo 1"
    cbo_BO.Request = "exec SOM_Sales_Reps_cbo 2"
    
    
    cbo_STD_UM.Request = "exec SOM_UM_cbo '" & ms_Language_Code & "'"
    cbo_SEM_UM.Request = "exec SOM_UM_cbo '" & ms_Language_Code & "'"
    cbo_CUS_UM.Request = "exec SOM_UM_cbo '" & ms_Language_Code & "'"
        
    cbo_STD_System.Request = "exec SOM_System_cbo '" & ms_Language_Code & "'"
    cbo_SEM_System.Request = "exec SOM_System_cbo '" & ms_Language_Code & "'"
    cbo_CUS_System.Request = "exec SOM_System_cbo '" & ms_Language_Code & "'"
    
    cbo_STD_System.FirstBlankItem = True
    cbo_SEM_System.FirstBlankItem = True
    cbo_CUS_System.FirstBlankItem = True
    
    cbo_FreightCurr.FirstBlankItem = True
        
    cal_ValidUntil.Language = ms_Language_Code
    cal_ValidUntil.ZOrder
    cal_OfferDate.Language = ms_Language_Code
    cal_OfferDate.ZOrder
    
    btn_OK.Caption = ""
    btn_OK.Picture = LoadResPicture(129, vbResIcon)
    
    Call fra_invalidate.Move(3833, 3870, 7425, 2265)
    fra_invalidate.Visible = False
    
    
    Exit Sub
    
ErrHandler:
    mo_Db.Close (lCursTB)
    Call ErrorHandler("InitComponents")
End Sub

Private Function Get_Code_Page() As Long
On Error GoTo ErrHandler

    Const Request As String = "SELECT Code_Page FROM Language WHERE Language_code = '$Language_code$'"
    
    Static lb_HasRun As Boolean
    Static ls_code_page As Long

    
    
    Dim ls_Req As String
    Dim ll_curs As Long
    If Not lb_HasRun Then
        ls_Req = Replace(Request, "$Language_code$", ms_Language_Code, , , vbTextCompare)
        
        ll_curs = OpenSQLSafe(mo_Db, ls_Req)
        
        If mo_Db.RowCount(ll_curs) = 0 Then
             Err.Raise C_ERRORRAISE + 503, "Get_Code_Page", "Enable to get the code page for the language " & ms_Language_Code & " - " & Join(mo_Db.SQLErrorMessages, vbCrLf)
        End If
        
        ls_code_page = mo_Db.GetFields(ll_curs, "Code_Page")
        
        mo_Db.Close (ll_curs)
    End If
    
    Get_Code_Page = ls_code_page
    
    
    Exit Function
 

ErrHandler:
    mo_Db.Close (ll_curs)
    Call ErrorHandler("Get_Code_Page")
End Function
Private Sub LockScreen(ByVal ab_lock As Boolean)

    Dim ll_errNumber As Long, ls_ErrSrc As String, ls_ErrDesc As String
    ll_errNumber = Err.Number
    ls_ErrSrc = Err.Source
    ls_ErrDesc = Err.Description

On Error GoTo ErrHandler
    Static ll_Count As Long
    Static ll_Mousepointer As Long
    Static lb_Locked As Boolean
      
      
    ll_Count = ll_Count + IIf(ab_lock, 1, -1)
    Debug.Assert (ll_Count >= 0)
    
    ' First lock
    If Not lb_Locked And ab_lock Then
        ll_Mousepointer = Screen.MousePointer
        Screen.MousePointer = vbHourglass
        LockWindowUpdate UserControl.hwnd
        lb_Locked = True
    End If
    
    ' Unlock
    If ll_Count = 0 Then
        DoEvents ' Flush events
        LockWindowUpdate 0
        UserControl.Refresh ' Repaint immediately
        Screen.MousePointer = ll_Mousepointer
        lb_Locked = False
    End If
    
    Err.Number = ll_errNumber
    Err.Source = ls_ErrSrc
    Err.Description = ls_ErrDesc
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("LockScreen")
End Sub

Public Function Unload_A_Com() As Boolean

On Error GoTo ErrHandler

    If Not mb_Initialized Then Exit Function
    
    Dim lo_Control As Control
    
    For Each lo_Control In UserControl.Controls
        Select Case UCase(TypeName(lo_Control))
            Case "TOOLBARCONTROL", "ARMCOMBOBOX", "ARMGRID"
                lo_Control.Unload_A_Com
        End Select
    Next
    
           
    Set mo_Db = Nothing
    
    mb_Initialized = False
    
    Unload_A_Com = True
    
    Exit Function
    
ErrHandler:
    Call ErrorHandler("Unload_A_Com")
End Function

Private Function BeginTran(as_Tran As String) As Boolean

On Error GoTo ErrHandler
    BeginTran = False
    ExecuteSQLSafe mo_Db, "BEGIN TRANSACTION " & as_Tran

    BeginTran = True
    Exit Function
    
ErrHandler:
    mo_Db.Disconnect
    Set mo_Db = Nothing
    MsgBox "A Fatal error occured in " & SCREEN_NAME & ".BeginTran, your application will be close. Please contact your IT support"
    End
End Function
Private Function CommitTran(as_Tran As String) As Boolean

On Error GoTo ErrHandler
    CommitTran = False
    ExecuteSQLSafe mo_Db, "COMMIT TRANSACTION " & as_Tran

    CommitTran = True
    Exit Function
    
ErrHandler:
    mo_Db.Disconnect
    Set mo_Db = Nothing
    MsgBox "A Fatal error occured in " & SCREEN_NAME & ".CommitTran, your application will be close. Please contact your IT support"
    End

End Function

Private Function RollbackTran(as_Tran As String) As Boolean
    
    Dim ll_errNumber As Long, ls_ErrSrc As String, ls_ErrDesc As String
    ll_errNumber = Err.Number
    ls_ErrSrc = Err.Source
    ls_ErrDesc = Err.Description

On Error GoTo ErrHandler
    RollbackTran = False
    
    ExecuteSQLSafe mo_Db, "ROLLBACK TRANSACTION " & as_Tran


    Err.Number = ll_errNumber
    Err.Source = ls_ErrSrc
    Err.Description = ls_ErrDesc

    RollbackTran = True
    Exit Function
    
ErrHandler:
    If mo_Db.LastErrorCode <> 3903 Then
        mo_Db.Disconnect
        Set mo_Db = Nothing
        MsgBox "A Fatal error occured in " & SCREEN_NAME & ".RollbackTran, your application will be close. Please contact your IT support"
        End
    Else
        Err.Number = ll_errNumber
        Err.Source = ls_ErrSrc
        Err.Description = ls_ErrDesc
    
        RollbackTran = True
    
    End If
End Function
Private Sub ErrorHandler(ByVal as_Fct As String)
    Err.Raise Err.Number, UserControl.Name & "." & UserControl.Ambient.DisplayName & "::" & as_Fct & SEP1 & Err.Source, Err.Description
End Sub

Function MsgText(ByVal aID As Long, ByVal aLang As String, ByVal aDefault As String, Optional ByVal aInfo As Variant) As String

On Error GoTo ErrHandler

Const DB_REQ As String = "SELECT message_text FROM error_message WHERE msgid = $id$ AND Language_code = '$lang$'"

    MsgText = ""
    
    Dim lRequest As String
    lRequest = Replace(DB_REQ, "$id$", aID)
    lRequest = Replace(lRequest, "$lang$", aLang)
    Dim lData As Long
    
    lData = OpenSQLSafe(mo_Db, lRequest)
    
    Dim lBuffer As String
    lBuffer = mo_Db.GetFields(lData, "message_text")
    mo_Db.Close (lData)
    If lBuffer = "" Then lBuffer = aDefault
    
    Dim li_Idx As Integer
    If Not IsMissing(aInfo) Then
        For li_Idx = 0 To UBound(aInfo)
            lBuffer = Replace(lBuffer, aInfo(li_Idx, 0), aInfo(li_Idx, 1), , , vbTextCompare)
        Next li_Idx
    End If
    
    
    MsgText = lBuffer
    Exit Function
ErrHandler:
    mo_Db.Close (lData)
    Call ErrorHandler("MsgText")
   
End Function
' Return the result of a SQL request
' Convert SQL runtime errors and process errors to VB Error
#If LIVE = 1 Then
Private Function OpenSQLSafe(ByVal ao_DB As Object, ByVal as_Request As String, Optional ByVal al_RowExpectedCount = -1) As Long
#Else
Private Function OpenSQLSafe(ByVal ao_DB As ARMSYSCOMLib.ArmDb, ByVal as_Request As String, Optional ByVal al_RowExpectedCount = -1) As Long
#End If

On Error GoTo ErrHandler

    Dim lc_Data As Long
    lc_Data = ao_DB.OpenSQL(as_Request)
    
    If lc_Data = 0 Then
        Err.Raise ArmErr.SQLFailure, "SQL : " & as_Request, Join(ao_DB.SQLErrorCodes, SEP2) & SEP1 & Join(ao_DB.SQLErrorMessages, SEP2)
    End If
'    Debug.Print 1 / 0
    If al_RowExpectedCount <> -1 Then
        ' Then check the rowcount
        If ao_DB.RowCount(lc_Data) <> al_RowExpectedCount Then
            Err.Raise ArmErr.SQLBadRowExpectedCount, "SQL : " & as_Request, al_RowExpectedCount & "<>" & ao_DB.RowCount(lc_Data)
        End If
    End If

    OpenSQLSafe = lc_Data

    Exit Function

ErrHandler:

    Call ErrorHandler("OpenSQLSafe")

End Function



' Execute a SQL request returning no data
' Convert SQL runtime errors and process errors to VB Error
' Params:
' ao_Db (Object)
' as_Request (String)
' al_RowAffectedCount (String)
#If LIVE = 1 Then
Private Sub ExecuteSQLSafe(ByVal ao_DB As Object, ByVal as_Request As String, Optional ByVal al_RowAffectedCount = -1, Optional ab_DuplicityCheck As Boolean = False)
#Else
Private Sub ExecuteSQLSafe(ByVal ao_DB As ARMSYSCOMLib.ArmDb, ByVal as_Request As String, Optional ByVal al_RowAffectedCount = -1, Optional ab_DuplicityCheck As Boolean = False)
#End If
On Error GoTo ErrHandler

    ' First execute the request
    If Not ao_DB.ExecuteSQL(as_Request) Then
        Err.Raise ArmErr.SQLFailure, "SQL : " & as_Request, Join(ao_DB.SQLErrorCodes, SEP2) & SEP1 & Join(ao_DB.SQLErrorMessages, SEP2)
    End If

    If al_RowAffectedCount <> -1 Then
        ' Then check the rowcount
        If ao_DB.SQLRowsAffected <> al_RowAffectedCount Then
            
            If ab_DuplicityCheck Then
                Err.Raise ArmCusErr.DuplicityDetected, "SQL : " & as_Request, al_RowAffectedCount & "<>" & ao_DB.SQLRowsAffected
            Else
                Err.Raise ArmErr.SQLBadRowAffectedCount, "SQL : " & as_Request, al_RowAffectedCount & "<>" & ao_DB.SQLRowsAffected
            End If
        End If
    End If

    Exit Sub

ErrHandler:
    Call ErrorHandler("ExecuteSQLSafe")
End Sub
' logs message to database
Private Sub LogMessage(ByVal as_logMsg As String, Optional ByVal as_logType As String = "I", Optional ab_throwException As Boolean = True)
On Error GoTo ErrHandler
Const InsertReq As String = "EXEC A_log_ins $UCODE$, '$LOGTYPE$', '$MSG$', '$APP$'"
    Dim ls_Req As String
    Dim ll_Cursor As Long
    
    ls_Req = Replace(InsertReq, "$UCODE$", CStr(ml_UCode))
    ls_Req = Replace(ls_Req, "$APP$", Left(Trim(SQLStr(SCREEN_NAME & " " & App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)), 50))
    ls_Req = Replace(ls_Req, "$MSG$", right(Trim(SQLStr(as_logMsg)), 4000))
    ls_Req = Replace(ls_Req, "$LOGTYPE$", SQLStr(as_logType), 1)
    
    Call ExecuteSQLSafe(mo_Db, ls_Req)
    
    Exit Sub
ErrHandler:
    If ab_throwException Then Call ErrorHandler(Extender.Name & ".LogMessage - " & Err.Number & ": " & Err.Description)
End Sub

Private Function SQLStr(ByVal as_str As String) As String
    SQLStr = Replace(as_str, "'", "''")
End Function

Public Function SqlDate(ByVal as_Date As String) As String
  SqlDate = "'" & Format$(as_Date, "YYYY-MM-DD") & "'"
End Function

Public Function SqlTime(ByVal ad_Seconds As Double) As String
Dim ll_Hours As Long
Dim ll_Minutes As Long
Dim ll_Seconds As Long
  
  ll_Seconds = ad_Seconds
  ll_Hours = ll_Seconds \ 3600
  ll_Minutes = (ll_Seconds - (ll_Hours * 3600)) \ 60
  ll_Seconds = ll_Seconds Mod 60
  SqlTime = "'" & Format(ll_Hours, "00") & ":" & Format(ll_Minutes, "00") & ":" & Format(ll_Seconds, "00") & "'"
End Function

Private Sub Load_ClassInfo()
On Error GoTo ErrHandler

    ReDim mt_ClassInfoLst(3)
    
        With mt_ClassInfoLst(0)
            .RequestView = "exec SOM_Quote_Sel $Quote_ID$, '$Language_code$'"
            
            .RequestAdd = "exec SOM_GetNextQuoteRef $Proj_ID$" & SEP & _
            "exec SOM_Quote_Ins $Mode$, $Quote_ID$, $Quote_Ref$, $ProjCustLink_ID$ , '$Language_code$', " & _
            "$Quote_Include$, '$Quote_CURR_code$', $Quote_Type$, $Status$, " & _
            "'$StatusDate$', $STD_SS_Code$, '$STD_Quote_Area$', '$STD_UM_Code$', '$STD_Quote_ValueLC$', " & _
            "$STD_Quote_Value_CHF$, '$STD_Quote_DB$', $STD_Quote_PrimeMargin$, $SEM_SS_Code$, " & _
            "'$SEM_Quote_Area$', '$SEM_UM_Code$', '$SEM_Quote_ValueLC$', $SEM_Quote_Value_CHF$, " & _
            "'$SEM_Quote_DB$', $SEM_Quote_PrimeMargin$, $CUS_SS_Code$, '$CUS_Quote_Area$', '$CUS_UM_Code$', " & _
            "'$CUS_Quote_ValueLC$', $CUS_Quote_Value_CHF$, '$CUS_Quote_DB$', $CUS_Quote_PrimeMargin$, " & _
            "$TOT_Quote_Value_CHF$, $TOT_Quote_DB$, $TOT_Quote_PrimeMargin$, $TOT_Quote_Area$, " & _
            "'$TOT_UM_System$', $RL_Code$, '$Quote_FRGHTCostLC$', '$FRGHT_CURR_Code$', $Quote_FRGHTCost_CHF$, " & _
            "'$Quote_ValidToDate$', '$Quote_Comment$', $Q_SSR_code$, $BO_SSR_Code$, $Z_creator$, " & _
            "$iConcurrencyEXCH_Rate_Quote$, $iConcurrencyEXCH_Rate_FRGHT$, '$Quote_OfferDate$'" & SEP & _
            "exec SOM_Project_LastUpd_Upd $Proj_ID$,$Z_last_upd_user$" & SEP & _
            "exec SOM_Customer_LastUpd_Upd $Cust_ID$,$Z_last_upd_user$" & SEP & _
            "exec SOM_GetReference_Quote_Sel $Quote_ID$"
            
            .RequestUpd = "exec SOM_Quote_Upd3 $Quote_ID$, $Quote_Include$, '$Quote_CURR_code$', $Quote_Type$, $Status$, " & _
                    "$STD_SS_Code$, '$STD_Quote_Area$', '$STD_UM_Code$', '$STD_Quote_ValueLC$', " & _
                    "$STD_Quote_Value_CHF$, '$STD_Quote_DB$', $STD_Quote_PrimeMargin$, $SEM_SS_Code$, " & _
                    "'$SEM_Quote_Area$', '$SEM_UM_Code$', '$SEM_Quote_ValueLC$', $SEM_Quote_Value_CHF$, " & _
                    "'$SEM_Quote_DB$', $SEM_Quote_PrimeMargin$, $CUS_SS_Code$, '$CUS_Quote_Area$', '$CUS_UM_Code$', " & _
                    "'$CUS_Quote_ValueLC$', $CUS_Quote_Value_CHF$, '$CUS_Quote_DB$', $CUS_Quote_PrimeMargin$, " & _
                    "$TOT_Quote_Value_CHF$, $TOT_Quote_DB$, $TOT_Quote_PrimeMargin$, $TOT_Quote_Area$, " & _
                    "'$TOT_UM_System$', $RL_Code$, '$Quote_FRGHTCostLC$', '$FRGHT_CURR_Code$', $Quote_FRGHTCost_CHF$, " & _
                    "'$Quote_ValidToDate$', '$Quote_Comment$', $Q_SSR_code$, $BO_SSR_Code$, $iConcurrency$, $Z_last_upd_user$, " & _
                    "$iConcurrencyEXCH_Rate_Quote$, $iConcurrencyEXCH_Rate_FRGHT$, '$Quote_OfferDate$'" & SEP & _
                "exec SOM_Project_LastUpd_Upd $Proj_ID$,$Z_last_upd_user$" & SEP & _
                "exec SOM_Customer_LastUpd_Upd $Cust_ID$,$Z_last_upd_user$"
                                                        
            .RequestDel = "exec SOM_Quote_Del2 $Quote_ID$,$iConcurrency$,$Z_last_upd_user$" & SEP & _
            "exec SOM_Project_LastUpd_Upd $Proj_ID$,$Z_last_upd_user$" & SEP & _
            "exec SOM_Customer_LastUpd_Upd $Cust_ID$,$Z_last_upd_user$"
            
            ReDim .ListFieldsMandatory(7, 1)
            Set .ListFieldsMandatory(0, 0) = cbo_Project
             .ListFieldsMandatory(0, 1) = 2
            Set .ListFieldsMandatory(1, 0) = cbo_Customer
             .ListFieldsMandatory(1, 1) = 1
            Set .ListFieldsMandatory(2, 0) = cbo_quote_curr
             .ListFieldsMandatory(2, 1) = 3
            Set .ListFieldsMandatory(3, 0) = cbo_SalesRep
             .ListFieldsMandatory(3, 1) = 4
            Set .ListFieldsMandatory(4, 0) = cal_ValidUntil
             .ListFieldsMandatory(4, 1) = 31
            Set .ListFieldsMandatory(5, 0) = cbo_realisation
             .ListFieldsMandatory(5, 1) = 34
            Set .ListFieldsMandatory(6, 0) = cbo_BO
             .ListFieldsMandatory(6, 1) = 35
            Set .ListFieldsMandatory(7, 0) = cal_OfferDate
             .ListFieldsMandatory(7, 1) = 60
             
            ReDim .ListFieldsDefaultValue(23, 1)
            Set .ListFieldsDefaultValue(0, 0) = opt_type(0)
             .ListFieldsDefaultValue(0, 1) = True
            Set .ListFieldsDefaultValue(1, 0) = opt_include(1)
             .ListFieldsDefaultValue(1, 1) = True
            Set .ListFieldsDefaultValue(2, 0) = txt_Status
             .ListFieldsDefaultValue(2, 1) = "5"
             
            Set .ListFieldsDefaultValue(3, 0) = txt_STD_Area
             .ListFieldsDefaultValue(3, 1) = "0"
            Set .ListFieldsDefaultValue(4, 0) = txt_STD_ValueLC
             .ListFieldsDefaultValue(4, 1) = "0"
            Set .ListFieldsDefaultValue(5, 0) = txt_STD_DB
             .ListFieldsDefaultValue(5, 1) = "0"
            Set .ListFieldsDefaultValue(6, 0) = txt_STD_ValueCHF
             .ListFieldsDefaultValue(6, 1) = "0"
            Set .ListFieldsDefaultValue(7, 0) = txt_STD_PrimeMarg
             .ListFieldsDefaultValue(7, 1) = "0.00"
             
            Set .ListFieldsDefaultValue(8, 0) = txt_SEM_Area
             .ListFieldsDefaultValue(8, 1) = "0"
            Set .ListFieldsDefaultValue(9, 0) = txt_SEM_ValueLC
             .ListFieldsDefaultValue(9, 1) = "0"
            Set .ListFieldsDefaultValue(10, 0) = txt_SEM_DB
             .ListFieldsDefaultValue(10, 1) = "0"
            Set .ListFieldsDefaultValue(11, 0) = txt_SEM_ValueCHF
             .ListFieldsDefaultValue(11, 1) = "0"
            Set .ListFieldsDefaultValue(12, 0) = txt_SEM_PrimeMarg
             .ListFieldsDefaultValue(12, 1) = "0.00"
             
            Set .ListFieldsDefaultValue(13, 0) = txt_CUS_Area
             .ListFieldsDefaultValue(13, 1) = "0"
            Set .ListFieldsDefaultValue(14, 0) = txt_CUS_ValueLC
             .ListFieldsDefaultValue(14, 1) = "0"
            Set .ListFieldsDefaultValue(15, 0) = txt_CUS_DB
             .ListFieldsDefaultValue(15, 1) = "0"
            Set .ListFieldsDefaultValue(16, 0) = txt_CUS_ValueCHF
             .ListFieldsDefaultValue(16, 1) = "0"
            Set .ListFieldsDefaultValue(17, 0) = txt_CUS_PrimeMarg
             .ListFieldsDefaultValue(17, 1) = "0.00"
             
            Set .ListFieldsDefaultValue(18, 0) = txt_TOT_DB
             .ListFieldsDefaultValue(18, 1) = "0"
            Set .ListFieldsDefaultValue(19, 0) = txt_TOT_ValueCHF
             .ListFieldsDefaultValue(19, 1) = "0"
            Set .ListFieldsDefaultValue(20, 0) = txt_TOT_PrimeMarg
             .ListFieldsDefaultValue(20, 1) = "0.00"
            
            Set .ListFieldsDefaultValue(21, 0) = txt_FreightCost
             .ListFieldsDefaultValue(21, 1) = "0"
            
            Set .ListFieldsDefaultValue(22, 0) = txt_StatusDesc
             .ListFieldsDefaultValue(22, 1) = "#Active"
             
            Set .ListFieldsDefaultValue(23, 0) = txt_TOT_ValueLC
             .ListFieldsDefaultValue(23, 1) = "0"
             
            ReDim .ListFieldsToDisable(2)
            Set .ListFieldsToDisable(0) = txt_Ref
            Set .ListFieldsToDisable(1) = txt_StatusDesc
            Set .ListFieldsToDisable(2) = txt_StatusDate
             
        End With

    
        With mt_ClassInfoLst(1)
            ReDim .ListFieldsMandatory(4, 1)
            Set .ListFieldsMandatory(0, 0) = cbo_STD_System
             .ListFieldsMandatory(0, 1) = 6
            Set .ListFieldsMandatory(1, 0) = txt_STD_Area
             .ListFieldsMandatory(1, 1) = 7
            Set .ListFieldsMandatory(2, 0) = cbo_STD_UM
             .ListFieldsMandatory(2, 1) = 8
            Set .ListFieldsMandatory(3, 0) = txt_STD_ValueLC
             .ListFieldsMandatory(3, 1) = 9
            Set .ListFieldsMandatory(4, 0) = txt_STD_DB
             .ListFieldsMandatory(4, 1) = 10
             
             
            
            ReDim .ListFieldsDefaultValue(4, 1)
            Set .ListFieldsDefaultValue(0, 0) = txt_STD_Area
             .ListFieldsDefaultValue(0, 1) = "0"
            Set .ListFieldsDefaultValue(1, 0) = txt_STD_ValueLC
             .ListFieldsDefaultValue(1, 1) = "0"
            Set .ListFieldsDefaultValue(2, 0) = txt_STD_DB
             .ListFieldsDefaultValue(2, 1) = "0"
            Set .ListFieldsDefaultValue(3, 0) = txt_STD_ValueCHF
             .ListFieldsDefaultValue(3, 1) = "0"
            Set .ListFieldsDefaultValue(4, 0) = txt_STD_PrimeMarg
             .ListFieldsDefaultValue(4, 1) = "0.00"

             
             
        End With
    
         With mt_ClassInfoLst(2)
            ReDim .ListFieldsMandatory(4, 1)
            Set .ListFieldsMandatory(0, 0) = cbo_SEM_System
             .ListFieldsMandatory(0, 1) = 19
            Set .ListFieldsMandatory(1, 0) = txt_SEM_Area
             .ListFieldsMandatory(1, 1) = 18
            Set .ListFieldsMandatory(2, 0) = cbo_SEM_UM
             .ListFieldsMandatory(2, 1) = 17
            Set .ListFieldsMandatory(3, 0) = txt_SEM_ValueLC
             .ListFieldsMandatory(3, 1) = 16
            Set .ListFieldsMandatory(4, 0) = txt_SEM_DB
             .ListFieldsMandatory(4, 1) = 15
             
            ReDim .ListFieldsDefaultValue(4, 1)
            Set .ListFieldsDefaultValue(0, 0) = txt_SEM_Area
             .ListFieldsDefaultValue(0, 1) = "0"
            Set .ListFieldsDefaultValue(1, 0) = txt_SEM_ValueLC
             .ListFieldsDefaultValue(1, 1) = "0"
            Set .ListFieldsDefaultValue(2, 0) = txt_SEM_DB
             .ListFieldsDefaultValue(2, 1) = "0"
            Set .ListFieldsDefaultValue(3, 0) = txt_SEM_ValueCHF
             .ListFieldsDefaultValue(3, 1) = "0"
            Set .ListFieldsDefaultValue(4, 0) = txt_SEM_PrimeMarg
             .ListFieldsDefaultValue(4, 1) = "0.00"
             
        End With
   
         With mt_ClassInfoLst(3)
            ReDim .ListFieldsMandatory(4, 1)
            Set .ListFieldsMandatory(0, 0) = cbo_CUS_System
             .ListFieldsMandatory(0, 1) = 20
            Set .ListFieldsMandatory(1, 0) = txt_CUS_Area
             .ListFieldsMandatory(1, 1) = 21
            Set .ListFieldsMandatory(2, 0) = cbo_CUS_UM
             .ListFieldsMandatory(2, 1) = 22
            Set .ListFieldsMandatory(3, 0) = txt_CUS_ValueLC
             .ListFieldsMandatory(3, 1) = 23
            Set .ListFieldsMandatory(4, 0) = txt_CUS_DB
             .ListFieldsMandatory(4, 1) = 24
             
            ReDim .ListFieldsDefaultValue(4, 1)
            Set .ListFieldsDefaultValue(0, 0) = txt_CUS_Area
             .ListFieldsDefaultValue(0, 1) = "0"
            Set .ListFieldsDefaultValue(1, 0) = txt_CUS_ValueLC
             .ListFieldsDefaultValue(1, 1) = "0"
            Set .ListFieldsDefaultValue(2, 0) = txt_CUS_DB
             .ListFieldsDefaultValue(2, 1) = "0"
            Set .ListFieldsDefaultValue(3, 0) = txt_CUS_ValueCHF
             .ListFieldsDefaultValue(3, 1) = "0"
            Set .ListFieldsDefaultValue(4, 0) = txt_CUS_PrimeMarg
             .ListFieldsDefaultValue(4, 1) = "0.00"
             
             
        End With
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Load_ClassInfo")
    
End Sub

Private Sub Item_LoadDefaultValue(ByVal al_InfoArrayIndex As Long)
On Error GoTo ErrHandler
    Dim lIdx As Long, lCount As Long
    Dim lParams As Variant
    lCount = UBound(mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue, 1)
    
    mb_Internal = True
    
    For lIdx = 0 To lCount
            Select Case UCase(TypeName(mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 0)))
                Case "FRAME", "LABEL", "MSFLEXGRID", "TOOLBARCONTROL"
                    ' Do nothing !
                
                Case "TEXTBOX"
                    mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 0).Text = mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 1)
                    
                Case "ARMGRID", "ARMCHECKVIEW", "COMMANDBUTTON", "ARMTREEVIEW", "LISTBOX", "PICTUREBOX", "TABSTRIP", "CHECKBOX"
                
                Case "OPTIONBUTTON"
                    
                Case "ARMCOMBOBOX"
                    lParams = Split(mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 1), SEP1)
                    If mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 0).SearchItem(lParams(0), 0, 0, True) = False Then
                        If Not mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 0).AddItem(Array(lParams(0), lParams(1)), True) Is Nothing Then
                            'message
                        End If
                    End If
                Case "A_CALOCX"
                     mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 0).date_courte = Format(Now + mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 1), "dd\/mm\/yyyy")
                
                Case Else
                    Debug.Print "Item_LoadDefaultValue " & UCase(TypeName(mt_ClassInfoLst(al_InfoArrayIndex).ListFieldsDefaultValue(lIdx, 0)))
            End Select
    Next
    
    mb_Internal = False
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_LoadDefaultValue")
   
End Sub



Private Sub ClearForm(ByRef aControls As Variant, ByRef aContainer As Object)
On Error GoTo ErrHandler
    
    mb_Internal = True

    Dim lIdx As Long, lCount As Long, lControl As Object
    lCount = aControls.Count - 1
    For lIdx = 0 To lCount
        Set lControl = aControls.Item(lIdx)
        
        If HasContainer(lControl, aContainer) Then
            Select Case UCase(TypeName(lControl))
                Case "TEXTBOX"
                    lControl.Text = ""
                
                Case "ARMCOMBOBOX"
                    'Set lControl.SelectedItem = Nothing
                    lControl.Clear
                    DoEvents
                    
                Case "A_CALOCX"
                    lControl.reinit_cal
                
                Case "CHECKBOX"
                    lControl.value = vbUnchecked
                
                Case "ARMCHECKVIEW"
                    'lControl.Reset
                    
                Case "FRAME", "LABEL", "TOOLBARCONTROL", "PICTUREBOX", "COMMANDBUTTON"
                
                Case "ARMGRID"
                    lControl.ClearGrid
                    lControl.Requests = ""
                
                Case "LISTBOX"
                    lControl.ListIndex = -1
                
                Case "OPTIONBUTTON"
                    Dim lValues As Variant
                    lValues = Split(lControl.Tag, SEP)
                    lControl.value = lValues(1)
                
                Case "TABSTRIP", "DRIVELISTBOX", "DIRLISTBOX", "FILELISTBOX"
                
                Case Else
                    Debug.Print "ClearForm " & UCase(TypeName(lControl))
            End Select
        End If
        
        Set lControl = Nothing
    Next
    
    mb_Internal = False

    Exit Sub
ErrHandler:
    Call ErrorHandler("ClearForm")
End Sub
Private Sub Item_Exit(Optional ByVal ab_ByUser As Boolean = False)
On Error GoTo ErrHandler
    ms_SrzStrFromWLD = ""
    If ml_Cursor > 0 Then
        mo_Db.Close (ml_Cursor)
        ml_Cursor = 0
    End If
    mb_Internal = True
    RaiseEvent OnExit(ab_ByUser)
    DoEvents
    mb_Internal = False
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_Exit")
End Sub

Private Sub Item_ViewInit(ByVal al_Key As Long)
On Error GoTo ErrHandler
    
    Call SetMode(eMode.emView)
    
    'visuel
    Call ClearForm(UserControl.Controls, Me)
    Call EnableFrame(UserControl.Controls, Me, False)
    
    Select Case ml_Driver
        Case eProject
            Call HandleToolbar(tbl_main, 3, mb_IsFullAccess)
        Case eCustomer
            Call HandleToolbar(tbl_main, 4, mb_IsFullAccess)
        Case eQuote
            Call HandleToolbar(tbl_main, 0, mb_IsFullAccess)
    End Select
    
    txt_key.Text = al_Key
    
    Call OpenCursor(mt_ClassInfoLst(0).RequestView)
    
    Call LoadDataToForm(ml_Cursor, UserControl.Controls, Me)
    
    If mo_Db.GetFields(ml_Cursor, "PS_code") <> eProjSpecification And mo_Db.GetFields(ml_Cursor, "PS_code") <> eProjQuoteTender Then
        tbl_main.ButtonEnabled("R") = False
        tbl_main.ButtonEnabled("Z") = False
        tbl_main.ButtonEnabled("B") = False
    Else
        tbl_main.ButtonEnabled("R") = True
        tbl_main.ButtonEnabled("Z") = True
        tbl_main.ButtonEnabled("B") = True
    End If
    
    
    
    fra_Customer.Visible = True
    fra_project.Visible = True
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Item_ViewInit")
End Sub
Private Sub Item_RevisionInit(ByVal al_Key As Long)
On Error GoTo ErrHandler
    
    Call SetMode(emRevision)
    
    'visuel
    Call ClearForm(UserControl.Controls, Me)
    Call EnableFrame(UserControl.Controls, Me, True)
    Call DisableFrameParts(0)
    
    Call EnableFrame(UserControl.Controls, fra_STD, False)
    cbo_STD_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_SEM, False)
    cbo_SEM_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_CUS, False)
    cbo_CUS_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_project, False)
    Call EnableFrame(UserControl.Controls, fra_Customer, False)
    Call EnableFrame(UserControl.Controls, fra_ModifInfo, False)
    
    Call HandleToolbar(tbl_main, 1, mb_IsFullAccess)
    
    txt_key.Text = al_Key
    
    cbo_quote_curr.Load
    cbo_FreightCurr.Load
    
    Call OpenCursor(mt_ClassInfoLst(0).RequestView)
    
    Call LoadDataToForm(ml_Cursor, UserControl.Controls, Me)
    
    
    opt_include(0).value = False
    opt_include(1).value = False
    
    If cbo_IsFilled(cbo_STD_System) Then
        Call EnableFrame(UserControl.Controls, fra_STD, True)
    End If
    
    If cbo_IsFilled(cbo_SEM_System) Then
        Call EnableFrame(UserControl.Controls, fra_SEM, True)
    End If
    
    If cbo_IsFilled(cbo_CUS_System) Then
        Call EnableFrame(UserControl.Controls, fra_CUS, True)
    End If
    
    txt_Ref.Text = ""
    
    fra_project.Visible = True
    fra_Customer.Visible = True
    
    cbo_Project.Enabled = False
    cbo_Customer.Enabled = False
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Item_RevisionInit")
End Sub

Private Sub Item_UpdateInit(ByVal al_Key As Long, ByVal as_SrzFields As String)
On Error GoTo ErrHandler
    
    Call SetMode(eMode.emUpdate)
    
    'visuel
    Call ClearForm(UserControl.Controls, Me)
    Call EnableFrame(UserControl.Controls, Me, True)
    Call DisableFrameParts(0)
    
    Call EnableFrame(UserControl.Controls, fra_STD, False)
    cbo_STD_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_SEM, False)
    cbo_SEM_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_CUS, False)
    cbo_CUS_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_project, False)
    Call EnableFrame(UserControl.Controls, fra_Customer, False)
    Call EnableFrame(UserControl.Controls, fra_ModifInfo, False)
    
    Call HandleToolbar(tbl_main, 5, mb_IsFullAccess)
    
    txt_key.Text = al_Key
    
    cbo_quote_curr.Load
    cbo_FreightCurr.Load
    
    Call OpenCursor(mt_ClassInfoLst(0).RequestView)
    
    Call LoadDataToForm(ml_Cursor, UserControl.Controls, Me)
    
    If as_SrzFields <> "" Then
        ms_SrzStrFromWLD = as_SrzFields
        txt_Status.Text = GetFieldValueFromSrz(ms_SrzStrFromWLD, "Status")
        txt_StatusDesc.Text = GetFieldValueFromSrz(ms_SrzStrFromWLD, "Status_Desc")
        txt_StatusDate.Text = GetFieldValueFromSrz(ms_SrzStrFromWLD, "StatusDate")
    End If
    
    If cbo_IsFilled(cbo_STD_System) Then
        Call EnableFrame(UserControl.Controls, fra_STD, True)
    End If
    
    If cbo_IsFilled(cbo_SEM_System) Then
        Call EnableFrame(UserControl.Controls, fra_SEM, True)
    End If
    
    If cbo_IsFilled(cbo_CUS_System) Then
        Call EnableFrame(UserControl.Controls, fra_CUS, True)
    End If
    
    
    fra_project.Visible = True
    fra_Customer.Visible = True
    
    cbo_Project.Enabled = False
    cbo_Customer.Enabled = False
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Item_UpdateInit")
End Sub

Private Function Item_Update() As Boolean
On Error GoTo ErrHandler
    
    Dim lb_StopProcess As Boolean
    Dim lv_Request As Variant
    Dim ls_Request As String
    Dim ls_SrzStr As String
    
    
    'check the data validity -> Item_Check
    If Not Item_CheckMandatory(0) Then Exit Function
    
    If Not cbo_IsFilled(cbo_STD_System) And _
        Not cbo_IsFilled(cbo_SEM_System) And _
        Not cbo_IsFilled(cbo_CUS_System) Then
        MsgBox MsgText(0, ms_Language_Code, "#At least one of the Standard, Semi standard or Custom block must be field."), vbInformation
        cbo_STD_System.SetFocus
        Exit Function
    End If
    
    
    If cbo_IsFilled(cbo_STD_System) Then
        If Not Item_CheckMandatory(1) Then Exit Function
    End If
    
    If cbo_IsFilled(cbo_SEM_System) Then
        If Not Item_CheckMandatory(2) Then Exit Function
    End If
    
    If cbo_IsFilled(cbo_CUS_System) Then
        If Not Item_CheckMandatory(3) Then Exit Function
    End If
    
    If Not Item_Check Then Exit Function
    
    lv_Request = Split(mt_ClassInfoLst(0).RequestUpd, SEP)
    
    ls_Request = ReplaceALLHolders(UserControl.Controls, Me, lv_Request(0))
    ls_SrzStr = Build_SrzString(UserControl.Controls, Me)
    
    RaiseEvent OnValidate(ls_Request, ls_SrzStr, lb_StopProcess)

    If Not lb_StopProcess Then
        'update data on the db ->
        If Not Item_UpdateDB Then Exit Function  'GoTo BackToGrid
        
        RaiseEvent OnItemUpdate(eQuote, CLng(txt_key.Text), Build_SrzString(UserControl.Controls, Me))
    
    End If
    
    Call Item_Exit
    
    Item_Update = True
    
    Exit Function

ErrHandler:
    Call ErrorHandler("Item_Update")

End Function

Private Function Item_UpdateDB() As Boolean
On Error GoTo ErrHandler
    Dim lv_Request As Variant
    Dim lb_TranOpened As Boolean
    Dim ls_Req As String

    

'open the transaction
    If Not BeginTran("UpdQuoteDB") Then
        Err.Raise C_ERRORRAISE + 3, SCREEN_NAME, "Transaction Failure." & vbCrLf & "Enable to Start the transaction." & vbCrLf & Join(mo_Db.SQLErrorMessages, vbCrLf)
    End If
    lb_TranOpened = True
    
    ls_Req = mt_ClassInfoLst(0).RequestUpd
    
'replace the holders
    ls_Req = ReplaceALLHolders(UserControl.Controls, Me, ls_Req)
    
    lv_Request = Split(ls_Req, SEP)
    'lv_Request(0) = Replace(lv_Request(0), "$iConcurrency$", mo_Db.GetFields(ml_Cursor, "iConcurrency"), , , vbTextCompare)
    
    ExecuteSQLSafe mo_Db, lv_Request(0), 1
    
    ExecuteSQLSafe mo_Db, lv_Request(1)
    
    ExecuteSQLSafe mo_Db, lv_Request(2)


'close the transaction
    If Not CommitTran("UpdQuoteDB") Then
        Err.Raise C_ERRORRAISE + 4, SCREEN_NAME, "Transaction Failure." & vbCrLf & "Enable to commit the transaction." & vbCrLf & Join(mo_Db.SQLErrorMessages, vbCrLf)
    End If
    lb_TranOpened = False
    
    Item_UpdateDB = True

    Exit Function
    
ErrHandler:
    Item_UpdateDB = False
    If lb_TranOpened Then
         Call RollbackTran("UpdQuoteDB")
    End If
    
    Call ErrorHandler("Item_UpdateDB")
End Function



Private Sub Item_CopyInit(ByVal al_Key As Long)
On Error GoTo ErrHandler
    
    Call SetMode(eMode.emCopy)
    
    'visuel
    Call ClearForm(UserControl.Controls, Me)
    Call EnableFrame(UserControl.Controls, Me, True)
    Call DisableFrameParts(0)
    
    Call EnableFrame(UserControl.Controls, fra_STD, False)
    cbo_STD_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_SEM, False)
    cbo_SEM_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_CUS, False)
    cbo_CUS_System.Enabled = True
    
    Call EnableFrame(UserControl.Controls, fra_project, False)
    Call EnableFrame(UserControl.Controls, fra_Customer, False)
    Call EnableFrame(UserControl.Controls, fra_ModifInfo, False)
    
    Call HandleToolbar(tbl_main, 1, mb_IsFullAccess)
    
    txt_key.Text = al_Key
    
    cbo_quote_curr.Load
    cbo_FreightCurr.Load

    
    Call OpenCursor(mt_ClassInfoLst(0).RequestView)
    
    Call LoadDataToForm(ml_Cursor, UserControl.Controls, Me)
    
    opt_include(0).value = False
    opt_include(1).value = False
    
    
    Call ClearForm(UserControl.Controls, fra_Customer)
    Call ClearForm(UserControl.Controls, fra_project)
    
    If cbo_IsFilled(cbo_STD_System) Then
        Call EnableFrame(UserControl.Controls, fra_STD, True)
    End If
    
    If cbo_IsFilled(cbo_SEM_System) Then
        Call EnableFrame(UserControl.Controls, fra_SEM, True)
    End If
    
    If cbo_IsFilled(cbo_CUS_System) Then
        Call EnableFrame(UserControl.Controls, fra_CUS, True)
    End If
    
    txt_Ref.Text = ""
    txt_QuoteRef.Text = 0
    txt_key.Text = 0
    
    fra_project.Visible = False
    fra_Customer.Visible = False
    
    cbo_Project.Enabled = False
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Item_CopyInit")
End Sub

Private Sub Item_DeleteInit(ByVal al_Key As Long)
On Error GoTo ErrHandler

    Call SetMode(eMode.emDelete)
    'visuel
    Call ClearForm(UserControl.Controls, Me)
    Call EnableFrame(UserControl.Controls, Me, False)
    Call HandleToolbar(tbl_main, 2, mb_IsFullAccess)
    
    txt_key.Text = al_Key
    
    Call OpenCursor(mt_ClassInfoLst(0).RequestView)
    
    Call LoadDataToForm(ml_Cursor, UserControl.Controls, Me)
    
    fra_Customer.Visible = True
    fra_project.Visible = True
    

    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Item_DeleteInit")
End Sub

Private Sub Item_Delete()
On Error GoTo ErrHandler

    If MsgBox(MsgText(C_ERRORRAISE + 53, ms_Language_Code, "#Do you really want to delete the selected item?"), vbExclamation + vbDefaultButton2 + vbYesNo) <> vbYes Then Exit Sub

    If Not Item_DeleteDB() Then Exit Sub
        
    RaiseEvent OnItemDelete(eQuote, CLng(txt_key.Text))

    Call Item_Exit

    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_Delete")
End Sub
Private Function Item_DeleteDB() As Boolean
On Error GoTo ErrHandler

    Dim lv_DEL_Request As Variant
    Dim lb_TranOpened As Boolean
    

'open the transaction
    If Not BeginTran("DelQuoteDB") Then
        Err.Raise C_ERRORRAISE + 3, SCREEN_NAME, "Transaction Failure." & vbCrLf & "Enable to Start the transaction." & vbCrLf & Join(mo_Db.SQLErrorMessages, vbCrLf)
    End If
    
    lb_TranOpened = True
    
    lv_DEL_Request = Split(ReplaceHolders(UserControl.Controls, Me, Replace(mt_ClassInfoLst(0).RequestDel, "$iConcurrency$", mo_Db.GetFields(ml_Cursor, "iConcurrency"))), SEP)
    
    ExecuteSQLSafe mo_Db, lv_DEL_Request(0), 1
    
    ExecuteSQLSafe mo_Db, lv_DEL_Request(1)
    
    ExecuteSQLSafe mo_Db, lv_DEL_Request(2)
    
'close the transaction
    If Not CommitTran("DelQuoteDB") Then
        Err.Raise C_ERRORRAISE + 4, SCREEN_NAME, "Transaction Failure." & vbCrLf & "Enable to commit the transaction." & vbCrLf & Join(mo_Db.SQLErrorMessages, vbCrLf)
    End If
    lb_TranOpened = False
    
    Item_DeleteDB = True

    Exit Function
    
ErrHandler:
    Item_DeleteDB = False
    If lb_TranOpened Then
         Call RollbackTran("DelQuoteDB")
    End If
    
    Call ErrorHandler("Item_DeleteDB")
End Function
Private Function ReplaceALLHolders(ByRef aControls As Variant, ByRef aContainer As Object, ByVal as_Request As String) As String
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_Tot_Area As Long
    Dim ls_UM_system As String
    Dim ls_SS_desc As String
       
    

    txt_TOT_area.Text = Val(IIf(txt_STD_Area.Text = "", 0, txt_STD_Area.Text)) + Val(IIf(txt_SEM_Area.Text = "", 0, txt_SEM_Area.Text)) + Val(IIf(txt_CUS_Area.Text = "", 0, txt_CUS_Area.Text))
    
        mb_Internal = False
        Call cbo_FreightCurr_ComboItemSelected
        mb_Internal = True
        
    
    ls_UM_system = ""
    If cbo_IsFilled(cbo_STD_UM) Then
        ls_UM_system = cbo_STD_UM.SelectedItem.Key & "/"
    End If
    If cbo_IsFilled(cbo_SEM_UM) Then
        ls_UM_system = ls_UM_system & IIf(InStr(1, ls_UM_system, cbo_SEM_UM.SelectedItem.Key & "/"), "", cbo_SEM_UM.SelectedItem.Key & "/")
    End If
    If cbo_IsFilled(cbo_CUS_UM) Then
        ls_UM_system = ls_UM_system & IIf(InStr(1, ls_UM_system, cbo_CUS_UM.SelectedItem.Key & "/"), "", cbo_CUS_UM.SelectedItem.Key & "/")
    End If
    
    If right(ls_UM_system, 1) = "/" Then ls_UM_system = Mid(ls_UM_system, 1, Len(ls_UM_system) - 1)

    txt_TOT_UM.Text = ls_UM_system

    ls_SS_desc = ""
    If cbo_IsFilled(cbo_STD_System) Then
        ls_SS_desc = cbo_STD_System.SelectedItem.GetData(1) & "/"
    Else
        ls_SS_desc = ls_SS_desc & "/"
    End If
    If cbo_IsFilled(cbo_SEM_System) Then
        ls_SS_desc = ls_SS_desc & cbo_SEM_System.SelectedItem.GetData(1) & "/"
    Else
        ls_SS_desc = ls_SS_desc & "/"
    End If
    If cbo_IsFilled(cbo_CUS_System) Then
        ls_SS_desc = ls_SS_desc & cbo_CUS_System.SelectedItem.GetData(1) & "/"
    Else
        ls_SS_desc = ls_SS_desc & "/"
    End If
    
    If right(ls_SS_desc, 1) = "/" Then ls_SS_desc = Mid(ls_SS_desc, 1, Len(ls_SS_desc) - 1)

    txt_TOT_SS_desc.Text = ls_SS_desc

    'If ml_Cursor <> 0 Then
    ls_Request = Replace(as_Request, "$iConcurrency$", mo_Db.GetFields(ml_Cursor, "iConcurrency"))
   ' End If

    
    ls_Request = ReplaceHolders(aControls, aContainer, ls_Request)

    ReplaceALLHolders = ls_Request
    
    Exit Function
    
ErrHandler:
    Call ErrorHandler("ReplaceALLHolders")
End Function




Private Function ReplaceHolders(ByRef aControls As Variant, ByRef aContainer As Object, ByVal as_Request As String) As String
    
On Error GoTo ErrHandler

    Dim lIdx As Long, lCount As Long
    Dim lControl As Control
    Dim lv_number As Variant
    Dim lValues As Variant
    
    
    lCount = aControls.Count - 1
    
    For lIdx = 0 To lCount
        Set lControl = aControls.Item(lIdx)
        If HasContainer(lControl, aContainer) Then
            Select Case UCase(TypeName(lControl))
                Case "TEXTBOX"
                    'handle numeric
                    lValues = Split(lControl.Tag, SEP)
                    If UBound(lValues) > 0 Then
                        Select Case lValues(1)
                            Case "Text"
                                as_Request = Replace(as_Request, "$" & lValues(0) & "$", Replace(Trim(lControl.Text), "'", "''"), , , vbTextCompare)
                            Case "Num"
                                lv_number = Replace(Trim(IIf(lControl.Text = "", 0, lControl.Text)), ms_ThousandSeparator, "", , , vbTextCompare)
                                lv_number = Replace(lv_number, ms_DecimalSeparator, ".", , , vbTextCompare)
                                as_Request = Replace(as_Request, "$" & lValues(0) & "$", lv_number, , , vbTextCompare)
                            Case "Date"
                                as_Request = Replace(as_Request, "$" & lValues(0) & "$", IIf(lControl.Text = "", "NULL", "'" & SqlDate(lControl.Text) & "'"), , , vbTextCompare)
                            
                        End Select
                    End If
                Case "ARMCOMBOBOX"
                    lValues = Split(lControl.Tag, SEP)
                    If Not lControl.SelectedItem Is Nothing Then
                        as_Request = Replace(as_Request, "$" & lValues(0) & "$", IIf(lControl.SelectedItem.Key = "", "NULL", lControl.SelectedItem.Key), , , vbTextCompare)
                    Else
                        as_Request = Replace(as_Request, "$" & lValues(0) & "$", "NULL", , , vbTextCompare)
                    End If
                    
                Case "OPTIONBUTTON" ', "ARMTREEVIEW", "LISTBOX", "PICTUREBOX" '"A_CALOCX",
                    If lControl.value = True Then
                        lValues = Split(lControl.Tag, SEP)
                        as_Request = Replace(as_Request, "$" & lValues(0) & "$", lValues(2), , , vbTextCompare)
                    End If
                Case "CHECKBOX"
                        lValues = Split(lControl.Tag, SEP)
                  If lControl.value = vbChecked Then
                    as_Request = Replace(as_Request, "$" & lValues(0) & "$", "X", , , vbTextCompare)
                  Else
                    as_Request = Replace(as_Request, "$" & lValues(0) & "$", "", , , vbTextCompare)
                  End If
                Case "A_CALOCX"
                    as_Request = Replace(as_Request, "$" & lControl.Tag & "$", lControl.date_sql, , , vbTextCompare)
            End Select
        End If
        Set lControl = Nothing
    Next
    
    as_Request = Replace(as_Request, "$Language_code$", ms_Language_Code, , , vbTextCompare)
    as_Request = Replace(as_Request, "$Z_Creator$", ml_UCode, , , vbTextCompare)
    as_Request = Replace(as_Request, "$Z_last_upd_user$", ml_UCode, , , vbTextCompare)
    
    as_Request = Replace(as_Request, "$iConcurrencyEXCH_Rate_Quote$", cbo_quote_curr.SelectedItem.GetData(3), , , vbTextCompare)
    
    If cbo_IsFilled(cbo_FreightCurr) Then
        If Not IsEmpty(cbo_FreightCurr.SelectedItem.Key) Then
            as_Request = Replace(as_Request, "$iConcurrencyEXCH_Rate_FRGHT$", cbo_FreightCurr.SelectedItem.GetData(3), , , vbTextCompare)
        Else
            as_Request = Replace(as_Request, "$iConcurrencyEXCH_Rate_FRGHT$", "NULL", , , vbTextCompare)
        End If
    Else
        as_Request = Replace(as_Request, "$iConcurrencyEXCH_Rate_FRGHT$", "NULL", , , vbTextCompare)
    End If
    
    as_Request = Replace(as_Request, "'NULL'", "NULL", , , vbTextCompare)

    ReplaceHolders = as_Request
    Exit Function
    
ErrHandler:
    If Not lControl Is Nothing Then Set lControl = Nothing
    Call ErrorHandler("ReplaceHolders")
    
End Function

Private Sub EnableFrame(ByRef aControls As Variant, ByRef aContainer As Object, ByVal aEnabled As Boolean)
On Error GoTo ErrHandler
    Dim lIdx As Long, lCount As Long
    Dim lControl As Control
    
    lCount = aControls.Count - 1
    
    For lIdx = 0 To lCount
        Set lControl = aControls.Item(lIdx)
        If HasContainer(lControl, aContainer) Then
            'Debug.Print "EnableFrame trace -> " & aContainer.Name & " -> " & UCase(TypeName(lControl))
            Select Case UCase(TypeName(lControl))
                Case "TOOLBARCONTROL"
                    lControl.Visible = aEnabled
                
                Case "FRAME", "LABEL", "MSFLEXGRID"
                    ' Do nothing !
                
                Case "TEXTBOX"
                    If aEnabled And (UCase(lControl.Name) Like "TXT_*_VALUECHF" Or UCase(lControl.Name) Like "TXT_*_PRIMEMARG" Or UCase(lControl.Name) Like "TXT_TOT_DB" Or UCase(lControl.Name) = "TXT_TOT_VALUELC") Then
                        lControl.Locked = aEnabled
                        lControl.BackColor = IIf(aEnabled, CL_COLOR_LOCKED, CL_COLOR_DISABLED)
                    Else
                        lControl.Locked = Not aEnabled
                        lControl.BackColor = IIf(aEnabled, CL_COLOR_ENABLED, CL_COLOR_DISABLED)
                    End If
                
                Case "ARMGRID", "ARMCHECKVIEW"
                    
                Case "DIRLISTBOX", "DRIVELISTBOX", "FILELISTBOX"
                    lControl.Enabled = aEnabled
                    lControl.BackColor = IIf(aEnabled, CL_COLOR_ENABLED, CL_COLOR_DISABLED)

                Case "ARMCOMBOBOX", "A_CALOCX", "OPTIONBUTTON", "ARMTREEVIEW", "LISTBOX", "PICTUREBOX", "TABSTRIP", "CHECKBOX"
                    lControl.Enabled = aEnabled
                
                Case "COMMANDBUTTON"
                
                
                Case "SOM_LINK", "SOM_QUOTE"
                
                Case Else
                    lControl.Enabled = aEnabled
                    Debug.Print "EnableFrame " & UCase(TypeName(lControl))
            End Select
        End If
        Set lControl = Nothing
    Next
    Exit Sub
ErrHandler:
    If Not lControl Is Nothing Then Set lControl = Nothing
    Call ErrorHandler("EnableFrame")

End Sub
Private Sub OpenCursor(ByVal as_Request As String)
On Error GoTo ErrHandler
    Dim ls_SelectRequest As String
        
        
    ls_SelectRequest = Replace(as_Request, "$Language_code$", ms_Language_Code, , , vbTextCompare)
    ls_SelectRequest = Replace(ls_SelectRequest, "$Quote_ID$", CLng(txt_key.Text), , , vbTextCompare)
    
    If ml_Cursor > 0 Then
        mo_Db.Close (ml_Cursor)
        ml_Cursor = 0
    End If
    
    ml_Cursor = OpenSQLSafe(mo_Db, ls_SelectRequest, 1)
    
    Exit Sub

ErrHandler:
    mo_Db.Close (ml_Cursor)
    Call ErrorHandler("OpenCursor")

End Sub
Private Function HasContainer(ByRef aControl As Control, ByRef aContainer As Object) As Boolean
    
    HasContainer = False
    Dim lControl As Control
    
    Set lControl = aControl
    While Not (lControl Is Nothing)
        On Error GoTo NotFound
        If lControl.Container Is aContainer Then
            Set lControl = Nothing
            HasContainer = True
            Exit Function
        End If
        Set lControl = lControl.Container
    Wend

NotFound:
    Set lControl = Nothing
    HasContainer = False
End Function
Private Sub LoadDataToForm(ByVal ac_Cursor As Long, ByRef aControls As Variant, ByRef aContainer As Object)
On Error GoTo ErrHandler
   
    Dim lIdx As Long, lCount As Long
    Dim lControl As Control
    Dim lValues As Variant
    Dim ls_TempTag As String
    
        mb_Internal = True
    
        lCount = aControls.Count - 1
    
        For lIdx = 0 To lCount
            Set lControl = aControls.Item(lIdx)
            If HasContainer(lControl, aContainer) Then
                Select Case UCase(TypeName(lControl))
                    Case "TEXTBOX"
                            ls_TempTag = lControl.Tag & SEP
                            lValues = Split(ls_TempTag, SEP)
                            If mo_Db.GetFieldIndex(ac_Cursor, lValues(0)) >= 0 Then
                                Select Case lValues(1)
                                    Case "Text", "Date"
                                        lControl.Text = mo_Db.GetFields(ac_Cursor, lValues(0))
                                    Case "Num"
                                        If (me_Mode = eMode.emView Or me_Mode = eMode.emDelete) Then
                                            lControl.Text = FormatNumber(mo_Db.GetFields(ac_Cursor, lValues(0)), lValues(2))
                                        Else
                                            lControl.Text = Replace(mo_Db.GetFields(ac_Cursor, lValues(0)), ms_DecimalSeparator, ".", , , vbTextCompare)
                                        End If
                                End Select
                            End If
                    
                    Case "ARMCOMBOBOX"
                        ls_TempTag = lControl.Tag & SEP
                        lValues = Split(ls_TempTag, SEP)
                        If mo_Db.GetFieldIndex(ac_Cursor, lValues(0)) >= 0 Then
                            If mo_Db.GetFields(ac_Cursor, lValues(0)) = 0 Or mo_Db.GetFields(ac_Cursor, lValues(0)) = "" Then
                                Set lControl.SelectedItem = Nothing
                            Else
                                If lControl.SearchItem(mo_Db.GetFields(ac_Cursor, lValues(0)), 0, 0, True) = False Then
                                    If lControl.AddItem(Array(mo_Db.GetFields(ac_Cursor, lValues(0)), mo_Db.GetFields(ac_Cursor, lValues(1))), True) Is Nothing Then
                                        Err.Raise 2222, "", ""
                                    End If
                                End If
                            End If
                        End If
                        
                    Case "OPTIONBUTTON"
                        lValues = Split(lControl.Tag, SEP)
                        If mo_Db.GetFieldIndex(ac_Cursor, lValues(0)) >= 0 Then
                            If UCase(lValues(2)) Like UCase(mo_Db.GetFields(ac_Cursor, lValues(0))) Then
                                lControl.value = True
                            End If
                        End If
                        
                    Case "CHECKBOX"
                        If mo_Db.GetFieldIndex(ac_Cursor, lControl.Tag) >= 0 Then
                            If UCase(mo_Db.GetFields(ac_Cursor, lControl.Tag)) Like "X" Then
                                lControl.value = vbChecked
                            Else
                                lControl.value = vbUnchecked
                            End If
                        End If
                        
                    Case "A_CALOCX"
                        lControl.date_courte = mo_Db.GetFields(ac_Cursor, lControl.Tag)
                        
                    Case "LABEL", "FRAME", "DIRLISTBOX", "FILELISTBOX", "DRIVELISTBOX", "TOOLBARCONTROL"
                        'Do Nothing
                    
                    Case "ARMGRID"
                    
                    Case Else
                        Debug.Print "LoadDataToForm  -> " & UCase(TypeName(lControl))
                End Select
            End If
            Set lControl = Nothing
        Next
        
        mb_Internal = False
    
    Exit Sub

ErrHandler:
    If Not lControl Is Nothing Then Set lControl = Nothing
    Call ErrorHandler("LoadDataToForm")

End Sub

Private Sub LoadDataToFormFromSrzString(ByRef aControls As Variant, ByRef aContainer As Object, ByVal as_SrzFields)
On Error GoTo ErrHandler
   
    Dim lIdx As Long, lCount As Long
    Dim lControl As Control
    Dim lValues As Variant
    Dim lsrz As String
    Dim ls_TempTag As String
    
    Dim ls_SrzFields As String
    
        mb_Internal = True
    
        lCount = aControls.Count - 1
    
        ls_SrzFields = SEP & as_SrzFields & SEP
    
        For lIdx = 0 To lCount
            Set lControl = aControls.Item(lIdx)
            If HasContainer(lControl, aContainer) Then
                Select Case UCase(TypeName(lControl))
                    Case "TEXTBOX"
                            ls_TempTag = lControl.Tag & SEP
                            lValues = Split(ls_TempTag, SEP)
                            
                        If InStr(1, ls_SrzFields, SEP & lValues(0) & SEP1, vbTextCompare) Then
                            
                            If aContainer Is fra_Customer Or aContainer Is fra_project Then
                                If UCase(lValues(0)) Like UCase("CustCT_desc") Or UCase(lValues(0)) Like UCase("ProjCT_desc") Then lValues(0) = "CT_desc"
                                If UCase(lValues(0)) Like UCase("Cust_SSR_desc") Or UCase(lValues(0)) Like UCase("Proj_SSR_desc") Then lValues(0) = "SSR_desc"
                            End If
                            
                            lsrz = GetFieldValueFromSrz(as_SrzFields, lValues(0))
                            
                            Select Case lValues(1)
                                Case "Text", "Date"
                                    lControl.Text = lsrz
                                Case "Num"
                                    If (me_Mode = eMode.emView Or me_Mode = eMode.emDelete) Then
                                        lControl.Text = FormatNumber(Replace(Val(lsrz), ".", ms_DecimalSeparator, , , vbTextCompare), lValues(2))
                                    Else
                                        lControl.Text = Replace(Val(lsrz), ms_DecimalSeparator, ".", , , vbTextCompare)
                                    End If
                            End Select
                            
                            
                        End If
                            
                    Case "ARMCOMBOBOX"
                        ls_TempTag = lControl.Tag & SEP
                        lValues = Split(ls_TempTag, SEP)
                        
                        If InStr(1, ls_SrzFields, SEP & lValues(0) & SEP1, vbTextCompare) Then
                        
                            
                            lsrz = GetFieldValueFromSrz(as_SrzFields, lValues(0))
                            
                            If lsrz = "0" Or lsrz = "" Then
                                Set lControl.SelectedItem = Nothing
                            Else
                                If lControl.SearchItem(lsrz, 0, 0, True) = False Then
                                    If lControl.AddItem(Array(lsrz, GetFieldValueFromSrz(as_SrzFields, lValues(1))), True) Is Nothing Then
                                        Err.Raise 2222, "", ""
                                    End If
                                End If
                            End If
                        
                        End If
                        
                    Case "OPTIONBUTTON"
                        lValues = Split(lControl.Tag, SEP)
                        If InStr(1, ls_SrzFields, SEP & lValues(0) & SEP1, vbTextCompare) Then

                            lsrz = GetFieldValueFromSrz(as_SrzFields, lValues(0))
                            
                            If UCase(lValues(2)) Like UCase(lsrz) Then
                                lControl.value = True
                            End If
                            
                        End If
                        
                    Case "A_CALOCX"
                        If InStr(1, ls_SrzFields, SEP & lControl.Tag & SEP1, vbTextCompare) Then
                            lControl.date_courte = GetFieldValueFromSrz(as_SrzFields, lControl.Tag)
                        End If
                    Case Else
                        Debug.Print "LoadDataToForm  -> " & UCase(TypeName(lControl))
                            
                End Select
            End If
            Set lControl = Nothing
        Next
        
        mb_Internal = False
    
    Exit Sub

ErrHandler:
    If Not lControl Is Nothing Then Set lControl = Nothing
    Call ErrorHandler("LoadDataToFormFromSrzString")

End Sub



Private Sub SetMode(ByVal aMode As eMode)
    me_OldMode = me_Mode
    me_Mode = aMode
End Sub

Private Function Build_SrzString(ByRef aControls As Variant, ByRef aContainer As Object) As String
On Error GoTo ErrHandler
    Dim ls_SrzString As String
    Dim lo_Control As CheckBox
    Dim lIdx As Long, lCount As Long
    
    Dim lValues As Variant
    Dim ls_TempTag As String
    Dim ls_Str As String
    Dim lControl As Control
   
    
        lCount = aControls.Count - 1
        ls_SrzString = ""
    
        For lIdx = 0 To lCount
            Set lControl = aControls.Item(lIdx)
            If HasContainer(lControl, aContainer) And Not HasContainer(lControl, fra_Customer) And Not HasContainer(lControl, fra_project) Then
                
                ls_TempTag = lControl.Tag & SEP
                lValues = Split(ls_TempTag, SEP)
                
                Select Case UCase(TypeName(lControl))
                    Case "TEXTBOX"
                            Select Case lValues(1)
                                Case "Text", "Date"
                                    ls_SrzString = ls_SrzString & lValues(0) & SEP1 & lControl.Text & SEP
                                Case "Num"
                                    If lControl.Enabled = False Then
                                    ls_Str = Replace(lControl.Text, ms_ThousandSeparator, "")
                                    ls_Str = Replace(ls_Str, ms_DecimalSeparator, ".")
                                    Else
                                        ls_Str = lControl.Text
                                    End If
                                    ls_SrzString = ls_SrzString & lValues(0) & SEP1 & ls_Str & SEP
                           End Select
                    
                    Case "ARMCOMBOBOX"
                        If Not lControl.SelectedItem Is Nothing Then
                            ls_SrzString = ls_SrzString & lValues(0) & SEP1 & lControl.SelectedItem.Key & SEP
                            ls_SrzString = ls_SrzString & lValues(1) & SEP1 & lControl.SelectedItem.GetData(1) & SEP
                        End If
                        
                    Case "OPTIONBUTTON"
                        If lControl.value = True Then
                            ls_SrzString = ls_SrzString & lValues(0) & SEP1 & lValues(2) & SEP
                            ls_SrzString = ls_SrzString & lValues(3) & SEP1 & lControl.Caption & SEP
                        End If
                    
                    Case "CHECKBOX"
                        
                    Case "A_CALOCX"
'                        lControl.date_courte = mo_Db.GetFields(ac_Cursor, lControl.Tag)
                        ls_SrzString = ls_SrzString & lValues(0) & SEP1 & lControl.date_courte & SEP
                        
                        
                    Case "LABEL", "FRAME", "DIRLISTBOX", "FILELISTBOX", "DRIVELISTBOX", "TOOLBARCONTROL"
                        'Do Nothing
                    
                    Case "ARMGRID"
                    
                    Case Else
                        Debug.Print "Build_SrzString  -> " & UCase(TypeName(lControl))
                End Select
            End If
            Set lControl = Nothing
        Next
    
    ls_SrzString = Trim(ls_SrzString)
    Build_SrzString = ls_SrzString
    
    Exit Function
    
ErrHandler:
    If Not lControl Is Nothing Then Set lControl = Nothing
    Call ErrorHandler("Build_SrzString")
End Function

Private Sub btn_OK_Click()
On Error GoTo ErrHandler

    Call Item_Exit

    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("btn_OK_Click: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub cbo_BO_ComboDropDown()
On Error GoTo ErrHandler

    cbo_BO.AutoDroppedWidth
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_BO_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub cbo_CUS_System_ComboDropDown()
On Error GoTo ErrHandler
    
    cbo_CUS_System.AutoDroppedWidth
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_CUS_System_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_CUS_System_ComboItemSelected()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    Call LockScreen(True)
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then GoTo ExitNow
    
    If Not cbo_IsFilled(cbo_CUS_System) Then
        Call ClearForm(UserControl.Controls, fra_CUS)
        Call EnableFrame(UserControl.Controls, fra_CUS, False)
        Call Item_LoadDefaultValue(3)

        Call txt_CUS_ValueLC_Change
               
        cbo_CUS_System.Enabled = True
    Else
        Call EnableFrame(UserControl.Controls, fra_CUS, True)
    End If

ExitNow:
    Call LockScreen(False)
    
    Exit Sub
    
ErrHandler:
    Call LockScreen(False)
    Call ErrorHandler("cbo_CUS_System_ComboItemSelected")
End Sub

Private Sub cbo_CUS_UM_ComboDropDown()
On Error GoTo ErrHandler

    cbo_CUS_UM.AutoDroppedWidth
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_CUS_UM_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_customer_ComboDropDown()
On Error GoTo ErrHandler
    
    Const Request As String = "exec SOM_Customer_cbo $Proj_ID$, '$Language_code$'"
    
    Dim ls_Req As String
    
    ls_Req = Replace(Request, "$Language_code$", ms_Language_Code)
    ls_Req = Replace(ls_Req, "$Proj_ID$", cbo_Project.SelectedItem.Key)
    
    cbo_Customer.Request = ls_Req
    
    cbo_Customer.Load
    DoEvents
    cbo_Customer.AutoDroppedWidth
    
    Exit Sub
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_customer_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_customer_ComboItemSelected()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If Not cbo_IsFilled(cbo_Customer) Then Exit Sub

    txt_LinkID.Text = cbo_Customer.SelectedItem.GetData(2)

    Exit Sub
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_customer_ComboItemSelected: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_FreightCurr_ComboDropDown()
On Error GoTo ErrHandler
    cbo_FreightCurr.AutoDroppedWidth
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_FreightCurr_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
    
End Sub

Private Sub cbo_FreightCurr_ComboItemSelected()
On Error GoTo ErrHandler

    If mb_Internal Then Exit Sub
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If Not cbo_IsFilled(cbo_FreightCurr) Then
        txt_FreightCostCHF.Text = 0
        Exit Sub
    End If
    
    
    If IsEmpty(cbo_FreightCurr.SelectedItem.Key) Then Exit Sub

    If cbo_FreightCurr.SelectedItem.GetData(2) = 0 Then
        Err.Raise 3064, SCREEN_NAME, "The exchange rate is 0 :: " & cbo_quote_curr.SelectedItem.GetData(0)
    End If

    Call txt_FreightCost_Change

    Exit Sub
ErrHandler:
    
    Select Case Err.Number
    
    Case 3064
        Call LogMessage("cbo_FreightCurr_ComboItemSelected: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    
    Case Else
        Call LogMessage("cbo_FreightCurr_ComboItemSelected: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select


End Sub

Private Sub cbo_project_ComboDropDown()
On Error GoTo ErrHandler
    
    Const Request As String = "exec SOM_Project_cbo $Cust_ID$, '$Language_code$'"
    
    Dim ls_Req As String
    
    ls_Req = Replace(Request, "$Language_code$", ms_Language_Code)
    ls_Req = Replace(ls_Req, "$Cust_ID$", cbo_Customer.SelectedItem.Key)
    
    cbo_Project.Request = ls_Req
    
    cbo_Project.Load
    DoEvents
    cbo_Project.AutoDroppedWidth
    
    Exit Sub
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_project_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_project_ComboItemSelected()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If Not cbo_IsFilled(cbo_Project) Then Exit Sub

    txt_LinkID.Text = cbo_Project.SelectedItem.GetData(2)
    txt_ProjNumber.Text = cbo_Project.SelectedItem.GetData(3)

    Exit Sub
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_project_ComboItemSelected: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_quote_curr_ComboDropDown()
On Error GoTo ErrHandler
    
    cbo_quote_curr.AutoDroppedWidth
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("cbo_quote_curr_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_quote_curr_ComboItemSelected()
On Error GoTo ErrHandler

    
    If mb_Internal Then Exit Sub
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If cbo_quote_curr.SelectedItem.GetData(2) = 0 Then
        Err.Raise 3064, SCREEN_NAME, "The exchange rate is 0 :: " & cbo_quote_curr.SelectedItem.GetData(0)
    End If
        
    If cbo_IsFilled(cbo_STD_System) Then
        Call txt_STD_ValueLC_Change
    End If
    
    If cbo_IsFilled(cbo_SEM_System) Then
        Call txt_SEM_ValueLC_Change
    End If
    
    If cbo_IsFilled(cbo_CUS_System) Then
        Call txt_CUS_ValueLC_Change
    End If

    Exit Sub
ErrHandler:
    
    Select Case Err.Number
    
    Case 3064
        Call LogMessage("cbo_quote_curr_ComboItemSelected: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    
    Case Else
        Call LogMessage("cbo_quote_curr_ComboItemSelected: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_realisation_ComboDropDown()
On Error GoTo ErrHandler

    cbo_realisation.AutoDroppedWidth
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_realisation_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_SalesRep_ComboDropDown()
On Error GoTo ErrHandler
    
    cbo_SalesRep.AutoDroppedWidth
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_SalesRep_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_SEM_System_ComboDropDown()
On Error GoTo ErrHandler
    
    cbo_SEM_System.AutoDroppedWidth
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_SEM_System_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_SEM_System_ComboItemSelected()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub

    Call LockScreen(True)
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then GoTo ExitNow
    
    If Not cbo_IsFilled(cbo_SEM_System) Then
        Call ClearForm(UserControl.Controls, fra_SEM)
        Call EnableFrame(UserControl.Controls, fra_SEM, False)
        Call Item_LoadDefaultValue(2)
        
        Call txt_SEM_ValueLC_Change
        
        cbo_SEM_System.Enabled = True
    Else
        Call EnableFrame(UserControl.Controls, fra_SEM, True)
    End If
    
ExitNow:
    Call LockScreen(False)
    
    Exit Sub
    
ErrHandler:
    Call LockScreen(False)
    Call ErrorHandler("cbo_SEM_System_ComboItemSelected")
End Sub

Private Sub cbo_SEM_UM_ComboDropDown()
On Error GoTo ErrHandler
    
    cbo_SEM_UM.AutoDroppedWidth
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_SEM_UM_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_STD_System_ComboDropDown()
On Error GoTo ErrHandler

    cbo_STD_System.AutoDroppedWidth
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_STD_System_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub cbo_STD_System_ComboItemSelected()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    Call LockScreen(True)
    
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then GoTo ExitNow
    
    If Not cbo_IsFilled(cbo_STD_System) Then
        Call ClearForm(UserControl.Controls, fra_STD)
        Call EnableFrame(UserControl.Controls, fra_STD, False)
        Call Item_LoadDefaultValue(1)
        
        Call txt_STD_ValueLC_Change
        
        cbo_STD_System.Enabled = True
    
    Else
        Call EnableFrame(UserControl.Controls, fra_STD, True)
    End If
    
    
    
ExitNow:
    Call LockScreen(False)
    
    Exit Sub
    
ErrHandler:
    Call LockScreen(False)
    Call ErrorHandler("cbo_STD_System_ComboItemSelected")
    
End Sub

Private Sub cbo_STD_UM_ComboDropDown()
On Error GoTo ErrHandler
    
    cbo_STD_UM.AutoDroppedWidth
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case Else
        Call LogMessage("cbo_STD_UM_ComboDropDown: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Function CheckNumericBeforeCalculation(ByVal ao_Source As TextBox, ByVal al_SrcLabelIdx As Long, ByVal ai_NbDecimal As Integer, ByVal av_Min As Variant, ByVal av_Max As Variant, Optional ByVal ab_Verbose = True) As Boolean
On Error GoTo ErrHandler

    Dim ll_IsNum As Long
    
    If ao_Source.Text Like "+" Or ao_Source.Text Like "-" Then Exit Function
    
    ll_IsNum = CheckNumericField(ao_Source, ai_NbDecimal, av_Min, av_Max)
    If ll_IsNum <> 0 Then
        If Not ab_Verbose Then
            Exit Function
        End If
        
        ReDim lv_MsgReplaceInfo(2, 1)
        lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
        lv_MsgReplaceInfo(0, 1) = lbl_label(al_SrcLabelIdx).Caption
        lv_MsgReplaceInfo(1, 0) = "$Min$"
        lv_MsgReplaceInfo(1, 1) = FormatNumber(av_Min, ai_NbDecimal)
        lv_MsgReplaceInfo(2, 0) = "$Max$"
        lv_MsgReplaceInfo(2, 1) = FormatNumber(av_Max, ai_NbDecimal)
        Select Case ll_IsNum
            Case 2131
                Call MsgBox(MsgText(ll_IsNum, ms_Language_Code, "#The field " & lv_MsgReplaceInfo(0, 1) & " must be numeric.", lv_MsgReplaceInfo), vbInformation)
            Case 2134
                Call MsgBox(MsgText(ll_IsNum, ms_Language_Code, "#The field " & lv_MsgReplaceInfo(0, 1) & " does not accept decimal number.", lv_MsgReplaceInfo), vbInformation)
            Case 2132
                Call MsgBox(MsgText(ll_IsNum, ms_Language_Code, "#The field " & lv_MsgReplaceInfo(0, 1) & " must be a number between " & lv_MsgReplaceInfo(1, 1) & " and " & lv_MsgReplaceInfo(2, 1) & ".", lv_MsgReplaceInfo), vbInformation)
        End Select
        
        If ao_Source.Visible Then
            Debug.Print "Before"
            Call ao_Source.SetFocus
            DoEvents
            Debug.Print "After"
        End If
        
        Exit Function
    End If
    
    CheckNumericBeforeCalculation = True
    Exit Function
    
ErrHandler:
    Call ErrorHandler("CheckNumericBeforeCalculation")

End Function


Private Function ConvertToCHF(ByRef ao_Source As TextBox, ByRef ao_Currency As ArmCombobox, ByRef ao_Destination As TextBox) As Boolean ', ByVal al_SrcLabelIdx As Long, ByVal al_DestLabelIdx As Long, ByVal ai_NbDecimal As Integer, ByVal av_Min As Variant, ByVal av_Max As Variant, Optional ByVal ab_Verbose = True) As Boolean
On Error GoTo ErrHandler

    Dim ld_rate As Double
    Dim lc_rate As Long
    Dim lv_MsgReplaceInfo As Variant
    Dim lValues As Variant
    
    ' Check if reference data are selected
    If Not cbo_IsFilled(ao_Currency) Then
        ao_Destination.Text = "0"
        Exit Function
    End If
    
    ' If the money is CHF, no conversion needed
    If ao_Currency.SelectedItem.GetData(0) = "CHF" Then
        ao_Destination.Text = IIf(ao_Source.Text = "", 0, ao_Source.Text)
        ConvertToCHF = True
        Exit Function
    End If
    
    ld_rate = ao_Currency.SelectedItem.GetData(2)
    
    If ld_rate = 0 Then
        Err.Raise 3064, SCREEN_NAME, "The exchange rate is 0 :: " & ao_Currency.SelectedItem.GetData(0)
    End If
    
    
    lValues = Split(ao_Destination.Tag, SEP)
    
    Select Case me_Mode
        Case eMode.emAdd, eMode.emCopy, eMode.emRevision, eMode.emUpdate
            ao_Destination.Text = Format(CDbl(IIf(ao_Source.Text = "", 0, ao_Source.Text)) / ld_rate, "0")
        Case Else
            ao_Destination.Text = FormatNumber(CDbl(IIf(ao_Source.Text = "", 0, ao_Source.Text)) / ld_rate, lValues(2))
    End Select
        
    
    ConvertToCHF = True
    Exit Function

ErrHandler:
    Call ErrorHandler("ConvertToCHF")

End Function

Private Sub Item_Reload()
On Error GoTo ErrHandler
    
    Dim ll_ID As Long
    Dim ls_Desc As String
    
    Select Case me_Mode
        Case eMode.emAdd
            
            Select Case ml_Driver
                Case eProject
                    ll_ID = cbo_Project.SelectedItem.Key
                    ls_Desc = cbo_Project.SelectedItem.GetData(1)
                Case eCustomer
                    ll_ID = cbo_Customer.SelectedItem.Key
                    ls_Desc = cbo_Customer.SelectedItem.GetData(1)
            End Select
            
            
            Call ClearForm(UserControl.Controls, Me)
            Call EnableFrame(UserControl.Controls, Me, True)
            
            Call DisableFrameParts(0)
            'Call HandleToolbar(tbl_main, 1, mb_IsFullAccess)
            
            fra_project.Visible = False
            fra_Customer.Visible = False
            
            Call EnableFrame(UserControl.Controls, fra_ModifInfo, False)
             
             
            Call EnableFrame(UserControl.Controls, fra_STD, False)
            cbo_STD_System.Enabled = True
            
            Call EnableFrame(UserControl.Controls, fra_SEM, False)
            cbo_SEM_System.Enabled = True
            
            Call EnableFrame(UserControl.Controls, fra_CUS, False)
            cbo_CUS_System.Enabled = True
    
    
            txt_key.Text = 0
     
            'Default values
            Call Item_LoadDefaultValue(0)
    
    
            Select Case ml_Driver
                Case eProject
                    cbo_Project.Enabled = False
                    If Not cbo_Project.SearchItem(ll_ID) Then
                        Call cbo_Project.AddItem(Array(ll_ID, ls_Desc), True)
                    End If
                                
                Case eCustomer
                    cbo_Customer.Enabled = False
                    If Not cbo_Customer.SearchItem(ll_ID) Then
                        Call cbo_Customer.AddItem(Array(ll_ID, ls_Desc), True)
                    End If
                
            End Select
        
        Case eMode.emCopy, eMode.emRevision, eMode.emUpdate
            Call ClearForm(UserControl.Controls, Me)
            cbo_quote_curr.Load
            cbo_FreightCurr.Load
            Call LoadDataToForm(ml_Cursor, UserControl.Controls, Me)
            
            'tas478-A Nov. 07: reference not have to be filled for emRevision & emCopy
            If me_Mode <> eMode.emUpdate Then
                txt_Ref.Text = ""
                opt_include(0).value = False
                opt_include(1).value = False
            End If
            
            If ms_SrzStrFromWLD <> "" Then
                txt_Status.Text = GetFieldValueFromSrz(ms_SrzStrFromWLD, "Status")
                txt_StatusDesc.Text = GetFieldValueFromSrz(ms_SrzStrFromWLD, "Status_Desc")
                txt_StatusDate.Text = GetFieldValueFromSrz(ms_SrzStrFromWLD, "StatusDate")
            End If
            
            
            If cbo_IsFilled(cbo_STD_System) Then
                Call EnableFrame(UserControl.Controls, fra_STD, True)
            Else
                Call EnableFrame(UserControl.Controls, fra_STD, False)
                cbo_STD_System.Enabled = True
            End If
            
            If cbo_IsFilled(cbo_SEM_System) Then
                Call EnableFrame(UserControl.Controls, fra_SEM, True)
            Else
                Call EnableFrame(UserControl.Controls, fra_SEM, False)
                cbo_SEM_System.Enabled = True
            End If
            
            If cbo_IsFilled(cbo_CUS_System) Then
                Call EnableFrame(UserControl.Controls, fra_CUS, True)
            Else
                Call EnableFrame(UserControl.Controls, fra_CUS, False)
                cbo_CUS_System.Enabled = True
            End If
            
            
    End Select
    

    Exit Sub

ErrHandler:
    Call ErrorHandler("Item_Reload")
End Sub

Private Sub tbl_main_action(ByVal as_Role As String, as_Language As String)
On Error GoTo ErrHandler
    Static DoCheck As Boolean
    
    If DoCheck = True Then Exit Sub
    DoCheck = True
    
    Call LockScreen(True)

    tbl_main.Enabled = False
    
    mb_Internal = True

    Select Case as_Role
        
        Case "I" 'Reload
            Call Item_Reload
        
        Case "D" 'Delete
            Call Item_Delete
            
        Case "H" 'Add
            Call Item_Add
        
        Case "F" 'Refresh
            Call Item_ViewInit(CLng(txt_key.Text))
            
        Case "R" 'Revision
            Call Item_RevisionInit(CLng(txt_key.Text))
            
        Case "Z" 'Copy
            Call Item_CopyInit(CLng(txt_key.Text))
        
        Case "J" 'Goto previous item
            RaiseEvent OnItemPrevious
        
        Case "K" 'Goto next item
            RaiseEvent OnItemNext
        
        Case "B"
            Call Item_UpdateInit(CLng(txt_key.Text), "")
            
        Case "U"
            'todo
            Call Item_Update
            
        Case "T"
            Call Item_Exit(True)
    End Select
    
    mb_Internal = False
    
    tbl_main.Enabled = True
    
    Call LockScreen(False)
    
    DoCheck = False
    
    Exit Sub
    
ErrHandler:
    
    DoCheck = False
    
    tbl_main.Enabled = True
    
    Call LockScreen(False)
    
    Select Case Err.Number
    
    Case 3007
        MsgBox MsgText(3054, ms_Language_Code, "#This data has been updated by another user. Please reload the data and try again."), vbInformation
    
    Case 3008
        MsgBox MsgText(2138, ms_Language_Code, "#The record you try to open has been deleted by an other user. Please refresh the grid."), vbInformation
        Call Item_Exit
    
    Case Else
        Call LogMessage("tbl_main_action: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E", False)
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub




Private Sub txt_CUS_Area_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_CUS_Area)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_CUS_Area_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
    
End Sub


Private Sub SelectTextBoxContents(ByVal ao_Source As TextBox)
On Error GoTo ErrHandler
    
    If ao_Source.Locked = True Then Exit Sub
    
    ao_Source.SelStart = 0
    ao_Source.SelLength = Len(ao_Source.Text)
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("SelectTextBoxContents")
End Sub

Private Sub txt_CUS_DB_Change()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
        
    If Not CheckNumericBeforeCalculation(txt_CUS_DB, 24, 0, 1, 1000) Then
        txt_TOT_DB.Text = "0"
        txt_CUS_PrimeMarg.Text = "0"
        txt_TOT_PrimeMarg.Text = "0"
        Exit Sub
    End If
    
    Call Calculation(txt_CUS_ValueLC, txt_CUS_ValueCHF, txt_CUS_DB, txt_CUS_PrimeMarg)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_CUS_DB_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_CUS_DB_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub



Private Sub txt_CUS_DB_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_CUS_DB)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_CUS_DB_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub


Private Sub txt_CUS_DB_LostFocus()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If UCase(TypeName(UserControl.ActiveControl)) = UCase("ToolbarControl") Then Exit Sub
    
    mb_Internal = True
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If txt_CUS_DB.Locked = True Then Exit Sub
    
   
    If Not CheckNumericBeforeCalculation(txt_CUS_DB, 24, 0, 1, 1000, True) Then
        txt_TOT_DB.Text = "0"
        txt_CUS_PrimeMarg.Text = "0"
        txt_TOT_PrimeMarg.Text = "0"
        mb_Internal = False
        Exit Sub
    End If
    
    Call Calculation(txt_CUS_ValueLC, txt_CUS_ValueCHF, txt_CUS_DB, txt_CUS_PrimeMarg)
    
    mb_Internal = False
    
    Exit Sub
    
ErrHandler:
    
    mb_Internal = False
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_CUS_DB_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_CUS_DB_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_CUS_ValueLC_Change()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If cbo_IsFilled(cbo_CUS_System) Then
        If Not CheckNumericBeforeCalculation(txt_CUS_ValueLC, 23, 0, 1, 99999999) Then
            txt_CUS_ValueCHF.Text = "0"
            txt_CUS_PrimeMarg.Text = "0"
            txt_TOT_ValueCHF = "0"
            txt_TOT_ValueLC = "0"
            txt_TOT_PrimeMarg.Text = "0"
            Exit Sub
        End If
    End If
    
    
    Call Calculation(txt_CUS_ValueLC, txt_CUS_ValueCHF, txt_CUS_DB, txt_CUS_PrimeMarg)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_CUS_ValueLC_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_CUS_ValueLC_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_CUS_ValueLC_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_CUS_ValueLC)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_CUS_ValueLC_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_CUS_ValueLC_LostFocus()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If UCase(TypeName(UserControl.ActiveControl)) = UCase("ToolbarControl") Then Exit Sub
    
    mb_Internal = True
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If txt_CUS_ValueLC.Locked = True Then Exit Sub
    
    If Not CheckNumericBeforeCalculation(txt_CUS_ValueLC, 23, 0, 1, 99999999, True) Then
        txt_CUS_ValueCHF.Text = "0"
        txt_CUS_PrimeMarg.Text = "0"
        txt_TOT_ValueCHF = "0"
        txt_TOT_ValueLC = "0"
        txt_TOT_PrimeMarg.Text = "0"
        mb_Internal = False
        Exit Sub
    End If
    
    Call Calculation(txt_CUS_ValueLC, txt_CUS_ValueCHF, txt_CUS_DB, txt_CUS_PrimeMarg)
    
    mb_Internal = False
    
    Exit Sub
    
ErrHandler:
    
    mb_Internal = False
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_CUS_ValueLC_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_CUS_ValueLC_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub



Private Sub txt_FreightCost_Change()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If Not cbo_IsFilled(cbo_FreightCurr) Then Exit Sub

    If IsEmpty(cbo_FreightCurr.SelectedItem.Key) Then Exit Sub

    If Not CheckNumericBeforeCalculation(txt_FreightCost, 32, 0, 1, 99999999) Then
        Exit Sub
    End If
    
    If Not ConvertToCHF(txt_FreightCost, cbo_FreightCurr, txt_FreightCostCHF) Then Exit Sub
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_FreightCost_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_FreightCost_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select


End Sub



Private Sub txt_FreightCost_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_FreightCost)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_FreightCost_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
    
End Sub

Private Sub txt_SEM_Area_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_SEM_Area)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_SEM_Area_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_SEM_DB_Change()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    

    If Not CheckNumericBeforeCalculation(txt_SEM_DB, 15, 0, 1, 1000) Then
        txt_TOT_DB.Text = "0"
        txt_SEM_PrimeMarg.Text = "0"
        txt_TOT_PrimeMarg.Text = "0"
        Exit Sub
    End If
    
    Call Calculation(txt_SEM_ValueLC, txt_SEM_ValueCHF, txt_SEM_DB, txt_SEM_PrimeMarg)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_SEM_DB_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_SEM_DB_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub txt_SEM_DB_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_SEM_DB)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_SEM_DB_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_SEM_DB_LostFocus()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If UCase(TypeName(UserControl.ActiveControl)) = UCase("ToolbarControl") Then Exit Sub
    
    mb_Internal = True
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If txt_SEM_DB.Locked = True Then Exit Sub
    
    
    If Not CheckNumericBeforeCalculation(txt_SEM_DB, 15, 0, 1, 1000, True) Then
        txt_TOT_DB.Text = "0"
        txt_SEM_PrimeMarg.Text = "0"
        txt_TOT_PrimeMarg.Text = "0"
        mb_Internal = False
        Exit Sub
    End If
    
    Call Calculation(txt_SEM_ValueLC, txt_SEM_ValueCHF, txt_SEM_DB, txt_SEM_PrimeMarg)
    
    mb_Internal = False
    
    Exit Sub
    
ErrHandler:

    mb_Internal = False
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_SEM_DB_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_SEM_DB_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub txt_SEM_ValueLC_Change()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If cbo_IsFilled(cbo_SEM_System) Then
        If Not CheckNumericBeforeCalculation(txt_SEM_ValueLC, 16, 0, 1, 99999999) Then
            txt_SEM_ValueCHF.Text = "0"
            txt_SEM_PrimeMarg.Text = "0"
            txt_TOT_ValueCHF = "0"
            txt_TOT_ValueLC = "0"
            txt_TOT_PrimeMarg.Text = "0"
            Exit Sub
        End If
    End If
    
    
    Call Calculation(txt_SEM_ValueLC, txt_SEM_ValueCHF, txt_SEM_DB, txt_SEM_PrimeMarg)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_SEM_ValueLC_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_SEM_ValueLC_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub



Private Sub txt_SEM_ValueLC_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_SEM_ValueLC)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_SEM_ValueLC_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
    
End Sub

Private Sub txt_SEM_ValueLC_LostFocus()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If UCase(TypeName(UserControl.ActiveControl)) = UCase("ToolbarControl") Then Exit Sub
    
    mb_Internal = True
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If txt_SEM_ValueLC.Locked = True Then Exit Sub
    
    If Not CheckNumericBeforeCalculation(txt_SEM_ValueLC, 16, 0, 1, 99999999, True) Then
        txt_SEM_ValueCHF.Text = "0"
        txt_SEM_PrimeMarg.Text = "0"
        txt_TOT_ValueCHF = "0"
        txt_TOT_ValueLC = "0"
        txt_TOT_PrimeMarg.Text = "0"
        mb_Internal = False
        Exit Sub
    End If
        
    Call Calculation(txt_SEM_ValueLC, txt_SEM_ValueCHF, txt_SEM_DB, txt_SEM_PrimeMarg)
    
    mb_Internal = False
    
    Exit Sub
    
ErrHandler:
    
    mb_Internal = False
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_SEM_ValueLC_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_SEM_ValueLC_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub




Private Sub txt_STD_Area_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_STD_Area)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_STD_Area_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_STD_DB_Change()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    
    If Not CheckNumericBeforeCalculation(txt_STD_DB, 10, 0, 1, 1000) Then
        txt_TOT_DB.Text = "0"
        txt_STD_PrimeMarg.Text = "0"
        txt_TOT_PrimeMarg.Text = "0"
        mb_Internal = False
        Exit Sub
    End If
       
    Call Calculation(txt_STD_ValueLC, txt_STD_ValueCHF, txt_STD_DB, txt_STD_PrimeMarg)
    
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_STD_DB_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_STD_DB_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub txt_STD_DB_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_STD_DB)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_STD_DB_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_STD_DB_LostFocus()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If UCase(TypeName(UserControl.ActiveControl)) = UCase("ToolbarControl") Then Exit Sub
    
    mb_Internal = True
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If txt_STD_DB.Locked = True Then Exit Sub
        
    If Not CheckNumericBeforeCalculation(txt_STD_DB, 10, 0, 1, 1000, True) Then
        txt_TOT_DB.Text = "0"
        txt_STD_PrimeMarg.Text = "0"
        txt_TOT_PrimeMarg.Text = "0"
        mb_Internal = False
        Exit Sub
    End If
       
    Call Calculation(txt_STD_ValueLC, txt_STD_ValueCHF, txt_STD_DB, txt_STD_PrimeMarg)
    
    mb_Internal = False
    
    Exit Sub
    
ErrHandler:
    mb_Internal = False
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_STD_DB_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    Case Else
        Call LogMessage("txt_STD_DB_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_STD_ValueLC_Change()

On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    
    Debug.Print "txt_STD_ValueLC_Change"
    If cbo_IsFilled(cbo_STD_System) Then
        If Not CheckNumericBeforeCalculation(txt_STD_ValueLC, 9, 0, 1, 99999999) Then
            txt_STD_ValueCHF.Text = "0"
            txt_STD_PrimeMarg.Text = "0"
            txt_TOT_ValueCHF = "0"
            txt_TOT_ValueLC = "0"
            txt_TOT_PrimeMarg.Text = "0"
            mb_Internal = False
            Exit Sub
        End If
    End If
    
    
    Call Calculation(txt_STD_ValueLC, txt_STD_ValueCHF, txt_STD_DB, txt_STD_PrimeMarg)
    
    
    Exit Sub
    
ErrHandler:
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_STD_ValueLC_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
    
    Case Else
        Call LogMessage("txt_STD_ValueLC_Change: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
   
End Sub

Private Sub txt_STD_ValueLC_GotFocus()
On Error GoTo ErrHandler

    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub

    Call SelectTextBoxContents(txt_STD_ValueLC)
    
    Exit Sub
    
ErrHandler:
    
    Select Case Err.Number
    
    Case Else
        Call LogMessage("txt_STD_ValueLC_GotFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select

End Sub

Private Sub txt_STD_ValueLC_LostFocus()
On Error GoTo ErrHandler
    
    If mb_Internal Then Exit Sub
    
    If UCase(TypeName(UserControl.ActiveControl)) = UCase("ToolbarControl") Then Exit Sub
       
    mb_Internal = True
    
    If me_Mode = eMode.emView Or me_Mode = eMode.emDelete Then Exit Sub
    
    If txt_STD_ValueLC.Locked = True Then Exit Sub
    
    If Not CheckNumericBeforeCalculation(txt_STD_ValueLC, 9, 0, 1, 99999999, True) Then
        txt_STD_ValueCHF.Text = "0"
        txt_STD_PrimeMarg.Text = "0"
        txt_TOT_ValueCHF = "0"
        txt_TOT_ValueLC = "0"
        txt_TOT_PrimeMarg.Text = "0"
        mb_Internal = False
        Exit Sub
    End If
    
    
    Call Calculation(txt_STD_ValueLC, txt_STD_ValueCHF, txt_STD_DB, txt_STD_PrimeMarg)
    
    mb_Internal = False
    
    Exit Sub
    
ErrHandler:
    mb_Internal = False
    
    Select Case Err.Number
    Case 3064
        Call LogMessage("txt_STD_ValueLC_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox(MsgText(3064, ms_Language_Code, "#The currency you choose is not valide. Choose an other one."), vbInformation)
        
    Case Else
        Call LogMessage("txt_STD_ValueLC_LostFocus: " & Err.Number & ": " & Err.Source & ": " & Err.Description, "E")
        Call MsgBox("Error during the process, Contact immediatly your IT support.", vbCritical)
        End
    End Select
End Sub

Private Sub Calculation(ByRef ao_ValueLC As TextBox, ByRef ao_ValueCHF As TextBox, ByRef ao_DB As TextBox, ByRef ao_PrimeMarg As TextBox)
On Error GoTo ErrHandler

    If Not ConvertToCHF(ao_ValueLC, cbo_quote_curr, ao_ValueCHF) Then Exit Sub
    
    ao_PrimeMarg.Text = Replace(Format((CDbl(IIf(ao_ValueCHF.Text = "", 0, ao_ValueCHF.Text)) / 100) * (CDbl(Replace(IIf(ao_DB.Text = "", 0, ao_DB.Text), ".", ms_DecimalSeparator))), "0.00"), ms_DecimalSeparator, ".", , , vbTextCompare)
    'ao_PrimeMarg.Text = FormatNumber(Replace(ao_PrimeMarg.Text, ".", ms_DecimalSeparator, , , vbTextCompare), 2)
    
    txt_TOT_ValueCHF.Text = CDbl(IIf(txt_STD_ValueCHF.Text = "", 0, txt_STD_ValueCHF.Text)) + CDbl(IIf(txt_SEM_ValueCHF.Text = "", 0, txt_SEM_ValueCHF.Text)) + CDbl(IIf(txt_CUS_ValueCHF.Text = "", 0, txt_CUS_ValueCHF.Text))
    'txt_TOT_ValueCHF.Text = FormatNumber(CDbl(IIf(txt_STD_ValueCHF.Text = "", 0, txt_STD_ValueCHF.Text)) + CDbl(IIf(txt_SEM_ValueCHF.Text = "", 0, txt_SEM_ValueCHF.Text)) + CDbl(IIf(txt_CUS_ValueCHF.Text = "", 0, txt_CUS_ValueCHF.Text)), 0)
    txt_TOT_PrimeMarg.Text = Replace(Format(CDbl(Replace(IIf(txt_STD_PrimeMarg.Text = "", 0, txt_STD_PrimeMarg.Text), ".", ms_DecimalSeparator, , , vbTextCompare)) + CDbl(Replace(IIf(txt_SEM_PrimeMarg.Text = "", 0, txt_SEM_PrimeMarg.Text), ".", ms_DecimalSeparator, , , vbTextCompare)) + CDbl(Replace(IIf(txt_CUS_PrimeMarg.Text = "", 0, txt_CUS_PrimeMarg.Text), ".", ms_DecimalSeparator, , , vbTextCompare)), "0.00"), ms_DecimalSeparator, ".", , , vbTextCompare)
    'txt_TOT_PrimeMarg.Text = FormatNumber(Replace(txt_TOT_PrimeMarg.Text, ".", ms_DecimalSeparator, , , vbTextCompare))
    
    txt_TOT_ValueLC.Text = CDbl(IIf(txt_STD_ValueLC.Text = "", 0, txt_STD_ValueLC.Text)) + CDbl(IIf(txt_SEM_ValueLC.Text = "", 0, txt_SEM_ValueLC.Text)) + CDbl(IIf(txt_CUS_ValueLC.Text = "", 0, txt_CUS_ValueLC.Text))
    If CDbl(Replace(IIf(txt_TOT_PrimeMarg.Text = "", 0, txt_TOT_PrimeMarg.Text), ".", ms_DecimalSeparator)) = 0 Or CDbl(IIf(txt_TOT_ValueCHF.Text = "", 0, txt_TOT_ValueCHF.Text)) = 0 Then
        txt_TOT_DB.Text = "0"
    Else
        txt_TOT_DB.Text = Replace(Format((CDbl(Replace(IIf(txt_TOT_PrimeMarg.Text = "", 0, txt_TOT_PrimeMarg.Text), ".", ms_DecimalSeparator)) / CDbl(IIf(txt_TOT_ValueCHF.Text = "", 0, txt_TOT_ValueCHF.Text))) * 100, "0"), ms_DecimalSeparator, ".", , , vbTextCompare)
        'txt_TOT_DB.Text = FormatNumber(Replace(txt_TOT_DB.Text, ".", ms_DecimalSeparator, , , vbTextCompare), 0)
    End If
    
    If CDbl(txt_TOT_ValueCHF.Text) > 999999999 Then
        ReDim lv_MsgReplaceInfo(2, 1)
        lv_MsgReplaceInfo(0, 0) = "$LabelCaption$"
        lv_MsgReplaceInfo(0, 1) = fra_TOT.Caption & " " & lbl_label(28)
        lv_MsgReplaceInfo(1, 0) = "$Min$"
        lv_MsgReplaceInfo(1, 1) = FormatNumber(0, 0)
        lv_MsgReplaceInfo(2, 0) = "$Max$"
        lv_MsgReplaceInfo(2, 1) = FormatNumber(999999999, 0)

        Call MsgBox(MsgText(3063, ms_Language_Code, "#The " & lv_MsgReplaceInfo(0, 1) & " cannot be greater than" & lv_MsgReplaceInfo(2, 1) & ".", lv_MsgReplaceInfo), vbInformation)
    End If
    
    Exit Sub
    
ErrHandler:
    Call ErrorHandler("Calculation")
End Sub

