VERSION 5.00
Begin VB.UserControl DPC_Subconstruction 
   ClientHeight    =   11085
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   15285
   ScaleHeight     =   11085
   ScaleWidth      =   15285
   Tag             =   "DPC_Suspension"
   Begin VB.Frame fra_Subconstruction 
      Height          =   10335
      Left            =   0
      TabIndex        =   22
      Tag             =   "fra_Subconstruction"
      Top             =   0
      Width           =   15135
      Begin VB.PictureBox pct_HangerType 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   5250
         Left            =   11295
         ScaleHeight     =   5220
         ScaleWidth      =   3735
         TabIndex        =   84
         Top             =   135
         Width           =   3765
      End
      Begin VB.Frame fra_SubconstMain 
         Height          =   5415
         Left            =   0
         TabIndex        =   46
         Tag             =   "fra_SubconstMain"
         Top             =   15
         Width           =   7500
         Begin VB.PictureBox pct_Article 
            Appearance      =   0  'Flat
            AutoRedraw      =   -1  'True
            BackColor       =   &H80000005&
            ForeColor       =   &H80000008&
            Height          =   630
            Left            =   6630
            ScaleHeight     =   600
            ScaleWidth      =   750
            TabIndex        =   105
            Top             =   2025
            Visible         =   0   'False
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   16
            Left            =   5790
            TabIndex        =   103
            TabStop         =   0   'False
            Tag             =   "PUS_P"
            Top             =   4410
            Width           =   780
         End
         Begin Project1.A_calocx cal_DeliveryDate 
            Height          =   360
            Left            =   5595
            TabIndex        =   2
            Top             =   510
            Width           =   1845
            _ExtentX        =   3254
            _ExtentY        =   635
         End
         Begin Project1.A_calocx cal_ShipDate 
            Height          =   360
            Left            =   1815
            TabIndex        =   85
            Top             =   510
            Width           =   1845
            _ExtentX        =   3254
            _ExtentY        =   635
         End
         Begin Project1.A_calocx cal_WishDate 
            Height          =   360
            Left            =   5595
            TabIndex        =   1
            Top             =   165
            Width           =   1845
            _ExtentX        =   3254
            _ExtentY        =   635
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   11
            Left            =   5790
            TabIndex        =   82
            TabStop         =   0   'False
            Tag             =   "PUS_QtyPCS"
            Top             =   1245
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   9
            Left            =   5790
            TabIndex        =   71
            TabStop         =   0   'False
            Tag             =   "MaxA0"
            Top             =   4065
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   10
            Left            =   5790
            TabIndex        =   69
            TabStop         =   0   'False
            Tag             =   "MaxA1"
            Top             =   3720
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   8
            Left            =   5790
            TabIndex        =   67
            TabStop         =   0   'False
            Tag             =   "LoadKNm2"
            Top             =   2310
            Visible         =   0   'False
            Width           =   780
         End
         Begin VB.CheckBox chk_ASFlag 
            Caption         =   "#AS Item"
            Height          =   225
            Left            =   3990
            TabIndex        =   66
            Tag             =   "chk_ASFlag"
            Top             =   5130
            Width           =   1500
         End
         Begin VB.CommandButton btn_Calculate 
            Caption         =   "#Calculate"
            Height          =   510
            Left            =   5595
            TabIndex        =   47
            Tag             =   "btn_Calculate"
            Top             =   4800
            Width           =   1770
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   7
            Left            =   2280
            TabIndex        =   15
            TabStop         =   0   'False
            Tag             =   "PUS_PanB"
            Top             =   4725
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   6
            Left            =   2280
            TabIndex        =   14
            TabStop         =   0   'False
            Tag             =   "PUS_PanA"
            Top             =   4380
            Width           =   780
         End
         Begin VB.CheckBox chk_PanelSecurity 
            Caption         =   "#Panel security"
            Height          =   255
            Left            =   2265
            TabIndex        =   11
            Tag             =   "chk_PanelSecurity"
            Top             =   5115
            Width           =   1635
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   5
            Left            =   2280
            TabIndex        =   13
            TabStop         =   0   'False
            Tag             =   "PUS_A0"
            Top             =   4035
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   4
            Left            =   2280
            TabIndex        =   12
            TabStop         =   0   'False
            Tag             =   "PUS_A1"
            Top             =   3690
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   3
            Left            =   2280
            TabIndex        =   10
            TabStop         =   0   'False
            Tag             =   "PUS_A2"
            Top             =   3345
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   2
            Left            =   1815
            TabIndex        =   7
            TabStop         =   0   'False
            Tag             =   "PUS_Height"
            Top             =   2310
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   1
            Left            =   1815
            TabIndex        =   4
            TabStop         =   0   'False
            Tag             =   "PUS_QtyM2"
            Top             =   1245
            Width           =   780
         End
         Begin VB.TextBox txt_TextBox 
            Height          =   345
            Index           =   0
            Left            =   1815
            TabIndex        =   3
            TabStop         =   0   'False
            Tag             =   "OFD_Pos"
            Top             =   150
            Width           =   780
         End
         Begin Project1.ArmCombobox cbo_LoadCase 
            Height          =   345
            Left            =   1815
            TabIndex        =   8
            Tag             =   "cbo_LoadCase"
            Top             =   2655
            Width           =   4725
            _ExtentX        =   8334
            _ExtentY        =   609
         End
         Begin Project1.ArmCombobox cbo_HangerAlignment 
            Height          =   345
            Left            =   1815
            TabIndex        =   9
            Tag             =   "cbo_HangerAlignment"
            Top             =   3000
            Width           =   4725
            _ExtentX        =   8334
            _ExtentY        =   609
         End
         Begin Project1.ArmCombobox cbo_SubType 
            Height          =   345
            Left            =   1815
            TabIndex        =   5
            Top             =   1605
            Width           =   4725
            _ExtentX        =   8334
            _ExtentY        =   609
         End
         Begin Project1.ArmCombobox cbo_HangerType 
            Height          =   345
            Left            =   1815
            TabIndex        =   6
            Top             =   1965
            Width           =   4725
            _ExtentX        =   8334
            _ExtentY        =   609
         End
         Begin Project1.ArmCombobox cbo_Vendor 
            Height          =   345
            Left            =   1815
            TabIndex        =   62
            Top             =   885
            Width           =   1845
            _ExtentX        =   3254
            _ExtentY        =   609
         End
         Begin Project1.ArmCombobox cbo_ShipPoint 
            Height          =   345
            Left            =   5595
            TabIndex        =   63
            Top             =   885
            Width           =   1830
            _ExtentX        =   3228
            _ExtentY        =   609
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#P [m]"
            Height          =   255
            Index           =   37
            Left            =   3840
            TabIndex        =   104
            Tag             =   "lbl_PUS_P"
            Top             =   4440
            Width           =   1920
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Ship date"
            Height          =   255
            Index           =   29
            Left            =   75
            TabIndex        =   86
            Tag             =   "lbl_OFD_ShipDate"
            Top             =   540
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Panels qty"
            Height          =   255
            Index           =   21
            Left            =   3855
            TabIndex        =   83
            Tag             =   "lbl_PanelQtyPCS"
            Top             =   1290
            Width           =   1740
         End
         Begin VB.Label lbl_HangAlignBPossible 
            Caption         =   "#Hanger alignment B possible"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   238
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3615
            TabIndex        =   73
            Tag             =   "lbl_HangerAlignBPossible"
            Top             =   3375
            Visible         =   0   'False
            Width           =   3540
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Max a0"
            Height          =   255
            Index           =   19
            Left            =   3840
            TabIndex        =   72
            Tag             =   "lbl_MaxA0"
            Top             =   4140
            Width           =   1920
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Max a1"
            Height          =   255
            Index           =   20
            Left            =   3840
            TabIndex        =   70
            Tag             =   "lbl_MaxA1"
            Top             =   3780
            Width           =   1920
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Load [kN/m2]"
            Height          =   255
            Index           =   18
            Left            =   3885
            TabIndex        =   68
            Tag             =   "lbl_LoadKNm2"
            Top             =   2370
            Visible         =   0   'False
            Width           =   1290
         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            =   3855
            TabIndex        =   65
            Tag             =   "lbl_ShipPoint"
            Top             =   930
            Width           =   1740
         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           =   28
            Left            =   75
            TabIndex        =   64
            Tag             =   "lbl_PlantVendor"
            Top             =   930
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Delivery date"
            Height          =   255
            Index           =   6
            Left            =   3855
            TabIndex        =   61
            Tag             =   "lbl_OFD_DeliveryDate"
            Top             =   570
            Width           =   1470
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Wish date"
            Height          =   255
            Index           =   185
            Left            =   3855
            TabIndex        =   60
            Tag             =   "lbl_OFD_WishDate"
            Top             =   240
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Panel width B [m]"
            Height          =   255
            Index           =   10
            Left            =   45
            TabIndex        =   59
            Tag             =   "lbl_PanelB"
            Top             =   4770
            Width           =   2235
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Panel length A [m]"
            Height          =   255
            Index           =   9
            Left            =   60
            TabIndex        =   58
            Tag             =   "lbl_PanelA"
            Top             =   4425
            Width           =   2235
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#(a0)"
            Height          =   255
            Index           =   8
            Left            =   60
            TabIndex        =   57
            Tag             =   "lbl_a0"
            Top             =   4080
            Width           =   2235
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#(a1)"
            Height          =   255
            Index           =   5
            Left            =   60
            TabIndex        =   56
            Tag             =   "lbl_a1"
            Top             =   3750
            Width           =   2235
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#(a2)"
            Height          =   255
            Index           =   4
            Left            =   60
            TabIndex        =   55
            Tag             =   "lbl_a2"
            Top             =   3405
            Width           =   2235
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Susp. height [m]"
            Height          =   255
            Index           =   3
            Left            =   60
            TabIndex        =   54
            Tag             =   "lbl_SuspensionHeight"
            Top             =   2385
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Hanger type"
            Height          =   255
            Index           =   2
            Left            =   60
            TabIndex        =   53
            Tag             =   "lbl_HangerType"
            Top             =   2055
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Surface [m2]"
            Height          =   255
            Index           =   1
            Left            =   60
            TabIndex        =   52
            Tag             =   "lbl_Surface"
            Top             =   1305
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Position"
            Height          =   255
            Index           =   0
            Left            =   60
            TabIndex        =   51
            Tag             =   "lbl_Position"
            Top             =   225
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Load case"
            Height          =   255
            Index           =   7
            Left            =   60
            TabIndex        =   50
            Tag             =   "lbl_LoadCase"
            Top             =   2730
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Hanger alignment"
            Height          =   255
            Index           =   52
            Left            =   60
            TabIndex        =   49
            Tag             =   "lbl_HangerAlignment"
            Top             =   3075
            Width           =   1740
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#System"
            Height          =   255
            Index           =   99
            Left            =   60
            TabIndex        =   48
            Tag             =   "lbl_System"
            Top             =   1695
            Width           =   1740
         End
      End
      Begin VB.PictureBox pct_SubType 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   5250
         Left            =   7515
         ScaleHeight     =   5220
         ScaleWidth      =   3735
         TabIndex        =   23
         Top             =   135
         Width           =   3765
      End
      Begin VB.Frame fra_SubArt 
         Height          =   4965
         Left            =   45
         TabIndex        =   24
         Tag             =   "fra_SuspArt"
         Top             =   5325
         Width           =   15030
         Begin Project1.ArmGrid grd_Sub 
            Height          =   3450
            Left            =   60
            TabIndex        =   0
            Tag             =   "grd_Sub"
            Top             =   210
            Width           =   14205
            _ExtentX        =   25056
            _ExtentY        =   6085
         End
         Begin Project1.ToolbarControl tlb_SubconstMain 
            Height          =   3495
            Left            =   14325
            TabIndex        =   29
            Tag             =   "2924"
            Top             =   165
            Width           =   690
            _ExtentX        =   1217
            _ExtentY        =   6165
         End
         Begin VB.Frame fra_SubArtDetail 
            Height          =   1290
            Left            =   45
            TabIndex        =   25
            Tag             =   "fra_SubArtDetail"
            Top             =   3630
            Width           =   15000
            Begin VB.TextBox txt_OFD_TotalP 
               Height          =   345
               Left            =   11115
               TabIndex        =   98
               Tag             =   "txt_OFD_TotalP"
               Top             =   540
               Width           =   825
            End
            Begin VB.TextBox txt_OFD_Price 
               Height          =   345
               Left            =   8370
               TabIndex        =   97
               Tag             =   "txt_OFD_Price"
               Top             =   540
               Width           =   825
            End
            Begin VB.TextBox txt_SUA_Bwrt 
               Height          =   345
               Left            =   5925
               TabIndex        =   44
               Top             =   885
               Width           =   840
            End
            Begin VB.TextBox txt_SUA_PU 
               Height          =   345
               Left            =   3690
               TabIndex        =   42
               Tag             =   "txt_SUA_PU"
               Top             =   885
               Width           =   840
            End
            Begin VB.TextBox txt_OFD_QtyAPCS 
               Height          =   345
               Left            =   1440
               TabIndex        =   40
               Top             =   885
               Width           =   840
            End
            Begin VB.TextBox txt_OFD_Cost 
               Height          =   345
               Left            =   8370
               TabIndex        =   35
               Tag             =   "txt_OFD_Cost"
               Top             =   885
               Width           =   825
            End
            Begin VB.TextBox txt_OFD_TotalC 
               Height          =   345
               Left            =   11115
               TabIndex        =   34
               Tag             =   "txt_OFD_TotalC"
               Top             =   885
               Width           =   825
            End
            Begin VB.TextBox txt_SUA_TWgh 
               Height          =   345
               Left            =   14085
               TabIndex        =   32
               Tag             =   "txt_SUA_TWgh"
               Top             =   885
               Width           =   840
            End
            Begin VB.TextBox txt_OFD_QtySpare 
               Height          =   345
               Left            =   5925
               TabIndex        =   30
               Top             =   510
               Width           =   840
            End
            Begin VB.TextBox txt_OFD_QtyA 
               Height          =   345
               Left            =   1440
               TabIndex        =   17
               Top             =   510
               Width           =   840
            End
            Begin VB.TextBox txt_OFD_Qty 
               Height          =   345
               Left            =   3690
               TabIndex        =   18
               Tag             =   "txt_OFD_Qty"
               Top             =   510
               Width           =   840
            End
            Begin Project1.ToolbarControl tlb_SubconstDetail 
               Height          =   690
               Left            =   12945
               TabIndex        =   19
               Tag             =   "2925"
               Top             =   165
               Width           =   2010
               _ExtentX        =   3545
               _ExtentY        =   1217
            End
            Begin Project1.ArmCombobox cbo_Subconst 
               Height          =   345
               Left            =   1440
               TabIndex        =   16
               Top             =   165
               Width           =   11445
               _ExtentX        =   20188
               _ExtentY        =   609
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Total Price [Curr]"
               Height          =   255
               Index           =   36
               Left            =   9735
               TabIndex        =   102
               Tag             =   "lbl_OFD_TotalP"
               Top             =   600
               Width           =   1320
            End
            Begin VB.Label lbl_Price 
               Caption         =   "#CHF"
               Height          =   210
               Index           =   5
               Left            =   12015
               TabIndex        =   101
               Tag             =   "_lbl_CURR_TotalCost"
               Top             =   600
               Width           =   480
            End
            Begin VB.Label lbl_Price 
               Caption         =   "#CHF"
               Height          =   210
               Index           =   4
               Left            =   9240
               TabIndex        =   100
               Tag             =   "_lbl_CURR_Cost"
               Top             =   600
               Width           =   480
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#UP Price [Curr/PU]"
               Height          =   255
               Index           =   14
               Left            =   6810
               TabIndex        =   99
               Tag             =   "lbl_OFD_Price"
               Top             =   600
               Width           =   1470
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Coeff"
               Height          =   255
               Index           =   17
               Left            =   4560
               TabIndex        =   45
               Tag             =   "lbl_Coeff"
               Top             =   930
               Width           =   1305
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#PU"
               Height          =   255
               Index           =   16
               Left            =   2325
               TabIndex        =   43
               Tag             =   "lbl_PU"
               Top             =   930
               Width           =   1305
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Total II [PCS]"
               Height          =   255
               Index           =   15
               Left            =   75
               TabIndex        =   41
               Tag             =   "lbl_OFD_QtyAPCS"
               Top             =   930
               Width           =   1305
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#UP ICTP [Curr/PU]"
               Height          =   255
               Index           =   24
               Left            =   6810
               TabIndex        =   39
               Tag             =   "lbl_OFD_Cost"
               Top             =   945
               Width           =   1470
            End
            Begin VB.Label lbl_Price 
               Caption         =   "#CHF"
               Height          =   210
               Index           =   0
               Left            =   9240
               TabIndex        =   38
               Tag             =   "_lbl_CURR_Cost"
               Top             =   945
               Width           =   480
            End
            Begin VB.Label lbl_Price 
               Caption         =   "#CHF"
               Height          =   210
               Index           =   3
               Left            =   12015
               TabIndex        =   37
               Tag             =   "_lbl_CURR_TotalCost"
               Top             =   945
               Width           =   480
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Total ICTP [Curr]"
               Height          =   255
               Index           =   12
               Left            =   9735
               TabIndex        =   36
               Tag             =   "lbl_OFD_TotalC"
               Top             =   945
               Width           =   1320
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Total weight [kg]"
               Height          =   255
               Index           =   13
               Left            =   12705
               TabIndex        =   33
               Tag             =   "lbl_SUA_TWgh"
               Top             =   930
               Width           =   1320
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Spare III [%]"
               Height          =   255
               Index           =   11
               Left            =   4560
               TabIndex        =   31
               Tag             =   "lbl_OFD_QtySpare"
               Top             =   555
               Width           =   1305
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Article"
               Height          =   255
               Index           =   27
               Left            =   120
               TabIndex        =   28
               Tag             =   "lbl_Article"
               Top             =   210
               Width           =   1215
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Full PU [no]"
               Height          =   255
               Index           =   26
               Left            =   90
               TabIndex        =   27
               Tag             =   "lbl_OFD_QtyA"
               Top             =   555
               Width           =   1305
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Full PU [no]"
               Height          =   255
               Index           =   25
               Left            =   2325
               TabIndex        =   26
               Tag             =   "lbl_OFD_Qty"
               Top             =   555
               Width           =   1305
            End
         End
      End
   End
   Begin VB.CommandButton btn_Quit 
      Height          =   612
      Left            =   14505
      Style           =   1  'Graphical
      TabIndex        =   21
      Tag             =   "btn_Quit"
      Top             =   10425
      Width           =   612
   End
   Begin VB.CommandButton btn_Validate 
      Height          =   612
      Left            =   13830
      Style           =   1  'Graphical
      TabIndex        =   20
      Tag             =   "btn_Validate"
      Top             =   10425
      Width           =   612
   End
   Begin VB.Frame fra_Price 
      Caption         =   "#Subconstruction price"
      Height          =   795
      Index           =   10
      Left            =   60
      TabIndex        =   74
      Tag             =   "fra_SubconstructionCost"
      Top             =   10305
      Width           =   13590
      Begin VB.TextBox txt_TextBox 
         BackColor       =   &H8000000F&
         Height          =   345
         Index           =   15
         Left            =   10785
         Locked          =   -1  'True
         TabIndex        =   95
         TabStop         =   0   'False
         Tag             =   "PUS_WghtArea"
         Top             =   390
         Width           =   885
      End
      Begin VB.TextBox txt_TextBox 
         BackColor       =   &H8000000F&
         Height          =   345
         Index           =   14
         Left            =   8985
         Locked          =   -1  'True
         TabIndex        =   93
         TabStop         =   0   'False
         Tag             =   "PUS_Wght"
         Top             =   390
         Width           =   885
      End
      Begin VB.TextBox txt_TextBox 
         BackColor       =   &H8000000F&
         Height          =   345
         Index           =   13
         Left            =   6975
         Locked          =   -1  'True
         TabIndex        =   91
         TabStop         =   0   'False
         Tag             =   "PUS_ICTPArea"
         Top             =   390
         Width           =   885
      End
      Begin VB.TextBox txt_TextBox 
         BackColor       =   &H8000000F&
         Height          =   345
         Index           =   12
         Left            =   5970
         Locked          =   -1  'True
         TabIndex        =   89
         TabStop         =   0   'False
         Tag             =   "PUS_Area"
         Top             =   390
         Width           =   885
      End
      Begin VB.TextBox txt_Price 
         BackColor       =   &H8000000F&
         Height          =   345
         Index           =   2
         Left            =   4785
         Locked          =   -1  'True
         TabIndex        =   87
         TabStop         =   0   'False
         Tag             =   "SUBCOST_A"
         Text            =   "0"
         Top             =   375
         Width           =   885
      End
      Begin VB.CheckBox chk_FreeOfCharge 
         Caption         =   "#Free of charge"
         Height          =   225
         Left            =   3210
         TabIndex        =   81
         Tag             =   "chk_FreeOfCharge"
         Top             =   465
         Width           =   1755
      End
      Begin VB.TextBox txt_Price 
         BackColor       =   &H8000000F&
         Height          =   345
         Index           =   1
         Left            =   1710
         Locked          =   -1  'True
         TabIndex        =   76
         TabStop         =   0   'False
         Tag             =   "SUBPRICE_M"
         Text            =   "0"
         Top             =   405
         Width           =   885
      End
      Begin VB.TextBox txt_Price 
         BackColor       =   &H8000000F&
         Height          =   345
         Index           =   0
         Left            =   90
         Locked          =   -1  'True
         TabIndex        =   75
         TabStop         =   0   'False
         Tag             =   "SUBPRICE_A"
         Text            =   "0"
         Top             =   405
         Width           =   885
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weight/Area [kg/m2]"
         Height          =   255
         Index           =   35
         Left            =   10770
         TabIndex        =   96
         Tag             =   "lbl_WeightArea"
         Top             =   150
         Width           =   2010
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weight Total [kg]"
         Height          =   255
         Index           =   34
         Left            =   8970
         TabIndex        =   94
         Tag             =   "lbl_TotalWeight"
         Top             =   150
         Width           =   2010
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ICTP/Area [currency/m2]"
         Height          =   255
         Index           =   33
         Left            =   6960
         TabIndex        =   92
         Tag             =   "lbl_ICTPArea"
         Top             =   150
         Width           =   2010
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Area [m2]"
         Height          =   255
         Index           =   32
         Left            =   5955
         TabIndex        =   90
         Tag             =   "lbl_Area"
         Top             =   150
         Width           =   1110
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ICTP Total"
         Height          =   255
         Index           =   31
         Left            =   4800
         TabIndex        =   88
         Tag             =   "lbl_CostAuto"
         Top             =   165
         Width           =   915
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Manual"
         Height          =   255
         Index           =   23
         Left            =   1710
         TabIndex        =   80
         Tag             =   "lbl_PriceManual"
         Top             =   195
         Width           =   915
      End
      Begin VB.Label lbl_Price 
         Caption         =   "#CHF"
         Height          =   210
         Index           =   1
         Left            =   1035
         TabIndex        =   79
         Tag             =   "_lbl_CURR_Auto"
         Top             =   465
         Width           =   465
      End
      Begin VB.Label lbl_Price 
         Caption         =   "#CHF"
         Height          =   210
         Index           =   2
         Left            =   2670
         TabIndex        =   78
         Tag             =   "_lbl_CURR_Manual"
         Top             =   465
         Width           =   465
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Auto"
         Height          =   255
         Index           =   22
         Left            =   105
         TabIndex        =   77
         Tag             =   "lbl_PriceAuto"
         Top             =   195
         Width           =   915
      End
   End
