VERSION 5.00
Begin VB.UserControl DPC_ConfigFree 
   ClientHeight    =   11370
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   15945
   ScaleHeight     =   11370
   ScaleWidth      =   15945
   Tag             =   "DPC_ConfigFree"
   Begin VB.Frame fra_Header 
      Caption         =   "#Header"
      Height          =   2295
      Left            =   135
      TabIndex        =   0
      Tag             =   "fra_Header"
      Top             =   0
      Width           =   14925
      Begin VB.CheckBox chk_ASFlag 
         Caption         =   "#AS Item"
         Height          =   225
         Left            =   13230
         TabIndex        =   107
         Tag             =   "chk_ASFlag"
         Top             =   1980
         Width           =   1575
      End
      Begin VB.CheckBox chk_FreeOfCharge 
         Caption         =   "#Free of charge"
         Height          =   225
         Left            =   11190
         TabIndex        =   106
         Tag             =   "chk_FreeOfCharge"
         Top             =   1980
         Width           =   1755
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   510
         Index           =   5
         Left            =   8295
         MaxLength       =   250
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   100
         Tag             =   "PRD_OfferComment"
         Top             =   705
         Width           =   6570
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   495
         Index           =   11
         Left            =   8295
         MaxLength       =   250
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   8
         Tag             =   "PRD_InternalComment"
         Top             =   195
         Width           =   6570
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   330
         Index           =   2
         Left            =   1650
         MaxLength       =   30
         TabIndex        =   1
         Tag             =   "OFD_PosCus"
         Top             =   187
         Width           =   1965
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   330
         Index           =   20
         Left            =   5160
         TabIndex        =   2
         Tag             =   "OFD_Pos"
         Top             =   187
         Width           =   1575
      End
      Begin VB.TextBox txt_Textbox 
         Alignment       =   1  'Right Justify
         Height          =   330
         Index           =   3
         Left            =   1650
         TabIndex        =   3
         Tag             =   "PanelQtyPCS"
         Top             =   1230
         Width           =   1095
      End
      Begin VB.TextBox txt_Textbox 
         Alignment       =   1  'Right Justify
         Height          =   330
         Index           =   4
         Left            =   3945
         TabIndex        =   75
         Tag             =   "PanelQtyM2"
         Top             =   1230
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   330
         Index           =   0
         Left            =   1650
         MaxLength       =   80
         TabIndex        =   4
         Tag             =   "PRD_Name"
         Top             =   885
         Width           =   5085
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   330
         Index           =   1
         Left            =   8295
         TabIndex        =   5
         TabStop         =   0   'False
         Tag             =   "PRD_Code"
         Top             =   1230
         Width           =   1455
      End
      Begin VB.TextBox txt_Textbox 
         Alignment       =   1  'Right Justify
         Height          =   330
         Index           =   6
         Left            =   6675
         TabIndex        =   74
         Tag             =   "RPL_ModA"
         Top             =   1575
         Visible         =   0   'False
         Width           =   780
      End
      Begin VB.TextBox txt_Textbox 
         Alignment       =   1  'Right Justify
         Height          =   330
         Index           =   7
         Left            =   8940
         TabIndex        =   73
         Tag             =   "RPL_ModB"
         Top             =   1575
         Visible         =   0   'False
         Width           =   780
      End
      Begin VB.TextBox txt_Textbox 
         Alignment       =   1  'Right Justify
         Height          =   330
         Index           =   9
         Left            =   1650
         TabIndex        =   6
         Tag             =   "RPL_PanA"
         Top             =   1575
         Width           =   780
      End
      Begin VB.TextBox txt_Textbox 
         Alignment       =   1  'Right Justify
         Height          =   330
         Index           =   10
         Left            =   4260
         TabIndex        =   7
         Tag             =   "RPL_PanB"
         Top             =   1575
         Width           =   780
      End
      Begin Project1.ArmCombobox cbo_Material 
         Height          =   345
         Left            =   11565
         TabIndex        =   9
         Top             =   1230
         Width           =   3300
         _ExtentX        =   5821
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_Thickness 
         Height          =   345
         Left            =   11565
         TabIndex        =   10
         Top             =   1575
         Width           =   3300
         _ExtentX        =   5821
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_Vendor 
         Height          =   345
         Left            =   1650
         TabIndex        =   102
         Top             =   525
         Width           =   1965
         _ExtentX        =   3466
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_ShipPoint 
         Height          =   345
         Left            =   5160
         TabIndex        =   103
         Top             =   525
         Width           =   1575
         _ExtentX        =   2778
         _ExtentY        =   609
      End
      Begin Project1.A_calocx cal_OFD_WshDat 
         Height          =   360
         Left            =   1650
         TabIndex        =   111
         Tag             =   "OFD_WshDat"
         Top             =   1905
         Width           =   1845
         _ExtentX        =   3254
         _ExtentY        =   635
      End
      Begin Project1.A_calocx cal_OFD_DelDat 
         Height          =   360
         Left            =   8520
         TabIndex        =   112
         Tag             =   "OFD_DelDat"
         Top             =   1905
         Width           =   1845
         _ExtentX        =   3254
         _ExtentY        =   635
      End
      Begin Project1.A_calocx cal_OFD_ShpDat 
         Height          =   360
         Left            =   5115
         TabIndex        =   113
         Tag             =   "OFD_ShpDat"
         Top             =   1905
         Width           =   1845
         _ExtentX        =   3254
         _ExtentY        =   635
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Shipment date"
         Height          =   255
         Index           =   69
         Left            =   3525
         TabIndex        =   116
         Tag             =   "lbl_OFD_ShpDat"
         Top             =   1965
         Width           =   1470
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Delivery date"
         Height          =   255
         Index           =   70
         Left            =   6975
         TabIndex        =   115
         Tag             =   "lbl_OFD_DelDat"
         Top             =   1965
         Width           =   1470
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Requested date"
         Height          =   255
         Index           =   71
         Left            =   45
         TabIndex        =   114
         Tag             =   "lbl_OFD_WshDat"
         Top             =   1965
         Width           =   1470
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Plant/Vendor"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Index           =   11
         Left            =   60
         TabIndex        =   105
         Tag             =   "lbl_PlantVendor"
         Top             =   570
         Width           =   1395
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Shipping point"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Index           =   30
         Left            =   3660
         TabIndex        =   104
         Tag             =   "lbl_ShipPoint"
         Top             =   570
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Offer Comment"
         Height          =   255
         Index           =   6
         Left            =   6780
         TabIndex        =   101
         Tag             =   "lbl_OfferComment"
         Top             =   765
         Width           =   1530
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Internal Comment"
         Height          =   255
         Index           =   5
         Left            =   6780
         TabIndex        =   93
         Tag             =   "lbl_InternalComment"
         Top             =   225
         Width           =   1530
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Customer position"
         Height          =   255
         Index           =   56
         Left            =   60
         TabIndex        =   91
         Tag             =   "lbl_PanelCodeC"
         Top             =   225
         Width           =   1500
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Armstrong position"
         Height          =   255
         Index           =   53
         Left            =   3660
         TabIndex        =   90
         Tag             =   "lbl_OFD_Pos"
         Top             =   225
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Name"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   54
         Left            =   60
         TabIndex        =   89
         Tag             =   "lbl_PanelName"
         Top             =   930
         Width           =   1230
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Quantity"
         Height          =   255
         Index           =   0
         Left            =   60
         TabIndex        =   88
         Tag             =   "lbl_PanelQty"
         Top             =   1275
         Width           =   1500
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#pcs"
         Height          =   255
         Index           =   1
         Left            =   2865
         TabIndex        =   87
         Tag             =   "lbl_UM_CodePCS"
         Top             =   1290
         Width           =   600
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#m2"
         Height          =   255
         Index           =   2
         Left            =   5130
         TabIndex        =   86
         Tag             =   "lbl_UM_CodeM2"
         Top             =   1275
         Visible         =   0   'False
         Width           =   600
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Module length [mm]"
         Height          =   255
         Index           =   3
         Left            =   5085
         TabIndex        =   85
         Tag             =   "lbl_ModuleA"
         Top             =   1620
         Visible         =   0   'False
         Width           =   1545
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Module width [mm]"
         Height          =   255
         Index           =   4
         Left            =   7470
         TabIndex        =   84
         Tag             =   "lbl_ModuleB"
         Top             =   1620
         Visible         =   0   'False
         Width           =   1500
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Panel length A [mm]"
         Height          =   255
         Index           =   14
         Left            =   60
         TabIndex        =   82
         Tag             =   "lbl_PanelA"
         Top             =   1620
         Width           =   1725
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Panel width B [mm]"
         Height          =   255
         Index           =   16
         Left            =   2490
         TabIndex        =   79
         Tag             =   "lbl_PanelB"
         Top             =   1620
         Width           =   1725
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Material"
         Height          =   285
         Index           =   57
         Left            =   10110
         TabIndex        =   78
         Tag             =   "lbl_Material"
         Top             =   1260
         Width           =   1440
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Thickness [mm]"
         Height          =   255
         Index           =   10
         Left            =   10035
         TabIndex        =   77
         Tag             =   "lbl_Thickness"
         Top             =   1620
         Width           =   1470
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Code"
         Height          =   255
         Index           =   55
         Left            =   6690
         TabIndex        =   76
         Tag             =   "lbl_PanelCode"
         Top             =   1275
         Width           =   1530
      End
   End
   Begin VB.Frame fra_Perforation 
      Caption         =   "#Perforation"
      Height          =   1800
      Left            =   120
      TabIndex        =   92
      Tag             =   "fra_Perforation"
      Top             =   2280
      Width           =   7530
      Begin VB.CheckBox chk_StandardPerf 
         Caption         =   "#Std"
         Height          =   312
         Left            =   6510
         TabIndex        =   118
         Tag             =   "chk_PerfStandardValues"
         Top             =   210
         Width           =   780
      End
      Begin VB.CheckBox chk_CorrectStep 
         Caption         =   "#Correct"
         Height          =   312
         Left            =   6510
         TabIndex        =   117
         Tag             =   "chk_PerfCorrectedSetp"
         Top             =   525
         Width           =   990
      End
      Begin VB.OptionButton opt_UnperfBorder 
         Caption         =   "#Other"
         Height          =   240
         Index           =   2
         Left            =   150
         TabIndex        =   14
         Tag             =   "opt_UnperfBorderOther"
         Top             =   1260
         Width           =   3390
      End
      Begin VB.OptionButton opt_UnperfBorder 
         Caption         =   "#Overperforated border"
         Height          =   240
         Index           =   1
         Left            =   150
         TabIndex        =   13
         Tag             =   "opt_UnperfBorderOver"
         Top             =   975
         Width           =   3360
      End
      Begin VB.OptionButton opt_UnperfBorder 
         Caption         =   "#Standard unperofated border (8 - 12 mm)"
         Height          =   240
         Index           =   0
         Left            =   150
         TabIndex        =   12
         Tag             =   "opt_UnperfBorderStd"
         Top             =   690
         Width           =   3375
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   13
         Left            =   5850
         TabIndex        =   17
         Tag             =   "RPL_UBorC"
         Text            =   "0"
         Top             =   165
         Width           =   650
      End
      Begin VB.CheckBox chk_PerfBorder 
         Caption         =   "#C over border"
         Height          =   270
         Index           =   0
         Left            =   3675
         TabIndex        =   15
         Tag             =   "chk_PerfBorderC"
         Top             =   180
         Width           =   1485
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   17
         Left            =   5190
         TabIndex        =   16
         Tag             =   "RPL_UBoWC"
         Text            =   "0"
         Top             =   165
         Width           =   650
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   8
         Left            =   5850
         TabIndex        =   20
         Tag             =   "RPL_UBorD"
         Text            =   "0"
         Top             =   510
         Width           =   650
      End
      Begin VB.CheckBox chk_PerfBorder 
         Caption         =   "#D over border"
         Height          =   270
         Index           =   1
         Left            =   3675
         TabIndex        =   18
         Tag             =   "chk_PerfBorderD"
         Top             =   540
         Width           =   1485
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   16
         Left            =   5190
         TabIndex        =   19
         Tag             =   "RPL_UBoWD"
         Text            =   "0"
         Top             =   510
         Width           =   650
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   19
         Left            =   5850
         TabIndex        =   23
         Tag             =   "RPL_UBorE"
         Text            =   "0"
         Top             =   855
         Width           =   650
      End
      Begin VB.CheckBox chk_PerfBorder 
         Caption         =   "#E over border"
         Height          =   270
         Index           =   2
         Left            =   3675
         TabIndex        =   21
         Tag             =   "chk_PerfBorderE"
         Top             =   885
         Width           =   1485
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   15
         Left            =   5190
         TabIndex        =   22
         Tag             =   "RPL_UBoWE"
         Text            =   "0"
         Top             =   855
         Width           =   650
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   18
         Left            =   5850
         TabIndex        =   26
         Tag             =   "RPL_UBorF"
         Text            =   "0"
         Top             =   1200
         Width           =   650
      End
      Begin VB.CheckBox chk_PerfBorder 
         Caption         =   "#F over border"
         Height          =   270
         Index           =   3
         Left            =   3675
         TabIndex        =   24
         Tag             =   "chk_PerfBorderF"
         Top             =   1230
         Width           =   1485
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   14
         Left            =   5190
         TabIndex        =   25
         Tag             =   "RPL_UBoWF"
         Text            =   "0"
         Top             =   1200
         Width           =   650
      End
      Begin Project1.ArmCombobox cbo_Perforation 
         Height          =   345
         Left            =   195
         TabIndex        =   11
         Top             =   270
         Width           =   3225
         _ExtentX        =   5689
         _ExtentY        =   609
      End
   End
   Begin VB.Frame fra_Coating 
      Caption         =   "#Coating"
      Height          =   1800
      Left            =   7710
      TabIndex        =   94
      Tag             =   "fra_Coating"
      Top             =   2280
      Width           =   7350
      Begin VB.TextBox txt_Textbox 
         Height          =   720
         Index           =   28
         Left            =   3585
         MaxLength       =   80
         TabIndex        =   123
         Tag             =   "COA_Desc"
         Top             =   1035
         Width           =   3675
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   360
         Index           =   12
         Left            =   2355
         TabIndex        =   119
         Tag             =   "COA_Name"
         Top             =   210
         Width           =   4950
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   330
         Index           =   24
         Left            =   105
         MaxLength       =   80
         TabIndex        =   27
         Tag             =   "COA_Code"
         Top             =   225
         Width           =   1890
      End
      Begin VB.CommandButton cmd_Coating 
         Caption         =   "..."
         Height          =   330
         Left            =   1995
         TabIndex        =   28
         Tag             =   "cmd_Coating"
         Top             =   225
         Width           =   390
      End
      Begin Project1.ArmCombobox cbo_Coating 
         Height          =   345
         Left            =   2385
         TabIndex        =   29
         Tag             =   "COA_Name"
         Top             =   225
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin VB.Frame fra_InOutApp 
         Caption         =   "#Application"
         Height          =   495
         Left            =   3720
         TabIndex        =   34
         Tag             =   "fra_Application"
         Top             =   540
         Visible         =   0   'False
         Width           =   3540
         Begin VB.OptionButton opt_InOut 
            Caption         =   "#Outside"
            Height          =   276
            Index           =   1
            Left            =   1935
            TabIndex        =   36
            Tag             =   "opt_ApplicationOutside"
            Top             =   195
            Width           =   1560
         End
         Begin VB.OptionButton opt_InOut 
            Caption         =   "#Inside"
            Height          =   276
            Index           =   0
            Left            =   144
            TabIndex        =   35
            Tag             =   "opt_ApplicationInside"
            Top             =   195
            Width           =   1770
         End
      End
      Begin VB.Frame fra_CoatingSide 
         Height          =   1215
         Left            =   105
         TabIndex        =   30
         Tag             =   "fra_CoatingSide"
         Top             =   540
         Width           =   3465
         Begin VB.OptionButton opt_CoatingSide 
            Caption         =   "#One side coated"
            Height          =   300
            Index           =   0
            Left            =   75
            TabIndex        =   31
            Tag             =   "opt_CoatingSideOne"
            Top             =   150
            Width           =   3285
         End
         Begin VB.OptionButton opt_CoatingSide 
            Caption         =   "#Both side coated"
            Height          =   300
            Index           =   1
            Left            =   75
            TabIndex        =   32
            Tag             =   "opt_CoatingSideBoth"
            Top             =   472
            Width           =   3285
         End
         Begin VB.OptionButton opt_CoatingSide 
            Caption         =   "#Corrosive protection, backside full coverage"
            Height          =   375
            Index           =   2
            Left            =   75
            TabIndex        =   33
            Tag             =   "opt_CoatingSideFull"
            Top             =   795
            Width           =   3285
         End
      End
   End
   Begin VB.Frame fra_Gasket 
      Caption         =   "#Gasket/Spacer"
      Height          =   1035
      Left            =   120
      TabIndex        =   37
      Tag             =   "fra_Gasket"
      Top             =   4065
      Width           =   14970
      Begin Project1.ArmCombobox cbo_GSK 
         Height          =   345
         Index           =   0
         Left            =   525
         TabIndex        =   39
         Top             =   255
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_GSK 
         Height          =   345
         Index           =   1
         Left            =   4260
         TabIndex        =   41
         Top             =   255
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_GSK 
         Height          =   345
         Index           =   2
         Left            =   7980
         TabIndex        =   43
         Top             =   255
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_GSK 
         Height          =   345
         Index           =   3
         Left            =   11700
         TabIndex        =   45
         Top             =   255
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_GSK2 
         Height          =   345
         Index           =   0
         Left            =   525
         TabIndex        =   47
         Top             =   600
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_GSK2 
         Height          =   345
         Index           =   1
         Left            =   4260
         TabIndex        =   49
         Top             =   600
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_GSK2 
         Height          =   345
         Index           =   2
         Left            =   7980
         TabIndex        =   51
         Top             =   600
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_GSK2 
         Height          =   345
         Index           =   3
         Left            =   11700
         TabIndex        =   53
         Top             =   600
         Width           =   3240
         _ExtentX        =   5715
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Gasket 
         Caption         =   "#C"
         Height          =   300
         Index           =   0
         Left            =   45
         TabIndex        =   38
         Tag             =   "chk_GasketC"
         Top             =   285
         Width           =   555
      End
      Begin VB.CheckBox chk_Gasket 
         Caption         =   "#D"
         Height          =   300
         Index           =   1
         Left            =   3795
         TabIndex        =   40
         Tag             =   "chk_GasketD"
         Top             =   285
         Width           =   555
      End
      Begin VB.CheckBox chk_Gasket 
         Caption         =   "#E"
         Height          =   300
         Index           =   2
         Left            =   7515
         TabIndex        =   42
         Tag             =   "chk_GasketE"
         Top             =   285
         Width           =   555
      End
      Begin VB.CheckBox chk_Gasket 
         Caption         =   "#F"
         Height          =   300
         Index           =   3
         Left            =   11250
         TabIndex        =   44
         Tag             =   "chk_GasketF"
         Top             =   285
         Width           =   555
      End
      Begin VB.CheckBox chk_Gasket2 
         Caption         =   "#C"
         Height          =   300
         Index           =   0
         Left            =   45
         TabIndex        =   46
         Tag             =   "chk_Gasket2C"
         Top             =   630
         Width           =   555
      End
      Begin VB.CheckBox chk_Gasket2 
         Caption         =   "#D"
         Height          =   300
         Index           =   1
         Left            =   3795
         TabIndex        =   48
         Tag             =   "chk_Gasket2D"
         Top             =   630
         Width           =   555
      End
      Begin VB.CheckBox chk_Gasket2 
         Caption         =   "#E"
         Height          =   300
         Index           =   2
         Left            =   7515
         TabIndex        =   50
         Tag             =   "chk_Gasket2E"
         Top             =   630
         Width           =   555
      End
      Begin VB.CheckBox chk_Gasket2 
         Caption         =   "#F"
         Height          =   300
         Index           =   3
         Left            =   11250
         TabIndex        =   52
         Tag             =   "chk_Gasket2F"
         Top             =   630
         Width           =   555
      End
   End
   Begin VB.Frame fra_Inlay 
      Caption         =   "#Inlay"
      Height          =   1605
      Left            =   120
      TabIndex        =   54
      Tag             =   "fra_Inlay"
      Top             =   5070
      Width           =   11565
      Begin VB.TextBox txt_Textbox 
         Height          =   360
         Index           =   25
         Left            =   1470
         TabIndex        =   122
         Tag             =   "INL_Name1"
         Top             =   465
         Width           =   4020
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   360
         Index           =   26
         Left            =   1470
         TabIndex        =   121
         Tag             =   "INL_Name2"
         Top             =   825
         Width           =   4020
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   360
         Index           =   27
         Left            =   1470
         TabIndex        =   120
         Tag             =   "INL_Name3"
         Top             =   1185
         Width           =   4020
      End
      Begin VB.CheckBox chk_InlaySetupCharge 
         Caption         =   "#Setup charge per call"
         Height          =   270
         Index           =   2
         Left            =   9180
         TabIndex        =   110
         Tag             =   "chk_InlaySetupCharge"
         Top             =   1230
         Width           =   2355
      End
      Begin VB.CheckBox chk_InlaySetupCharge 
         Caption         =   "#Setup charge per call"
         Height          =   270
         Index           =   1
         Left            =   9180
         TabIndex        =   109
         Tag             =   "chk_InlaySetupCharge"
         Top             =   870
         Width           =   2355
      End
      Begin VB.CheckBox chk_InlaySetupCharge 
         Caption         =   "#Setup charge per call"
         Height          =   270
         Index           =   0
         Left            =   9180
         TabIndex        =   108
         Tag             =   "chk_InlaySetupCharge"
         Top             =   480
         Width           =   2355
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   23
         Left            =   60
         MaxLength       =   80
         TabIndex        =   55
         Tag             =   "INL_Code1"
         Top             =   465
         Width           =   975
      End
      Begin VB.CommandButton cmd_Inlay 
         Caption         =   "..."
         Height          =   330
         Index           =   0
         Left            =   1035
         TabIndex        =   56
         Tag             =   "cmd_Inlay0"
         Top             =   465
         Width           =   390
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   22
         Left            =   60
         MaxLength       =   80
         TabIndex        =   60
         Tag             =   "INL_Code2"
         Top             =   825
         Width           =   975
      End
      Begin VB.CommandButton cmd_Inlay 
         Caption         =   "..."
         Height          =   330
         Index           =   1
         Left            =   1035
         TabIndex        =   61
         Tag             =   "cmd_Inlay1"
         Top             =   825
         Width           =   390
      End
      Begin VB.TextBox txt_Textbox 
         Height          =   345
         Index           =   21
         Left            =   60
         MaxLength       =   80
         TabIndex        =   65
         Tag             =   "INL_Code3"
         Top             =   1185
         Width           =   975
      End
      Begin VB.CommandButton cmd_Inlay 
         Caption         =   "..."
         Height          =   330
         Index           =   2
         Left            =   1035
         TabIndex        =   66
         Tag             =   "cmd_Inlay2"
         Top             =   1185
         Width           =   390
      End
      Begin Project1.ArmCombobox cbo_InlayName 
         Height          =   345
         Index           =   0
         Left            =   1815
         TabIndex        =   57
         Tag             =   "INL_Name1"
         Top             =   465
         Width           =   3720
         _ExtentX        =   6562
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayDelivery 
         Height          =   345
         Index           =   0
         Left            =   5550
         TabIndex        =   58
         Top             =   465
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayPurchase 
         Height          =   345
         Index           =   0
         Left            =   7350
         TabIndex        =   59
         Top             =   465
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayName 
         Height          =   345
         Index           =   1
         Left            =   1815
         TabIndex        =   62
         Tag             =   "INL_Name2"
         Top             =   825
         Width           =   3720
         _ExtentX        =   6562
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayDelivery 
         Height          =   345
         Index           =   1
         Left            =   5550
         TabIndex        =   63
         Top             =   825
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayPurchase 
         Height          =   345
         Index           =   1
         Left            =   7350
         TabIndex        =   64
         Top             =   825
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayName 
         Height          =   345
         Index           =   2
         Left            =   1815
         TabIndex        =   67
         Tag             =   "INL_Name3"
         Top             =   1185
         Width           =   3720
         _ExtentX        =   6562
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayDelivery 
         Height          =   345
         Index           =   2
         Left            =   5550
         TabIndex        =   68
         Top             =   1185
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_InlayPurchase 
         Height          =   345
         Index           =   2
         Left            =   7350
         TabIndex        =   69
         Top             =   1185
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   609
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Code"
         Height          =   255
         Index           =   46
         Left            =   195
         TabIndex        =   98
         Tag             =   "lbl_PanelCode"
         Top             =   210
         Width           =   1260
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Name"
         Height          =   255
         Index           =   47
         Left            =   1470
         TabIndex        =   97
         Tag             =   "lbl_INL_Name"
         Top             =   210
         Width           =   2235
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Delivery"
         Height          =   255
         Index           =   48
         Left            =   5565
         TabIndex        =   96
         Tag             =   "lbl_PanelCode"
         Top             =   210
         Width           =   1530
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Purchase"
         Height          =   255
         Index           =   49
         Left            =   7350
         TabIndex        =   95
         Tag             =   "lbl_PanelCode"
         Top             =   210
         Width           =   1530
      End
   End
   Begin VB.Frame fra_Files 
      Caption         =   "#Files"
      Height          =   2925
      Left            =   135
      TabIndex        =   72
      Tag             =   "fra_Files"
      Top             =   7350
      Width           =   14955
      Begin Project1.ArmGrid grd_File 
         Height          =   2640
         Left            =   90
         TabIndex        =   80
         Tag             =   "grd_File"
         Top             =   210
         Width           =   14130
         _ExtentX        =   24924
         _ExtentY        =   4657
      End
      Begin Project1.ToolbarControl tlb_File 
         Height          =   2775
         Left            =   14220
         TabIndex        =   81
         Tag             =   "2951"
         Top             =   105
         Width           =   690
         _ExtentX        =   1217
         _ExtentY        =   4895
      End
   End
   Begin VB.CommandButton btn_Validate 
      Height          =   612
      Left            =   13770
      Style           =   1  'Graphical
      TabIndex        =   83
      Tag             =   "btn_Validate"
      Top             =   10380
      Width           =   612
   End
   Begin VB.CommandButton btn_Quit 
      Height          =   612
      Left            =   14400
      Style           =   1  'Graphical
      TabIndex        =   99
      Tag             =   "btn_Quit"
      Top             =   10380
      Width           =   612
   End
   Begin VB.Frame fra_Packing 
      Caption         =   "#Packing"
      Height          =   660
      Left            =   120
      TabIndex        =   70
      Tag             =   "fra_Packing"
      Top             =   6675
      Width           =   14970
      Begin Project1.ArmCombobox cbo_Packing 
         Height          =   345
         Left            =   180
         TabIndex        =   71
         Top             =   225
         Width           =   3225
         _ExtentX        =   5689
         _ExtentY        =   609
      End
   End
   Begin VB.Frame fra_SetupCost 
      Caption         =   "#Setup costs"
      Height          =   1605
      Left            =   11760
      TabIndex        =   124
      Tag             =   "fra_SetupCost"
      Top             =   5070
      Width           =   3330
      Begin VB.Frame fra_PanelSetupUNP 
         BorderStyle     =   0  'None
         Height          =   1035
         Left            =   150
         TabIndex        =   125
         Tag             =   "fra_PanelSetupUNP"
         Top             =   270
         Width           =   3090
         Begin VB.CheckBox chk_Price 
            Caption         =   "#Change of width position"
            Height          =   195
            Index           =   12
            Left            =   15
            TabIndex        =   128
            Tag             =   "chk_PanelChangeBUNP"
            Top             =   735
            Width           =   3015
         End
         Begin VB.CheckBox chk_Price 
            Caption         =   "#Change of length position"
            Height          =   195
            Index           =   13
            Left            =   15
            TabIndex        =   127
            Tag             =   "chk_PanelChangeAUNP"
            Top             =   420
            Width           =   3030
         End
         Begin VB.CheckBox chk_Price 
            Caption         =   "#Setup charge per call"
            Height          =   195
            Index           =   14
            Left            =   15
            TabIndex        =   126
            Tag             =   "chk_PanelSetupChargeUNP"
            Top             =   90
            Width           =   3030
         End
      End
      Begin VB.Frame fra_PanelSetupPRF 
         BorderStyle     =   0  'None
         Height          =   1035
         Left            =   150
         TabIndex        =   129
         Tag             =   "fra_PanelSetupPRF"
         Top             =   270
         Width           =   3135
         Begin VB.CheckBox chk_Price 
            Caption         =   "#Setup charge per call"
            Height          =   195
            Index           =   0
            Left            =   15
            TabIndex        =   132
            Tag             =   "chk_PanelSetupChargePRF"
            Top             =   90
            Width           =   3045
         End
         Begin VB.CheckBox chk_Price 
            Caption         =   "#Change of length position"
            Height          =   195
            Index           =   1
            Left            =   15
            TabIndex        =   131
            Tag             =   "chk_PanelChangeAPRF"
            Top             =   420
            Width           =   3045
         End
         Begin VB.CheckBox chk_Price 
            Caption         =   "#Change of width position"
            Height          =   195
            Index           =   2
            Left            =   15
            TabIndex        =   130
            Tag             =   "chk_PanelChangeBPRF"
            Top             =   735
            Width           =   3030
         End
         Begin VB.Label lbl_Price 
            Alignment       =   2  'Center
            Caption         =   "#Curr"
            Height          =   240
            Index           =   5
            Left            =   4365
            TabIndex        =   135
            Tag             =   "_lbl_CURR_PanelSetupChargePrf"
            Top             =   45
            Width           =   435
         End
         Begin VB.Label lbl_Price 
            Alignment       =   2  'Center
            Caption         =   "#Curr"
            Height          =   240
            Index           =   6
            Left            =   4365
            TabIndex        =   134
            Tag             =   "_lbl_CURR_PanelChangeAPrf"
            Top             =   390
            Visible         =   0   'False
            Width           =   435
         End
         Begin VB.Label lbl_Price 
            Alignment       =   2  'Center
            Caption         =   "#Curr"
            Height          =   240
            Index           =   7
            Left            =   4365
            TabIndex        =   133
            Tag             =   "_lbl_CURR_PanelChangeBPrf"
            Top             =   735
            Visible         =   0   'False
            Width           =   435
         End
      End
   End
End
Attribute VB_Name = "DPC_ConfigFree"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Const SEP = "®©"
Private Const C_SEP As String = "@@"
Private Const SEP1 As String = "®"
Private Const SEP2 As String = "©"
Private Const CL_COLOR_ENABLED As Long = &H80000005
Private Const CL_COLOR_DISABLED As Long = &H8000000F
Private Const SCREEN_NAME As String = "DPC_ConfigFree"
Private Const SW_SHOWNORMAL = 1

Private Const LOCALE_SDECIMAL = &HE ' Decimal separator
Private Const LOCALE_STHOUSAND = &HF ' Thousand separator
Private Const LOCALE_USER_DEFAULT = &H400
Private Const C_ERRORRAISE As Long = 2500
Private Const C_MSG_ID_BASE As Long = 9700

#If ENV = LIVE Then
Private mo_Sys As Object
Private mo_Db As Object
Private mo_DbBaeurer As Object
Private mo_FSO As Object
#Else
Private mo_Sys As ARMSYSCOMLib.ArmSYS
Private mo_Db As ARMSYSCOMLib.ArmDb
Private mo_DbBaeurer As ARMSYSCOMLib.ArmDb
Private mo_FSO As Scripting.FileSystemObject
#End If

Private mo_Tools As DPC_Tools

Public Result As Boolean
Private ml_U_Code As Long

Private ms_Caption As String
Private ms_DPCImageCachePath As String

Public mo_PrdConfig As New DPC_Product
Private mo_PrdTemp As New DPC_Product
Private mo_CurrentBOM As DPC_BOM
Private mo_CurrentBOR As DPC_BOR

Private me_BOMScreen As eDPCScreenMode
Private me_BORScreen As eDPCScreenMode
Private me_PrdScreen As eDPCScreenMode

Private mb_Initialized As Boolean
Private ms_DecimalSeparator As String
Private ms_ThousandSeparator As String
Private mc_ScreenLabels As Long
Private mc_Toolbars As Long
Private mo_WshNetwork As Object
Private ms_ComputerName As String
Private ms_Language_Code                As String       'current user interface language
Private ms_COF_Lang                     As String       'current user data language
Private ms_LoginName                    As String       'contain loginname
Private ms_UserName                     As String       'contain name of logged user as defined in GEN_People

Private mb_InternalInit As Boolean
Private mb_CurrentTextBoxChanged As Boolean
Private mb_IsProduction As Boolean
Private mv_Edge As Variant

Private mao_Inlays(2) As DPC_Inlay

Private ms_BaeurerServer As String
Private ms_BaeurerDatabase As String
Private ms_BaeurerLoginName As String
Private ms_BaeurerPassword As String
Private ms_BaeurerSource As String
Private ml_BaeurerFi_Nr As Long

Private Enum ArmErr
    DBCnxFailed = vbObjectError + 1             ' Unable to connect to the database
    CPTAlreadyInitialized = vbObjectError + 2   ' We try to initialize a component that is already initialized
    CPTNotInitialized = vbObjectError + 3       ' We try to use or free that is not initialized yet
    InvalidArgument = vbObjectError + 4
    PropertyNotSet = vbObjectError + 5
    SQLFailure = vbObjectError + 6               ' A SQL runtime error has occured : syntax wrong....
    SQLBadRowAffectedCount = vbObjectError + 7   ' A SQL request has not affected the expected rowcount (ex: one Update do nothing)
    SQLBadRowExpectedCount = vbObjectError + 8   ' A SQL request does not return the expected rowcount : select an item return nothing...
    DrivingError = vbObjectError + 9
    CompFncFailed = vbObjectError + 10           ' when component function fail
    GridLoadFailed = vbObjectError + 11          ' load function failed ... bad sql
    QuietException = vbObjectError + 12          ' do not display error message
    SQLTableReferenceConstraint = vbObjectError + 13 ' A SQL request cannot be executed : Table reference constraint
    DuplicityDetected = vbObjectError + 2301     ' detected row with same unique id
End Enum

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

Public Event quit()