End
Attribute VB_Name = "DPC_Subconstruction"
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 CL_COLOR_LOCKED As Long = &H80000018
Private Const SCREEN_NAME As String = "DPC_Subconstruction"

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

Private Const FRM_SPACE_VER = 120
Private Const FRM_SPACE_HOR = 100

Private COLOR_SUBOPTION As Long
Private COLOR_SUBREPLACE As Long

Public Result As Boolean

#If ENV = LIVE Then
Private mo_Sys As Object
Public mo_Db As Object
#Else
Private mo_Sys As ARMSYSCOMLib.ArmSYS
Public mo_Db As ARMSYSCOMLib.ArmDb
#End If

Private mo_Tools As DPC_Tools

Public COF_Id As String
Public CanChangeManualPrice As Boolean
Public CURR_Code As String
Public CT_Code As String
Public ValidityDate As Date
Public ml_U_Code As Long

Private me_PrdScreen As eDPCScreenMode
Private me_SubconstScreen As eDPCScreenMode

Private mb_InternalInit As Boolean
Private mb_CurrentTextBoxChanged As Boolean
Private mo_CurrentSubArt As DPC_SubArt
Private me_PriceBookType As eDPCPriceBookType
Private ms_Caption As String
Private ms_DPCImageCachePath As String
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_FSO As FileSystemObject
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_IsProduction As Boolean