Public Property Set ArmDb(ByRef ao_Db As Object)
On Error GoTo ErrorHandler

  Set mo_Db = ao_Db
  Exit Property
ErrorHandler:
  Call ErrorHandler("ArmDb.Set")
End Property

Public Property Set Tools(ByRef ao_Tools As Object)
On Error GoTo ErrorHandler

  Set mo_Tools = ao_Tools
  Exit Property
ErrorHandler:
  Call ErrorHandler("Tools.Set")
End Property

Public Property Let Language_Code(as_Language_Code As String)
On Error GoTo ErrHandler
  
  ms_Language_Code = as_Language_Code
  Exit Property
ErrHandler:
  Call ErrorHandler("Language_Code.Let")
End Property

Public Property Get Language_Code() As String
On Error GoTo ErrHandler
  
  Language_Code = ms_Language_Code
  Exit Property
ErrHandler:
  Call ErrorHandler("Language_Code.Get")
End Property

Property Let COF_Lang(as_Value As String)
On Error GoTo ErrHandler

  ms_COF_Lang = as_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("COF_Lang.Let")
End Property

Public Property Get COF_Lang() As String
On Error GoTo ErrHandler
  
  COF_Lang = ms_COF_Lang
  Exit Property
ErrHandler:
  Call ErrorHandler("COF_Lang.Get")
End Property

Public Property Let U_Code(ByVal al_U_Code As Long)
On Error GoTo ErrorHandler

  ml_U_Code = al_U_Code
  Exit Property
ErrorHandler:
  Call ErrorHandler("U_Code.Let")
End Property

Public Property Let LoginName(ByVal as_Value As String)
On Error GoTo ErrorHandler

  ms_LoginName = as_Value
  Exit Property
ErrorHandler:
  Call ErrorHandler("LoginName.Let")
End Property

Public Property Let Caption(ByVal as_Value As String)
On Error GoTo ErrHandler
    
  ms_Caption = as_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Caption.Let")
End Property

Public Property Get Caption() As String
On Error GoTo ErrHandler
    
  Caption = ms_Caption
  Exit Property
ErrHandler:
  Call ErrorHandler("Caption.Get")
End Property

Public Property Let Name(ByVal as_Value As String)
On Error GoTo ErrHandler
    
  UserControl.Extender.Name = as_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Name.Let")
End Property

Public Property Get Name() As String
On Error GoTo ErrHandler
    
  Name = UserControl.Extender.Name
  Exit Property
ErrHandler:
  Call ErrorHandler("Name.Get")
End Property

Public Property Let Tag(ByVal as_Value As String)
On Error GoTo ErrHandler
    
  UserControl.Tag = as_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Tag.Let")
End Property

Public Property Get Tag() As String
On Error GoTo ErrHandler
    
  Tag = UserControl.Tag
  Exit Property
ErrHandler:
  Call ErrorHandler("Tag.Get")
End Property

Public Property Let Visible(ByVal aVisible As Boolean)
On Error GoTo ErrHandler
    
  UserControl.Extender.Visible = aVisible
  Exit Property
ErrHandler:
  Call ErrorHandler("Visible.Let")
End Property

Public Property Get Visible() As Boolean
On Error GoTo ErrHandler
    
  Visible = UserControl.Extender.Visible
  Exit Property
ErrHandler:
  Call ErrorHandler("Visible.Get")
End Property

Public Property Let Top(ByVal aTop As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Top = aTop
  Exit Property
ErrHandler:
  Call ErrorHandler("Top.Let")
End Property

Public Property Get Top() As Single
On Error GoTo ErrHandler
    
  Top = UserControl.Extender.Top
  Exit Property
ErrHandler:
  Call ErrorHandler("Top.Get")
End Property

Public Property Let Height(ByVal aHeight As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Height = aHeight
  Exit Property
ErrHandler:
  Call ErrorHandler("Height.Let")
End Property

Public Property Get Height() As Single
On Error GoTo ErrHandler
    
  Height = UserControl.Extender.Height
  Exit Property
ErrHandler:
  Call ErrorHandler("Height.Get")
End Property

Public Property Let Left(ByVal aLeft As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Left = aLeft
  Exit Property
ErrHandler:
  Call ErrorHandler("Left.Let")
End Property

Public Property Get Left() As Single
On Error GoTo ErrHandler
    
  Left = UserControl.Extender.Left
  Exit Property
ErrHandler:
  Call ErrorHandler("Left.Get")
End Property

Public Property Let Width(ByVal aWidth As Single)
On Error GoTo ErrHandler
    
  UserControl.Extender.Width = aWidth
  Exit Property
ErrHandler:
  Call ErrorHandler(".Let")
End Property

Public Property Get Width() As Single
On Error GoTo ErrHandler
    
  Width = UserControl.Extender.Width
  Exit Property
ErrHandler:
  Call ErrorHandler("Width.Get")
End Property

Public Sub Move(ByVal aLeft As Single, ByVal aTop As Single, ByVal aWidth As Single, ByVal aHeight As Single)
On Error GoTo ErrHandler
  
  Call UserControl.Extender.Move(aLeft, aTop, aWidth, aHeight)
  Exit Sub
ErrHandler:
  Call ErrorHandler("Move")
End Sub

Public Property Let Enabled(ByVal ab_Value As Boolean)
On Error GoTo ErrHandler

  UserControl.Enabled = ab_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("Enabled.Let")
End Property

Public Property Get Enabled() As Boolean
 On Error GoTo ErrHandler

  Enabled = UserControl.Enabled
  Exit Property
ErrHandler:
  Call ErrorHandler("Enabled.Get")
End Property

Public Sub Zorder()
On Error GoTo ErrHandler

  Call UserControl.Extender.Zorder
  Exit Sub
ErrHandler:
  Call ErrorHandler("Zorder")
End Sub

Public Sub Refresh()
On Error GoTo ErrHandler

  Call UserControl.Refresh
  Exit Sub
ErrHandler:
  Call ErrorHandler("Refresh")
End Sub

Public Property Get hwnd() As Long
On Error GoTo ErrHandler
  
  hwnd = UserControl.hwnd
  Exit Property
ErrHandler:
  Call ErrorHandler("hwnd.Get")
End Property

Public Property Get Initialized() As Boolean
On Error GoTo ErrHandler
    
  Initialized = mb_Initialized
  Exit Property
ErrHandler:
  Call ErrorHandler("Initialized.Get")
End Property

Public Property Let COF_Id(ByVal as_Value As String)
On Error GoTo ErrHandler
  
  mo_PrdConfig.COF_Id = as_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("COF_Id.Let")
End Property

Public Property Get COF_Id() As String
On Error GoTo ErrHandler
  
  COF_Id = mo_PrdConfig.COF_Id
  Exit Property
ErrHandler:
  Call ErrorMessage("COF_Id.Get")
End Property

Public Property Let LEN_Id(ByVal as_Value As Long)
On Error GoTo ErrHandler
  
  mo_PrdConfig.LEN_Id = as_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("LEN_Id.Let")
End Property

Public Property Let CURR_Code(ByVal as_Value As String)
On Error GoTo ErrHandler
  
  mo_PrdConfig.CURR_Code = as_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("CURR_Code.Let")
End Property

Public Property Get CURR_Code() As String
On Error GoTo ErrHandler
  
  CURR_Code = mo_PrdConfig.CURR_Code
  Exit Property
ErrHandler:
  Call ErrorMessage("CURR_Code.Get")
End Property

Public Property Let CT_Code(ByVal as_Value As String)
On Error GoTo ErrHandler
  
  mo_PrdConfig.CT_Code = as_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("CT_Code.Let")
End Property

Public Property Get CT_Code() As String
On Error GoTo ErrHandler
  
  CT_Code = mo_PrdConfig.CT_Code
  Exit Property
ErrHandler:
  Call ErrorMessage("CT_Code.Get")
End Property

Public Property Let OFD_Pos(ByVal al_Value As Long)
On Error GoTo ErrHandler
  
  mo_PrdConfig.OFD_Pos = al_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_Pos.Let")
End Property

Public Property Get OFD_Pos() As Long
On Error GoTo ErrHandler
  
  OFD_Pos = mo_PrdConfig.OFD_Pos
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_Pos.Get")
End Property

Public Property Let ValidityDate(ByVal ad_Value As Date)
On Error GoTo ErrHandler
  
  mo_PrdConfig.ValidityDate = ad_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("ValidityDate.Let")
End Property

Public Property Get ValidityDate() As Date
On Error GoTo ErrHandler
  
  ValidityDate = mo_PrdConfig.ValidityDate
  Exit Property
ErrHandler:
  Call ErrorMessage("ValidityDate.Get")
End Property

Public Property Let OFD_WshDat(ByVal ad_Value As Date)
On Error GoTo ErrHandler
  
  mo_PrdConfig.OFD_WshDat = ad_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_WshDat.Let")
End Property

Public Property Get OFD_WshDat() As Date
On Error GoTo ErrHandler
  
  OFD_WshDat = mo_PrdConfig.OFD_WshDat
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_WshDat.Get")
End Property

Public Property Let OFD_ShpDat(ByVal ad_Value As Date)
On Error GoTo ErrHandler
  
  mo_PrdConfig.OFD_ShpDat = ad_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_ShpDat.Let")
End Property

Public Property Get OFD_ShpDat() As Date
On Error GoTo ErrHandler
  
  OFD_ShpDat = mo_PrdConfig.OFD_ShpDat
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_ShpDat.Get")
End Property

Public Property Let OFD_DelDat(ByVal ad_Value As Date)
On Error GoTo ErrHandler
  
  mo_PrdConfig.OFD_DelDat = ad_Value
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_DelDat.Let")
End Property

Public Property Get OFD_DelDat() As Date
On Error GoTo ErrHandler
  
  OFD_DelDat = mo_PrdConfig.OFD_DelDat
  Exit Property
ErrHandler:
  Call ErrorMessage("OFD_DelDat.Get")
End Property

Public Property Let IsProduction(ByVal ab_Value As Boolean)
On Error GoTo ErrHandler

  mb_IsProduction = ab_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("IsProduction.Let")
End Property

Public Property Get IsProduction() As Boolean
On Error GoTo ErrHandler

  IsProduction = mb_IsProduction
  Exit Property
ErrHandler:
  Call ErrorHandler("IsProduction.Get")
End Property

Public Property Get IsTemplate() As Boolean
On Error GoTo ErrHandler

  IsTemplate = mo_PrdConfig.IsTemplate
  Exit Property
ErrHandler:
  Call ErrorHandler("IsTemplate.Get")
End Property

Public Property Let IsTemplate(ByVal ab_Value As Boolean)
On Error GoTo ErrHandler

  mo_PrdConfig.IsTemplate = ab_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("IsTemplate.Let")
End Property

Public Property Get IsStandard() As Boolean
On Error GoTo ErrHandler

  IsStandard = mo_PrdConfig.IsStandard
  Exit Property
ErrHandler:
  Call ErrorHandler("IsStandard.Get")
End Property

Public Function Load_A_COM() As Boolean
On Error GoTo ErrHandler
    
Dim la_Columns() As Variant
Dim ll_Idx As Integer
Dim ls_Request As String
Dim ls_Connect() As String
  
  Load_A_COM = False
  
  If mb_Initialized Then
      Call Err.Raise(ArmErr.CPTAlreadyInitialized)
  End If
  If mo_Db Is Nothing Then
      Call Err.Raise(ArmErr.PropertyNotSet)
  End If
  If mo_Tools Is Nothing Then
      Call Err.Raise(ArmErr.PropertyNotSet)
  End If
  
  mb_InternalInit = True
  
  Call mo_Tools.Load_A_ComControls(UserControl.Controls, mo_Db, ms_Language_Code)
  
  ms_DecimalSeparator = Format(0, ".")
  ms_ThousandSeparator = mo_Tools.GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND)
  mc_Toolbars = 0
  
  Set mo_FSO = CreateObject("Scripting.FileSystemObject")
#If ENV = LIVE Then
  Set mo_Sys = CreateObject("ArmSYSCOM.ArmSys")
  Set mo_DbBaeurer = CreateObject("ArmSYSCOM.ArmDb")
#Else
  Set mo_Sys = New ARMSYSCOMLib.ArmSYS
  Set mo_DbBaeurer = New ARMSYSCOMLib.ArmDb
#End If
  
  Set mo_WshNetwork = CreateObject("WScript.Network")
  ms_ComputerName = mo_WshNetwork.ComputerName
  
  ms_DPCImageCachePath = prg.AppCache_Dir & DPC_IMAGE_CACHE
  btn_Validate.Picture = LoadResPicture(RES_OK, 1)
  btn_Quit.Picture = LoadResPicture(RES_QUIT, 1)
'  btn_ImageQuit.Picture = LoadResPicture(RES_QUIT, 1)
'  btn_PriceMatrixQuit.Picture = LoadResPicture(RES_QUIT, 1)
'  btn_Next.Picture = LoadResPicture(RES_RIGHT, 1)
'  btn_Default.Picture = LoadResPicture(77, 1)
'  btn_Back.Picture = LoadResPicture(RES_LEFT, 1)
'  btn_Image.Picture = LoadResPicture(108, 1)
'  btn_Error.Picture = LoadResPicture(146, 1)
  
  ls_Connect = Split(mo_Tools.GetAConfigData("DPC_BaeurerConnection"), SEP)
  If UBound(ls_Connect) = 5 Then
    ms_BaeurerServer = ls_Connect(0)
    ms_BaeurerDatabase = ls_Connect(1)
    ms_BaeurerLoginName = ls_Connect(2)
    ms_BaeurerPassword = ls_Connect(3)
    ms_BaeurerSource = ls_Connect(4)
    ml_BaeurerFi_Nr = Val(ls_Connect(5))
  Else
      Err.Raise ArmErr.PropertyNotSet, "Split(mo_Tools.GetAConfigData(""DPC_BaeurerConnection"")", "Missing or invalid configuration"
  End If
  
'  ms_BaeurerSource = "Capture"
'  ms_BaeurerServer = "10.68.16.40\LIVE_SAGE"
'  ms_BaeurerDatabase = "test70"
'  ms_BaeurerLoginName = "test70"
'  ms_BaeurerPassword = "erp"
  
  mv_Edge = Array("C", "D", "E", "F")
  Result = False
  
  mb_InternalInit = True
  
  Set mo_PrdConfig.Tools = mo_Tools
  Set mo_PrdConfig.ArmDb = mo_Db
  mo_PrdConfig.U_Code = ml_U_Code
  mo_PrdConfig.CT_Code = CT_Code
  mo_PrdConfig.CURR_Code = CURR_Code
  mo_PrdConfig.ValidityDate = ValidityDate
  mo_PrdConfig.Language_Code = ms_COF_Lang
  mo_PrdConfig.COF_Id = COF_Id
  Call mo_PrdConfig.Load_A_COM
  Call mo_PrdConfig.InitOffer
  
  Set mo_PrdTemp.Tools = mo_Tools
  Set mo_PrdTemp.ArmDb = mo_Db
  mo_PrdTemp.U_Code = ml_U_Code
  mo_PrdTemp.CT_Code = CT_Code
  mo_PrdTemp.CURR_Code = CURR_Code
  mo_PrdTemp.ValidityDate = ValidityDate
  mo_PrdTemp.Language_Code = ms_COF_Lang
  mo_PrdTemp.COF_Id = COF_Id
  Call mo_PrdTemp.Load_A_COM

  cal_OFD_WshDat.opening_toward_top = 1
  cal_OFD_ShpDat.opening_toward_top = 1
  cal_OFD_DelDat.opening_toward_top = 1
  
  grd_File.UnBound = True
  ReDim la_Columns(6) As Variant
  la_Columns(0) = "Idx" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "Idx" & CH_LDELIMIT & ""
  la_Columns(1) = "PFI_Id" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PFI_Id" & CH_LDELIMIT & ""
  la_Columns(2) = "PRD_Id" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PRD_Id" & CH_LDELIMIT & ""
  la_Columns(3) = "FIL_Id" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "FIL_Id" & CH_LDELIMIT & ""
  la_Columns(4) = "FIL_Name" & CH_LDELIMIT & "2500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "FIL_Name" & CH_LDELIMIT & "#Name"
  la_Columns(5) = "FIL_FileName" & CH_LDELIMIT & "7000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "FIL_FileName" & CH_LDELIMIT & "#File"
  la_Columns(6) = "PFI_Order" & CH_LDELIMIT & "400" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PFI_Order" & CH_LDELIMIT & "#Order"
  Call grd_File.SetColumns(la_Columns)
  
  Call InitPerforationCombo(cbo_Perforation, eDPCCutoutType.eNone)
  Call InitCoatingCombo(cbo_Coating)
  For ll_Idx = 0 To cbo_InlayName.Count - 1
    Call InitInlayCombo(cbo_InlayName(ll_Idx))
    Call InitReferencesCombo(cbo_InlayDelivery(ll_Idx), eDPCReferenceML.rfInlayDeliveryKind)
    Call InitReferencesCombo(cbo_InlayPurchase(ll_Idx), eDPCReferenceML.rfInlayPurchaseType)
  Next

'  For ll_Idx = 0 To cbo_Cutout.Count - 1
'    Call InitCutoutCombo(cbo_Cutout(ll_Idx))
'  Next

  For ll_Idx = 0 To cbo_GSK.Count - 1
    Call InitGasketCombo(cbo_GSK(ll_Idx), eDPCGasketType.gtGasket, 0)
    Call InitGasketCombo(cbo_GSK2(ll_Idx), eDPCGasketType.gtSpacer, 0)
  Next
  
  Call InitVendorCombo(cbo_Vendor)
  Call InitShipPointCombo(cbo_ShipPoint)
  Call InitMaterialCombo
  ms_Caption = "#Product configuration"
  cbo_Coating.Locked = False
  
  Call Resize
  
  Call mo_Tools.LoadToolbars(mo_Db, UserControl.Controls, "DPC", SCREEN_NAME)
  
  'Screen csts
  mc_ScreenLabels = mo_Tools.LoadLabels(mo_Db, UserControl.Controls, Me, SCREEN_NAME, ms_Language_Code)
  Call mo_Tools.ChangeCharset(UserControl.Controls, gl_CodePage, mo_Tools.GetCodePageFromLanguage(mo_Db, ms_COF_Lang))
  
  mo_PrdConfig.lbl_ShipPoint = mo_Tools.GetControl(lbl_Label, "lbl_ShipPoint").Caption
  mo_PrdConfig.lbl_PlantVendor = mo_Tools.GetControl(lbl_Label, "lbl_PlantVendor").Caption
  
  mb_InternalInit = False
  mb_Initialized = True
  Load_A_COM = mb_Initialized
  Exit Function
ErrHandler:
  mb_InternalInit = False
  Load_A_COM = False
  Call ErrorMessage("Load_A_COM")
End Function

Public Sub Unload_A_COM()
On Error GoTo ErrHandler

  Call mo_PrdConfig.Unload_A_COM
  Call mo_Tools.Unload_A_ComControls(UserControl.Controls)
  Call mo_Db.Close(mc_ScreenLabels)
  Set mo_Sys = Nothing
  Set mo_FSO = Nothing
  Set mo_Db = Nothing
  Exit Sub
ErrHandler:
  Call ErrorMessage("Unload_A_COM")
End Sub

Private Sub InitThicknessCombo()
On Error GoTo ErrHandler
  
Dim ls_Request As String

  Call cbo_Thickness.Clear
  ls_Request = "exec DPC_Coil_lst2 $MAT_Id$, $COF_Lang$"
  ls_Request = Replace(ls_Request, "$MAT_Id$", mo_Tools.SqlInt(mo_PrdConfig.MAT_Id), , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  cbo_Thickness.Request = ls_Request
  cbo_Thickness.FirstBlankItem = IsTemplate
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitThicknessCombo")
End Sub

Private Sub InitMaterialCombo()
On Error GoTo ErrHandler
  
Dim ls_Request As String

  ls_Request = "exec DPC_Material_lst2 $COF_Lang$"
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  cbo_Material.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitMaterialCombo")
End Sub

Private Sub InitPerforationCombo(ByVal ao_Combo As ArmCombobox, ByVal ae_CutoutType As eDPCCutoutType)
On Error GoTo ErrHandler
  
Dim ls_Request As String

  ls_Request = "exec DPC_Perforation_lst2 $COF_Lang$, $PRF_AllowVent$, $PRF_AllowLoud$"
  If ae_CutoutType = eDPCCutoutType.eVentilation Then
    ls_Request = Replace(ls_Request, "$PRF_AllowVent$", "X", , , vbTextCompare)
    ls_Request = Replace(ls_Request, "$PRF_AllowLoud$", "NULL", , , vbTextCompare)
  ElseIf ae_CutoutType = eDPCCutoutType.eLoudspeaker Then
    ls_Request = Replace(ls_Request, "$PRF_AllowVent$", "NULL", , , vbTextCompare)
    ls_Request = Replace(ls_Request, "$PRF_AllowLoud$", "X", , , vbTextCompare)
  Else
    ls_Request = Replace(ls_Request, "$PRF_AllowVent$", "NULL", , , vbTextCompare)
    ls_Request = Replace(ls_Request, "$PRF_AllowLoud$", "NULL", , , vbTextCompare)
  End If
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitPerforationCombo")
End Sub

Private Sub InitReferencesCombo(ByVal ao_Combo As ArmCombobox, ByVal ae_GR_Code As eDPCReferenceML)
On Error GoTo ErrHandler
  
Dim ls_Request As String

  ls_Request = "exec A_References_ML_Lst $GR_Code$, $COF_Lang$"
  ls_Request = Replace(ls_Request, "$GR_Code$", mo_Tools.SqlInt(ae_GR_Code), , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitReferencesCombo")
End Sub

Private Sub InitVendorCombo(ByVal ao_Combo As ArmCombobox)
On Error GoTo ErrHandler

  Dim ls_Request As String
  ls_Request = "exec DPC_Vendor_SAP_View_lst $LEN_Id$, $COF_Lang$"
  ls_Request = Replace(ls_Request, "$LEN_Id$", mo_Tools.SqlInt(mo_PrdConfig.LEN_Id), , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitVendorCombo")
End Sub

Private Sub InitShipPointCombo(ByVal ao_Combo As ArmCombobox)
On Error GoTo ErrHandler

  Dim ls_Request As String
  ls_Request = "exec DPC_ShipPoint_SAP_View_lst $LEN_Id$, $VEN_Id$, $COF_Lang$"
  ls_Request = Replace(ls_Request, "$LEN_Id$", mo_Tools.SqlInt(mo_PrdConfig.LEN_Id), , , vbTextCompare)
  ls_Request = Replace(ls_Request, "$VEN_Id$", mo_Tools.SQLStr(mo_PrdConfig.VEN_Id), , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitShipPointCombo")
End Sub

Private Sub InitCutoutCombo(ByVal ao_Combo As ArmCombobox)
On Error GoTo ErrHandler

  Dim ls_Request As String
  ls_Request = "exec DPC_CutType_cbo $CUT_Type$, $COF_Lang$"
  ls_Request = Replace(ls_Request, "$CUT_Type$", "NULL", , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  ao_Combo.FirstBlankItem = True
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitCutoutCombo")
End Sub
     
Private Sub InitGasketCombo(ByVal ao_Combo As ArmCombobox, ByVal ae_GSK_Type As eDPCGasketType, ByVal ad_Gap As Double)
On Error GoTo ErrHandler
  
Dim ls_Request As String

  ls_Request = "exec DPC_Gasket_lst2 $GSK_Type$, $GSK_Gap$, $COF_Lang$"
    
  ls_Request = Replace(ls_Request, "$GSK_Type$", mo_Tools.SqlInt(ae_GSK_Type), , , vbTextCompare)
  ls_Request = Replace(ls_Request, "$GSK_Gap$", "NULL", , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitMaterialCombo")
End Sub

Private Sub InitInlayCombo(ByVal ao_Combo As ArmCombobox)
On Error GoTo ErrHandler
  
Dim ls_Request As String

  ls_Request = "exec DPC_Inlay_lst $COF_Lang$"
    
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  ao_Combo.FirstBlankItem = True
  ao_Combo.Locked = True
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitInlayCombo")
End Sub

Private Sub InitCoatingCombo(ByVal ao_Combo As ArmCombobox)
On Error GoTo ErrHandler
  
Dim ls_Request As String

  ls_Request = "exec DPC_Coating_cbo $COF_Lang$"
    
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  ao_Combo.Locked = True
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitInlayCombo")
End Sub

Private Sub InitPackingCombo()
On Error GoTo ErrHandler
  
Dim ls_Request As String
    
  ls_Request = "exec DPC_Packing_lst3 $SYS_Id$, $COF_Lang$"
  
  ls_Request = Replace(ls_Request, "$SYS_Id$", mo_Tools.SqlInt(mo_PrdConfig.SYS_Id), , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  cbo_Packing.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitPackingCombo")
End Sub
     
Private Sub DisplayPanelQtySize()
On Error GoTo ErrHandler

Dim ll_SideIdx As Long
Dim ls_Value As String

  'Call mo_Tools.SetTextBox(txt_Textbox, "PanelQtyM2", mo_Tools.DblToScreen(mo_PrdConfig.PanelQtyM2), Not (mo_PrdConfig.QtyType = eDPCQtyType.qtPCS))
  Call mo_Tools.SetTextBox(txt_Textbox, "PanelQtyPCS", mo_Tools.LongToScreen(mo_PrdConfig.PanelQtyPCS), Not (mo_PrdConfig.QtyType = eDPCQtyType.qtM2))
  
  'Call mo_Tools.SetTextBox(txt_Textbox, "RPL_PU", mo_Tools.LongToScreen(mo_PrdConfig.RPL_PU))
  
  'Call mo_Tools.SetTextBox(txt_Textbox, "RPL_ModA", mo_Tools.DblToScreen(mo_PrdConfig.RPL_ModA))
  'Call mo_Tools.SetTextBox(txt_Textbox, "RPL_ModB", mo_Tools.DblToScreen(mo_PrdConfig.RPL_ModB))
  
  ls_Value = IIf(mo_PrdConfig.RPL_PanA >= 0, mo_Tools.DblToScreen(mo_PrdConfig.RPL_PanA), "")
  Call mo_Tools.SetTextBox(txt_Textbox, "RPL_PanA", ls_Value)
  ls_Value = IIf(mo_PrdConfig.RPL_PanB >= 0, mo_Tools.DblToScreen(mo_PrdConfig.RPL_PanB), "")
  Call mo_Tools.SetTextBox(txt_Textbox, "RPL_PanB", ls_Value)
  'Call mo_Tools.SetTextBox(txt_Textbox, "PanelSurface", mo_Tools.DblToScreen(mo_PrdConfig.PanelSurface), False)
  
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPanelQtySize")
End Sub

Private Sub DisplayPanelMaterial()
On Error GoTo ErrHandler

  If mo_PrdConfig.MAT_Id = 0 Then
    Set cbo_Material.SelectedItem = Nothing
  Else
    If Not cbo_Material.SearchItem(mo_PrdConfig.MAT_Id) Then
      Call cbo_Material.AddItem(Array(mo_PrdConfig.MAT_Id, mo_PrdConfig.MAT_Name), True)
    End If
  End If
  Call InitThicknessCombo
  If Not cbo_Thickness.SearchItem(mo_PrdConfig.RPL_Thick) Then
    Call cbo_Thickness.AddItem(Array(mo_PrdConfig.RPL_Thick, mo_Tools.DblToScreen(mo_PrdConfig.RPL_Thick)), True)
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPanelMaterial")
End Sub

Private Sub DisplayPanelData()
On Error GoTo ErrHandler

Dim lsa_PRD_Code() As String
Dim ll_Idx As Long

  Call mo_Tools.SetTextValue(txt_Textbox, "PRD_Name", mo_PrdConfig.PRD_Name)
  Call mo_Tools.SetTextBox(txt_Textbox, "OFD_Pos", OFD_Pos, False)
  Call mo_Tools.SetTextValue(txt_Textbox, "OFD_PosCus", mo_PrdConfig.OFD_PosCus)
  Call mo_Tools.SetTextBox(txt_Textbox, "PRD_Code", mo_PrdConfig.PRD_Code, IsTemplate)
  
  chk_ASFlag.Value = IIf(mo_PrdConfig.OFD_IsAsItem, vbChecked, vbUnchecked)
  chk_FreeOfCharge.Value = IIf(mo_PrdConfig.OFD_IsFree, vbChecked, vbUnchecked)
  
  Call InitVendorCombo(cbo_Vendor)
  Call InitShipPointCombo(cbo_ShipPoint)
  If Not cbo_Vendor.SearchItem(mo_PrdConfig.VEN_Id) Then
    Call cbo_Vendor.AddItem(Array(mo_PrdConfig.VEN_Id, mo_PrdConfig.VEN_Name), True)
  End If
  If Not cbo_ShipPoint.SearchItem(mo_PrdConfig.SHP_Id) Then
    Call cbo_ShipPoint.AddItem(Array(mo_PrdConfig.SHP_Id, mo_PrdConfig.SHP_Name), True)
  End If
  
  Call mo_Tools.SetTextBox(txt_Textbox, "PRD_OfferComment", mo_PrdConfig.GetErrorText(eDPCError.erOfferComment, Nothing))
  Call mo_Tools.SetTextBox(txt_Textbox, "PRD_InternalComment", mo_PrdConfig.GetErrorText(eDPCError.erInternalComment, Nothing))
 
  Call mo_Tools.SetCalendarDate(cal_OFD_WshDat, mo_PrdConfig.OFD_WshDat)
  Call mo_Tools.SetCalendarDate(cal_OFD_ShpDat, mo_PrdConfig.OFD_ShpDat)
  Call mo_Tools.SetCalendarDate(cal_OFD_DelDat, mo_PrdConfig.OFD_DelDat)
  'Call mo_Tools.SetTextBox(txt_Textbox, "PanelPerMod", mo_PrdConfig.PanelPerMod, False)
  'Call mo_Tools.SetTextValue(txt_Textbox, "RPL_CorW", mo_Tools.DblToScreen(mo_PrdConfig.RPL_CorW))
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPanelData")
End Sub

'Private Sub DisplayBending()
'On Error GoTo ErrHandler
'
'  Exit Sub
'ErrHandler:
'  Call ErrorHandler("DisplayBending")
'End Sub
'
'Private Sub DisplayBendingSide(ByVal al_SideIdx As Long)
'On Error GoTo ErrHandler
'
'Dim ll_IMG_Id As Long
'Dim ls_value As String
'
'  If Not cbo_Bending(al_SideIdx).SearchItem(mo_PrdConfig.BND_Id(al_SideIdx)) Then
'    Call cbo_Bending(al_SideIdx).Clear
'    If mo_PrdConfig.BND_Id(al_SideIdx) <> "" Then
'      Call cbo_Bending(al_SideIdx).AddItem(Array(mo_PrdConfig.BND_Id(al_SideIdx), mo_PrdConfig.BND_Name(al_SideIdx)), True)
'    End If
'  End If
'
'  ls_value = IIf(mo_PrdConfig.RPL_H(al_SideIdx) >= 0 And (Not mo_PrdConfig.BND_IsCus(al_SideIdx)), mo_Tools.DblToScreen(mo_PrdConfig.RPL_H(al_SideIdx)), "")
'  Call mo_Tools.SetTextBox(txt_Textbox, "RPL_H" & mv_Edge(al_SideIdx), ls_value)
'  ls_value = IIf(mo_PrdConfig.RPL_S(al_SideIdx) >= 0 And (Not mo_PrdConfig.BND_IsCus(al_SideIdx)), mo_Tools.DblToScreen(mo_PrdConfig.RPL_S(al_SideIdx)), "")
'  Call mo_Tools.SetTextBox(txt_Textbox, "RPL_S" & mv_Edge(al_SideIdx), ls_value)
'
'  ls_value = IIf(mo_PrdConfig.RPL_U(al_SideIdx) >= 0 And (Not mo_PrdConfig.BND_IsCus(al_SideIdx)), mo_Tools.DblToScreen(mo_PrdConfig.RPL_U(al_SideIdx)), "")
'  If (al_SideIdx = eDPCSide.esSideC) Or (al_SideIdx = eDPCSide.esSideD) Then
'    Call mo_Tools.SetTextBox(txt_Textbox, "RPL_U" & mv_Edge(al_SideIdx), ls_value, False)
'  Else
'    Call mo_Tools.SetTextBox(txt_Textbox, "RPL_U" & mv_Edge(al_SideIdx), ls_value)
'  End If
'
'  If (al_SideIdx = eDPCSide.esSideC) Or (al_SideIdx = eDPCSide.esSideD) Then
'    ls_value = IIf(mo_PrdConfig.RPL_UMin(al_SideIdx) >= 0 And (Not mo_PrdConfig.BND_IsCus(al_SideIdx)), mo_Tools.DblToScreen(mo_PrdConfig.RPL_UMin(al_SideIdx)), "")
'    Call mo_Tools.SetTextBox(txt_Textbox, "RPL_UMin" & mv_Edge(al_SideIdx), ls_value)
'    ls_value = IIf(mo_PrdConfig.RPL_UMax(al_SideIdx) >= 0 And (Not mo_PrdConfig.BND_IsCus(al_SideIdx)), mo_Tools.DblToScreen(mo_PrdConfig.RPL_UMax(al_SideIdx)), "")
'    Call mo_Tools.SetTextBox(txt_Textbox, "RPL_UMax" & mv_Edge(al_SideIdx), ls_value)
'  End If
'
'  chk_RPL_BVis(al_SideIdx).value = IIf(mo_PrdConfig.RPL_BVis(al_SideIdx), vbChecked, vbUnchecked)
'  chk_RPL_NClo(al_SideIdx).value = IIf(mo_PrdConfig.RPL_NClo(al_SideIdx), vbChecked, vbUnchecked)
'
'  Exit Sub
'ErrHandler:
'  Call ErrorHandler("DisplayBendingSide")
'End Sub

Private Sub DisplayPrice(Optional ByVal ae_Screen As eDPCScreen = eDPCScreen.psPanelSummary, Optional ao_Cutout As DPC_Cutout = Nothing, Optional ao_SubArt As DPC_SubArt = Nothing, Optional ao_Inlay As DPC_Inlay = Nothing)
On Error GoTo ErrHandler

  Call DisplayPriceVisibility
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPrice")
End Sub

Private Sub DisplayPriceValidity(ByVal ao_OfferPos As DPC_OfferPos)
On Error GoTo ErrHandler

Dim lo_CheckBox As CheckBox

  Set lo_CheckBox = mo_Tools.GetControl(chk_Price, "chk_" & ao_OfferPos.DOF_Tag)
  If Not lo_CheckBox Is Nothing Then
    lo_CheckBox.Value = IIf(ao_OfferPos.OFD_Valid, vbChecked, vbUnchecked)
    'Call mo_Tools.SetLabelVisible(lbl_Price, "_lbl_CURR_" & ao_OfferPos.DOF_Tag, ao_OfferPos.OFD_Valid)
    'Call mo_Tools.SetTextVisible(txt_Price, "txt_" & ao_OfferPos.DOF_Tag & "_A", ao_OfferPos.OFD_Valid)
    'Call mo_Tools.SetTextVisible(txt_Price, "txt_" & ao_OfferPos.DOF_Tag & "_M", ao_OfferPos.OFD_Valid)
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPriceValidity")
End Sub

Private Sub DisplayPriceVisibility()
On Error GoTo ErrHandler

  Dim lo_Offer As DPC_OfferPos
  
  fra_PanelSetupPRF.Visible = mo_PrdConfig.HasPerforation
  fra_PanelSetupUNP.Visible = Not mo_PrdConfig.HasPerforation
  
  For Each lo_Offer In mo_PrdConfig.OfferPrice
    Call DisplayPriceValidity(lo_Offer)
  Next
'  If Not (mo_CurrentInlay Is Nothing) Then
'    For Each lo_Offer In mo_CurrentInlay.OfferPrice
'      Call DisplayPriceValidity(lo_Offer)
'    Next
'  End If
'  If Not (mo_CurrentCutout Is Nothing) Then
'    For Each lo_Offer In mo_CurrentCutout.OfferPrice
'      Call DisplayPriceValidity(lo_Offer)
'    Next
'  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPriceVisibility")
End Sub

Private Sub DisplayPerforation()
On Error GoTo ErrHandler

  If mo_PrdConfig.PRF_Id = "" Then
    Set cbo_Perforation.SelectedItem = Nothing
  Else
    If Not cbo_Perforation.SearchItem(mo_PrdConfig.PRF_Id) Then
      Call cbo_Perforation.AddItem(Array(mo_PrdConfig.PRF_Id, mo_PrdConfig.PRF_Name), True)
    End If
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPerforation")
End Sub

Private Sub DisplayPerforationBorder()
On Error GoTo ErrHandler

Dim ll_SideIdx As Long
Dim ll_Idx As Long

  If mo_PrdConfig.RPL_PBord > 0 Then
    opt_UnperfBorder(mo_PrdConfig.RPL_PBord - 1).Value = True
  Else
    Call mo_Tools.ResetOptionButton(opt_UnperfBorder)
    For ll_Idx = 0 To opt_UnperfBorder.Count - 1
      opt_UnperfBorder(ll_Idx).Enabled = mo_PrdConfig.HasPerforation
    Next
  End If
  
  chk_CorrectStep.Value = IIf(mo_PrdConfig.PRF_IsCorrStep, vbChecked, vbUnchecked)
  chk_CorrectStep.Visible = mo_PrdConfig.HasPerforation
  chk_StandardPerf.Value = IIf(mo_PrdConfig.PRF_IsStandard, vbChecked, vbUnchecked)
  chk_StandardPerf.Enabled = (mo_PrdConfig.RPL_PBord = eDPCPerforationBorderType.pbOther)
  chk_StandardPerf.Visible = mo_PrdConfig.HasPerforation
  
  For ll_SideIdx = eDPCSide.esSideC To eDPCSide.esSideF
    Call mo_Tools.SetTextBox(txt_Textbox, "RPL_UBor" & mv_Edge(ll_SideIdx), mo_Tools.DblToScreen(mo_PrdConfig.RPL_UBor(ll_SideIdx)), False, mo_PrdConfig.HasPerforation)
    Call mo_Tools.SetTextBox(txt_Textbox, "RPL_UBoW" & mv_Edge(ll_SideIdx), mo_Tools.DblToScreen(mo_PrdConfig.RPL_UBoW(ll_SideIdx)), Not mo_PrdConfig.PRF_IsStandard, mo_PrdConfig.HasPerforation)
    chk_PerfBorder(ll_SideIdx).Value = IIf(mo_PrdConfig.RPL_UBoW(ll_SideIdx) >= 0, vbUnchecked, vbChecked)
    chk_PerfBorder(ll_SideIdx).Enabled = (mo_PrdConfig.RPL_PBord = eDPCPerforationBorderType.pbOther)
    chk_PerfBorder(ll_SideIdx).Visible = mo_PrdConfig.HasPerforation
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPerforationBorder")
End Sub

Public Sub DisplayGasket()
On Error GoTo ErrHandler
Dim ll_SideIdx As Long

  For ll_SideIdx = eDPCSide.esSideC To eDPCSide.esSideF
    Call DisplayGasketSide(ll_SideIdx)
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayGasket")
End Sub

Private Sub DisplayGasketSide(ByVal Index As Long)
On Error GoTo ErrHandler

  'chk_Gasket(Index).Visible = (mo_PrdConfig.RPL_Gap(Index) > 0) Or mo_PrdConfig.GTT_Selected(Index)
  If mo_PrdConfig.GTT_Selected(Index) Then
    If mo_PrdConfig.IsGasketOn(Index) Then
      If Not cbo_GSK(Index).SearchItem(mo_PrdConfig.GSK_Id(Index)) Then
        Call cbo_GSK(Index).AddItem(Array(mo_PrdConfig.GSK_Id(Index), mo_PrdConfig.GSK_Name(Index)), True)
      End If
    Else
      Call cbo_GSK(Index).Clear
    End If
    chk_Gasket(Index).Value = vbChecked
    cbo_GSK(Index).Visible = True
  Else
    chk_Gasket(Index).Value = vbUnchecked
    cbo_GSK(Index).Visible = False
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayGasketSide")
End Sub

Public Sub DisplaySpacer()
On Error GoTo ErrHandler
Dim ll_SideIdx As Long

  For ll_SideIdx = eDPCSide.esSideC To eDPCSide.esSideF
    Call DisplaySpacerSide(ll_SideIdx)
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplaySpacer")
End Sub

Private Sub DisplaySpacerSide(ByVal Index As Long)
On Error GoTo ErrHandler

  
  'chk_Gasket2(Index).Visible = (mo_PrdConfig.RPL_Gap(Index) > 0) Or mo_PrdConfig.GTT_Selected2(Index)
  If mo_PrdConfig.GTT_Selected2(Index) Then
  
    If mo_PrdConfig.IsSpacerOn(Index) Then
      If Not cbo_GSK2(Index).SearchItem(mo_PrdConfig.GSK_Id2(Index)) Then
        Call cbo_GSK2(Index).AddItem(Array(mo_PrdConfig.GSK_Id2(Index), mo_PrdConfig.GSK_Name2(Index)), True)
      End If
    Else
      Set cbo_GSK2(Index).SelectedItem = Nothing
    End If
    chk_Gasket2(Index).Value = vbChecked
    cbo_GSK2(Index).Visible = True
  Else
    chk_Gasket2(Index).Value = vbUnchecked
    cbo_GSK2(Index).Visible = False
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplaySpacerSide")
End Sub

Private Sub DisplayCoating()
On Error GoTo ErrHandler


  If Not cbo_Coating.SearchItem(mo_PrdConfig.COA_Id) Then
    Call cbo_Coating.AddItem(Array(mo_PrdConfig.COA_Id, mo_PrdConfig.COA_Name), True)
  End If
  cbo_Coating.Visible = Not mo_PrdConfig.COA_IsCus
  
  Call mo_Tools.SetTextBox(txt_Textbox, "COA_Code", mo_PrdConfig.COA_Code, False)
  Call mo_Tools.SetTextBox(txt_Textbox, "COA_Name", mo_PrdConfig.COA_Name, True, mo_PrdConfig.COA_IsCus)
  Call mo_Tools.SetTextBox(txt_Textbox, "COA_Desc", mo_PrdConfig.COA_Desc, mo_PrdConfig.COA_IsCus)
  
  If mo_PrdConfig.RPL_CoSid = eDPCCoatingExecution.ceUndef Then
    Call mo_Tools.ResetOptionButton(opt_CoatingSide)
  Else
    If (mo_PrdConfig.RPL_CoSid >= eDPCCoatingExecution.ceOneSide) And (mo_PrdConfig.RPL_CoSid <= eDPCCoatingExecution.ceBackSideFull) Then
      opt_CoatingSide(mo_PrdConfig.RPL_CoSid - 1).Value = True
    End If
  End If
  Call mo_Tools.EnableFrame(UserControl.Controls, fra_CoatingSide, mo_PrdConfig.HasCoating)
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayCoating")
End Sub

Private Sub DisplayInlay()
On Error GoTo ErrHandler

Dim lo_Inlay As DPC_Inlay
Dim ll_Idx As Long

  For ll_Idx = 0 To cbo_InlayName.Count - 1
    Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(ll_Idx)
    Call DisplayInlayFrame(ll_Idx, lo_Inlay)
  Next
  
  For ll_Idx = 0 To cbo_InlayName.Count - 1
    cbo_InlayName(ll_Idx).Enabled = ll_Idx <= mo_PrdConfig.GetInlayCount
    Call mo_Tools.SetTextEnabled(txt_Textbox, "INL_Code" & (ll_Idx + 1), ll_Idx <= mo_PrdConfig.GetInlayCount)
    cbo_InlayPurchase(ll_Idx).Enabled = ll_Idx < mo_PrdConfig.GetInlayCount
    cbo_InlayDelivery(ll_Idx).Enabled = ll_Idx < mo_PrdConfig.GetInlayCount
    chk_InlaySetupCharge(ll_Idx).Enabled = ll_Idx < mo_PrdConfig.GetInlayCount
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayInlay")
End Sub

Private Sub DisplayInlayFrame(ByVal al_Idx As Long, ByVal ao_Inlay As DPC_Inlay)
On Error GoTo ErrHandler

Dim lo_Offer As DPC_OfferPos
 
  If ao_Inlay Is Nothing Then
    Call mo_Tools.SetTextBox(txt_Textbox, "INL_Code" & (al_Idx + 1), "", False)
    Set cbo_InlayName(al_Idx).SelectedItem = Nothing
    Set cbo_InlayPurchase(al_Idx).SelectedItem = Nothing
    Set cbo_InlayDelivery(al_Idx).SelectedItem = Nothing
    chk_InlaySetupCharge(al_Idx).Value = vbUnchecked
    cbo_InlayName(al_Idx).Visible = True
    Call mo_Tools.SetTextBox(txt_Textbox, "INL_Name" & (al_Idx + 1), "", True, False)
  Else
  
    Call mo_Tools.SetTextBox(txt_Textbox, "INL_Code" & (al_Idx + 1), ao_Inlay.INL_Code, False)
    If Not cbo_InlayName(al_Idx).SearchItem(ao_Inlay.INL_Id) Then
      Call cbo_InlayName(al_Idx).AddItem(Array(ao_Inlay.INL_Id, ao_Inlay.INL_Name), True)
    End If
    cbo_InlayName(al_Idx).Visible = Not ao_Inlay.INL_IsCus
    Call mo_Tools.SetTextBox(txt_Textbox, "INL_Name" & (al_Idx + 1), ao_Inlay.INL_Name, True, ao_Inlay.INL_IsCus)

    If ao_Inlay.PIN_Purch = 0 Then
      Set cbo_InlayPurchase(al_Idx).SelectedItem = Nothing
    Else
      If Not cbo_InlayPurchase(al_Idx).SearchItem(ao_Inlay.PIN_Purch) Then
        Call cbo_InlayPurchase(al_Idx).AddItem(Array(ao_Inlay.PIN_Purch, ao_Inlay.PIN_PurchDesc), True)
      End If
    End If
    If ao_Inlay.PIN_Deliv = 0 Then
      Set cbo_InlayDelivery(al_Idx).SelectedItem = Nothing
    Else
      If Not cbo_InlayDelivery(al_Idx).SearchItem(ao_Inlay.PIN_Deliv) Then
        Call cbo_InlayDelivery(al_Idx).AddItem(Array(ao_Inlay.PIN_Deliv, ao_Inlay.PIN_DelivDesc), True)
      End If
    End If
    Set lo_Offer = ao_Inlay.GetOfferPos(eDPCOfferDetail.odInlaySetupCharge)
    If Not lo_Offer Is Nothing Then
      chk_InlaySetupCharge(al_Idx).Value = IIf(lo_Offer.OFD_Valid, vbChecked, vbUnchecked)
    End If
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayInlayFrame")
End Sub

Private Sub DisplayPacking()
On Error GoTo ErrHandler

  Call InitPackingCombo
  If mo_PrdConfig.HasPacking Then
    If Not cbo_Packing.SearchItem(mo_PrdConfig.PKG_Id) Then
      Call cbo_Packing.AddItem(Array(mo_PrdConfig.PKG_Id, mo_PrdConfig.PKG_Name), True)
    End If
  Else
    Set cbo_Packing.SelectedItem = Nothing
  End If
'  chk_SpcPkg.value = IIf(mo_PrdConfig.RPL_SpcPkg = eDPCSpecialPackage.spThermoPalette, vbChecked, vbUnchecked)
'  Call mo_Tools.SetTextValue(txt_Textbox, "RPL_PU_", mo_Tools.DblToScreen(mo_PrdConfig.RPL_PU))
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayPacking")
End Sub

Private Sub FileObjToGrid(ByVal ao_File As DPC_File, ByVal al_Idx As Long)
On Error GoTo ErrHandler

  grd_File.Data(al_Idx, "Idx") = ao_File.Idx
  grd_File.Data(al_Idx, "PFI_Id") = ao_File.PFI_Id
  grd_File.Data(al_Idx, "FIL_Id") = ao_File.FIL_Id
  grd_File.Data(al_Idx, "FIL_Name") = ao_File.FIL_Name
  grd_File.Data(al_Idx, "FIL_FileName") = ao_File.FIL_FileName
  grd_File.Data(al_Idx, "PFI_Order") = ao_File.PFI_Order
  grd_File.Data(al_Idx, "FIL_Ext") = ao_File.FIL_Ext
  Exit Sub
ErrHandler:
  Call ErrorHandler("FileObjToGrid")
End Sub

Private Sub DisplayFile()
On Error GoTo ErrHandler

Dim lo_File As DPC_File

  Call grd_File.ClearGrid
  For Each lo_File In mo_PrdConfig.Files
    If lo_File.RowStatus <> eDPCRowStatus.rsDrop Then
      Call grd_File.AddLine
      Call FileObjToGrid(lo_File, grd_File.Rows - 1)
    End If
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayFile")
End Sub

Private Sub DisplayData()
On Error GoTo ErrHandler

Dim ll_SideIdx As Long

  Call DisplayPanelData
'  Call DisplayPerimeter
  Call DisplayPanelQtySize
  Call DisplayPanelMaterial
  Call DisplayGasket
  Call DisplaySpacer
'  For ll_SideIdx = eDPCSide.esSideC To eDPCSide.esSideF
'    Call DisplayBendingSide(ll_SideIdx)
'  Next
  Call DisplayCoating
  Call DisplayInlay
  Call DisplayPerforation
  Call DisplayPerforationBorder
'
'  Call DisplayVentilation
'  Call DisplayLoudspeaker
'  Call DisplayCutout
  Call DisplayPacking
'  Call DisplayLabeling
  Call DisplayFile
  Call DisplayPriceVisibility
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayData")
End Sub

Private Sub cal_OFD_WshDat_changeposition(y As Integer)
On Error GoTo ErrHandler
  
  Call cal_OFD_WshDat.Zorder
  cal_OFD_WshDat.Top = cal_OFD_WshDat.Top + y
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_OFD_WshDat_changeposition")
End Sub

Private Sub cal_OFD_ShpDat_changeposition(y As Integer)
On Error GoTo ErrHandler
  
  Call cal_OFD_ShpDat.Zorder
  cal_OFD_ShpDat.Top = cal_OFD_ShpDat.Top + y
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_OFD_ShpDat_changeposition")
End Sub

Private Sub cal_OFD_DelDat_changeposition(y As Integer)
On Error GoTo ErrHandler
  
  Call cal_OFD_DelDat.Zorder
  cal_OFD_DelDat.Top = cal_OFD_DelDat.Top + y
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_OFD_DelDat_changeposition")
End Sub

Private Sub cal_OFD_WshDat_datechangee()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mo_PrdConfig.OFD_WshDat = cal_OFD_WshDat.date_dt
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_OFD_WshDat_datechangee")
End Sub

Private Sub cal_OFD_ShpDat_datechangee()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mo_PrdConfig.OFD_ShpDat = cal_OFD_ShpDat.date_dt
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_OFD_ShpDat_datechangee")
End Sub

Private Sub cal_OFD_DelDat_datechangee()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mo_PrdConfig.OFD_DelDat = cal_OFD_DelDat.date_dt
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_OFD_DelDat_datechangee")
End Sub

Private Sub cbo_Coating_ComboItemSelected()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call mo_PrdConfig.LoadCoating(mo_Tools.GetComboKey(cbo_Coating))
  If mo_PrdConfig.HasCoating Then
    If mo_PrdConfig.RPL_CoSid = eDPCCoatingExecution.ceUndef Then
      mo_PrdConfig.RPL_CoSid = eDPCCoatingExecution.ceOneSide
    End If
  Else
    mo_PrdConfig.RPL_CoSid = eDPCCoatingExecution.ceUndef
  End If
  Call DisplayCoating
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_Coating_ComboItemSelected")
End Sub

Private Sub cbo_InlayName_ComboItemSelected(Index As Integer)
On Error GoTo ErrHandler

Dim lo_Inlay As DPC_Inlay

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  If cbo_InlayName(Index).Text = "" Then
    Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(Index)
    If Not lo_Inlay Is Nothing Then
      Call mo_PrdConfig.InlayDrop(lo_Inlay)
    End If
  Else
    Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(Index)
    If lo_Inlay Is Nothing Then
      Set lo_Inlay = New DPC_Inlay
      Call mo_PrdConfig.InitInlay(lo_Inlay, eDPCRowStatus.rsAdd)
      Call mo_PrdConfig.InlayAdd(lo_Inlay)
    Else
      'Call mo_PrdConfig.SetErrorText(eDPCError.erInlayName, cbo_InlayName(Index).Text, lo_Inlay)
      'Call mo_PrdConfig.SetErrorText(eDPCError.erInlayName, cbo_InlayName(Index).Text, lo_Inlay)
      Call mo_PrdConfig.InlayUpdate(lo_Inlay)
    End If
    Call lo_Inlay.LoadInlay(mo_Tools.GetComboKey(cbo_InlayName(Index)))
    Call lo_Inlay.CalcInlaySize(mo_PrdConfig)
  End If
  Set lo_Inlay = Nothing
  Call DisplayInlay
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_InlayName_ComboItemSelected")
End Sub

Private Sub cbo_InlayDelivery_ComboItemSelected(Index As Integer)
On Error GoTo ErrHandler

Dim lo_Inlay As DPC_Inlay
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(Index)
  If Not lo_Inlay Is Nothing Then
    lo_Inlay.PIN_Deliv = mo_Tools.GetComboKey(cbo_InlayDelivery(Index))
    lo_Inlay.PIN_DelivDesc = cbo_InlayDelivery(Index).Text
    Call mo_PrdConfig.InlayUpdate(lo_Inlay)
  End If
  Call DisplayInlay
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_InlayDelivery_ComboItemSelected")
End Sub

Private Sub cbo_InlayPurchase_ComboItemSelected(Index As Integer)
On Error GoTo ErrHandler

Dim lo_Inlay As DPC_Inlay
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(Index)
  If Not lo_Inlay Is Nothing Then
    lo_Inlay.PIN_Purch = mo_Tools.GetComboKey(cbo_InlayPurchase(Index))
    lo_Inlay.PIN_PurchDesc = cbo_InlayPurchase(Index).Text
    Call mo_PrdConfig.InlayUpdate(lo_Inlay)
  End If
  Call DisplayInlay
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_InlayPurchase_ComboItemSelected")
End Sub

Private Sub cbo_Vendor_ComboItemSelected()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  mo_PrdConfig.VEN_Id = mo_Tools.GetComboKey(cbo_Vendor)
  mo_PrdConfig.VEN_Name = cbo_Vendor.Text
  Call cbo_ShipPoint.Clear
  mo_PrdConfig.SHP_Id = 0
  mo_PrdConfig.SHP_Name = ""
  Call InitShipPointCombo(cbo_ShipPoint)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_Vendor_ComboItemSelected")
End Sub

Private Sub cbo_ShipPoint_ComboItemSelected()
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  mo_PrdConfig.SHP_Id = mo_Tools.GetComboKey(cbo_ShipPoint)
  mo_PrdConfig.SHP_Name = cbo_ShipPoint.Text
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_ShipPoint_ComboItemSelected")
End Sub

Private Sub cbo_Material_ComboItemSelected()
On Error GoTo ErrHandler

Dim ls_Request As String
  
  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call mo_PrdConfig.LoadMaterial(mo_Tools.GetComboKey(cbo_Material))
  mo_PrdConfig.RPL_Thick = 0
  Call DisplayPanelMaterial
  Call InitThicknessCombo
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_Material_ComboItemSelected")
End Sub

Private Function GetSideIndex(ByVal as_Side As String) As eDPCSide
On Error GoTo ErrHandler

  Dim le_SideIdx As eDPCSide
  
  GetSideIndex = -1
  For le_SideIdx = eDPCSide.esSideC To eDPCSide.esSideF
    If StrComp(as_Side, mv_Edge(le_SideIdx), vbTextCompare) = 0 Then
      GetSideIndex = le_SideIdx
      Exit For
    End If
  Next
  Exit Function
ErrHandler:
  Call ErrorHandler("GetSideIndex")
End Function

Private Sub cbo_GSK_ComboItemSelected(Index As Integer)
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call mo_PrdConfig.LoadGasket(eDPCGasketType.gtGasket, Index, mo_Tools.GetComboKey(cbo_GSK(Index)))
  
  Call UpdateGap(eDPCGasketType.gtGasket, Index)
  Call DisplayGasket
  Call DisplayPanelQtySize
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_GSK_ComboItemSelected")
End Sub

Private Sub cbo_GSK2_ComboItemSelected(Index As Integer)
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call mo_PrdConfig.LoadGasket(eDPCGasketType.gtSpacer, Index, mo_Tools.GetComboKey(cbo_GSK2(Index)))
  Call UpdateGap(eDPCGasketType.gtSpacer, Index)
  Call DisplaySpacer
  Call DisplayPanelQtySize
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_GSK2_ComboItemSelected")
End Sub

Private Sub UpdateGap(ByVal ae_GskType As eDPCGasketType, ByVal ae_Side As eDPCSide)
On Error GoTo ErrHandler

Dim ld_RPL_PanA As Double, ld_RPL_PanB As Double

  ld_RPL_PanA = mo_PrdConfig.RPL_PanA
  ld_RPL_PanB = mo_PrdConfig.RPL_PanB
  If ae_GskType = eDPCGasketType.gtGasket Then
    mo_PrdConfig.RPL_Gap(ae_Side) = mo_PrdConfig.GSK_Gap(ae_Side)
    mo_PrdConfig.RPL_ModA = ld_RPL_PanA + mo_PrdConfig.RPL_Gap(eDPCSide.esSideE) + mo_PrdConfig.RPL_Gap(eDPCSide.esSideF)
    mo_PrdConfig.RPL_ModB = ld_RPL_PanB + mo_PrdConfig.RPL_Gap(eDPCSide.esSideC) + mo_PrdConfig.RPL_Gap(eDPCSide.esSideD)
  Else
    mo_PrdConfig.RPL_Gap(ae_Side) = mo_PrdConfig.GSK_Gap2(ae_Side)
    mo_PrdConfig.RPL_ModA = ld_RPL_PanA + mo_PrdConfig.RPL_Gap(eDPCSide.esSideE) + mo_PrdConfig.RPL_Gap(eDPCSide.esSideF)
    mo_PrdConfig.RPL_ModB = ld_RPL_PanB + mo_PrdConfig.RPL_Gap(eDPCSide.esSideC) + mo_PrdConfig.RPL_Gap(eDPCSide.esSideD)
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("UpdateGap")
End Sub

Private Function SelectRawMaterial(ByVal ae_Categ As eDPCBOMMaterial, ByVal ab_EnableFilter As Boolean) As DPC_BOM
On Error GoTo ErrHandler

Dim lo_frmDPC_BOM As frmDPC_BOM
Dim lo_BOM As DPC_BOM

  Set SelectRawMaterial = Nothing
  Set lo_frmDPC_BOM = New frmDPC_BOM
  Load lo_frmDPC_BOM
  Set lo_frmDPC_BOM.Tools = mo_Tools
  Set lo_frmDPC_BOM.ArmDb = mo_Db
  Set lo_frmDPC_BOM.ArmDbBaeurer = mo_DbBaeurer
  lo_frmDPC_BOM.Language_Code = ms_Language_Code
  lo_frmDPC_BOM.Categ = ae_Categ
  lo_frmDPC_BOM.FilterEnabled = ab_EnableFilter
  Call lo_frmDPC_BOM.Load_A_COM
  
  Call mo_Tools.LockScreen(Me, False)
  Call mo_Tools.ShowModalForm(lo_frmDPC_BOM)
  Call mo_Tools.LockScreen(Me, True)
  If lo_frmDPC_BOM.Result Then
    Set lo_BOM = New DPC_BOM
    Call mo_PrdConfig.InitBOM(lo_BOM, eDPCRowStatus.rsNone)
    Call lo_BOM.LoadBOMFromBaeurer(mo_Db, mo_DbBaeurer, ms_Language_Code, lo_frmDPC_BOM.IdentNr)
    Set SelectRawMaterial = lo_BOM
  End If
  Call lo_frmDPC_BOM.Unload_A_COM
  Unload lo_frmDPC_BOM
  Set lo_frmDPC_BOM = Nothing
  Exit Function
ErrHandler:
  Call ErrorHandler("SelectRawMaterial")
End Function

Private Sub cbo_Packing_ComboItemSelected()
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call mo_PrdConfig.LoadPacking(mo_Tools.GetComboKey(cbo_Packing))
  'Call LoadPackingPrice
  Call DisplayPacking
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_Packing_ComboItemSelected")
End Sub

Private Sub cmd_Coating_Click()
On Error GoTo ErrHandler

  Dim lo_BOM As DPC_BOM

  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  If mo_Tools.ReconnectSafe(mo_DbBaeurer, ms_BaeurerServer, ms_BaeurerDatabase, ms_BaeurerLoginName, ms_BaeurerPassword, ms_BaeurerSource) Then
    Set lo_BOM = SelectRawMaterial(eDPCBOMMaterial.bcCoating, False)
    If Not lo_BOM Is Nothing Then
      Call mo_PrdConfig.LoadCoatingBOM(lo_BOM)
      If mo_PrdConfig.RPL_CoSid = eDPCCoatingExecution.ceUndef Then
        mo_PrdConfig.RPL_CoSid = eDPCCoatingExecution.ceOneSide
      End If
      Call DisplayCoating
    End If
  End If
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cmd_Coating_Click")
End Sub

Private Sub cmd_Inlay_Click(Index As Integer)
On Error GoTo ErrHandler

  Dim ls_IdentNr As String
  Dim lo_BOM As DPC_BOM
  Dim lo_Inlay As DPC_Inlay
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  If mo_Tools.ReconnectSafe(mo_DbBaeurer, ms_BaeurerServer, ms_BaeurerDatabase, ms_BaeurerLoginName, ms_BaeurerPassword, ms_BaeurerSource) Then
    Set lo_BOM = SelectRawMaterial(eDPCBOMMaterial.bcInlay, False)
    If Not lo_BOM Is Nothing Then
      Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(Index)
      If lo_Inlay Is Nothing Then
        Set lo_Inlay = New DPC_Inlay
        Call mo_PrdConfig.InitInlay(lo_Inlay, eDPCRowStatus.rsAdd)
        Call mo_PrdConfig.InlayAdd(lo_Inlay)
      Else
        Call mo_PrdConfig.InlayUpdate(lo_Inlay)
      End If
      Call mo_PrdConfig.LoadInlayBOM(lo_BOM, lo_Inlay)
      Call lo_Inlay.CalcInlaySize(mo_PrdConfig)
      Call DisplayInlay
    End If
  End If
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cmd_Inlay_Click")
End Sub

Private Sub grd_File_ItemSelected()
On Error GoTo ErrHandler

Dim lo_frmDPC_File As frmDPC_File
Dim lo_File As DPC_File
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  If grd_File.SelectedCount = 1 Then
    
    Set lo_File = mo_PrdConfig.GetFile(Val(grd_File.SelectedLine(0, "Idx")))
    If Not lo_File Is Nothing Then
    
      Set lo_frmDPC_File = New frmDPC_File
      Load lo_frmDPC_File
      lo_frmDPC_File.FIL_Id = lo_File.FIL_Id
      lo_frmDPC_File.Mode = eDPCScreenMode.smNone
      Set lo_frmDPC_File.Tools = mo_Tools
      Set lo_frmDPC_File.ArmDb = mo_Db
      lo_frmDPC_File.Language_Code = ms_Language_Code
      Call lo_frmDPC_File.Load_A_COM
    
      Call mo_Tools.LockScreen(Me, False)
      Call mo_Tools.ShowModalForm(lo_frmDPC_File)
      Call mo_Tools.LockScreen(Me, True)
    
      Call lo_frmDPC_File.Unload_A_COM
      Unload lo_frmDPC_File
    End If
  End If
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("grd_File_ItemSelected")
End Sub

Private Sub chk_ASFlag_Click()
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  If IsTemplate Then Exit Sub
  mb_InternalInit = True
  mo_PrdConfig.OFD_IsAsItem = (chk_ASFlag.Value = vbChecked)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_ASFlag_Click")
End Sub

Private Sub chk_CorrectStep_Click()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_PrdConfig.PRF_IsCorrStep = (chk_CorrectStep.Value = vbChecked)
  Call mo_PrdConfig.CalcPerfBorder
  Call DisplayPerforationBorder
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_CorrectStep_Click")
End Sub

Private Sub chk_StandardPerf_Click()
On Error GoTo ErrHandler

Dim ll_SideIdx As Long
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_PrdConfig.PRF_IsStandard = (chk_StandardPerf.Value = vbChecked)
  If mo_PrdConfig.PRF_IsStandard Then
    For ll_SideIdx = eDPCSide.esSideC To eDPCSide.esSideF
      If chk_PerfBorder(ll_SideIdx).Value = vbChecked Then
        Call mo_PrdConfig.SetDefaultOverperforatedBorder(ll_SideIdx)
      Else
        Call mo_PrdConfig.SetDefaultUnperforatedBorder(ll_SideIdx)
      End If
    Next
  End If
  Call mo_PrdConfig.CalcPerfBorder
  Call DisplayPerforationBorder
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_StandardPerf_Click")
End Sub

Private Sub chk_FreeOfCharge_Click()
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  If IsTemplate Then Exit Sub
  mb_InternalInit = True
  mo_PrdConfig.OFD_IsFree = (chk_FreeOfCharge.Value = vbChecked)
  'Call mo_PrdConfig.CalcPositionPrice
  'Call DisplayPrice(eDPCScreen.psNone)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_FreeOfCharge_Click")
End Sub

Private Sub chk_Gasket_Click(Index As Integer)
On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_Idx As Long

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_PrdConfig.GTT_Selected(Index) = (chk_Gasket(Index).Value = vbChecked)
  Call cbo_GSK(Index).Clear
  
  If mo_PrdConfig.GTT_Selected(Index) Then
    Call mo_PrdConfig.LoadGasketDelivery(eDPCGasketDelivery.gdInstalled)
    
    Call InitGasketCombo(cbo_GSK(Index), eDPCGasketType.gtGasket, mo_PrdConfig.RPL_Gap(Index))
    Call cbo_GSK(Index).Load
    
    If cbo_GSK(Index).Count = 1 Then
      Call mo_PrdConfig.LoadGasket(eDPCGasketType.gtGasket, Index, cbo_GSK(Index).ComboItems(1).Key)
    Else
      For ll_Idx = eDPCSide.esSideC To eDPCSide.esSideF
        If (ll_Idx <> Index) And (mo_PrdConfig.GTT_Selected(ll_Idx)) Then
          If cbo_GSK(Index).SearchItem(mo_PrdConfig.GSK_Id(ll_Idx)) Then
            Call mo_PrdConfig.LoadGasket(eDPCGasketType.gtGasket, Index, cbo_GSK(Index).SelectedItem.Key)
            Exit For
          End If
        End If
      Next
    End If
  Else
    Call mo_PrdConfig.ResetGasket(eDPCGasketType.gtGasket, Index)
    If Not mo_PrdConfig.HasGasket Then
      Call mo_PrdConfig.LoadGasketDelivery(eDPCGasketDelivery.gdNoneGasket)
    End If
  End If
  
  Call UpdateGap(eDPCGasketType.gtGasket, Index)
  Call DisplayGasket
  Call DisplayPanelQtySize
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_Gasket_Click")
End Sub

Private Sub chk_Gasket2_Click(Index As Integer)
On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_Idx As Long

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_PrdConfig.GTT_Selected2(Index) = (chk_Gasket2(Index).Value = vbChecked)
  Call cbo_GSK2(Index).Clear
  
  If mo_PrdConfig.GTT_Selected2(Index) Then
    Call mo_PrdConfig.LoadSpacerDelivery(eDPCSpacerDelivery.sdInstalled)
    
    Call InitGasketCombo(cbo_GSK2(Index), eDPCGasketType.gtSpacer, mo_Tools.SqlDbl(mo_PrdConfig.RPL_Gap(Index)))
    Call cbo_GSK2(Index).Load
    
    If cbo_GSK2(Index).Count = 1 Then
      Call mo_PrdConfig.LoadGasket(eDPCGasketType.gtSpacer, Index, cbo_GSK2(Index).ComboItems(1).Key)
    Else
      For ll_Idx = eDPCSide.esSideC To eDPCSide.esSideF
        If (ll_Idx <> Index) And (mo_PrdConfig.GTT_Selected2(ll_Idx)) Then
          If cbo_GSK2(Index).SearchItem(mo_PrdConfig.GSK_Id2(ll_Idx)) Then
            Call mo_PrdConfig.LoadGasket(eDPCGasketType.gtSpacer, Index, cbo_GSK2(Index).SelectedItem.Key)
            Exit For
          End If
        End If
      Next
    End If
  Else
    Call mo_PrdConfig.ResetGasket(eDPCGasketType.gtSpacer, Index)
    If Not mo_PrdConfig.HasSpacer Then
      Call mo_PrdConfig.LoadSpacerDelivery(eDPCSpacerDelivery.sdNoneSpacer)
    End If
  End If
  
  Call UpdateGap(eDPCGasketType.gtSpacer, Index)
  Call DisplaySpacer
  Call DisplayPanelQtySize
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_Gasket2_Click")
End Sub

Private Sub cbo_Perforation_ComboItemSelected()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_PrdConfig.NoPerforation = True
  Call mo_PrdConfig.LoadPerforation(mo_Tools.GetComboKey(cbo_Perforation))
  Call DisplayPerforation
  Call DisplayPerforationBorder
  Call DisplayPriceVisibility
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_Perforation_ComboItemSelected")
End Sub

Private Sub cbo_Thickness_ComboItemSelected()
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_PrdConfig.RPL_Thick = mo_Tools.GetComboKey(cbo_Thickness)
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_Thickness_ComboItemSelected")
End Sub

Private Sub chk_InlaySetupCharge_Click(Index As Integer)
On Error GoTo ErrHandler

Dim lo_Offer As DPC_OfferPos
Dim lo_Inlay As DPC_Inlay

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(Index)
  If Not lo_Inlay Is Nothing Then
    Set lo_Offer = lo_Inlay.GetOfferPos(eDPCOfferDetail.odInlaySetupCharge)
    If lo_Offer Is Nothing Then
      Err.Raise ArmErr.InvalidArgument, "chk_InlaySetupCharge(Index).Tag", "Unknown price checkbox: " & chk_InlaySetupCharge(Index).Tag
    Else
      lo_Offer.OFD_Valid = (chk_InlaySetupCharge(Index).Value = vbChecked)
      lo_Offer.ValidManual = IIf(lo_Offer.OFD_Valid, eDPCOfferPosValidManual.vmSetValid, eDPCOfferPosValidManual.vmSetInvalid)
      'Call mo_PrdConfig.CalcPositionPrice
    End If
  End If
  Call DisplayInlay
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_InlaySetupCharge_Click")
End Sub

Private Sub chk_Price_Click(Index As Integer)
On Error GoTo ErrHandler

Dim lo_Offer As DPC_OfferPos
Dim lo_Offer2 As DPC_OfferPos
Dim ls_Tag As String

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  ls_Tag = right(chk_Price(Index).Tag, Len(chk_Price(Index).Tag) - 4)
  Set lo_Offer = mo_PrdConfig.GetOfferPosByTag(ls_Tag)
  Set lo_Offer2 = Nothing
  
  If lo_Offer Is Nothing Then
    Err.Raise ArmErr.InvalidArgument, "chk_Price(Index).Tag", "Unknown price checkbox: " & chk_Price(Index).Tag
  Else
    If lo_Offer.DOF_Id = eDPCOfferDetail.odPanelSetupChargeUnp Then
      Set lo_Offer2 = mo_PrdConfig.GetOfferPos(eDPCOfferDetail.odPanelSetupChargePrf)
    ElseIf lo_Offer.DOF_Id = eDPCOfferDetail.odPanelSetupChargePrf Then
      Set lo_Offer2 = mo_PrdConfig.GetOfferPos(eDPCOfferDetail.odPanelSetupChargeUnp)
    ElseIf lo_Offer.DOF_Id = eDPCOfferDetail.odPanelChangeLengthCostUnp Then
      Set lo_Offer2 = mo_PrdConfig.GetOfferPos(eDPCOfferDetail.odPanelChangeLengthCostPrf)
    ElseIf lo_Offer.DOF_Id = eDPCOfferDetail.odPanelChangeLengthCostPrf Then
      Set lo_Offer2 = mo_PrdConfig.GetOfferPos(eDPCOfferDetail.odPanelChangeLengthCostUnp)
    ElseIf lo_Offer.DOF_Id = eDPCOfferDetail.odPanelChangeWidthCostUnp Then
      Set lo_Offer2 = mo_PrdConfig.GetOfferPos(eDPCOfferDetail.odPanelChangeWidthCostPrf)
    ElseIf lo_Offer.DOF_Id = eDPCOfferDetail.odPanelChangeWidthCostPrf Then
      Set lo_Offer2 = mo_PrdConfig.GetOfferPos(eDPCOfferDetail.odPanelChangeWidthCostUnp)
    End If
    
    lo_Offer.OFD_Valid = (chk_Price(Index).Value = vbChecked)
    lo_Offer.ValidManual = IIf(lo_Offer.OFD_Valid, eDPCOfferPosValidManual.vmSetValid, eDPCOfferPosValidManual.vmSetInvalid)
    If Not lo_Offer2 Is Nothing Then
      lo_Offer2.ValidManual = lo_Offer.ValidManual
    End If
    
    'Call mo_PrdConfig.CalcPositionPrice
    Call DisplayPriceVisibility
    'Call DisplayPrice
  End If
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_Price_Click")
End Sub

Private Sub opt_CoatingSide_Click(Index As Integer)
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call mo_PrdConfig.LoadCoatingSide(mo_Tools.WhichOptionIsTrue(opt_CoatingSide) + 1)
  
  Call DisplayCoating
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("opt_CoatingSide_Click")
End Sub

Private Sub opt_InOut_Click(Index As Integer)
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_PrdConfig.RPL_IsOut = IIf(Index = 0, eDPCPanelInOut.ioInside, eDPCPanelInOut.ioOutside)
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("opt_InOut_Click")
End Sub

Private Sub opt_UnperfBorder_Click(Index As Integer)
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call mo_PrdConfig.LoadPerforationBorder(mo_Tools.WhichOptionIsTrue(opt_UnperfBorder) + 1)
  Call DisplayPerforationBorder
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("opt_UnperfBorder_Click")
End Sub

Private Sub chk_PerfBorder_Click(Index As Integer)
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  If chk_PerfBorder(Index).Value = vbUnchecked Then
    Call mo_PrdConfig.SetDefaultUnperforatedBorder(Index)
  Else
    Call mo_PrdConfig.SetDefaultOverperforatedBorder(Index)
  End If
  Call mo_PrdConfig.CalcPerfBorder
  Call DisplayPerforationBorder
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_PerfBorder_Click")
End Sub

Private Sub tlb_File_action(ByVal as_Role As String, as_Language As String)
On Error GoTo ErrHandler

Dim lo_frmDPC_File As frmDPC_File
Dim lo_File As DPC_File

  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Select Case as_Role
  Case "A"
    Set lo_frmDPC_File = New frmDPC_File
    Load lo_frmDPC_File
    Set lo_File = New DPC_File
    Call mo_PrdConfig.InitFile(lo_File, eDPCRowStatus.rsAdd)
    lo_frmDPC_File.Mode = eDPCScreenMode.smAdd
    
    Set lo_frmDPC_File.Tools = mo_Tools
    Set lo_frmDPC_File.ArmDb = mo_Db
    lo_frmDPC_File.Language_Code = ms_Language_Code
    Call lo_frmDPC_File.Load_A_COM
  
    Call mo_Tools.LockScreen(Me, False)
    Call mo_Tools.ShowModalForm(lo_frmDPC_File)
    Call mo_Tools.LockScreen(Me, True)
  
    If lo_frmDPC_File.Result = True Then
      lo_File.FIL_Id = lo_frmDPC_File.FIL_Id
      lo_File.FIL_FileName = lo_frmDPC_File.txt_FileName.Text
      lo_File.FIL_Ext = lo_frmDPC_File.txt_FIL_Ext.Text
      lo_File.FIL_Name = lo_frmDPC_File.txt_FIL_Name.Text
      Call mo_PrdConfig.FileAdd(lo_File)
      Call DisplayFile
    End If
    
    Call lo_frmDPC_File.Unload_A_COM
    Unload lo_frmDPC_File
    
  Case "C"
    If grd_File.SelectedCount <> 1 Then
      Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9723, "#Please, select one row")
      Call mo_Tools.LockScreen(Me, False)
      mb_InternalInit = False
      Exit Sub
    End If
    If mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9735, "#Are you sure to remove this record ?", , VbMsgBoxStyle.vbYesNo) = vbYes Then
      Set lo_File = mo_PrdConfig.GetFile(Val(grd_File.SelectedLine(0, "Idx")))
      If Not lo_File Is Nothing Then
        Call mo_PrdConfig.FileDrop(lo_File)
        Call DisplayFile
      End If
    End If
  End Select
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("tlb_File_action")
End Sub

Private Sub txt_Textbox_Change(Index As Integer)
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  mb_CurrentTextBoxChanged = True
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_TextBox_Change")
End Sub

Private Sub txt_Textbox_Validate(Index As Integer, Cancel As Boolean)
On Error GoTo ErrHandler

Dim ll_SideIdx As Long
Dim ll_ItemIdx As Long
Dim lo_Inlay As DPC_Inlay

  If mb_InternalInit Then Exit Sub
  If Not mb_CurrentTextBoxChanged Then Exit Sub
  
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  ll_SideIdx = GetSideIndex(right(txt_Textbox(Index).Tag, 1))
  Select Case txt_Textbox(Index).Tag
  Case "PRD_Name"
    mo_PrdConfig.PRD_Name = Trim(txt_Textbox(Index).Text)
  Case "PRD_Code"
    mo_PrdConfig.PRD_Code = Trim(txt_Textbox(Index).Text)
  Case "OFD_PosCus"
    mo_PrdConfig.OFD_PosCus = Trim(txt_Textbox(Index).Text)
'  Case "PanelQtyM2"
'    mo_PrdConfig.PanelQtyM2 = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text)
'    If IsStandard And (Not mo_PrdConfig.IsQtyMatchingPU) Then
'      If mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 666, "#Panel quantity does not represent correct packing unit. Do you want to update quantity automatically ?", , vbYesNo) Then
'        mo_PrdConfig.PanelQtyM2 = mo_PrdConfig.GetCorrectPUQtyForM2
'      End If
'    End If
'    Call DisplayPanelQtySize
  Case "PanelQtyPCS"
    mo_PrdConfig.PanelQtyPCS = mo_Tools.ScreenToLong(txt_Textbox(Index).Text)
'    If IsStandard And (Not mo_PrdConfig.IsQtyMatchingPU) Then
'      If mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 666, "#Panel quantity does not represent correct packing unit. Do you want to update quantity automatically ?", , vbYesNo) Then
'        mo_PrdConfig.PanelQtyPCS = mo_PrdConfig.GetCorrectPUQtyForPCS
'      End If
'    End If
    Call DisplayPanelQtySize
  Case "PRD_OfferComment"
    Call mo_PrdConfig.SetErrorText(eDPCError.erOfferComment, txt_Textbox(Index).Text, Nothing)
  Case "PRD_InternalComment"
    Call mo_PrdConfig.SetErrorText(eDPCError.erInternalComment, txt_Textbox(Index).Text, Nothing)
  Case "PanelQtyPU"
  Case "RPL_PU"
    mo_PrdConfig.RPL_PU = mo_Tools.ScreenToLong(txt_Textbox(Index).Text)
  Case "RPL_CorG1"
    'mo_PrdConfig.RPL_CorG1 = mo_Tools.ScreenToDbl(txt_TextBox(Index).Text)
  Case "RPL_CorG2"
    'mo_PrdConfig.RPL_CorG2 = mo_Tools.ScreenToDbl(txt_TextBox(Index).Text)
  Case "RPL_PanA"
    mo_PrdConfig.RPL_ModA = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text) + mo_PrdConfig.GapB
    Call DisplayPanelMaterial
    Call DisplayPanelQtySize
  Case "RPL_PanB"
    mo_PrdConfig.RPL_ModB = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text) + mo_PrdConfig.GapA
    
    Call DisplayPanelMaterial
    Call DisplayPanelQtySize
  Case "RPL_GapC", "RPL_GapD", "RPL_GapE", "RPL_GapF"
    mo_PrdConfig.RPL_Gap(ll_SideIdx) = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text)
    Call mo_Tools.SetTextBox(txt_Textbox, "RPL_Gap" & mv_Edge(ll_SideIdx) & "_", mo_Tools.DblToScreen(mo_PrdConfig.RPL_Gap(ll_SideIdx)), False)
    Call DisplayPanelMaterial
    Call DisplayPanelQtySize
  Case "PCT_SizeD_V", "PCT_SizeJ_V", "PCT_SizeK_V", "PCT_SizeL_V", "PCT_SizeM_V"
  Case "PCT_SizeD_L", "PCT_SizeJ_L", "PCT_SizeK_L", "PCT_SizeL_L", "PCT_SizeM_L"
  Case "PCT_SizeD_C", "PCT_SizeJ_C", "PCT_SizeK_C", "PCT_SizeL_C", "PCT_SizeM_C"
  Case "RPL_UBoWC", "RPL_UBoWD", "RPL_UBoWE", "RPL_UBoWF"
    mo_PrdConfig.RPL_UBoW(ll_SideIdx) = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text)
    Call mo_PrdConfig.CalcPerfBorder
    Call DisplayPerforationBorder
  Case "RPL_UBorC", "RPL_UBorD", "RPL_UBorE", "RPL_UBorF"
  Case "PCT_UBoWC_V", "PCT_UBoWD_V", "PCT_UBoWE_V", "PCT_UBoWF_V"
  Case "PCT_UBoWC_L", "PCT_UBoWD_L", "PCT_UBoWE_L", "PCT_UBoWF_L"
  Case "PCT_UBoWC_C", "PCT_UBoWD_C", "PCT_UBoWE_C", "PCT_UBoWF_C"
  Case "PCT_UBorC_V", "PCT_UBorD_V", "PCT_UBorE_V", "PCT_UBorF_V"
  Case "PCT_UBorC_L", "PCT_UBorD_L", "PCT_UBorE_L", "PCT_UBorF_L"
  Case "PCT_UBorC_C", "PCT_UBorD_C", "PCT_UBorE_C", "PCT_UBorF_C"
  Case "INL_SizeA", "INL_SizeB", "INL_Desc"
  Case "INL_Code1", "INL_Code2", "INL_Code3"
    ll_ItemIdx = Val(right(txt_Textbox(Index).Tag, 1)) - 1
    Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(ll_ItemIdx)
    If Trim(txt_Textbox(Index).Text) = "" Then
      If Not lo_Inlay Is Nothing Then
        Call mo_PrdConfig.InlayDrop(lo_Inlay)
      End If
    Else
      If lo_Inlay Is Nothing Then
        Set lo_Inlay = New DPC_Inlay
        Call mo_PrdConfig.InitInlay(lo_Inlay, eDPCRowStatus.rsAdd)
        Call mo_PrdConfig.InlayAdd(lo_Inlay)
      Else
        Call mo_PrdConfig.InlayUpdate(lo_Inlay)
      End If
      If Not lo_Inlay.LoadInlayCode(txt_Textbox(Index).Text) Then
        If mo_Tools.ReconnectSafe(mo_DbBaeurer, ms_BaeurerServer, ms_BaeurerDatabase, ms_BaeurerLoginName, ms_BaeurerPassword, ms_BaeurerSource) Then
          Call mo_PrdConfig.LoadInlayIdentNr(mo_DbBaeurer, txt_Textbox(Index).Text, lo_Inlay)
        End If
      End If
      Call lo_Inlay.CalcInlaySize(mo_PrdConfig)
    End If
    Call DisplayInlay
  Case "INL_Name1", "INL_Name2", "INL_Name3"
    ll_ItemIdx = Val(right(txt_Textbox(Index).Tag, 1)) - 1
    Set lo_Inlay = mo_PrdConfig.GetInlayByIndex(ll_ItemIdx)
    If Trim(txt_Textbox(Index).Text) = "" Then
      If Not lo_Inlay Is Nothing Then
        Call mo_PrdConfig.InlayDrop(lo_Inlay)
      End If
    Else
      If lo_Inlay Is Nothing Then
        Set lo_Inlay = New DPC_Inlay
        Call mo_PrdConfig.InitInlay(lo_Inlay, eDPCRowStatus.rsAdd)
        Call mo_PrdConfig.InlayAdd(lo_Inlay)
      Else
        Call mo_PrdConfig.InlayUpdate(lo_Inlay)
      End If
      Call mo_PrdConfig.SetErrorText(eDPCError.erInlayName, txt_Textbox(Index).Text, lo_Inlay)
      Call mo_PrdConfig.SetErrorText(eDPCError.erInlayDesc, "", lo_Inlay)
      lo_Inlay.INL_Name = txt_Textbox(Index).Text
      Call lo_Inlay.CalcInlaySize(mo_PrdConfig)
    End If
    Call DisplayInlay
  Case "COA_Code"
    If Trim(txt_Textbox(Index).Text) = "" Then
      Call mo_PrdConfig.ResetCoating
    Else
      mo_PrdConfig.COA_Code = txt_Textbox(Index).Text
    End If
    Call DisplayCoating
  Case "COA_Name"
    If Trim(txt_Textbox(Index).Text) = "" Then
      Call mo_PrdConfig.ResetCoating
    Else
      mo_PrdConfig.COA_Name = txt_Textbox(Index).Text
      Call mo_PrdConfig.SetErrorText(eDPCError.erCoatingName, mo_PrdConfig.COA_Name, Nothing)
    End If
    Call DisplayCoating
  Case "COA_Desc"
    mo_PrdConfig.COA_Desc = txt_Textbox(Index).Text
    Call mo_PrdConfig.SetErrorText(eDPCError.erCoatingDesc, mo_PrdConfig.COA_Desc, Nothing)
    Call DisplayCoating
  Case "RPL_PlCnt"
    mo_PrdConfig.RPL_PlCnt = mo_Tools.ScreenToLong(txt_Textbox(Index).Text)
    Call DisplayInlay
  Case "RPL_SwGap"
    mo_PrdConfig.RPL_SwGap = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text)
  Case "OFD_Pos"
    OFD_Pos = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text)
  Case Else
    Err.Raise ArmErr.InvalidArgument, "txt_TextBox(" & Index & ").Tag", "Unknown textbox tag:" & txt_Textbox(Index).Tag
  End Select
  mb_CurrentTextBoxChanged = False
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_Textbox_Validate " & txt_Textbox(Index).Tag & ":" & txt_Textbox(Index).Text)
End Sub

Public Sub ItemAdd(ByVal as_PRD_Id As String)
On Error GoTo ErrHandler

  mb_InternalInit = True
  me_PrdScreen = eDPCScreenMode.smAdd

  Call mo_PrdTemp.Load(as_PRD_Id)
  Call mo_PrdConfig.CopyFrom(mo_PrdTemp)
  mo_PrdConfig.PRD_IdPar = mo_PrdTemp.PRD_Id
  Set mo_PrdConfig.ProductTemplate = mo_PrdTemp
  Call mo_PrdConfig.Init
  mo_PrdConfig.PRD_Name = ""
  mo_PrdConfig.PRD_Desc = ""
  
  mo_PrdConfig.RPL_PerDe = eDPCPerimeterDelivery.pdNoPerimeter
  If mo_PrdTemp.HasPerforation Then
    mo_PrdConfig.RPL_PBord = eDPCPerforationBorderType.pbStandardUnperforated
  Else
    mo_PrdConfig.RPL_PBord = eDPCPerforationBorderType.pbUndef
  End If
  
  Call mo_PrdConfig.ResetCoating
  mo_PrdConfig.CAT_Id = eDPCCategory.cgMetalCustomRectPanel
  
  mo_PrdConfig.NoPerforation = True
  mo_PrdConfig.NoInlay = True
  mo_PrdConfig.NoCutout = True
  mo_PrdConfig.NoLoudspeaker = True
  mo_PrdConfig.NoVentilation = True
  
  'Call mo_PrdConfig.LoadVendorShipPoint(CT_Code)
  Call mo_PrdConfig.LoadSystemMargin
  Call mo_PrdConfig.LoadOfferOptions(COF_Id)
  Call mo_PrdConfig.ResetPriceFound
  Call DisplayData
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorHandler("ItemAdd")
End Sub

Public Sub ItemUpdate(ByVal as_PRD_Id As String)
On Error GoTo ErrHandler

Dim lo_Offer As DPC_OfferPos

  mb_InternalInit = True
  me_PrdScreen = eDPCScreenMode.smUpdate

  Call mo_PrdConfig.Load(as_PRD_Id)
  Call mo_PrdConfig.LoadPrdFile
  If (Not IsStandard) And (mo_PrdConfig.PRD_IdPar <> "") Then
    Call mo_PrdTemp.Load(mo_PrdConfig.PRD_IdPar)
    Set mo_PrdConfig.ProductTemplate = mo_PrdTemp
  End If

  mo_PrdConfig.NoPerforation = True
  mo_PrdConfig.NoInlay = True
  mo_PrdConfig.NoCutout = True
  mo_PrdConfig.NoLoudspeaker = True
  mo_PrdConfig.NoVentilation = True
  
  Call DisplayData
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorHandler("ItemUpdate")
End Sub

Public Sub LoadOffer(ByVal as_COF_Id As String, ByVal as_OFD_IdPar As String)
On Error GoTo ErrHandler

Dim lo_ErrCol As Collection
  
  mb_InternalInit = True
  Call mo_PrdConfig.LoadOffer(as_COF_Id, as_OFD_IdPar)
  Call DisplayData
  'Call DisplayPanelQtySize
  'Call DisplayPanelData
  Call DisplayPriceVisibility
  
  'Call DisplayPrice
  ' do not check anything when production user editing template
'  If (Not IsTemplate) And (Not IsProduction) Then
'    Call ClearScreenErrorType(GetControl(fra_Step, GetStepFrameName(eDPCCategory.cgNone)))
'    Set lo_ErrCol = mo_PrdConfig.CheckScreen(eDPCCategory.cgNone)
'    Call ApplyScreenError(lo_ErrCol)
'  End If
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorHandler("LoadOffer")
End Sub

'Public Sub ApplyOffer(ByVal ao_OfferCollection As Collection)
'On Error GoTo ErrHandler
'
'Dim lo_ErrCol As Collection
'
'  mb_InternalInit = True
'  Call mo_PrdConfig.ApplyOffer(ao_OfferCollection)
'  Call DisplayPanelQtySize
''  Call DisplayPrice
''  ' do not check anything when production user editing template
''  If (Not IsTemplate) And (Not IsProduction) Then
''    Call ClearAllScreenErrorType
''    Set lo_ErrCol = mo_PrdConfig.CheckAllScreen
''    Call ApplyScreenError(lo_ErrCol)
''  End If
'  mb_InternalInit = False
'  Exit Sub
'ErrHandler:
'  Call ErrorHandler("ApplyOffer")
'End Sub

Public Sub ItemSave()
On Error GoTo ErrHandler

  If (me_PrdScreen = eDPCScreenMode.smAdd) Then
    Call mo_PrdConfig.Insert
  ElseIf me_PrdScreen = eDPCScreenMode.smUpdate Then
    Call mo_PrdConfig.Update
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("ItemSave")
End Sub

Public Function GenerateOfferDetail() As Collection
On Error GoTo ErrHandler

Dim lo_Collection As Collection
Dim lo_Offer As DPC_OfferPos

  Set lo_Collection = mo_PrdConfig.GenerateOfferDetail
  For Each lo_Offer In lo_Collection
    lo_Offer.LEV_Id = mo_PrdConfig.LEV_Id
    If lo_Offer.DOF_Id = eDPCOfferDetail.odPosition Then
      lo_Offer.ERR_Type = eDPCErrorType.etNeedApproval
    Else
      lo_Offer.ERR_Type = eDPCErrorType.etNone
    End If
  Next
  Set GenerateOfferDetail = lo_Collection
  Exit Function
ErrHandler:
  Call ErrorHandler("GenerateOfferDetail")
End Function

Public Function GetMaxErrorType() As eDPCErrorType
On Error GoTo ErrHandler

Dim lo_Tab As MSComctlLib.Tab
Dim le_ErrType As eDPCErrorType
  
'  le_ErrType = eDPCErrorType.etNone
'  For Each lo_Tab In tbs_Step.Tabs
'    If lo_Tab.Image > le_ErrType Then
'      le_ErrType = lo_Tab.Image
'    End If
'  Next
'  GetMaxErrorType = le_ErrType
  Exit Function
ErrHandler:
  Call ErrorHandler("GetMaxErrorType")
End Function

Private Sub SetControlErrorColor(ByVal ao_Control As Object, ByVal ae_ERR_Type As eDPCErrorType)
On Error GoTo ErrHandler

Dim ll_Color As Long

  If Not ao_Control Is Nothing Then
    If ae_ERR_Type = eDPCErrorType.etStop Then
      ll_Color = RGB(255, 75, 75) 'vbRed
    ElseIf ae_ERR_Type = eDPCErrorType.etNeedApproval Then
      ll_Color = RGB(255, 225, 75) 'vbYellow
    ElseIf ae_ERR_Type = eDPCErrorType.etInfo Then
      ll_Color = RGB(0, 225, 255) 'vbBlue
    Else
      If TypeOf ao_Control Is VB.Frame Then
        ll_Color = vbWindowText
      Else
        ll_Color = vbButtonFace
      End If
    End If
    Select Case UCase(TypeName(ao_Control))
    Case UCase("Label"), UCase("CheckBox"), UCase("OptionButton")
      ao_Control.BackColor = ll_Color
    Case UCase("Frame")
      If ae_ERR_Type = eDPCErrorType.etNone Then
        ao_Control.Font.Bold = False
      Else
        ao_Control.Font.Bold = True
      End If
      ao_Control.ForeColor = ll_Color
    Case UCase("Tabstrip")
    End Select
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("SetControlErrorColor")
End Sub

Private Sub ClearAllScreenErrorType()
On Error GoTo ErrHandler

Dim lo_Control As VB.Control
  
  For Each lo_Control In UserControl.Controls
    Call SetControlErrorColor(lo_Control, eDPCErrorType.etNone)
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("ClearAllScreenErrorType")
End Sub

'Public Function FindControlByTag(ByRef ao_Controls As Object, ByRef ao_Frame As Frame, ByVal as_Tag As String) As VB.Control
'On Error GoTo errorHandler
'
'    Dim lo_Control As Object
'
'    Set FindControlByTag = Nothing
'
'    For Each lo_Control In ao_Controls
'      If (ao_Frame Is Nothing) Or mo_Tools.HasContainer(lo_Control, ao_Frame) Then
'        If StrComp(Trim(lo_Control.Tag), as_Tag, vbTextCompare) = 0 Then
'            Set FindControlByTag = lo_Control
'            Exit Function
'        End If
'      End If
'    Next
'    Exit Function
'errorHandler:
'    Call errorHandler("FindControlByTag")
'End Function

Private Sub ApplyScreenError(ByVal ao_ErrCol As Collection)
On Error GoTo ErrHandler

Dim lo_Error As DPC_Error
Dim lsa_ControlTags() As String
Dim lv_Tag As Variant
Dim lo_Control As VB.Control
Dim le_ERR_Type As eDPCErrorType

  For le_ERR_Type = eDPCErrorType.etInfo To eDPCErrorType.etStop
    For Each lo_Error In ao_ErrCol
      If le_ERR_Type = lo_Error.ERR_Type Then
        If Trim(lo_Error.ERR_Ctrl) <> "" Then
          lsa_ControlTags = Split(lo_Error.ERR_Ctrl, SEP)
          For Each lv_Tag In lsa_ControlTags
            Set lo_Control = mo_Tools.GetControl(UserControl.Controls, lv_Tag)
            If Not lo_Control Is Nothing Then
              Call SetControlErrorColor(lo_Control, le_ERR_Type)
            End If
          Next
        End If
      End If
    Next
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("ApplyScreenError")
End Sub

Private Function CheckStep() As Boolean
On Error GoTo ErrHandler

Dim lo_ErrCol As Collection
Dim le_Screen As eDPCScreen
Dim ll_Idx As Long

  ' do not check anything when production user editing template
  If IsTemplate And IsProduction Then
    CheckStep = True
    Exit Function
  End If
  
  CheckStep = False
  
  Call ClearAllScreenErrorType
  Set lo_ErrCol = mo_PrdConfig.CheckAllScreen
  
  Call ApplyScreenError(lo_ErrCol)
  If ConfirmCheckList(lo_ErrCol) Then
    CheckStep = True
  End If
  Exit Function
ErrHandler:
  Call ErrorHandler("CheckStep")
End Function

Private Function ConfirmCheckList(ByVal ao_ErrCol As Collection) As Boolean
On Error GoTo ErrHandler

Dim lo_ErrorMsg As frmDPC_ErrorMsg
  
  ConfirmCheckList = True
  If ao_ErrCol.Count > 0 Then
    Set lo_ErrorMsg = New frmDPC_ErrorMsg
    Load lo_ErrorMsg
    Set lo_ErrorMsg.Tools = mo_Tools
    Set lo_ErrorMsg.ArmDb = mo_Db
    lo_ErrorMsg.Language_Code = ms_Language_Code
    lo_ErrorMsg.U_Code = ml_U_Code
    Set lo_ErrorMsg.ErrCollection = ao_ErrCol
    Call lo_ErrorMsg.Load_A_COM
    
    Call mo_Tools.LockScreen(Me, False)
    Call mo_Tools.ShowModalForm(lo_ErrorMsg)
    Call mo_Tools.LockScreen(Me, True)
    
    If lo_ErrorMsg.Result = False Then
      ConfirmCheckList = False
    End If
    Call mo_PrdConfig.UpdateErrorText(lo_ErrorMsg.ErrCollection)
    Call lo_ErrorMsg.Unload_A_COM
    Unload lo_ErrorMsg
  End If
  Exit Function
ErrHandler:
  Call ErrorHandler("ConfirmCheckList")
End Function

Private Sub EnableNavigation(ByVal ab_Enable As Boolean)
On Error GoTo ErrHandler

  btn_Validate.Enabled = ab_Enable
  btn_Quit.Enabled = ab_Enable
'  tbs_Main.Enabled = ab_Enable
  Exit Sub
ErrHandler:
  Call ErrorHandler("EnableNavigation")
End Sub

Private Sub btn_Quit_Click()
On Error GoTo ErrHandler
  
  Call mo_Tools.LockScreen(Me, True)
  Result = False
  RaiseEvent quit
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("btn_Quit_Click")
End Sub

Private Sub btn_Validate_Click()
On Error GoTo ErrHandler
  
  Call mo_Tools.LockScreen(Me, True)
  'Call mo_PrdConfig.ResetPriceFound
  If Not CheckStep() Then
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
  End If
  Result = True
  RaiseEvent quit
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("btn_Validate_Click")
End Sub

Public Sub SetFrameFocus()
On Error GoTo ErrHandler

'  Dim lo_Frame As VB.Frame
'
'  Set lo_Frame = GetControl(fra_Step, StepName)
'
'  Select Case UCase(lo_Frame.Tag)
'  Case UCase("fra_Panel")
'    If mo_PrdConfig.QtyType = eDPCQtyType.qtPCS Then
'      Call mo_Tools.SetTextFocus(txt_Textbox, "PanelQtyPCS")
'    Else
'      Call mo_Tools.SetTextFocus(txt_Textbox, "PanelQtyM2")
'    End If
'  Case UCase("fra_Gasket")
'  Case UCase("fra_Bending")
'  Case UCase("fra_Coating")
'  Case UCase("fra_Inlay")
'  Case UCase("fra_Perforation")
'  Case UCase("fra_Ventilation")
'  Case UCase("fra_Loudspeaker")
'  Case UCase("fra_Cutout")
'  Case UCase("fra_Summary")
'  End Select
  Exit Sub
ErrHandler:
  Call ErrorHandler("SetFrameFocus")
End Sub

Private Sub Resize()
On Error GoTo ErrHandler

Dim ll_Idx As Long

  btn_Validate.Top = UserControl.Height - btn_Validate.Height
  btn_Quit.Top = UserControl.Height - btn_Quit.Height
  Exit Sub
ErrHandler:
  Call ErrorHandler("Resize")
End Sub

Private Function ReplaceCommonPlaceholders(ByVal as_Request As String) As String
On Error GoTo ErrHandler

  as_Request = Replace(as_Request, "$Z_Creator$", mo_Tools.SqlInt(ml_U_Code), , , vbTextCompare)
  as_Request = Replace(as_Request, "$U_Code$", mo_Tools.SqlInt(ml_U_Code), , , vbTextCompare)
  as_Request = Replace(as_Request, "$Z_Last_Upd_User$", mo_Tools.SqlInt(ml_U_Code), , , vbTextCompare)
  as_Request = Replace(as_Request, "$Language_Code$", mo_Tools.SQLStr(ms_Language_Code), , , vbTextCompare)
  as_Request = Replace(as_Request, "$COF_Lang$", mo_Tools.SQLStr(ms_COF_Lang), , , vbTextCompare)
  ReplaceCommonPlaceholders = as_Request
  Exit Function
ErrHandler:
  Call ErrorHandler("ReplaceCommonPlaceholders")
End Function

' display standard error message
Public Sub ErrorMessage(ByVal as_Fct As String)
    Dim ls_ErrSource As String
    Dim ls_errDescription As String
    Dim ls_Message As String
    
    ls_ErrSource = as_Fct & SEP1 & Err.Source
    ls_errDescription = Err.Description
    ls_Message = SCREEN_NAME & " exception. Nr:" & Err.Number & ",Desc: " & ls_errDescription & ",Src:" & ls_ErrSource & "@"
    Call mo_Tools.LogMessage(mo_Db, ml_U_Code, SCREEN_NAME, ls_Message, "E")
    Call MsgBox("Error occured, please contact IT. Application will now shutdown." & vbCrLf & ls_ErrSource & vbCrLf & "Description: " & ls_errDescription, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
    End
End Sub

' Standard error handler
Private Sub ErrorHandler(ByVal as_Fct As String)
  
    Call Err.Raise(Err.Number, Extender.Name & "." & as_Fct & SEP1 & Err.Source, Err.Description)
End Sub