Public mo_DPC_SubSys As New DPC_SubSys

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

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

Private Type Guid
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
End Type

Private Type PictDesc
    cbSizeofStruct As Long
    picType As Long
    hImage As Long
    xExt As Long
    yExt As Long
End Type

Private Type TRect
    Top As Long
    Left As Long
    Width As Long
    Height As Long
End Type

Private Enum eImageType
  itSubconstructionSystem = 1
  itSubconstructionArticle = 2
  itData = 3
End Enum

Public Event quit()

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 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 Let Language_Code(ByVal 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 Get DPC_SubSys() As DPC_SubSys
On Error GoTo ErrHandler
  
  Set DPC_SubSys = mo_DPC_SubSys
  Exit Property
ErrHandler:
  Call ErrorHandler("DPC_SubSys.Get")
End Property

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

  mo_DPC_SubSys.IsArticleSync = ab_Value
  fra_SubArt.Visible = ab_Value
  Call DisplayFooterPrice
  Exit Property
ErrHandler:
  Call ErrorHandler("IsArticleSync.Let")
End Property

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


Public Property Let OFD_Type(ByVal ae_Type As eDPCPriceBookType)
On Error GoTo ErrHandler
  
  me_PriceBookType = ae_Type
  Exit Property
ErrHandler:
  Call ErrorHandler("OFD_Type.Let")
End Property

Public Property Get OFD_Type() As eDPCPriceBookType
On Error GoTo ErrHandler
  
  OFD_Type = me_PriceBookType
  Exit Property
ErrHandler:
  Call ErrorHandler("OFD_Type.Get")
End Property

Public Property Let OFD_Pos(ByVal al_Value As Long)
On Error GoTo ErrHandler

  mo_DPC_SubSys.OFD_Pos = al_Value
  Exit Property
ErrHandler:
  Call ErrorHandler("OFD_Pos.Let")
End Property

Public Property Get OFD_Pos() As Long
On Error GoTo ErrHandler

  OFD_Pos = mo_DPC_SubSys.OFD_Pos
  Exit Property
ErrHandler:
  Call ErrorHandler("OFD_Pos.Get")
End Property

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

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

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

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

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

Public Property Get OFD_DelDat() As Date
On Error GoTo ErrHandler
  
  OFD_DelDat = mo_DPC_SubSys.OFD_DelDat
  Exit Property
ErrHandler:
  Call ErrorHandler("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 Function Load_A_COM() As Boolean
On Error GoTo ErrHandler

Dim ll_Idx As Integer
Dim ls_Request As String
Dim lsa_PKG_Id() 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, UserControl.hwnd)
  
  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")
#Else
  Set mo_Sys = New ARMSYSCOMLib.ArmSYS
#End If
  
  Set mo_WshNetwork = CreateObject("WScript.Network")
  ms_ComputerName = mo_WshNetwork.ComputerName
    
  COLOR_SUBOPTION = RGB(90, 240, 110)
  COLOR_SUBREPLACE = RGB(110, 200, 180)
  ls_Request = "exec DPC_System_lst2 $COF_Lang$, NULL, NULL, 'X'"
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  cbo_SubType.Request = ls_Request
  
  ls_Request = "exec A_References_ML_lst $GR_Code$,$COF_Lang$"
  ls_Request = Replace(ls_Request, "$GR_Code$", mo_Tools.SqlInt(eDPCReferenceML.rfSubHangAlignment), , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  cbo_HangerAlignment.Request = ls_Request
  
  Call EnableSubArtNavigation(False)
  
  ReDim la_Columns(26) As Variant
  la_Columns(0) = "SubIdx" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "SubIdx" & CH_LDELIMIT & ""
  la_Columns(1) = "SUA_Id" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SUA_Id" & CH_LDELIMIT & ""
  la_Columns(2) = "DOF_Id" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "DOF_Id" & CH_LDELIMIT & ""
  la_Columns(3) = "DOF_Name" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "DOF_Name" & CH_LDELIMIT & "#Type"
  la_Columns(4) = "PRD_Code" & CH_LDELIMIT & "1100" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PRD_Code" & CH_LDELIMIT & "#Code" & CH_LDELIMIT & "STRING" & CH_LDELIMIT & CH_LDELIMIT & "LEFT"
  la_Columns(5) = "PRD_Name" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PRD_Name" & CH_LDELIMIT & "#Name" & CH_LDELIMIT & "STRING" & CH_LDELIMIT & CH_LDELIMIT & "LEFT"
  la_Columns(6) = "PRD_Desc" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PRD_Desc" & CH_LDELIMIT & "#Description" & CH_LDELIMIT & "STRING" & CH_LDELIMIT & CH_LDELIMIT & "LEFT"
  la_Columns(7) = "SUA_Bwrt" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SUA_Bwrt" & CH_LDELIMIT & "#Coeff"
  la_Columns(8) = "PSA_NeedM2" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PSA_NeedM2" & CH_LDELIMIT & "#Need [UoM/m2]" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.000"
  la_Columns(9) = "PSA_NeedPCS" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "PSA_NeedPCS" & CH_LDELIMIT & "#Total I [UoM]"
  la_Columns(10) = "UM_Code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "UM_Code" & CH_LDELIMIT & "#UoM"
  la_Columns(11) = "UM_Name" & CH_LDELIMIT & "400" & CH_LDELIMIT & "0" & CH_LDELIMIT & "UM_Name" & CH_LDELIMIT & "#UoM"
  la_Columns(12) = "SUA_PU" & CH_LDELIMIT & "400" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SUA_PU" & CH_LDELIMIT & "#Packing [PCS/PU]"
  la_Columns(13) = "OFD_QtyA" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_QtyA" & CH_LDELIMIT & "#Full PU [no]"
  la_Columns(14) = "OFD_QtyAPCS" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_QtyAPCS" & CH_LDELIMIT & "#Total II [PCS]"
  la_Columns(15) = "OFD_QtyASpare" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_QtyASpare" & CH_LDELIMIT & "#Spare II [%]"
  la_Columns(16) = "OFD_Qty" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_Qty" & CH_LDELIMIT & "#Full PU [no]"
  la_Columns(17) = "OFD_QtyPCS" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_QtyPCS" & CH_LDELIMIT & "#Total III [PCS]"
  la_Columns(18) = "OFD_QtySpare" & CH_LDELIMIT & "750" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_QtySpare" & CH_LDELIMIT & "#Spare III [%]"
  la_Columns(19) = "SUA_PUWgh" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SUA_PUWgh" & CH_LDELIMIT & "#Weight PU" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.000"
  la_Columns(20) = "SUA_MatRe" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SUA_MatRe" & CH_LDELIMIT & "#Mat.reserve" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.0"
  la_Columns(21) = "SUA_TWght" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SUA_TWght" & CH_LDELIMIT & "#Tot.weight" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.0"
  la_Columns(22) = "IMG_Id" & CH_LDELIMIT & "0" & CH_LDELIMIT & "0" & CH_LDELIMIT & "IMG_Id" & CH_LDELIMIT & ""
  la_Columns(23) = "OFD_Cost" & CH_LDELIMIT & "650" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_Cost" & CH_LDELIMIT & "#UP ICTP [Curr/PU]" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.00"
  la_Columns(24) = "OFD_TotalC" & CH_LDELIMIT & "850" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_TotalC" & CH_LDELIMIT & "#Total [Curr]" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.00"
  la_Columns(25) = "OFD_Price" & CH_LDELIMIT & "650" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_Price" & CH_LDELIMIT & "#UP Price [Curr/PU]" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.00"
  la_Columns(26) = "OFD_TotalP" & CH_LDELIMIT & "850" & CH_LDELIMIT & "0" & CH_LDELIMIT & "OFD_TotalC" & CH_LDELIMIT & "#Total Price [Curr]" & CH_LDELIMIT & "FLOAT" & CH_LDELIMIT & "0.00"
  
  grd_Sub.SetColumns la_Columns
  grd_Sub.UnBound = True
  
  mo_DPC_SubSys.Language_Code = ms_COF_Lang
  mo_DPC_SubSys.U_Code = ml_U_Code
  Set mo_DPC_SubSys.ArmDb = mo_Db
  Set mo_DPC_SubSys.Tools = mo_Tools
  mo_DPC_SubSys.CURR_Code = CURR_Code
  mo_DPC_SubSys.CT_Code = CT_Code
  mo_DPC_SubSys.COF_Id = COF_Id
  mo_DPC_SubSys.ValidityDate = ValidityDate
  Call mo_DPC_SubSys.Load_A_COM
  
  Call InitVendorCombo(cbo_Vendor)
  Call InitShipPointCombo(cbo_ShipPoint)
  
  ms_DPCImageCachePath = prg.AppCache_Dir & DPC_IMAGE_CACHE
  ms_Caption = "#Subconstruction system"
  btn_Validate.Picture = LoadResPicture(RES_OK, 1)
  btn_Quit.Picture = LoadResPicture(RES_QUIT, 1)

  Call mo_Tools.SetTextEnabled(txt_Price, "SUBPRICE_M", CanChangeManualPrice)
  Call mo_Tools.SetTextEnabled(txt_Price, "SUBPRICE_A", False)
  Call mo_Tools.SetTextEnabled(txt_Price, "SUBCOST_A", False)
  
  Call EnableSubArtNavigation(False)
  
  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, UserControl.hwnd)
  Call mo_Tools.ChangeCharset(UserControl.Controls, gl_CodePage, mo_Tools.GetCodePageFromLanguage(mo_Db, ms_COF_Lang))
  
  Call SetPriceLabel(CURR_Code)
  mo_DPC_SubSys.lbl_ShipPoint = mo_Tools.GetControl(lbl_Label, "lbl_ShipPoint").Caption
  mo_DPC_SubSys.lbl_PlantVendor = mo_Tools.GetControl(lbl_Label, "lbl_PlantVendor").Caption
  Result = False
  mb_InternalInit = False
  mb_Initialized = True
  Load_A_COM = mb_Initialized
  Exit Function
ErrHandler:
  Call ErrorHandler("Load_A_COM")
End Function

Public Sub Unload_A_COM()
On Error GoTo ErrHandler

  Call mo_DPC_SubSys.Unload_A_COM
  Call mo_Tools.Unload_A_ComControls(UserControl.Controls, UserControl.hwnd)
  Call mo_Db.Close(mc_ScreenLabels)
  Set mo_Sys = Nothing
  Set mo_FSO = Nothing
  Set mo_Db = Nothing
  mb_Initialized = False
  Exit Sub
ErrHandler:
  Call ErrorHandler("Unload_A_COM")
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_DPC_SubSys.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_DPC_SubSys.LEN_Id), , , vbTextCompare)
  ls_Request = Replace(ls_Request, "$VEN_Id$", mo_Tools.SQLStr(mo_DPC_SubSys.VEN_Id), , , vbTextCompare)
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  ao_Combo.Request = ls_Request
  Exit Sub
ErrHandler:
  Call ErrorHandler("InitShipPointCombo")
End Sub

Private Function CheckStep(ByVal ae_Screen As eDPCScreen) As Boolean
On Error GoTo ErrHandler

Dim lo_ErrCol As Collection

  CheckStep = False
  Call ClearScreenErrorType
  Set lo_ErrCol = mo_DPC_SubSys.CheckScreen(ae_Screen)
  Call ApplyScreenError(lo_ErrCol)
  If ConfirmCheckList(lo_ErrCol) Then
    CheckStep = True
  End If
  Exit Function
ErrHandler:
  Call ErrorHandler("CheckStep")
End Function

Private Function CheckStepSubArtItem(ByVal ao_SubArt As DPC_SubArt) As Boolean
On Error GoTo ErrHandler

Dim lo_ErrCol As New Collection

  Call ClearScreenErrorType
  Call mo_DPC_SubSys.CheckSubArtItem(lo_ErrCol, ao_SubArt)
  Call ApplyScreenError(lo_ErrCol)
  CheckStepSubArtItem = ConfirmCheckList(lo_ErrCol)
  Exit Function
ErrHandler:
  Call ErrorHandler("CheckStepSubArtItem")
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_DPC_SubSys.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 btn_Calculate_Click()
On Error GoTo ErrHandler

  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  IsArticleSync = False
  Call mo_DPC_SubSys.Calculate
  If CheckStep(eDPCScreen.psSubconstruction) Then
    Call DisplaySubGrid
    Call DisplayHeader
    Call DisplayFooterPrice
    IsArticleSync = True
  End If
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("btn_Calculate_Click")
End Sub

Private Sub btn_Quit_Click()
On Error GoTo ErrHandler

  Result = False
  RaiseEvent quit
  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)
  If CheckStep(eDPCScreen.psSubconstructionSummary) Then
    Result = True
    RaiseEvent quit
  End If
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("btn_Validate_Click")
End Sub

Public Sub ItemAdd()
On Error GoTo ErrHandler
  
  mb_InternalInit = True
  me_PrdScreen = eDPCScreenMode.smAdd
  IsArticleSync = False
  'Call mo_DPC_SubSys.LoadVendorShipPoint(CT_Code)
  Call ItemDisplay(mo_DPC_SubSys)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorHandler("ItemAdd")
End Sub

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

Dim lc_Cursor As Long
Dim ls_req As String

  mb_InternalInit = True
  me_PrdScreen = eDPCScreenMode.smUpdate
  Call mo_DPC_SubSys.Load(as_PUS_Id)
  'Call mo_DPC_SubSys.LoadSystemMargin
  'Call mo_DPC_SubSys.LoadOffer(as_COF_Id, as_OFD_IdPar)
  'Call ItemDisplay(mo_DPC_SubSys)
  IsArticleSync = True
  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_DPC_SubSys.LoadOffer(as_COF_Id, as_OFD_IdPar)
  Call ItemDisplay(mo_DPC_SubSys)
  ' do not check anything when production user editing template
  Call ClearScreenErrorType
  Set lo_ErrCol = mo_DPC_SubSys.CheckScreen(eDPCScreen.psSubconstructionSummary)
  Call ApplyScreenError(lo_ErrCol)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorHandler("LoadOffer")
End Sub

Private Sub DisplayFooterPrice()
On Error GoTo ErrHandler

Dim lo_Offer As DPC_OfferPos

  chk_FreeOfCharge.Value = IIf(mo_DPC_SubSys.OFD_IsFree, vbChecked, vbUnchecked)
  Call mo_DPC_SubSys.CalcPositionPrice
  Set lo_Offer = mo_DPC_SubSys.GetOfferPos(eDPCOfferDetail.odSubconstPosition)
  Call mo_Tools.SetTextValue(txt_Price, "SUBPRICE_M", mo_Tools.DblToScreen(lo_Offer.OFD_TotalP))
  Call mo_Tools.SetTextValue(txt_Price, "SUBPRICE_A", mo_Tools.DblToScreen(lo_Offer.OFD_TotalPA))
  Call mo_Tools.SetTextValue(txt_Price, "SUBCOST_A", mo_Tools.DblToScreen(lo_Offer.OFD_TotalCA))
  
  Call mo_Tools.SetTextValue(txt_Textbox, "PUS_Wght", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_Wght))
  Call mo_Tools.SetTextValue(txt_Textbox, "PUS_Area", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_QtyM2))
  
  If mo_DPC_SubSys.PUS_QtyM2 > 0 Then
    Call mo_Tools.SetTextValue(txt_Textbox, "PUS_ICTPArea", mo_Tools.DblToScreen(lo_Offer.OFD_TotalCA / mo_DPC_SubSys.PUS_QtyM2))
    Call mo_Tools.SetTextValue(txt_Textbox, "PUS_WghtArea", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_Wght / mo_DPC_SubSys.PUS_QtyM2))
  Else
    Call mo_Tools.SetTextValue(txt_Textbox, "PUS_ICTPArea", "")
    Call mo_Tools.SetTextValue(txt_Textbox, "PUS_WghtArea", "")
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayFooterPrice")
End Sub

Private Sub DisplaySubGrid()
On Error GoTo ErrHandler

Dim lo_Subart As DPC_SubArt

  grd_Sub.Redraw = False
  Call grd_Sub.ClearGrid
  For Each lo_Subart In mo_DPC_SubSys.Subconst
    If lo_Subart.RowStatus <> eDPCRowStatus.rsDrop Then
      Call grd_Sub.AddLine
      Call SubconstObjToGrid(lo_Subart, grd_Sub.Rows - 1)
    End If
  Next
  Call grd_Sub.DeselectRow
  grd_Sub.Redraw = True
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplaySubGrid")
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 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 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 Sub ClearScreenErrorType()
On Error GoTo ErrHandler

Dim lo_Control As VB.Control
Dim lo_Frame As VB.Frame
  
  Set lo_Frame = fra_Subconstruction
  Call SetControlErrorColor(lo_Frame, eDPCErrorType.etNone)
  For Each lo_Control In UserControl.Controls
    If mo_Tools.HasContainer(lo_Control, lo_Frame) Then
      Call SetControlErrorColor(lo_Control, eDPCErrorType.etNone)
    End If
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("ClearScreenErrorType")
End Sub

Public Function GenerateOfferDetail() As Collection
On Error GoTo ErrHandler
  
  Set GenerateOfferDetail = mo_DPC_SubSys.GenerateOfferDetail
  Exit Function
ErrHandler:
  Call ErrorHandler("GenerateOfferDetail")
End Function

Private Sub ItemDisplay(ByVal ao_SubArtMain As DPC_SubSys)
On Error GoTo ErrHandler

  
  Call DisplayHeader
  Call DisplaySuspImages
  Call DisplaySubGrid
  Call DisplayFooterPrice
  Exit Sub
ErrHandler:
  Call ErrorHandler("ItemDisplay")
End Sub

Private Sub DisplayHeader()
On Error GoTo ErrHandler

  
  Call InitVendorCombo(cbo_Vendor)
  Call InitShipPointCombo(cbo_ShipPoint)
  
  If Not cbo_Vendor.SearchItem(mo_DPC_SubSys.VEN_Id) Then
    Call cbo_Vendor.AddItem(Array(mo_DPC_SubSys.VEN_Id, mo_DPC_SubSys.VEN_Name), True)
  End If
  If Not cbo_ShipPoint.SearchItem(mo_DPC_SubSys.SHP_Id) Then
    Call cbo_ShipPoint.AddItem(Array(mo_DPC_SubSys.SHP_Id, mo_DPC_SubSys.SHP_Name), True)
  End If
  
  Call mo_Tools.SetCalendarDate(cal_WishDate, mo_DPC_SubSys.OFD_WshDat)
  Call mo_Tools.SetCalendarDate(cal_ShipDate, mo_DPC_SubSys.OFD_ShpDat)
  Call mo_Tools.SetCalendarDate(cal_DeliveryDate, mo_DPC_SubSys.OFD_DelDat)
  chk_ASFlag.Value = IIf(mo_DPC_SubSys.OFD_IsAsItem, vbChecked, vbUnchecked)
  
  If Not cbo_LoadCase.SearchItem(mo_DPC_SubSys.PUS_Load) Then
    Call cbo_LoadCase.AddItem(Array(mo_DPC_SubSys.PUS_Load, mo_DPC_SubSys.PUS_LoadDesc), True)
  End If
  If Not cbo_HangerAlignment.SearchItem(mo_DPC_SubSys.PUS_HaAlg) Then
    Call cbo_HangerAlignment.AddItem(Array(mo_DPC_SubSys.PUS_HaAlg, mo_DPC_SubSys.PUS_HaAlgDesc), True)
  End If
  If Not cbo_HangerType.SearchItem(mo_DPC_SubSys.SHT_Id) Then
    Call cbo_HangerType.AddItem(Array(mo_DPC_SubSys.SHT_Id, mo_DPC_SubSys.SHT_Name), True)
  End If
  If Not cbo_SubType.SearchItem(mo_DPC_SubSys.SYS_Id) Then
    Call cbo_SubType.AddItem(Array(mo_DPC_SubSys.SYS_Id, mo_DPC_SubSys.SYS_Name), True)
  End If
  
  Call mo_Tools.SetTextBox(txt_Textbox, "OFD_Pos", mo_Tools.LongToScreen(mo_DPC_SubSys.OFD_Pos), False)
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_QtyM2", mo_Tools.LongToScreen(mo_DPC_SubSys.PUS_QtyM2))
  
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_Height", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_Height, 3))
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_A0", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_A0, 3))
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_A1", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_A1, 3))
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_A2", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_A2, 3))
  
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_P", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_P, 3), True, mo_DPC_SubSys.SYS_UseCPro)
  Call mo_Tools.SetLabelVisible(lbl_Label, "lbl_PUS_P", mo_DPC_SubSys.SYS_UseCPro)
  
  chk_PanelSecurity.Value = IIf(mo_DPC_SubSys.PUS_PaSec, vbChecked, vbUnchecked)
  chk_PanelSecurity.Enabled = mo_DPC_SubSys.SYS_PaSec
  
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_PanA", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_PanA, 3))
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_PanB", mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_PanB, 3))
  
  Call mo_Tools.SetLabelText(lbl_Label, "lbl_A0", mo_DPC_SubSys.RF_DescA0)
  Call mo_Tools.SetLabelText(lbl_Label, "lbl_A1", mo_DPC_SubSys.RF_DescA1)
  Call mo_Tools.SetLabelText(lbl_Label, "lbl_A2", mo_DPC_SubSys.RF_DescA2)
  
  Call mo_Tools.SetTextBox(txt_Textbox, "PUS_QtyPCS", mo_Tools.LongToScreen(mo_DPC_SubSys.PUS_QtyPCS), False)
  Call mo_Tools.SetTextBox(txt_Textbox, "MaxA0", mo_Tools.DblToScreen(mo_DPC_SubSys.MaxA0Value, 3), False)
  Call mo_Tools.SetTextBox(txt_Textbox, "MaxA1", mo_Tools.DblToScreen(mo_DPC_SubSys.MaxA1Value, 3), False)
  Call mo_Tools.SetTextBox(txt_Textbox, "LoadKNm2", mo_Tools.DblToScreen(mo_DPC_SubSys.LoadKNm2, 3), False, False)
  lbl_HangAlignBPossible.Visible = mo_DPC_SubSys.FallBPossible
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayHeader")
End Sub

Public Sub ItemSave()
On Error GoTo ErrHandler

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

Private Sub cbo_Subconst_ComboItemSelected()
On Error GoTo ErrHandler

Dim ls_req As String
Dim lc_Cursor As Long

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  ls_req = "exec DPC_SubArticle_sel $SUA_Id$, $COF_Lang$"
  ls_req = Replace(ls_req, "$SUA_Id$", mo_Tools.SqlStrKey(mo_Tools.GetComboKey(cbo_Subconst)), , , vbTextCompare)
  ls_req = ReplaceCommonPlaceholders(ls_req)
  lc_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_req)
  Call mo_DPC_SubSys.ReadSubconst(mo_CurrentSubArt, lc_Cursor)
  Call mo_Db.Close(lc_Cursor)
  Call mo_CurrentSubArt.CalculateRequiredQty(mo_DPC_SubSys.PUS_QtyM2, mo_DPC_SubSys.PUS_QtyPCS, mo_DPC_SubSys.PUS_A0, mo_DPC_SubSys.PUS_A1, mo_DPC_SubSys.PUS_A2)
  Call mo_DPC_SubSys.LoadSubArtPrice(mo_CurrentSubArt)
  'mo_CurrentSubArt.OfferPos.OFD_Qty = 0
  'mo_CurrentSubArt.OfferPos.OFD_QtyA = 0
  Call DisplaySubArtFrame(mo_CurrentSubArt)
  Call DisplayArtImage(mo_CurrentSubArt.IMG_Id)
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_Subconst_ComboItemSelected")
End Sub

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

Private Sub chk_FreeOfCharge_Click()
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  mo_DPC_SubSys.OFD_IsFree = (chk_FreeOfCharge.Value = vbChecked)
  Call mo_DPC_SubSys.CalcPositionPrice
  Call DisplayFooterPrice
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_FreeOfCharge_Click")
End Sub

Private Sub txt_OFD_Qty_Change()
On Error GoTo ErrHandler
  
'  If mb_InternalInit Then Exit Sub
'  Call mo_Tools.LockScreen(Me, True)
'  Call RecalculateSubconstDetailTotal
'  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_OFD_Qty_Change")
End Sub

Private Sub txt_OFD_Qty_Validate(Cancel As Boolean)
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  mo_CurrentSubArt.OfferPos.OFD_Qty = mo_Tools.ScreenToLong(txt_OFD_Qty.Text)
  Call mo_DPC_SubSys.LoadSubArtPrice(mo_CurrentSubArt)
  Call DisplaySubArtFrame(mo_CurrentSubArt)
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_OFD_Qty_Validate")
End Sub

Private Sub RecalculateSubconstDetailTotal()
On Error GoTo ErrHandler

  mo_CurrentSubArt.OfferPos.OFD_Qty = mo_Tools.ScreenToDbl(txt_OFD_Qty.Text)
  
  txt_OFD_TotalC.Text = mo_Tools.DblToScreen(mo_CurrentSubArt.OfferPos.OFD_TotalC)
  txt_OFD_TotalP.Text = mo_Tools.DblToScreen(mo_CurrentSubArt.OfferPos.OFD_TotalP)

  If mo_CurrentSubArt.OFD_QtySpare >= 0 Then
    txt_OFD_QtySpare.Text = mo_Tools.DblToScreen(mo_CurrentSubArt.OFD_QtySpare)
  Else
    txt_OFD_QtySpare.Text = ""
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("RecalculateSubconstDetailTotal")
End Sub

Private Sub txt_TextBox_GotFocus(Index As Integer)
On Error GoTo ErrHandler
  
  mb_CurrentTextBoxChanged = False
  txt_Textbox(Index).SelStart = 0
  txt_Textbox(Index).SelLength = Len(txt_Textbox(Index).Text)
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_TextBox_GotFocus")
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
  
  If Not mb_CurrentTextBoxChanged Then Exit Sub
  Call mo_Tools.LockScreen(Me, True)
  mb_InternalInit = True
  Select Case UCase(txt_Textbox(Index).Tag)
  Case UCase("PUS_QtyM2")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_QtyM2 = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text)
    txt_Textbox(Index).Text = mo_Tools.LongToScreen(mo_DPC_SubSys.PUS_QtyM2)
    Call DisplayHeader
'  Case UCase("OFD_Pos")
'    OFD_Pos = Val(txt_Textbox(Index).Text)
'    txt_Textbox(Index).Text = mo_Tools.LongToScreen(OFD_Pos)
  Case UCase("PUS_Height")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_Height = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text, 3)
    txt_Textbox(Index).Text = mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_Height, 3)
  Case UCase("PUS_A2")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_A2 = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text, 3)
    mo_DPC_SubSys.PUS_PanA = mo_DPC_SubSys.PUS_A2 - mo_DPC_SubSys.PUS_P
    Call mo_DPC_SubSys.CalculateHangerLimits
    mo_DPC_SubSys.PUS_A0 = mo_DPC_SubSys.MaxA0Value
    mo_DPC_SubSys.PUS_A1 = mo_DPC_SubSys.MaxA1Value
    Call DisplayHeader
  Case UCase("PUS_A1")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_A1 = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text, 3)
    txt_Textbox(Index).Text = mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_A1, 3)
  Case UCase("PUS_A0")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_A0 = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text, 3)
    txt_Textbox(Index).Text = mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_A0, 3)
  Case UCase("PUS_PanA")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_PanA = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text, 3)
    mo_DPC_SubSys.PUS_A2 = mo_DPC_SubSys.PUS_PanA + mo_DPC_SubSys.PUS_P
    Call mo_DPC_SubSys.CalculateHangerLimits
    Call DisplayHeader
  Case UCase("PUS_PanB")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_PanB = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text, 3)
    txt_Textbox(Index).Text = mo_Tools.DblToScreen(mo_DPC_SubSys.PUS_PanB, 3)
    Call DisplayHeader
  Case UCase("PUS_P")
    IsArticleSync = False
    mo_DPC_SubSys.PUS_P = mo_Tools.ScreenToDbl(txt_Textbox(Index).Text, 3)
     mo_DPC_SubSys.PUS_PanA = mo_DPC_SubSys.PUS_A2 - mo_DPC_SubSys.PUS_P
    Call mo_DPC_SubSys.CalculateHangerLimits
    mo_DPC_SubSys.PUS_A0 = mo_DPC_SubSys.MaxA0Value
    mo_DPC_SubSys.PUS_A1 = mo_DPC_SubSys.MaxA1Value
    Call DisplayHeader
  Case Else
    Err.Raise 0, "txt_Price(" & Index & ").Tag", "Unknown textbox tag:" & txt_Textbox(Index).Tag
  End Select
  mb_InternalInit = False
  mb_CurrentTextBoxChanged = False
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_TextBox_LostFocus")
End Sub

Private Sub cal_DeliveryDate_datechangee()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mo_DPC_SubSys.OFD_DelDat = cal_DeliveryDate.date_dt
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_DeliveryDate_datechangee")
End Sub

Private Sub cal_ShipDate_datechangee()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mo_DPC_SubSys.OFD_ShpDat = cal_ShipDate.date_dt
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_ShipDate_datechangee")
End Sub

Private Sub cal_WishDate_datechangee()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mo_DPC_SubSys.OFD_WshDat = cal_WishDate.date_dt
  Exit Sub
ErrHandler:
  Call ErrorMessage("cal_WishDate_datechangee")
End Sub

Private Sub txt_Price_GotFocus(Index As Integer)
On Error GoTo ErrHandler
  
  mb_CurrentTextBoxChanged = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_Price_GotFocus")
End Sub

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

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

Dim lo_Offer As DPC_OfferPos

  If mb_InternalInit Then Exit Sub
  If Not mb_CurrentTextBoxChanged Then Exit Sub
  
  mb_InternalInit = True
  Select Case txt_Price(Index).Tag
  Case "SUBPRICE_M"
    Set lo_Offer = mo_DPC_SubSys.GetOfferPos(eDPCOfferDetail.odSubconstPosition)
    lo_Offer.OFD_Cost = mo_Tools.ScreenToDbl(txt_Price(Index).Text)
  Case Else
    Err.Raise 0, "txt_Price(" & Index & ").Tag", "Unknown textbox tag:" & txt_Price(Index).Tag
  End Select
  mb_InternalInit = False
  mb_CurrentTextBoxChanged = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("txt_Price_LostFocus")
End Sub

Private Sub chk_PanelSecurity_Click()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  IsArticleSync = False
  mo_DPC_SubSys.PUS_PaSec = (chk_PanelSecurity.Value = vbChecked)
  Exit Sub
ErrHandler:
  Call ErrorMessage("chk_PanelSecurity_Click")
End Sub

Private Sub cbo_Vendor_ComboItemSelected()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  mo_DPC_SubSys.VEN_Id = mo_Tools.GetComboKey(cbo_Vendor)
  mo_DPC_SubSys.VEN_Name = cbo_Vendor.Text
  Call cbo_ShipPoint.Clear
  mo_DPC_SubSys.SHP_Id = 0
  mo_DPC_SubSys.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_DPC_SubSys.SHP_Id = mo_Tools.GetComboKey(cbo_ShipPoint)
  mo_DPC_SubSys.SHP_Name = cbo_ShipPoint.Text
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_ShipPoint_ComboItemSelected")
End Sub

Private Sub cbo_HangerAlignment_ComboItemSelected()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  IsArticleSync = False
  mo_DPC_SubSys.PUS_HaAlg = mo_Tools.GetComboKey(cbo_HangerAlignment)
  mo_DPC_SubSys.PUS_HaAlgDesc = cbo_HangerAlignment.Text
  Call mo_DPC_SubSys.CalculateHangerLimits
  mo_DPC_SubSys.PUS_A0 = mo_DPC_SubSys.MaxA0Value
  mo_DPC_SubSys.PUS_A1 = mo_DPC_SubSys.MaxA1Value
  Call DisplayHeader
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_HangerAlignment_ComboItemSelected")
End Sub

Private Sub cbo_HangerType_ComboItemSelected()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  IsArticleSync = False
  Call mo_DPC_SubSys.LoadHangerType(mo_DPC_SubSys.SYS_Id, mo_Tools.GetComboKey(cbo_HangerType))
  mo_DPC_SubSys.PUS_A0 = 0
  mo_DPC_SubSys.PUS_A1 = 0
  Call mo_DPC_SubSys.CalculateHangerLimits
  Call DisplaySuspImages
  Call DisplayHeader
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_HangerType_ComboItemSelected")
End Sub

Private Sub cbo_LoadCase_ComboItemSelected()
On Error GoTo ErrHandler

  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  IsArticleSync = False
  Call mo_DPC_SubSys.LoadHangerLoad(mo_DPC_SubSys.SYS_Id, mo_Tools.GetComboKey(cbo_LoadCase))
  Call mo_DPC_SubSys.CalculateHangerLimits
  mo_DPC_SubSys.PUS_A0 = mo_DPC_SubSys.MaxA0Value
  mo_DPC_SubSys.PUS_A1 = mo_DPC_SubSys.MaxA1Value
  Call DisplayHeader
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_LoadCase_ComboItemSelected")
End Sub

Private Sub cbo_SubType_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)
  
  ls_Request = "exec DPC_SubHangType_cbo $COF_Lang$, $SYS_Id$"
  ls_Request = Replace(ls_Request, "$SYS_Id$", mo_Tools.SqlInt(mo_Tools.GetComboKey(cbo_SubType)))
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  cbo_HangerType.Request = ls_Request
  
  ls_Request = "exec DPC_SysSubLoad_cbo $COF_Lang$, $SYS_Id$"
  ls_Request = Replace(ls_Request, "$SYS_Id$", mo_Tools.SqlInt(mo_Tools.GetComboKey(cbo_SubType)))
  ls_Request = ReplaceCommonPlaceholders(ls_Request)
  cbo_LoadCase.Request = ls_Request
  
  Call mo_DPC_SubSys.LoadSystem(mo_Tools.GetComboKey(cbo_SubType))
  mo_DPC_SubSys.PUS_A0 = 0
  mo_DPC_SubSys.PUS_A1 = 0
  If mo_DPC_SubSys.SYS_UseCPro Then
    mo_DPC_SubSys.PUS_P = 0.1
  End If
  Call mo_DPC_SubSys.CreateCode
  Call mo_DPC_SubSys.LoadSystemMargin
  
  Call DisplayHeader
  Call DisplaySuspImages
  Call DisplayArtImage(0)
  'Call mo_Tools.SetLabelText(lbl_Label, "lbl_A0", mo_DPC_SubSys.RF_DescA0)
  'Call mo_Tools.SetLabelText(lbl_Label, "lbl_A1", mo_DPC_SubSys.RF_DescA1)
  'Call mo_Tools.SetLabelText(lbl_Label, "lbl_A2", mo_DPC_SubSys.RF_DescA2)
  'Call SetSystem
  IsArticleSync = False
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("cbo_SubType_ComboItemSelected")
End Sub

Private Sub SetSystem()
On Error GoTo ErrHandler

Dim ls_Request As String
  
  Call cbo_HangerType.Clear
  cbo_HangerType.Enabled = (mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_DPC_SubSys.LoadHangerType(mo_DPC_SubSys.SYS_Id, 0)

  Call cbo_LoadCase.Clear
  cbo_LoadCase.Enabled = (mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_DPC_SubSys.LoadHangerLoad(mo_DPC_SubSys.SYS_Id, 0)
  
  Call cbo_HangerAlignment.Clear
  cbo_HangerAlignment.Enabled = (mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_DPC_SubSys.LoadHangerAlignment(0)
  
  Call mo_Tools.SetTextEnabled(txt_Textbox, "PUS_QtyM2", mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_Tools.SetTextEnabled(txt_Textbox, "PUS_Height", mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_Tools.SetTextEnabled(txt_Textbox, "PUS_A0", mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_Tools.SetTextEnabled(txt_Textbox, "PUS_A1", mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_Tools.SetTextEnabled(txt_Textbox, "PUS_A2", mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_Tools.SetTextEnabled(txt_Textbox, "PUS_PanA", mo_DPC_SubSys.SYS_Id <> 0)
  Call mo_Tools.SetTextEnabled(txt_Textbox, "PUS_PanB", mo_DPC_SubSys.SYS_Id <> 0)
  
  If mo_DPC_SubSys.SYS_PaSec Then
    chk_PanelSecurity.Enabled = True
  Else
    chk_PanelSecurity.Value = vbUnchecked
    chk_PanelSecurity.Enabled = False
    mo_DPC_SubSys.PUS_PaSec = False
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("SetSystem")
End Sub

Private Sub grd_Sub_Click()
On Error GoTo ErrHandler

  Call mo_Tools.LockScreen(Me, True)
  If grd_Sub.SelectedCount = 1 Then
    Call DisplayArtImage(grd_Sub.SelectedLine(0, "IMG_Id"))
  Else
    Call DisplayArtImage(0)
  End If
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("grd_Sub_Click")
End Sub

Private Sub grd_Sub_RowLoaded(ByVal al_Row As Long)
On Error GoTo ErrHandler

  If StrComp(grd_Sub.Data(al_Row, "SUS_Option"), "X", vbTextCompare) = 0 Then
    grd_Sub.LineColor(al_Row) = COLOR_SUBOPTION
  End If
  If StrComp(grd_Sub.Data(al_Row, "SUS_Replace"), "X", vbTextCompare) = 0 Then
    grd_Sub.LineColor(al_Row) = COLOR_SUBREPLACE
  End If
  Exit Sub
ErrHandler:
  Call ErrorMessage("grd_Sub_RowLoaded")
End Sub

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

Dim lo_Subart As DPC_SubArt
Dim ls_req As String

  Call mo_Tools.LockScreen(Me, True)
  Select Case as_Role
  Case "A"
    mb_InternalInit = True
    me_SubconstScreen = eDPCScreenMode.smAdd
    Call mo_Tools.ClearFrame(Controls, fra_SubArtDetail)
    Call mo_Tools.EnableFrame(Controls, fra_SubArtDetail, True)
    
    ls_req = "exec DPC_SubArticle_cbo $SYS_Id$,$SHT_Id$,$COF_Lang$"
    ls_req = Replace(ls_req, "$SYS_Id$", mo_Tools.SqlInt(mo_DPC_SubSys.SYS_Id), , , vbTextCompare)
    ls_req = Replace(ls_req, "$SHT_Id$", mo_Tools.SqlInt(mo_DPC_SubSys.SHT_Id), , , vbTextCompare)
    ls_req = ReplaceCommonPlaceholders(ls_req)
    cbo_Subconst.Request = ls_req
    Set mo_CurrentSubArt = New DPC_SubArt
    Call mo_DPC_SubSys.InitSubconst(mo_CurrentSubArt, eDPCOfferDetail.odSubconstItemAdditional, eDPCRowStatus.rsAdd)
    Call DisplaySubArtFrame(mo_CurrentSubArt)
    Call tlb_SubconstDetail.DisplayFace("0")
    Call EnableSubArtNavigation(True)
    Call EnableNavigation(False)
    mb_InternalInit = False
  Case "B"
    If grd_Sub.SelectedCount <> 1 Then
      Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9723, "#Please, select one item")
      Call mo_Tools.LockScreen(Me, False)
      Exit Sub
    End If
    mb_InternalInit = True
    me_SubconstScreen = eDPCScreenMode.smUpdate
    Call mo_Tools.ClearFrame(Controls, fra_SubArtDetail)
    
    Set lo_Subart = mo_DPC_SubSys.GetSubconst(Val(grd_Sub.SelectedLine(0, "SubIdx")))
    If Not lo_Subart Is Nothing Then
      
      Set mo_CurrentSubArt = New DPC_SubArt
      Call mo_DPC_SubSys.InitSubconst(mo_CurrentSubArt, lo_Subart.OfferPos.DOF_Id, eDPCRowStatus.rsUpdate)
      Call mo_CurrentSubArt.CopyFrom(lo_Subart)
      Call mo_Tools.EnableFrame(Controls, fra_SubArtDetail, True)
      
      Call DisplaySubArtFrame(mo_CurrentSubArt)
      Call tlb_SubconstDetail.DisplayFace("1")
      Call EnableSubArtNavigation(True)
      Call EnableNavigation(False)
    End If
    mb_InternalInit = False
    
  Case "C"
    If grd_Sub.SelectedCount <> 1 Then
      Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9723, "Please, select one item")
      Call mo_Tools.LockScreen(Me, False)
      Exit Sub
    End If
    me_SubconstScreen = eDPCScreenMode.smDelete
    mb_InternalInit = True
    Set mo_CurrentSubArt = mo_DPC_SubSys.GetSubconst(Val(grd_Sub.SelectedLine(0, "SubIdx")))
    If Not mo_CurrentSubArt Is Nothing Then
      Call mo_Tools.ClearFrame(Controls, fra_SubArtDetail)
      Call DisplaySubArtFrame(mo_CurrentSubArt)
      Call tlb_SubconstDetail.DisplayFace("2")
      Call mo_Tools.EnableFrame(Controls, fra_SubArtDetail, False)
      Call EnableSubArtNavigation(True)
      Call EnableNavigation(False)
    End If
    mb_InternalInit = False
  End Select
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("tlb_SubconstMain_action")
End Sub

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

Dim lo_ExistSubconst As DPC_SubArt
Dim ll_SubIdx As Long

  If mo_CurrentSubArt Is Nothing Then Exit Sub
  Call mo_Tools.LockScreen(Me, True)
  Select Case as_Role
  Case "H"
    Select Case me_SubconstScreen
    Case eDPCScreenMode.smAdd
      If Not CheckStepSubArtItem(mo_CurrentSubArt) Then
        Call mo_Tools.LockScreen(Me, False)
        Exit Sub
      End If
      Set lo_ExistSubconst = mo_DPC_SubSys.GetSubconstBySUA_Id(mo_CurrentSubArt.SUA_Id)
      If Not lo_ExistSubconst Is Nothing Then
        If lo_ExistSubconst.RowStatus <> eDPCRowStatus.rsDrop Then
          Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9725, "#This subconstruction item is already in the list")
          Call mo_Tools.LockScreen(Me, False)
          Exit Sub
        End If
      End If
      Call mo_DPC_SubSys.SubconstAdd(mo_CurrentSubArt)
      
    Case eDPCScreenMode.smUpdate
      If Not CheckStepSubArtItem(mo_CurrentSubArt) Then
        Call mo_Tools.LockScreen(Me, False)
        Exit Sub
      End If
      
      Set lo_ExistSubconst = mo_DPC_SubSys.GetSubconst(mo_CurrentSubArt.Idx)
      If lo_ExistSubconst Is Nothing Then
        Call mo_Tools.LockScreen(Me, False)
        Exit Sub
      Else
        Call lo_ExistSubconst.CopyFrom(mo_CurrentSubArt)
        Call mo_DPC_SubSys.SubconstUpdate(lo_ExistSubconst)
      End If
    Case eDPCScreenMode.smDelete
      Call mo_DPC_SubSys.SubconstDrop(mo_CurrentSubArt)
    Case Else
      Err.Raise 0, "tlb_SubconstDetail_action", "Invalid screen mode"
    End Select
    Call DisplaySubGrid
    Call DisplayFooterPrice
    Call EnableSubArtNavigation(False)
    Call EnableNavigation(True)
    Set mo_CurrentSubArt = Nothing
  Case "I"
    Select Case me_SubconstScreen
    Case eDPCScreenMode.smAdd
      Call mo_DPC_SubSys.InitSubconst(mo_CurrentSubArt, mo_CurrentSubArt.OfferPos.DOF_Id, eDPCRowStatus.rsAdd)
      Call DisplaySubArtFrame(mo_CurrentSubArt)
    Case eDPCScreenMode.smUpdate
      Set lo_ExistSubconst = mo_DPC_SubSys.GetSubconst(mo_CurrentSubArt.Idx)
      If Not lo_ExistSubconst Is Nothing Then
        Call mo_CurrentSubArt.CopyFrom(lo_ExistSubconst)
        Call DisplaySubArtFrame(mo_CurrentSubArt)
      End If
    End Select
  Case "T"
    Call EnableSubArtNavigation(False)
    Call EnableNavigation(True)
    Set mo_CurrentSubArt = Nothing
  End Select
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("tlb_SubconstDetail_action")
End Sub

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

  fra_SubArtDetail.Visible = ab_Enable
  tlb_SubconstMain.Enabled = Not ab_Enable
  grd_Sub.Enabled = Not ab_Enable
  If ab_Enable Then
    Call grd_Sub.Move(0, 0, tlb_SubconstMain.Left, fra_SubArtDetail.Top)
  Else
    Call grd_Sub.Move(0, 0, tlb_SubconstMain.Left, fra_SubArt.Height)
  End If
  
  If ab_Enable Then
    Call mo_Tools.EnableFrame(Controls, fra_SubArtDetail, False)
    tlb_SubconstDetail.Enabled = True
    If me_SubconstScreen = eDPCScreenMode.smAdd Then
      Call mo_Tools.EnableControl(cbo_Subconst, True)
      Call mo_Tools.EnableControl(txt_OFD_Qty, True)
    ElseIf me_SubconstScreen = eDPCScreenMode.smUpdate Then
      Call mo_Tools.EnableControl(txt_OFD_Qty, True)
    End If
  End If
  Exit Sub
ErrHandler:
  Call ErrorHandler("EnableSubArtNavigation")
End Sub

Private Sub DisplaySubArtFrame(ByVal ao_SubArt As DPC_SubArt)
On Error GoTo ErrHandler

  If Not cbo_Subconst.SearchItem(ao_SubArt.SUA_Id) Then
    Call cbo_Subconst.AddItem(Array(ao_SubArt.SUA_Id, ao_SubArt.PRD_Code & " " & ao_SubArt.PRD_Name & " " & ao_SubArt.PRD_Desc), True)
  End If
  txt_OFD_Qty.Text = mo_Tools.LongToScreen(ao_SubArt.OfferPos.OFD_Qty)
  txt_OFD_QtyA.Text = mo_Tools.LongToScreen(ao_SubArt.OfferPos.OFD_QtyA)
  
  If mo_CurrentSubArt.OFD_QtySpare >= 0 Then
    txt_OFD_QtySpare.Text = mo_Tools.DblToScreen(mo_CurrentSubArt.OFD_QtySpare * 100, 1)
  Else
    txt_OFD_QtySpare.Text = ""
  End If
  txt_SUA_TWgh.Text = mo_Tools.DblToScreen(ao_SubArt.SUA_TWght)
  
  txt_OFD_Price.Text = mo_Tools.DblToScreen(ao_SubArt.OfferPos.OFD_Price)
  txt_OFD_TotalP.Text = mo_Tools.DblToScreen(ao_SubArt.OfferPos.OFD_TotalP)
  
  txt_OFD_Cost.Text = mo_Tools.DblToScreen(ao_SubArt.OfferPos.OFD_Cost)
  txt_OFD_TotalC.Text = mo_Tools.DblToScreen(ao_SubArt.OfferPos.OFD_TotalC)

  
  txt_OFD_QtyAPCS.Text = mo_Tools.LongToScreen(ao_SubArt.OfferPos.OFD_QtyAPCS)
  txt_SUA_PU.Text = mo_Tools.LongToScreen(ao_SubArt.SUA_PU)
  txt_SUA_Bwrt.Text = mo_Tools.DblToScreen(ao_SubArt.SUA_Bwrt, 3)
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplaySubArtFrame")
End Sub

Private Sub SubconstObjToGrid(ByVal ao_SubArt As DPC_SubArt, ByVal al_Idx As Long)
On Error GoTo ErrHandler

Dim lo_Offer As DPC_OfferPos


    grd_Sub.Data(al_Idx, "SubIdx") = ao_SubArt.Idx
    grd_Sub.Data(al_Idx, "SUA_Id") = ao_SubArt.SUA_Id
    grd_Sub.Data(al_Idx, "DOF_Id") = ao_SubArt.OfferPos.DOF_Id
    grd_Sub.Data(al_Idx, "DOF_Name") = ao_SubArt.OfferPos.DOF_Name
    grd_Sub.Data(al_Idx, "PRD_Code") = ao_SubArt.PRD_Code
    grd_Sub.Data(al_Idx, "PRD_Name") = ao_SubArt.PRD_Name
    grd_Sub.Data(al_Idx, "PRD_Desc") = ao_SubArt.PRD_Desc
    
    grd_Sub.Data(al_Idx, "SUA_Bwrt") = ao_SubArt.SUA_Bwrt
    grd_Sub.Data(al_Idx, "PSA_NeedM2") = ao_SubArt.PSA_NeedM2
    grd_Sub.Data(al_Idx, "PSA_NeedPCS") = ao_SubArt.PSA_NeedPCS
    grd_Sub.Data(al_Idx, "UM_Code") = ao_SubArt.UM_Code
    grd_Sub.Data(al_Idx, "UM_Name") = ao_SubArt.UM_Name
    grd_Sub.Data(al_Idx, "SUA_PU") = ao_SubArt.SUA_PU
    
    grd_Sub.Data(al_Idx, "SUA_PUWgh") = ao_SubArt.SUA_PUWgh
    grd_Sub.Data(al_Idx, "SUA_TWght") = ao_SubArt.SUA_TWght
    
    If ao_SubArt.OfferPos.DOF_Id = eDPCOfferDetail.odSubconstItemAdditional Then
      grd_Sub.Data(al_Idx, "OFD_QtyASpare") = ""
    Else
      If ao_SubArt.OFD_QtyASpare < 0 Then
        grd_Sub.Data(al_Idx, "OFD_QtyASpare") = ""
        grd_Sub.CellColor(al_Idx, "OFD_QtyASpare") = vbRed
      ElseIf ao_SubArt.OFD_QtyASpare < 0.001 Then
        grd_Sub.Data(al_Idx, "OFD_QtyASpare") = 0
        grd_Sub.CellColor(al_Idx, "OFD_QtyASpare") = vbYellow
      Else
        grd_Sub.Data(al_Idx, "OFD_QtyASpare") = mo_Tools.DblToScreen(ao_SubArt.OFD_QtyASpare * 100, 1)
      End If
    End If
    If ao_SubArt.OfferPos.DOF_Id = eDPCOfferDetail.odSubconstItemAdditional Then
      grd_Sub.Data(al_Idx, "OFD_QtySpare") = ""
    Else
      If ao_SubArt.OFD_QtySpare < 0 Then
        grd_Sub.Data(al_Idx, "OFD_QtySpare") = ""
        grd_Sub.CellColor(al_Idx, "OFD_QtySpare") = vbRed
      ElseIf ao_SubArt.OFD_QtySpare < 0.001 Then
        grd_Sub.Data(al_Idx, "OFD_QtySpare") = 0
        grd_Sub.CellColor(al_Idx, "OFD_QtySpare") = vbYellow
      Else
        grd_Sub.Data(al_Idx, "OFD_QtySpare") = mo_Tools.DblToScreen(ao_SubArt.OFD_QtySpare * 100, 1)
      End If
    End If
    
    grd_Sub.Data(al_Idx, "OFD_QtyA") = ao_SubArt.OfferPos.OFD_QtyA
    grd_Sub.Data(al_Idx, "OFD_QtyAPCS") = ao_SubArt.OfferPos.OFD_QtyAPCS
    grd_Sub.Data(al_Idx, "OFD_Qty") = ao_SubArt.OfferPos.OFD_Qty
    grd_Sub.Data(al_Idx, "OFD_QtyPCS") = ao_SubArt.OfferPos.OFD_QtyPCS
    
    grd_Sub.Data(al_Idx, "OFD_Cost") = ao_SubArt.OfferPos.OFD_Cost
    grd_Sub.Data(al_Idx, "OFD_TotalC") = ao_SubArt.OfferPos.OFD_TotalC
    
    grd_Sub.Data(al_Idx, "OFD_Price") = ao_SubArt.OfferPos.OFD_Price
    grd_Sub.Data(al_Idx, "OFD_TotalP") = ao_SubArt.OfferPos.OFD_TotalP
    
    grd_Sub.Data(al_Idx, "SUA_MatDesc") = ao_SubArt.SUA_MatDesc
    grd_Sub.Data(al_Idx, "SUA_Type") = ao_SubArt.SUA_Type
    grd_Sub.Data(al_Idx, "IMG_Id") = ao_SubArt.IMG_Id
  Exit Sub
ErrHandler:
  Call ErrorHandler("SubconstObjToGrid")
End Sub

Private Sub DisplaySuspImages()
On Error GoTo ErrHandler

  Call mo_Tools.DrawDPCImage(mo_Db, mo_FSO, ms_DPCImageCachePath, mo_DPC_SubSys.IMG_Id, pct_SubType, "")
  Call mo_Tools.DrawDPCImage(mo_Db, mo_FSO, ms_DPCImageCachePath, mo_DPC_SubSys.IMG_IdSHT, pct_HangerType, "")
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplaySuspImages")
End Sub

Private Sub DisplayArtImage(ByVal al_IMG_Id As Long)
On Error GoTo ErrHandler

  Call mo_Tools.DrawDPCImage(mo_Db, mo_FSO, ms_DPCImageCachePath, al_IMG_Id, pct_Article, "")
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayArtImage")
End Sub

Private Sub SetPriceLabel(ByVal as_CURR_Code As String)
On Error GoTo ErrHandler

Dim ll_Idx As Long

  For ll_Idx = 0 To lbl_Price.Count - 1
    lbl_Price(ll_Idx).Caption = as_CURR_Code
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("SetPriceLabel")
End Sub

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

  fra_SubconstMain.Enabled = ab_Enable
  btn_Validate.Enabled = ab_Enable
  btn_Quit.Enabled = ab_Enable
  Exit Sub
ErrHandler:
  Call ErrorHandler("EnableNavigation")
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

