VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "mscomctl.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Begin VB.UserControl DPC_Ref_PDFGenerator 
   ClientHeight    =   12675
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   19470
   ScaleHeight     =   12675
   ScaleWidth      =   19470
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Perf Param Detail"
      Height          =   735
      Index           =   2
      Left            =   13920
      TabIndex        =   188
      Top             =   4320
      Width           =   3165
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   7
         Left            =   5880
         TabIndex        =   295
         Tag             =   "BPP_OverprfBordF2®©F®©lbl_OverprfBordF2"
         Top             =   7440
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   6
         Left            =   5880
         TabIndex        =   292
         Tag             =   "BPP_OverprfBordE2®©F®©lbl_OverprfBordE2"
         Top             =   6960
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   5
         Left            =   5880
         TabIndex        =   289
         Tag             =   "BPP_OverprfBordD2®©F®©lbl_OverprfBordD2"
         Top             =   6480
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   4
         Left            =   5880
         TabIndex        =   286
         Tag             =   "BPP_OverprfBordC2®©F®©lbl_OverprfBordC2"
         Top             =   6000
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   3
         Left            =   5880
         TabIndex        =   283
         Tag             =   "BPP_UnprfBordF2®©F®©lbl_UnprfBordF2"
         Top             =   5040
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   2
         Left            =   5880
         TabIndex        =   280
         Tag             =   "BPP_UnprfBordE2®©F®©lbl_UnprfBordE2"
         Top             =   4560
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   1
         Left            =   5880
         TabIndex        =   277
         Tag             =   "BPP_UnprfBordD2®©F®©lbl_UnprfBordD2"
         Top             =   4080
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerfBord 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   0
         Left            =   5880
         TabIndex        =   274
         Tag             =   "BPP_UnprfBordC2®©F®©lbl_UnprfBordC2"
         Top             =   3600
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdPerf_PRF_Id 
         Alignment       =   1  'Right Justify
         Height          =   375
         Left            =   8880
         TabIndex        =   271
         TabStop         =   0   'False
         Tag             =   "PRF_Id"
         Top             =   240
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Frame fra_PrdPerfParam 
         Height          =   2175
         Left            =   120
         TabIndex        =   222
         Tag             =   "fra_PrdBendDef"
         Top             =   1080
         Width           =   13455
         Begin VB.TextBox txt_PrdPerfSYS_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   229
            Tag             =   "SYS_Name"
            Top             =   240
            Width           =   6255
         End
         Begin VB.TextBox txt_PrdPerfPRD_Code 
            Height          =   375
            Left            =   1920
            TabIndex        =   228
            Tag             =   "PRD_Code"
            Top             =   720
            Width           =   1695
         End
         Begin VB.TextBox txt_PrdPerfPRD_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   227
            Tag             =   "PRD_Name"
            Top             =   1200
            Width           =   6255
         End
         Begin VB.TextBox txt_PrdPerfModA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   226
            Tag             =   "RPL_ModA"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdPerfModB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   225
            Tag             =   "RPL_ModB"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdPerfPanA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   224
            Tag             =   "RPL_PanA"
            Top             =   1200
            Width           =   975
         End
         Begin VB.TextBox txt_PrdPerfPanB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   223
            Tag             =   "RPL_PanB"
            Top             =   1200
            Width           =   975
         End
         Begin Project1.ArmCombobox cbo_PrdPerfPRF_Name 
            Height          =   345
            Left            =   1920
            TabIndex        =   273
            Tag             =   "PRF_Id®©PRF_Name"
            Top             =   1680
            Width           =   6255
            _ExtentX        =   11033
            _ExtentY        =   609
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Perforation"
            Height          =   255
            Index           =   60
            Left            =   120
            TabIndex        =   272
            Tag             =   "lbl_PRF_Name"
            Top             =   1800
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#System"
            Height          =   255
            Index           =   79
            Left            =   120
            TabIndex        =   236
            Tag             =   "lbl_System_Desc"
            Top             =   360
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article code"
            Height          =   255
            Index           =   78
            Left            =   120
            TabIndex        =   235
            Tag             =   "lbl_Product_Code"
            Top             =   840
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article name"
            Height          =   255
            Index           =   77
            Left            =   120
            TabIndex        =   234
            Tag             =   "lbl_Product_Name"
            Top             =   1320
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod A"
            Height          =   255
            Index           =   76
            Left            =   8400
            TabIndex        =   233
            Tag             =   "lbl_RPL_ModA"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod B"
            Height          =   255
            Index           =   75
            Left            =   10440
            TabIndex        =   232
            Tag             =   "lbl_RPL_ModB"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan A"
            Height          =   255
            Index           =   74
            Left            =   8400
            TabIndex        =   231
            Tag             =   "lbl_RPL_PanA"
            Top             =   1320
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan B"
            Height          =   255
            Index           =   73
            Left            =   10440
            TabIndex        =   230
            Tag             =   "lbl_RPL_PanB"
            Top             =   1320
            Width           =   975
         End
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   2
         Left            =   10200
         TabIndex        =   190
         TabStop         =   0   'False
         Top             =   600
         Visible         =   0   'False
         Width           =   615
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   2
         Left            =   10200
         TabIndex        =   189
         TabStop         =   0   'False
         Tag             =   "PRD_Id"
         Top             =   240
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   2
         Left            =   240
         TabIndex        =   191
         Top             =   240
         Width           =   4335
         _ExtentX        =   7646
         _ExtentY        =   1217
      End
      Begin MSComctlLib.TabStrip tbs_SubDetail 
         Height          =   375
         Index           =   2
         Left            =   5760
         TabIndex        =   192
         Tag             =   "tbs_basetype"
         Top             =   360
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
            NumTabs         =   1
            BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   0
         Left            =   2040
         TabIndex        =   275
         Tag             =   "DFO_Id_UnprfBordC2®©DFO_Formula_UnprfBordC2"
         Top             =   3600
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   1
         Left            =   2040
         TabIndex        =   278
         Tag             =   "DFO_Id_UnprfBordD2®©DFO_Formula_UnprfBordD2"
         Top             =   4080
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   2
         Left            =   2040
         TabIndex        =   281
         Tag             =   "DFO_Id_UnprfBordE2®©DFO_Formula_UnprfBordE2"
         Top             =   4560
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   3
         Left            =   2040
         TabIndex        =   284
         Tag             =   "DFO_Id_UnprfBordF2®©DFO_Formula_UnprfBordF2"
         Top             =   5040
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   4
         Left            =   2040
         TabIndex        =   287
         Tag             =   "DFO_Id_OverprfBordC2®©DFO_Formula_OverprfBordC2"
         Top             =   6000
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   5
         Left            =   2040
         TabIndex        =   290
         Tag             =   "DFO_Id_OverprfBordD2®©DFO_Formula_OverprfBordD2"
         Top             =   6480
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   6
         Left            =   2040
         TabIndex        =   293
         Tag             =   "DFO_Id_OverprfBordE2®©DFO_Formula_OverprfBordE2"
         Top             =   6960
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdPerfBord 
         Height          =   345
         Index           =   7
         Left            =   2040
         TabIndex        =   296
         Tag             =   "DFO_Id_OverprfBordF2®©DFO_Formula_OverprfBordF2"
         Top             =   7440
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Overperf. border F2"
         Height          =   255
         Index           =   100
         Left            =   240
         TabIndex        =   297
         Tag             =   "lbl_OverprfBordF2"
         Top             =   7560
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Overperf. border E2"
         Height          =   255
         Index           =   99
         Left            =   240
         TabIndex        =   294
         Tag             =   "lbl_OverprfBordE2"
         Top             =   7080
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Overperf. border D2"
         Height          =   255
         Index           =   98
         Left            =   240
         TabIndex        =   291
         Tag             =   "lbl_OverprfBordD2"
         Top             =   6600
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Overperf. border C2"
         Height          =   255
         Index           =   97
         Left            =   240
         TabIndex        =   288
         Tag             =   "lbl_OverprfBordC2"
         Top             =   6120
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Unperf. border F2"
         Height          =   255
         Index           =   96
         Left            =   240
         TabIndex        =   285
         Tag             =   "lbl_UnprfBordF2"
         Top             =   5160
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Unperf. border E2"
         Height          =   255
         Index           =   95
         Left            =   240
         TabIndex        =   282
         Tag             =   "lbl_UnprfBordE2"
         Top             =   4680
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Unperf. border D2"
         Height          =   255
         Index           =   94
         Left            =   240
         TabIndex        =   279
         Tag             =   "lbl_UnprfBordD2"
         Top             =   4200
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Unperf. border C2"
         Height          =   255
         Index           =   61
         Left            =   240
         TabIndex        =   276
         Tag             =   "lbl_UnprfBordC2"
         Top             =   3720
         Width           =   1815
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Cut Param Detail"
      Height          =   9375
      Index           =   3
      Left            =   4080
      TabIndex        =   193
      Top             =   3960
      Width           =   14085
      Begin VB.TextBox txt_PrdCutParamValue 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   5
         Left            =   5880
         TabIndex        =   331
         Tag             =   "BCP_K_Hz®©F®©lbl_K_Hz"
         Top             =   6120
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdCutParamValue 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   4
         Left            =   5880
         TabIndex        =   328
         Tag             =   "BCP_K_z®©F®©lbl_K_z"
         Top             =   5640
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdCutParamValue 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   3
         Left            =   5880
         TabIndex        =   325
         Tag             =   "BCP_J_Hz®©F®©lbl_J_Hz"
         Top             =   5160
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdCutParamValue 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   2
         Left            =   5880
         TabIndex        =   322
         Tag             =   "BCP_J_z®©F®©lbl_J_z"
         Top             =   4680
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdCutParamValue 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   1
         Left            =   5880
         TabIndex        =   319
         Tag             =   "BCP_C_zL®©F®©lbl_C_zL"
         Top             =   4200
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdCutParamValue 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   0
         Left            =   5880
         TabIndex        =   316
         Tag             =   "BCP_E_zM®©F®©lbl_E_zM"
         Top             =   3720
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdCutCUT_Id 
         Alignment       =   1  'Right Justify
         Height          =   375
         Left            =   9120
         TabIndex        =   315
         Tag             =   "CUT_Id"
         Top             =   240
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Frame fra_PrdCutParam 
         Height          =   2175
         Left            =   120
         TabIndex        =   298
         Tag             =   "fra_PrdCutParam"
         Top             =   1080
         Width           =   13455
         Begin VB.TextBox txt_PrdCutPanB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   305
            Tag             =   "RPL_PanB"
            Top             =   1200
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCutRPL_PanA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   304
            Tag             =   "RPL_PanA"
            Top             =   1200
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCutModB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   303
            Tag             =   "RPL_ModB"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCutRPL_ModA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   302
            Tag             =   "RPL_ModA"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCutPRD_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   301
            Tag             =   "PRD_Name"
            Top             =   1200
            Width           =   6255
         End
         Begin VB.TextBox txt_PrdCutPRD_Code 
            Height          =   375
            Left            =   1920
            TabIndex        =   300
            Tag             =   "PRD_Code"
            Top             =   720
            Width           =   1695
         End
         Begin VB.TextBox txt_PrdCutSYS_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   299
            Tag             =   "SYS_Name"
            Top             =   240
            Width           =   6255
         End
         Begin Project1.ArmCombobox cbo_PrdCut_CUT_Name 
            Height          =   345
            Left            =   1920
            TabIndex        =   306
            Tag             =   "CUT_Id®©CUT_Name"
            Top             =   1680
            Width           =   6255
            _ExtentX        =   11033
            _ExtentY        =   609
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan B"
            Height          =   255
            Index           =   108
            Left            =   10440
            TabIndex        =   314
            Tag             =   "lbl_RPL_PanB"
            Top             =   1320
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan A"
            Height          =   255
            Index           =   107
            Left            =   8400
            TabIndex        =   313
            Tag             =   "lbl_RPL_PanA"
            Top             =   1320
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod B"
            Height          =   255
            Index           =   106
            Left            =   10440
            TabIndex        =   312
            Tag             =   "lbl_RPL_ModB"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod A"
            Height          =   255
            Index           =   105
            Left            =   8400
            TabIndex        =   311
            Tag             =   "lbl_RPL_ModA"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article name"
            Height          =   255
            Index           =   104
            Left            =   120
            TabIndex        =   310
            Tag             =   "lbl_Product_Name"
            Top             =   1320
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article code"
            Height          =   255
            Index           =   103
            Left            =   120
            TabIndex        =   309
            Tag             =   "lbl_Product_Code"
            Top             =   840
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#System"
            Height          =   255
            Index           =   102
            Left            =   120
            TabIndex        =   308
            Tag             =   "lbl_System_Desc"
            Top             =   360
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Cutout"
            Height          =   255
            Index           =   101
            Left            =   120
            TabIndex        =   307
            Tag             =   "lbl_CUT_Name"
            Top             =   1800
            Width           =   1815
         End
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   3
         Left            =   10200
         TabIndex        =   195
         TabStop         =   0   'False
         Tag             =   "PRD_Id"
         Top             =   240
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   3
         Left            =   10200
         TabIndex        =   194
         TabStop         =   0   'False
         Top             =   600
         Visible         =   0   'False
         Width           =   615
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   3
         Left            =   240
         TabIndex        =   196
         Top             =   240
         Width           =   4335
         _ExtentX        =   7646
         _ExtentY        =   1217
      End
      Begin MSComctlLib.TabStrip tbs_SubDetail 
         Height          =   375
         Index           =   3
         Left            =   5760
         TabIndex        =   197
         Tag             =   "tbs_basetype"
         Top             =   360
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
            NumTabs         =   1
            BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
      Begin Project1.ArmCombobox cbo_PrdCutFormula 
         Height          =   345
         Index           =   0
         Left            =   2040
         TabIndex        =   317
         Tag             =   "DFO_Id_E_zM®©DFO_Formula_E_zM"
         Top             =   3720
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdCutFormula 
         Height          =   345
         Index           =   1
         Left            =   2040
         TabIndex        =   320
         Tag             =   "DFO_Id_C_zL®©DFO_Formula_C_zL"
         Top             =   4200
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdCutFormula 
         Height          =   345
         Index           =   2
         Left            =   2040
         TabIndex        =   323
         Tag             =   "DFO_Id_J_z®©DFO_Formula_J_z"
         Top             =   4680
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdCutFormula 
         Height          =   345
         Index           =   3
         Left            =   2040
         TabIndex        =   326
         Tag             =   "DFO_Id_J_Hz®©DFO_Formula_J_Hz"
         Top             =   5160
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdCutFormula 
         Height          =   345
         Index           =   4
         Left            =   2040
         TabIndex        =   329
         Tag             =   "DFO_Id_K_z®©DFO_Formula_K_z"
         Top             =   5640
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdCutFormula 
         Height          =   345
         Index           =   5
         Left            =   2040
         TabIndex        =   332
         Tag             =   "DFO_Id_K_Hz®©DFO_Formula_K_Hz"
         Top             =   6120
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin VB.Label lbl_label 
         Caption         =   "#K_Hz"
         Height          =   255
         Index           =   112
         Left            =   240
         TabIndex        =   333
         Tag             =   "lbl_K_Hz"
         Top             =   6240
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#K_z"
         Height          =   255
         Index           =   111
         Left            =   240
         TabIndex        =   330
         Tag             =   "lbl_K_z"
         Top             =   5760
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#J_Hz"
         Height          =   255
         Index           =   110
         Left            =   240
         TabIndex        =   327
         Tag             =   "lbl_J_Hz"
         Top             =   5280
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#J_z"
         Height          =   255
         Index           =   109
         Left            =   240
         TabIndex        =   324
         Tag             =   "lbl_J_z"
         Top             =   4800
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#C_zL"
         Height          =   255
         Index           =   63
         Left            =   240
         TabIndex        =   321
         Tag             =   "lbl_C_zL"
         Top             =   4320
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#E_zM"
         Height          =   255
         Index           =   62
         Left            =   240
         TabIndex        =   318
         Tag             =   "lbl_E_zM"
         Top             =   3840
         Width           =   1815
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "BaseType Detail"
      Height          =   615
      Index           =   0
      Left            =   13560
      TabIndex        =   9
      Top             =   840
      Width           =   1605
      Begin VB.TextBox txt_SPD_System 
         Alignment       =   1  'Right Justify
         Height          =   375
         Left            =   1920
         TabIndex        =   108
         Tag             =   "RF_Desc"
         Top             =   1080
         Width           =   2295
      End
      Begin VB.Frame fra_SubDetail 
         Height          =   7335
         Index           =   2
         Left            =   15360
         TabIndex        =   44
         Top             =   2280
         Width           =   10335
         Begin VB.TextBox txt_SubDetailKey 
            Height          =   375
            Index           =   2
            Left            =   960
            TabIndex        =   65
            TabStop         =   0   'False
            Tag             =   "SYS_BaeType"
            Text            =   "Text1"
            Top             =   240
            Visible         =   0   'False
            Width           =   1575
         End
         Begin VB.Frame fra_SubDetailItem 
            Height          =   2775
            Index           =   2
            Left            =   120
            TabIndex        =   45
            Top             =   360
            Width           =   14055
            Begin VB.TextBox txt_CutParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   5
               Left            =   13200
               TabIndex        =   52
               Tag             =   "BCP_K_Hz®©F®©lbl_BCP_K_Hz"
               Top             =   2160
               Width           =   615
            End
            Begin VB.TextBox txt_CutParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   4
               Left            =   13200
               TabIndex        =   51
               Tag             =   "BCP_K_z®©F®©lbl_BCP_K_z"
               Top             =   1800
               Width           =   615
            End
            Begin VB.TextBox txt_CutParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   1
               Left            =   6600
               TabIndex        =   50
               Tag             =   "BCP_C_zL®©F®©lbl_BCP_C_zl"
               Top             =   1200
               Width           =   615
            End
            Begin VB.TextBox txt_BCP_MatThick 
               Alignment       =   1  'Right Justify
               Height          =   375
               Left            =   1440
               TabIndex        =   49
               Tag             =   "RPL_Thick®©F®©lbl_BCP_MatThick"
               Top             =   360
               Width           =   735
            End
            Begin VB.TextBox txt_CutParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   3
               Left            =   6600
               TabIndex        =   48
               Tag             =   "BCP_J_Hz®©F®©lbl_BCP_J_Hz"
               Top             =   2160
               Width           =   615
            End
            Begin VB.TextBox txt_CutParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   2
               Left            =   6600
               TabIndex        =   47
               Tag             =   "BCP_J_z®©F®©lbl_BCP_J_z"
               Top             =   1800
               Width           =   615
            End
            Begin VB.TextBox txt_CutParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   0
               Left            =   6600
               TabIndex        =   46
               Tag             =   "BCP_E_zM®©F®©lbl_BCP_E_zM"
               Top             =   840
               Width           =   615
            End
            Begin Project1.ArmCombobox cbo_formula_cutparam 
               Height          =   345
               Index           =   0
               Left            =   1440
               TabIndex        =   53
               Tag             =   "DFO_Id_E_zM®©DFO_Formula_E_zM"
               Top             =   840
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_cutparam 
               Height          =   345
               Index           =   1
               Left            =   1440
               TabIndex        =   100
               Tag             =   "DFO_Id_C_zL®©DFO_Formula_C_zL"
               Top             =   1200
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_cutparam 
               Height          =   345
               Index           =   2
               Left            =   1440
               TabIndex        =   101
               Tag             =   "DFO_Id_J_z®©DFO_Formula_J_z"
               Top             =   1800
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_cutparam 
               Height          =   345
               Index           =   3
               Left            =   1440
               TabIndex        =   102
               Tag             =   "DFO_Id_J_Hz®©DFO_Formula_J_Hz"
               Top             =   2160
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_cutparam 
               Height          =   345
               Index           =   4
               Left            =   8160
               TabIndex        =   103
               Tag             =   "DFO_Id_K_z®©DFO_Formula_K_z"
               Top             =   1800
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_cutparam 
               Height          =   345
               Index           =   5
               Left            =   8160
               TabIndex        =   104
               Tag             =   "DFO_Id_K_Hz®©DFO_Formula_K_Hz"
               Top             =   2160
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_bcp_cutout 
               Height          =   345
               Left            =   6600
               TabIndex        =   110
               Tag             =   "CUT_Id®©CUT_Name"
               Top             =   360
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Cut Name"
               Height          =   255
               Index           =   37
               Left            =   5400
               TabIndex        =   109
               Tag             =   "lbl_BCP_Cut_Name"
               Top             =   480
               Width           =   975
            End
            Begin VB.Label lbl_label 
               Caption         =   "Const K-Hz"
               Height          =   255
               Index           =   35
               Left            =   12240
               TabIndex        =   106
               Tag             =   "lbl_BCP_K_Hz_Cnst"
               Top             =   2280
               Width           =   975
            End
            Begin VB.Label lbl_label 
               Caption         =   "#K-Hz"
               Height          =   255
               Index           =   34
               Left            =   7440
               TabIndex        =   105
               Tag             =   "lbl_BCP_K_Hz"
               Top             =   2280
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#K-z"
               Height          =   255
               Index           =   42
               Left            =   7440
               TabIndex        =   64
               Tag             =   "lbl_BCP_K_z"
               Top             =   1920
               Width           =   375
            End
            Begin VB.Label lbl_label 
               Caption         =   "Const J-Hz"
               Height          =   255
               Index           =   41
               Left            =   5400
               TabIndex        =   63
               Tag             =   "lbl_BCP_J_Hz_Cnst"
               Top             =   2280
               Width           =   1095
            End
            Begin VB.Label lbl_label 
               Caption         =   "Const K-z"
               Height          =   255
               Index           =   26
               Left            =   12240
               TabIndex        =   62
               Tag             =   "lbl_BCP_K_z_Cnst"
               Top             =   1920
               Width           =   1095
            End
            Begin VB.Label lbl_label 
               Caption         =   "Const C-zL"
               Height          =   255
               Index           =   18
               Left            =   5400
               TabIndex        =   61
               Tag             =   "lbl_BCP_C_zL_Cnst"
               Top             =   1320
               Width           =   1095
            End
            Begin VB.Label lbl_label 
               Caption         =   "#C-zL"
               Height          =   255
               Index           =   17
               Left            =   240
               TabIndex        =   60
               Tag             =   "lbl_BCP_C_zL"
               Top             =   1320
               Width           =   495
            End
            Begin VB.Label lbl_label 
               Caption         =   "#J-Hz"
               Height          =   255
               Index           =   16
               Left            =   240
               TabIndex        =   59
               Tag             =   "lbl_BCP_J_Hz"
               Top             =   2280
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#J-z"
               Height          =   255
               Index           =   15
               Left            =   240
               TabIndex        =   58
               Tag             =   "lbl_BCP_J_z"
               Top             =   1920
               Width           =   495
            End
            Begin VB.Label lbl_label 
               Caption         =   "Const E-zM"
               Height          =   255
               Index           =   14
               Left            =   5400
               TabIndex        =   57
               Tag             =   "lbl_BCP_E_zM_Cnst"
               Top             =   960
               Width           =   1095
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Material Thick"
               Height          =   255
               Index           =   13
               Left            =   240
               TabIndex        =   56
               Tag             =   "lbl_BCP_MatThick"
               Top             =   480
               Width           =   1215
            End
            Begin VB.Label lbl_label 
               Caption         =   "Const J-z"
               Height          =   255
               Index           =   12
               Left            =   5400
               TabIndex        =   55
               Tag             =   "lbl_BCP_J_z_Cnst"
               Top             =   1920
               Width           =   1095
            End
            Begin VB.Label lbl_label 
               Caption         =   "#E-zM"
               Height          =   255
               Index           =   11
               Left            =   240
               TabIndex        =   54
               Tag             =   "lbl_BCP_E_zM"
               Top             =   960
               Width           =   1215
            End
         End
         Begin Project1.ToolbarControl tlb_SubDetail 
            Height          =   2850
            Index           =   2
            Left            =   14280
            TabIndex        =   66
            Top             =   360
            Width           =   690
            _ExtentX        =   1217
            _ExtentY        =   5027
         End
         Begin Project1.ArmGrid grd_SubDetail 
            Height          =   3735
            Index           =   2
            Left            =   120
            TabIndex        =   67
            Tag             =   "grd_SubBcp"
            Top             =   3240
            Width           =   13695
            _ExtentX        =   24156
            _ExtentY        =   6588
         End
      End
      Begin VB.Frame fra_SubDetail 
         Height          =   7215
         Index           =   1
         Left            =   14280
         TabIndex        =   20
         Top             =   2280
         Width           =   2655
         Begin VB.Frame fra_SubDetailItem 
            Height          =   3255
            Index           =   1
            Left            =   120
            TabIndex        =   22
            Top             =   360
            Width           =   13695
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   11
               Left            =   12480
               TabIndex        =   88
               Tag             =   "BBP_Fz®©F®©lbl_BBP_Fz_Cnst"
               Top             =   2760
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   10
               Left            =   12480
               TabIndex        =   87
               Tag             =   "BBP_Fx®©F®©lbl_BBP_Fx_Cnst"
               Top             =   2400
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   9
               Left            =   12480
               TabIndex        =   86
               Tag             =   "BBP_Fy®©F®©lbl_BBP_Fy_Cnst"
               Top             =   2040
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   5
               Left            =   6240
               TabIndex        =   85
               Tag             =   "BBP_Dz®©F®©lbl_BBP_Dz_Cnst"
               Top             =   2760
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   4
               Left            =   6240
               TabIndex        =   84
               Tag             =   "BBP_Dx®©F®©lbl_BBP_Dx_Cnst"
               Top             =   2400
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   0
               Left            =   6240
               TabIndex        =   30
               Tag             =   "BBP_Cy®©F®©lbl_BBP_Cnst_Cy"
               Top             =   720
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   2
               Left            =   6240
               TabIndex        =   29
               Tag             =   "BBP_Cz®©F®©lbl_BBP_Cz_Cnst"
               Top             =   1440
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   6
               Left            =   12480
               TabIndex        =   28
               Tag             =   "BBP_Ey®©F®©lbl_BBP_Ey_Cnst"
               Top             =   720
               Width           =   615
            End
            Begin VB.TextBox txt_BBP_MatThick 
               Alignment       =   1  'Right Justify
               Height          =   375
               Left            =   1440
               TabIndex        =   27
               Tag             =   "RPL_Thick®©F®©lbl_BBP_MatThick"
               Top             =   240
               Width           =   855
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   1
               Left            =   6240
               TabIndex        =   26
               Tag             =   "BBP_Cx®©F®©lbl_BBP_Cx_Cnst"
               Top             =   1080
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   3
               Left            =   6240
               TabIndex        =   25
               Tag             =   "BBP_Dy®©F®©lbl_BBP_Dy_Cnst"
               Top             =   2040
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   7
               Left            =   12480
               TabIndex        =   24
               Tag             =   "BBP_Ex®©F®©lbl_BBP_Ex_Cnst"
               Top             =   1080
               Width           =   615
            End
            Begin VB.TextBox txt_BendParam_Cnst 
               Alignment       =   1  'Right Justify
               Height          =   330
               Index           =   8
               Left            =   12480
               TabIndex        =   23
               Tag             =   "BBP_Ez®©F®©lbl_BBP_Ez_Cnst"
               Top             =   1440
               Width           =   615
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   0
               Left            =   1440
               TabIndex        =   31
               Tag             =   "DFO_Id_Cy®©DFO_Formula_Cy"
               Top             =   720
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   1
               Left            =   1440
               TabIndex        =   69
               Tag             =   "DFO_Id_Cx®©DFO_Formula_Cx"
               Top             =   1080
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   2
               Left            =   1440
               TabIndex        =   72
               Tag             =   "DFO_Id_Cz®©DFO_Formula_Cz"
               Top             =   1440
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   3
               Left            =   1440
               TabIndex        =   73
               Tag             =   "DFO_Id_Dy®©DFO_Formula_Dy"
               Top             =   2040
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   4
               Left            =   1440
               TabIndex        =   74
               Tag             =   "DFO_Id_Dx®©DFO_Formula_Dx"
               Top             =   2400
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   5
               Left            =   1440
               TabIndex        =   75
               Tag             =   "DFO_Id_Dz®©DFO_Formula_Dz"
               Top             =   2760
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   6
               Left            =   7800
               TabIndex        =   76
               Tag             =   "DFO_Id_Ey®©DFO_Formula_Ey"
               Top             =   720
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   7
               Left            =   7800
               TabIndex        =   79
               Tag             =   "DFO_Id_Ex®©DFO_Formula_Ex"
               Top             =   1080
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   8
               Left            =   7800
               TabIndex        =   80
               Tag             =   "DFO_Id_Ez®©DFO_Formula_Ez"
               Top             =   1440
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   9
               Left            =   7800
               TabIndex        =   81
               Tag             =   "DFO_Id_Fy®©DFO_Formula_Fy"
               Top             =   2040
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   10
               Left            =   7800
               TabIndex        =   82
               Tag             =   "DFO_Id_Fx®©DFO_Formula_Fx"
               Top             =   2400
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_formula_bendparam 
               Height          =   345
               Index           =   11
               Left            =   7800
               TabIndex        =   83
               Tag             =   "DFO_Id_Fz®©DFO_Formula_Fz"
               Top             =   2760
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Fz"
               Height          =   255
               Index           =   33
               Left            =   7080
               TabIndex        =   99
               Tag             =   "lbl_BBP_Fz"
               Top             =   2880
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Fy"
               Height          =   255
               Index           =   32
               Left            =   7080
               TabIndex        =   98
               Tag             =   "lbl_BBP_Fy"
               Top             =   2160
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Fx"
               Height          =   255
               Index           =   31
               Left            =   7080
               TabIndex        =   97
               Tag             =   "lbl_BBP_Fx"
               Top             =   2520
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Dz"
               Height          =   255
               Index           =   30
               Left            =   240
               TabIndex        =   96
               Tag             =   "lbl_BBP_Dz"
               Top             =   2880
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Dy"
               Height          =   255
               Index           =   29
               Left            =   240
               TabIndex        =   95
               Tag             =   "lbl_BBP_Dy"
               Top             =   2160
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Dx"
               Height          =   255
               Index           =   28
               Left            =   240
               TabIndex        =   94
               Tag             =   "lbl_BBP_Dx"
               Top             =   2520
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Fz"
               Height          =   255
               Index           =   27
               Left            =   11760
               TabIndex        =   93
               Tag             =   "lbl_BBP_Fz_Cnst"
               Top             =   2880
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Fx"
               Height          =   255
               Index           =   25
               Left            =   11760
               TabIndex        =   92
               Tag             =   "lbl_BBP_Fx_Cnst"
               Top             =   2520
               Width           =   735
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Fy"
               Height          =   255
               Index           =   24
               Left            =   11760
               TabIndex        =   91
               Tag             =   "lbl_BBP_Fy_Cnst"
               Top             =   2160
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Dz"
               Height          =   255
               Index           =   23
               Left            =   5400
               TabIndex        =   90
               Tag             =   "lbl_BBP_Dz_Cnst"
               Top             =   2880
               Width           =   735
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Dx"
               Height          =   255
               Index           =   22
               Left            =   5400
               TabIndex        =   89
               Tag             =   "lbl_BBP_Dx_Cnst"
               Top             =   2520
               Width           =   735
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Ez"
               Height          =   255
               Index           =   21
               Left            =   7080
               TabIndex        =   78
               Tag             =   "lbl_BBP_Ez"
               Top             =   1560
               Width           =   495
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Ex"
               Height          =   255
               Index           =   20
               Left            =   7080
               TabIndex        =   77
               Tag             =   "lbl_BBP_Ex"
               Top             =   1200
               Width           =   495
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Cz"
               Height          =   255
               Index           =   19
               Left            =   240
               TabIndex        =   71
               Tag             =   "lbl_BBP_Cz"
               Top             =   1560
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Cx"
               Height          =   255
               Index           =   4
               Left            =   240
               TabIndex        =   70
               Tag             =   "lbl_BBP_Cx"
               Top             =   1200
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Cy"
               Height          =   255
               Index           =   10
               Left            =   240
               TabIndex        =   41
               Tag             =   "lbl_BBP_Cy"
               Top             =   840
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Ey"
               Height          =   255
               Index           =   9
               Left            =   7080
               TabIndex        =   40
               Tag             =   "lbl_BBP_Ey"
               Top             =   840
               Width           =   495
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Material Thick"
               Height          =   255
               Index           =   8
               Left            =   240
               TabIndex        =   39
               Tag             =   "lbl_BBP_MatThick"
               Top             =   360
               Width           =   1215
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Cy"
               Height          =   255
               Index           =   7
               Left            =   5400
               TabIndex        =   38
               Tag             =   "lbl_BBP_Cy_Cnst"
               Top             =   840
               Width           =   855
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Cz"
               Height          =   255
               Index           =   6
               Left            =   5400
               TabIndex        =   37
               Tag             =   "lbl_BBP_Cz_Cnst"
               Top             =   1560
               Width           =   735
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Ey"
               Height          =   255
               Index           =   5
               Left            =   11760
               TabIndex        =   36
               Tag             =   "lbl_BBP_Ey_Cnst"
               Top             =   840
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Cx"
               Height          =   255
               Index           =   3
               Left            =   5400
               TabIndex        =   35
               Tag             =   "lbl_BBP_Cx_Cnst"
               Top             =   1200
               Width           =   855
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Dy"
               Height          =   255
               Index           =   2
               Left            =   5400
               TabIndex        =   34
               Tag             =   "lbl_BBP_Dy_Cnst"
               Top             =   2160
               Width           =   855
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Ex"
               Height          =   255
               Index           =   1
               Left            =   11760
               TabIndex        =   33
               Tag             =   "lbl_BBP_Ex_Cnst"
               Top             =   1200
               Width           =   615
            End
            Begin VB.Label lbl_label 
               Caption         =   "Cnst Ez"
               Height          =   255
               Index           =   0
               Left            =   11760
               TabIndex        =   32
               Tag             =   "lbl_BBP_Ez_Cnst"
               Top             =   1560
               Width           =   615
            End
         End
         Begin VB.TextBox txt_SubDetailKey 
            Height          =   375
            Index           =   1
            Left            =   960
            TabIndex        =   21
            TabStop         =   0   'False
            Tag             =   "SYS_BaeType"
            Text            =   "Text1"
            Top             =   240
            Visible         =   0   'False
            Width           =   1575
         End
         Begin Project1.ToolbarControl tlb_SubDetail 
            Height          =   2850
            Index           =   1
            Left            =   13920
            TabIndex        =   42
            Top             =   360
            Width           =   690
            _ExtentX        =   1217
            _ExtentY        =   5027
         End
         Begin Project1.ArmGrid grd_SubDetail 
            Height          =   3375
            Index           =   1
            Left            =   120
            TabIndex        =   43
            Tag             =   "grd_SubBbp"
            Top             =   3720
            Width           =   13695
            _ExtentX        =   24156
            _ExtentY        =   5953
         End
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   0
         Left            =   10200
         TabIndex        =   19
         TabStop         =   0   'False
         Top             =   600
         Visible         =   0   'False
         Width           =   615
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   0
         Left            =   10200
         TabIndex        =   17
         TabStop         =   0   'False
         Tag             =   "RF_Code"
         Top             =   240
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.Frame fra_SubDetail 
         Height          =   7215
         Index           =   0
         Left            =   480
         TabIndex        =   10
         Top             =   2160
         Width           =   15255
         Begin VB.TextBox txt_SubDetailKey 
            Height          =   375
            Index           =   0
            Left            =   960
            TabIndex        =   14
            TabStop         =   0   'False
            Text            =   "Text1"
            Top             =   240
            Visible         =   0   'False
            Width           =   1575
         End
         Begin VB.Frame fra_SubDetailItem 
            Height          =   2895
            Index           =   0
            Left            =   120
            TabIndex        =   11
            Top             =   360
            Width           =   14415
            Begin VB.Frame frm_Perf 
               Caption         =   "#Perforated Sides"
               Height          =   1935
               Left            =   7200
               TabIndex        =   130
               Tag             =   "lbl_BPP_Perf"
               Top             =   840
               Width           =   6975
               Begin VB.TextBox txt_BPP_OverprfBordF 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   138
                  Tag             =   "BPP_OverprfBordF®©F®©lbl_BPP_CnstF"
                  Top             =   1440
                  Width           =   735
               End
               Begin VB.TextBox txt_BPP_OverprfBordE 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   137
                  Tag             =   "BPP_OverprfBordE®©F®©lbl_BPP_CnstE"
                  Top             =   1080
                  Width           =   735
               End
               Begin VB.TextBox txt_BPP_OverprfBordD 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   136
                  Tag             =   "BPP_OverprfBordD®©F®©lbl_BPP_CnstD"
                  Top             =   720
                  Width           =   735
               End
               Begin VB.TextBox txt_BPP_OverprfBordC 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   135
                  Tag             =   "BPP_OverprfBordC®©F®©lbl_BPP_CnstC"
                  Top             =   360
                  Width           =   735
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   4
                  Left            =   1320
                  TabIndex        =   139
                  Tag             =   "DFO_Id_OverprfBordC®©DFO_Formula_OverprfBordC"
                  Top             =   360
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   5
                  Left            =   1320
                  TabIndex        =   140
                  Tag             =   "DFO_Id_OverprfBordD®©DFO_Formula_OverprfBordD"
                  Top             =   720
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   6
                  Left            =   1320
                  TabIndex        =   141
                  Tag             =   "DFO_Id_OverprfBordE®©DFO_Formula_OverprfBordE"
                  Top             =   1080
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   7
                  Left            =   1320
                  TabIndex        =   142
                  Tag             =   "DFO_Id_OverprfBordF®©DFO_Formula_OverprfBordF"
                  Top             =   1440
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side F"
                  Height          =   255
                  Index           =   56
                  Left            =   120
                  TabIndex        =   146
                  Tag             =   "lbl_BPP_SideF"
                  Top             =   1560
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side E"
                  Height          =   255
                  Index           =   55
                  Left            =   120
                  TabIndex        =   145
                  Tag             =   "lbl_BPP_SideE"
                  Top             =   1200
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side D"
                  Height          =   255
                  Index           =   54
                  Left            =   120
                  TabIndex        =   144
                  Tag             =   "lbl_BPP_SideD"
                  Top             =   840
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side C"
                  Height          =   255
                  Index           =   53
                  Left            =   120
                  TabIndex        =   143
                  Tag             =   "lbl_BPP_SideC"
                  Top             =   480
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const F"
                  Height          =   255
                  Index           =   52
                  Left            =   5280
                  TabIndex        =   134
                  Tag             =   "lbl_BPP_CnstF"
                  Top             =   1560
                  Width           =   735
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const E"
                  Height          =   255
                  Index           =   51
                  Left            =   5280
                  TabIndex        =   133
                  Tag             =   "lbl_BPP_CnstE"
                  Top             =   1200
                  Width           =   735
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const D"
                  Height          =   255
                  Index           =   50
                  Left            =   5280
                  TabIndex        =   132
                  Tag             =   "lbl_BPP_CnstD"
                  Top             =   840
                  Width           =   735
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const C"
                  Height          =   255
                  Index           =   49
                  Left            =   5280
                  TabIndex        =   131
                  Tag             =   "lbl_BPP_CnstC"
                  Top             =   480
                  Width           =   735
               End
            End
            Begin VB.Frame frm_Unperf 
               Caption         =   "#Unperforated Sides"
               Height          =   1935
               Left            =   120
               TabIndex        =   113
               Tag             =   "lbl_BPP_Unperf"
               Top             =   840
               Width           =   6975
               Begin VB.TextBox txt_BPP_UnprfBordF 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   121
                  Tag             =   "BPP_UnprfBordF®©F®©lbl_BPP_CnstF"
                  Top             =   1440
                  Width           =   735
               End
               Begin VB.TextBox txt_BPP_UnprfBordE 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   120
                  Tag             =   "BPP_UnprfBordE®©F®©lbl_BPP_CnstE"
                  Top             =   1080
                  Width           =   735
               End
               Begin VB.TextBox txt_BPP_UnprfBordD 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   119
                  Tag             =   "BPP_UnprfBordD®©F®©lbl_BPP_CnstD"
                  Top             =   720
                  Width           =   735
               End
               Begin VB.TextBox txt_BPP_UnprfBordC 
                  Alignment       =   1  'Right Justify
                  Height          =   330
                  Left            =   6120
                  TabIndex        =   118
                  Tag             =   "BPP_UnprfBordC®©F®©lbl_BPP_CnstC"
                  Top             =   360
                  Width           =   735
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   0
                  Left            =   1320
                  TabIndex        =   122
                  Tag             =   "DFO_Id_UnprfBordC®©DFO_Formula_UnprfBordC"
                  Top             =   360
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   1
                  Left            =   1320
                  TabIndex        =   124
                  Tag             =   "DFO_Id_UnprfBordD®©DFO_Formula_UnprfBordD"
                  Top             =   720
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   2
                  Left            =   1320
                  TabIndex        =   125
                  Tag             =   "DFO_Id_UnprfBordE®©DFO_Formula_UnprfBordE"
                  Top             =   1080
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin Project1.ArmCombobox cbo_formula_prfparam 
                  Height          =   345
                  Index           =   3
                  Left            =   1320
                  TabIndex        =   126
                  Tag             =   "DFO_Id_UnprfBordF®©DFO_Formula_UnprfBordF"
                  Top             =   1440
                  Width           =   3855
                  _ExtentX        =   6800
                  _ExtentY        =   609
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side F"
                  Height          =   255
                  Index           =   48
                  Left            =   120
                  TabIndex        =   129
                  Tag             =   "lbl_BPP_SideF"
                  Top             =   1560
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side E"
                  Height          =   255
                  Index           =   47
                  Left            =   120
                  TabIndex        =   128
                  Tag             =   "lbl_BPP_SideE"
                  Top             =   1200
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side D"
                  Height          =   255
                  Index           =   46
                  Left            =   120
                  TabIndex        =   127
                  Tag             =   "lbl_BPP_SideD"
                  Top             =   840
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Side C"
                  Height          =   255
                  Index           =   45
                  Left            =   120
                  TabIndex        =   123
                  Tag             =   "lbl_BPP_SideC"
                  Top             =   480
                  Width           =   1095
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const F"
                  Height          =   255
                  Index           =   44
                  Left            =   5280
                  TabIndex        =   117
                  Tag             =   "lbl_BPP_CnstF"
                  Top             =   1560
                  Width           =   735
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const E"
                  Height          =   255
                  Index           =   43
                  Left            =   5280
                  TabIndex        =   116
                  Tag             =   "lbl_BPP_CnstE"
                  Top             =   1200
                  Width           =   735
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const D"
                  Height          =   255
                  Index           =   40
                  Left            =   5280
                  TabIndex        =   115
                  Tag             =   "lbl_BPP_CnstD"
                  Top             =   840
                  Width           =   735
               End
               Begin VB.Label lbl_label 
                  Caption         =   "#Const C"
                  Height          =   255
                  Index           =   39
                  Left            =   5280
                  TabIndex        =   114
                  Tag             =   "lbl_BPP_CnstC"
                  Top             =   480
                  Width           =   735
               End
            End
            Begin VB.TextBox txt_BPP_MatThick 
               Alignment       =   1  'Right Justify
               Height          =   375
               Left            =   1680
               TabIndex        =   112
               Tag             =   "RPL_Thick®©F®©lbl_BPP_MatThick"
               Top             =   360
               Width           =   735
            End
            Begin Project1.ArmCombobox cbo_Perforation 
               Height          =   345
               Left            =   4200
               TabIndex        =   12
               Tag             =   "PRF_Id®©PRF_Name"
               Top             =   360
               Width           =   3855
               _ExtentX        =   6800
               _ExtentY        =   609
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Material Thick"
               Height          =   255
               Index           =   38
               Left            =   240
               TabIndex        =   111
               Tag             =   "lbl_BPP_MatThick"
               Top             =   480
               Width           =   1215
            End
            Begin VB.Label lbl_label 
               Caption         =   "#Perforation"
               Height          =   255
               Index           =   59
               Left            =   2520
               TabIndex        =   13
               Tag             =   "lbl_BPP_Perforation"
               Top             =   480
               Width           =   1695
            End
         End
         Begin Project1.ToolbarControl tlb_SubDetail 
            Height          =   2850
            Index           =   0
            Left            =   13920
            TabIndex        =   15
            Top             =   360
            Width           =   690
            _ExtentX        =   1217
            _ExtentY        =   5027
         End
         Begin Project1.ArmGrid grd_SubDetail 
            Height          =   3735
            Index           =   0
            Left            =   120
            TabIndex        =   16
            Tag             =   "grd_SubSpd"
            Top             =   3360
            Width           =   13695
            _ExtentX        =   24156
            _ExtentY        =   6588
         End
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   0
         Left            =   240
         TabIndex        =   18
         Top             =   240
         Width           =   4335
         _ExtentX        =   7646
         _ExtentY        =   1217
      End
      Begin MSComctlLib.TabStrip tbs_SubDetail 
         Height          =   375
         Index           =   0
         Left            =   120
         TabIndex        =   68
         Tag             =   "tbs_basetype"
         Top             =   1680
         Width           =   18015
         _ExtentX        =   31776
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
            NumTabs         =   3
            BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               Caption         =   "#BaseTypePerfParam"
               Key             =   "prfpar"
               ImageVarType    =   2
            EndProperty
            BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               Caption         =   "#BaseTypeBendParam"
               Key             =   "bndpar"
               ImageVarType    =   2
            EndProperty
            BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               Caption         =   "#BaseTypeCutParam"
               Key             =   "cutpar"
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Base Type"
         Height          =   255
         Index           =   36
         Left            =   360
         TabIndex        =   107
         Tag             =   "lbl_BaseType_Desc"
         Top             =   1200
         Width           =   1215
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "CAD Export Detail"
      Height          =   1095
      Index           =   4
      Left            =   14040
      TabIndex        =   198
      Top             =   1800
      Width           =   2805
      Begin VB.Frame fra_PrdCADExport_Group 
         Caption         =   "Group"
         Height          =   1215
         Left            =   240
         TabIndex        =   252
         Tag             =   "fra_CADExport_Group"
         Top             =   3000
         Width           =   13455
         Begin Project1.ArmCombobox cbo_PrdCADExportPRD_Name 
            Height          =   345
            Left            =   1920
            TabIndex        =   262
            Tag             =   "PRD_IdGroup®©PRD_NameGroup"
            Top             =   240
            Width           =   6255
            _ExtentX        =   11033
            _ExtentY        =   609
         End
         Begin VB.TextBox txt_PrdCADExportRPL_PanB2 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   256
            Tag             =   "RPL_PanBGroup"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCADExportRPL_PanA2 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   255
            Tag             =   "RPL_PanAGroup"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCADExportRPL_ModB2 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   254
            Tag             =   "RPL_ModBGroup"
            Top             =   240
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCADExportRPL_ModA2 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   253
            Tag             =   "RPL_ModAGroup"
            Top             =   240
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan B"
            Height          =   255
            Index           =   93
            Left            =   10440
            TabIndex        =   261
            Tag             =   "lbl_RPL_PanB"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan A"
            Height          =   255
            Index           =   92
            Left            =   8400
            TabIndex        =   260
            Tag             =   "lbl_RPL_PanA"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod B"
            Height          =   255
            Index           =   91
            Left            =   10440
            TabIndex        =   259
            Tag             =   "lbl_RPL_ModB"
            Top             =   360
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod A"
            Height          =   255
            Index           =   90
            Left            =   8400
            TabIndex        =   258
            Tag             =   "lbl_RPL_ModA"
            Top             =   360
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article name"
            Height          =   255
            Index           =   89
            Left            =   120
            TabIndex        =   257
            Tag             =   "`"
            Top             =   360
            Width           =   1815
         End
      End
      Begin VB.Frame fra_PrdCADExport 
         Height          =   1695
         Left            =   240
         TabIndex        =   237
         Tag             =   "fra_CADExport_Article"
         Top             =   1080
         Width           =   13455
         Begin VB.TextBox txt_PrdCADExportSYS_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   244
            Tag             =   "SYS_Name"
            Top             =   240
            Width           =   6255
         End
         Begin VB.TextBox txt_PrdCADExportPRD_Code 
            Height          =   375
            Left            =   1920
            TabIndex        =   243
            Tag             =   "PRD_Code"
            Top             =   720
            Width           =   1695
         End
         Begin VB.TextBox txt_PrdCADExportPRD_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   242
            Tag             =   "PRD_Name"
            Top             =   1200
            Width           =   6255
         End
         Begin VB.TextBox txt_PrdCADExportRPL_ModA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   241
            Tag             =   "RPL_ModA"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCADExportRPL_ModB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   240
            Tag             =   "RPL_ModB"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCADExportRPL_PanA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   239
            Tag             =   "RPL_PanA"
            Top             =   1200
            Width           =   975
         End
         Begin VB.TextBox txt_PrdCADExportRPL_PanB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   238
            Tag             =   "RPL_PanB"
            Top             =   1200
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#System"
            Height          =   255
            Index           =   86
            Left            =   120
            TabIndex        =   251
            Tag             =   "lbl_System_Desc"
            Top             =   360
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article code"
            Height          =   255
            Index           =   85
            Left            =   120
            TabIndex        =   250
            Tag             =   "lbl_Product_Code"
            Top             =   840
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article name"
            Height          =   255
            Index           =   84
            Left            =   120
            TabIndex        =   249
            Tag             =   "lbl_Product_Name"
            Top             =   1320
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod A"
            Height          =   255
            Index           =   83
            Left            =   8400
            TabIndex        =   248
            Tag             =   "lbl_RPL_ModA"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod B"
            Height          =   255
            Index           =   82
            Left            =   10440
            TabIndex        =   247
            Tag             =   "lbl_RPL_ModB"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan A"
            Height          =   255
            Index           =   81
            Left            =   8400
            TabIndex        =   246
            Tag             =   "lbl_RPL_PanA"
            Top             =   1320
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan B"
            Height          =   255
            Index           =   80
            Left            =   10440
            TabIndex        =   245
            Tag             =   "lbl_RPL_PanB"
            Top             =   1320
            Width           =   975
         End
      End
      Begin VB.TextBox txt_PRD_LayCADFile 
         Height          =   405
         Left            =   2160
         TabIndex        =   202
         Tag             =   "PRD_LayCADFile"
         Top             =   4920
         Width           =   4575
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   4
         Left            =   10200
         TabIndex        =   201
         TabStop         =   0   'False
         Tag             =   "PRD_Id"
         Top             =   240
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   4
         Left            =   10200
         TabIndex        =   200
         TabStop         =   0   'False
         Top             =   600
         Visible         =   0   'False
         Width           =   615
      End
      Begin VB.TextBox txt_PRD_CADFile 
         Height          =   375
         Left            =   2160
         TabIndex        =   199
         Tag             =   "PRD_CADFile"
         Top             =   4440
         Width           =   4575
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   4
         Left            =   240
         TabIndex        =   203
         Top             =   240
         Width           =   4335
         _ExtentX        =   7646
         _ExtentY        =   1217
      End
      Begin MSComctlLib.TabStrip tbs_SubDetail 
         Height          =   375
         Index           =   4
         Left            =   5760
         TabIndex        =   204
         Tag             =   "tbs_basetype"
         Top             =   360
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
            NumTabs         =   1
            BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
      Begin VB.Label lbl_label 
         Caption         =   "#CAD File"
         Height          =   255
         Index           =   65
         Left            =   360
         TabIndex        =   206
         Tag             =   "lbl_PrdCADFile_Desc"
         Top             =   4560
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#CAD Layout File"
         Height          =   255
         Index           =   64
         Left            =   360
         TabIndex        =   205
         Tag             =   "lbl_PrdLayCADFile_Desc"
         Top             =   5040
         Width           =   1815
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Bend Param Detail"
      Height          =   855
      Index           =   1
      Left            =   13800
      TabIndex        =   154
      Top             =   2400
      Width           =   2925
      Begin VB.TextBox txt_PrdBendPR 
         Alignment       =   1  'Right Justify
         Height          =   405
         Index           =   3
         Left            =   5880
         TabIndex        =   268
         Tag             =   "BBP_FzPR®©F®©lbl_BBP_FzPR"
         Top             =   4800
         Width           =   1095
      End
      Begin VB.TextBox txt_PrdBendPR 
         Alignment       =   1  'Right Justify
         Height          =   405
         Index           =   2
         Left            =   5880
         TabIndex        =   265
         Tag             =   "BBP_EzPR®©F®©lbl_BBP_EzPR"
         Top             =   4320
         Width           =   1095
      End
      Begin VB.Frame fra_PrdBendParam 
         Height          =   1695
         Left            =   240
         TabIndex        =   207
         Tag             =   "fra_PrdBendDef"
         Top             =   1200
         Width           =   13455
         Begin VB.TextBox txt_PrdBendRPL_PanB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   220
            Tag             =   "RPL_PanB"
            Top             =   1200
            Width           =   975
         End
         Begin VB.TextBox txt_PrdBendRPL_PanA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   218
            Tag             =   "RPL_PanA"
            Top             =   1200
            Width           =   975
         End
         Begin VB.TextBox txt_PrdBendRPL_ModB 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   11400
            TabIndex        =   216
            Tag             =   "RPL_ModB"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdBendRPL_ModA 
            Alignment       =   1  'Right Justify
            Height          =   375
            Left            =   9360
            TabIndex        =   214
            Tag             =   "RPL_ModA"
            Top             =   720
            Width           =   975
         End
         Begin VB.TextBox txt_PrdBendPRD_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   212
            Tag             =   "PRD_Name"
            Top             =   1200
            Width           =   6255
         End
         Begin VB.TextBox txt_PrdBendPRD_Code 
            Height          =   375
            Left            =   1920
            TabIndex        =   210
            Tag             =   "PRD_Code"
            Top             =   720
            Width           =   1695
         End
         Begin VB.TextBox txt_PrdBendSYS_Name 
            Height          =   375
            Left            =   1920
            TabIndex        =   208
            Tag             =   "SYS_Name"
            Top             =   240
            Width           =   6255
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan B"
            Height          =   255
            Index           =   72
            Left            =   10440
            TabIndex        =   221
            Tag             =   "lbl_RPL_PanB"
            Top             =   1320
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Pan A"
            Height          =   255
            Index           =   71
            Left            =   8400
            TabIndex        =   219
            Tag             =   "lbl_RPL_PanA"
            Top             =   1320
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod B"
            Height          =   255
            Index           =   70
            Left            =   10440
            TabIndex        =   217
            Tag             =   "lbl_RPL_ModB"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Mod A"
            Height          =   255
            Index           =   69
            Left            =   8400
            TabIndex        =   215
            Tag             =   "lbl_RPL_ModA"
            Top             =   840
            Width           =   975
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article name"
            Height          =   255
            Index           =   68
            Left            =   120
            TabIndex        =   213
            Tag             =   "lbl_Product_Name"
            Top             =   1320
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#Article code"
            Height          =   255
            Index           =   67
            Left            =   120
            TabIndex        =   211
            Tag             =   "lbl_Product_Code"
            Top             =   840
            Width           =   1815
         End
         Begin VB.Label lbl_label 
            Caption         =   "#System"
            Height          =   255
            Index           =   66
            Left            =   120
            TabIndex        =   209
            Tag             =   "lbl_System_Desc"
            Top             =   360
            Width           =   1815
         End
      End
      Begin VB.TextBox txt_PrdBendPR 
         Alignment       =   1  'Right Justify
         Height          =   405
         Index           =   1
         Left            =   5880
         TabIndex        =   162
         Tag             =   "BBP_DzPR®©F®©lbl_BBP_DzPR"
         Top             =   3840
         Width           =   1095
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   1
         Left            =   10200
         TabIndex        =   157
         TabStop         =   0   'False
         Tag             =   "PRD_Id"
         Top             =   240
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   1
         Left            =   10200
         TabIndex        =   156
         TabStop         =   0   'False
         Top             =   600
         Visible         =   0   'False
         Width           =   615
      End
      Begin VB.TextBox txt_PrdBendPR 
         Alignment       =   1  'Right Justify
         Height          =   375
         Index           =   0
         Left            =   5880
         TabIndex        =   155
         Tag             =   "BBP_CzPR®©F®©lbl_BBP_CzPR"
         Top             =   3360
         Width           =   1095
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   1
         Left            =   240
         TabIndex        =   158
         Top             =   240
         Width           =   4335
         _ExtentX        =   7646
         _ExtentY        =   1217
      End
      Begin MSComctlLib.TabStrip tbs_SubDetail 
         Height          =   375
         Index           =   1
         Left            =   5760
         TabIndex        =   159
         Tag             =   "tbs_basetype"
         Top             =   360
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
            NumTabs         =   1
            BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
      Begin Project1.ArmCombobox cbo_PrdBendPR 
         Height          =   345
         Index           =   0
         Left            =   2040
         TabIndex        =   263
         Tag             =   "DFO_Id_CzPR®©DFO_Formula_CzPR"
         Top             =   3360
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdBendPR 
         Height          =   345
         Index           =   1
         Left            =   2040
         TabIndex        =   264
         Tag             =   "DFO_Id_DzPR®©DFO_Formula_DzPR"
         Top             =   3840
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdBendPR 
         Height          =   345
         Index           =   2
         Left            =   2040
         TabIndex        =   267
         Tag             =   "DFO_Id_EzPR®©DFO_Formula_EzPR"
         Top             =   4320
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PrdBendPR 
         Height          =   345
         Index           =   3
         Left            =   2040
         TabIndex        =   270
         Tag             =   "DFO_Id_FzPR®©DFO_Formula_FzPR"
         Top             =   4800
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   609
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Fz PR"
         Height          =   255
         Index           =   88
         Left            =   240
         TabIndex        =   269
         Tag             =   "lbl_BBP_FzPR"
         Top             =   4920
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Ez PR"
         Height          =   255
         Index           =   87
         Left            =   240
         TabIndex        =   266
         Tag             =   "lbl_BBP_EzPR"
         Top             =   4440
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Cz PR"
         Height          =   255
         Index           =   57
         Left            =   240
         TabIndex        =   163
         Tag             =   "lbl_BBP_CzPR"
         Top             =   3480
         Width           =   1815
      End
      Begin VB.Label lbl_label 
         Caption         =   "#Dz PR"
         Height          =   255
         Index           =   58
         Left            =   240
         TabIndex        =   160
         Tag             =   "lbl_BBP_DzPR"
         Top             =   3960
         Width           =   1815
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "CAD Export Main"
      Height          =   975
      Index           =   4
      Left            =   240
      TabIndex        =   181
      Top             =   6600
      Width           =   3735
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   615
         Index           =   4
         Left            =   0
         TabIndex        =   183
         Top             =   840
         Width           =   2775
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   735
         Index           =   4
         Left            =   240
         TabIndex        =   182
         Top             =   2280
         Width           =   975
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   855
         Index           =   4
         Left            =   120
         TabIndex        =   184
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   1508
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   972
         Index           =   4
         Left            =   3240
         TabIndex        =   185
         Tag             =   "grd_M_BaseType"
         Top             =   2040
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1720
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   696
         Index           =   4
         Left            =   3360
         TabIndex        =   186
         Top             =   840
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   4
         Left            =   120
         TabIndex        =   187
         Top             =   1560
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   609
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Prd Cut Param Main"
      Height          =   975
      Index           =   3
      Left            =   240
      TabIndex        =   174
      Top             =   5160
      Width           =   3735
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   615
         Index           =   3
         Left            =   0
         TabIndex        =   176
         Top             =   840
         Width           =   2775
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   735
         Index           =   3
         Left            =   240
         TabIndex        =   175
         Top             =   2280
         Width           =   975
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   855
         Index           =   3
         Left            =   120
         TabIndex        =   177
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   1508
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   972
         Index           =   3
         Left            =   3240
         TabIndex        =   178
         Tag             =   "grd_M_BaseType"
         Top             =   2040
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1720
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   696
         Index           =   3
         Left            =   3360
         TabIndex        =   179
         Top             =   840
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   3
         Left            =   120
         TabIndex        =   180
         Top             =   1560
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   609
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Prd Perf Param Main"
      Height          =   975
      Index           =   2
      Left            =   240
      TabIndex        =   167
      Top             =   3840
      Width           =   3735
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   615
         Index           =   2
         Left            =   0
         TabIndex        =   169
         Top             =   840
         Width           =   2775
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   735
         Index           =   2
         Left            =   240
         TabIndex        =   168
         Top             =   2280
         Width           =   975
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   855
         Index           =   2
         Left            =   120
         TabIndex        =   170
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   1508
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   972
         Index           =   2
         Left            =   3240
         TabIndex        =   171
         Tag             =   "grd_M_BaseType"
         Top             =   2040
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1720
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   696
         Index           =   2
         Left            =   3360
         TabIndex        =   172
         Top             =   840
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   2
         Left            =   120
         TabIndex        =   173
         Top             =   1560
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   609
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Prd Bend Param Main"
      Height          =   975
      Index           =   1
      Left            =   240
      TabIndex        =   147
      Top             =   2280
      Width           =   3015
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   735
         Index           =   1
         Left            =   240
         TabIndex        =   149
         Top             =   2280
         Width           =   975
      End
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   615
         Index           =   1
         Left            =   0
         TabIndex        =   148
         Top             =   840
         Width           =   2775
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   855
         Index           =   1
         Left            =   120
         TabIndex        =   150
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   1508
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   972
         Index           =   1
         Left            =   3240
         TabIndex        =   151
         Tag             =   "grd_M_BaseType"
         Top             =   2040
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1720
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   696
         Index           =   1
         Left            =   3360
         TabIndex        =   152
         Top             =   840
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   1
         Left            =   120
         TabIndex        =   153
         Top             =   1560
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   609
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "BaseType Main"
      Height          =   855
      Index           =   0
      Left            =   240
      TabIndex        =   2
      Top             =   1080
      Width           =   3735
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   615
         Index           =   0
         Left            =   0
         TabIndex        =   5
         Top             =   840
         Width           =   2775
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   735
         Index           =   0
         Left            =   240
         TabIndex        =   3
         Top             =   2280
         Width           =   975
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   855
         Index           =   0
         Left            =   120
         TabIndex        =   4
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   1508
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   972
         Index           =   0
         Left            =   3240
         TabIndex        =   6
         Tag             =   "grd_M_BaseType"
         Top             =   2040
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1720
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   696
         Index           =   0
         Left            =   3360
         TabIndex        =   7
         Top             =   840
         Width           =   1452
         _ExtentX        =   2566
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   0
         Left            =   120
         TabIndex        =   8
         Top             =   1560
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   609
      End
   End
   Begin MSComctlLib.TabStrip tbs_Main 
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Tag             =   "tbs_m_bt"
      Top             =   120
      Width           =   4335
      _ExtentX        =   7646
      _ExtentY        =   661
      MultiRow        =   -1  'True
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   5
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab4 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab5 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TabStrip tbs_MainTabFilter 
      Height          =   375
      Index           =   0
      Left            =   9240
      TabIndex        =   1
      Top             =   240
      Width           =   735
      _ExtentX        =   1296
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   1
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin MSComDlg.CommonDialog dlg_Common 
      Left            =   5520
      Top             =   360
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin MSComctlLib.TabStrip tbs_MainTabFilter 
      Height          =   375
      Index           =   1
      Left            =   10080
      TabIndex        =   161
      Top             =   240
      Width           =   735
      _ExtentX        =   1296
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   1
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TabStrip tbs_MainTabFilter 
      Height          =   375
      Index           =   2
      Left            =   10920
      TabIndex        =   164
      Top             =   240
      Width           =   735
      _ExtentX        =   1296
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   1
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TabStrip tbs_MainTabFilter 
      Height          =   375
      Index           =   3
      Left            =   11760
      TabIndex        =   165
      Top             =   240
      Width           =   735
      _ExtentX        =   1296
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   1
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TabStrip tbs_MainTabFilter 
      Height          =   375
      Index           =   4
      Left            =   12600
      TabIndex        =   166
      Top             =   240
      Width           =   735
      _ExtentX        =   1296
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   1
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "DPC_Ref_PDFGenerator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Option Compare Text
'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK API FUNCTION DECLARES
'**********************************************************************************************************************************
'**********************************************************************************************************************************

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (lpPictDesc As PictDesc, riid As Guid, ByVal fPictureOwnsHandle As Long, ipic As IPicture) As Long
Private Declare Function LoadLibrary Lib "Kernel32" Alias "LoadLibraryA" _
   (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "Kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadIconFromDLL Lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Long) As Long
Private Declare Function GetLocaleInfo Lib "Kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Declare Function GetSystemDefaultLCID Lib "Kernel32" () As Long

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK VARIABLES
'**********************************************************************************************************************************
'**********************************************************************************************************************************

#If ENV = LIVE Then
    Dim mo_Db As Object
#Else
    Dim mo_Db As ARMSYSCOMLib.ArmDb
#End If

#If ENV = LIVE Then
    Dim mo_FSO As Object
#Else
    Dim mo_FSO As Scripting.FileSystemObject
#End If

#If ENV = LIVE Then
    Dim mo_Sys As Object
#Else
    Dim mo_Sys As ARMSYSCOMLib.ArmSYS
#End If

Private mo_Tools                        As DPC_Tools
Private mo_WshNetwork                   As Object
Private ms_Language_Code                As String       'current user interface language
Private ml_U_Code                       As Long         'U_Code (GEN_Systems_Users) of logged user
Private ms_LoginName                    As String       'contain loginname
Private ms_UserName                     As String       'contain name of logged user as defined in GEN_People
Private mb_InternalInit                 As Boolean      'framework is doing some own control manipulation, all events should handle
Private mb_CurrentTextBoxChanged        As Boolean
Private mc_Item                         As Long         'cursor which will contain currently loaded detail data
Private mc_Toolbars                     As Long         'cursor which will contain all toolbars for current usercontrol
Private ms_ToolbarRequest               As String       'request which load all toolbars for current usercontrol
Private mo_DocumentType                 As Collection
Private ml_MaxZipRecordCount            As Long
Private ms_DocumentServerDir            As String
Private ms_NetworkBoardID               As String
Private ms_ComputerName                 As String

Private mb_Initialized                  As Boolean      'framework is initialised or not
Private m_ConnectString                 As String       'connection string to connect SQL database
Private use_framework_connection        As Integer      'if framework should use outside connected armdb or its own connection
Private ms_DecimalSeparator             As String       'locale decimal separator
Private ms_ThousandSeparator            As String       'locale thousand separator
Private mc_ScreenLabels                 As Long         'cursor containing screen constants for current component

Private ms_PicPath                      As String       'used to save images from database

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK CONSTANTS
'**********************************************************************************************************************************
'**********************************************************************************************************************************

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

Private Const MODULE_NAME As String = "DPC_Ref"
Private Const SCREEN_NAME As String = "DPC_Ref_PDFGenerator"
Private Const LOCALE_USER_DEFAULT = &H400
Private Const STATUS_COLUMN = "RowStatus"
Private Const ICON_RELOAD = 115

Private Const SW_SHOWNORMAL = 1

Private Const LOCALE_SDECIMAL = &HE ' Decimal separator
Private Const LOCALE_STHOUSAND = &HF ' Thousand separator
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 C_ERRORRAISE As Long = 2500
Private Const C_MSG_ID_BASE As Long = 9800

Private Const FRM_SPACE_VER = 120
Private Const FRM_SPACE_HOR = 100

Private Const C_SERVICE_USER As String = "NXT"
Private Const C_SERVICE_PASSW As String = "ous42pri"
Private Const C_DOCUMENT_TYPE_GR_CODE As Long = 70
Private Const C_ERROR_FILES_DIR As String = "Bad_Files"

Private Const IMAGE_CLICK_MSG = "Image clicked"

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK CUSTOM TYPES
'**********************************************************************************************************************************
'**********************************************************************************************************************************

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

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

Private Type TTreeViewInfo
    Levels As Long
    NodeRequest() As String
    GridRequest() As String
    ExcelRequest() As String
    CountRequest() As String
    FindRequest() As String
    Images() As Integer
    SelectedImages() As Integer
    TreeViewCode As String
    Loaded As Boolean
End Type

Private Type TSubdetailConfig
    NameFrame                       As String
    FrameIndex                      As Long
    TabStribIndex                   As Long     'new
    TabIndex                        As Long     'new
    ShowInTabs                      As Boolean  'new
    DetailConfigIndex               As Long
    Initialized                     As Boolean
    ToolbarID                       As Long
    ToolbarIndex                    As Long
    ToolbarFaces                    As Variant
    RequestView                     As String
    RequestAdd                      As String
    RequestUpd                      As String
    RequestDel                      As String
    RequestCheckDelete              As String
    RequestCheckAdd                 As String
    RequestCheckUpdate              As String
    TableName                       As String
    TableOrder                      As String
    GridDelayMethod                 As eGridLoadMethod
    GridColumns                     As Variant
    DeletedRows                     As Variant
    ListFieldsMandatory             As Variant
    ListFieldsDefaultValue          As Variant
    ListFieldsToDisable             As Variant
    DeleteMsg(0, 1)                 As String
    UpdateMsg(0, 1)                 As String
    CheckAddUpdMsg(0, 1)            As String
    CheckDelMsg(0, 1)               As String
End Type

Private Type TDetailConfig
    NameFrame                       As String
    DetailKey                       As String
    FrameIndex                      As Long
    MainConfigIndex                 As Long
    IsMultiDetailFrame              As Boolean
    Initialized                     As Boolean
    ToolbarID                       As Long
    ToolbarIndex                    As Long
    ToolbarFaces                    As Variant
    RequestView                     As String
    RequestAdd                      As Variant
    RequestUpd                      As Variant
    RequestDel                      As Variant
    AffectedCount                   As Variant
    RequestCheckDelete              As String
    RequestCheckAdd                 As String
    RequestCheckUpdate              As String
    UseTransaction                  As Boolean
    TableName                       As String
    MainGridColumns                 As Variant
    InitControls                    As Variant
    ListFieldsMandatory             As Variant
    ListFieldsDefaultValue          As Variant
    ListFieldsToDisable             As Variant
    DeleteMsg(0, 1)                 As String
    UpdateMsg(0, 1)                 As String
    CheckAddUpdMsg(0, 1)            As String
    CheckDelMsg(0, 1)               As String
    PreviousDetailIndex             As Long         'new
    ClearControlsBeforeInit         As Boolean      'new
End Type

Private Type TMainConfig
    NameFrame                       As String
    ViewCode                        As String
    FrameIndex                      As Long
    IsMultiDetailView               As Boolean
    CurrentDetailIndex              As Long
    Initialized                     As Boolean
    ToolbarFace                     As String
    ToolbarIndex                    As Long
    ToolbarID                       As Long
    CurrentTvwSelMethod             As eTvwSelMethod
    GridDelayMethod                 As eGridLoadMethod
    GridDelayed                     As Boolean
    TreeDelayed                     As Boolean
    mTreeViewInfos()                As TTreeViewInfo
    RequestGrid                     As String
End Type

Private mt_SubdetailConfig() As TSubdetailConfig
Private mt_DetailConfig() As TDetailConfig
Private mt_MainConfig() As TMainConfig

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

Private Enum eMode
    emNone
    emList
    emView
    emAdd
    emUpdate
    emDelete
End Enum

Private Enum eControlPropertyIndex
    cpiControl
    cpiTag
    cpiVisible
    cpiRequest
End Enum

Private Enum eControlAction
    caDoubleClick
    caClick
    caSelect
    caLoad
End Enum

Private me_DetailMode                     As eMode
Private me_OldDetailMode                  As eMode
Private me_SubDetailMode                  As eMode

Private Enum eGridLoadMethod
    egmDelayedAlways = 0
    egmDelayedExceptLastLevel = 1
    egmLoadAlways = 2
End Enum

' The different way to select data in the treeview
Private Enum eTvwSelMethod
    etmNone = 0
    etmNode = 1         ' User click on the last node of a branch
    etmBranch = 2       ' User click on a branch and use the load button
    etmCheckBoxes = 3   ' User click on the load button when checkboxes mode is set
End Enum

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 Enum eTableType
    ttNone = 0
    ttDPC_BaseType = 1
End Enum

Private Type tExcelImported
    Count As Long
    InsertedCount As Long
    UpdatedCount As Long
    FileName As String
End Type

Private Type tFlexGridData
    MTH_Id As Long
    MTH_AMin As Double
    MTH_AMax As Double
    MTH_BMin As Double
    MTH_BMax As Double
    MTH_Thick As Double
    MTH_H As Double
    iConcurrency As Long
End Type

Private mt_FlexGridData() As tFlexGridData
Private ml_EditedRow As Long
Private ml_EditedCol As Long

Private Enum eEditedFlexGridType
    etMTH_Thick = 1
    etMTH_H = 2
End Enum

Private me_EditedFlexGrid As eEditedFlexGridType

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK EVENTS
'**********************************************************************************************************************************
'**********************************************************************************************************************************

Public Event quit()

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' COMPONENT CONSTANTS AND VARIABLES
'**********************************************************************************************************************************

Private Const CONST_CUT_TYPE_VENT = 1
Private Const CONST_CUT_TYPE_LOUD = 2
Private Const CONST_CUT_TYPE_CUTOUT = 3

'**********************************************************************************************************************************
'**********************************************************************************************************************************
'**********************************************************************************************************************************
' COMPONENT METHODS
'**********************************************************************************************************************************
'**********************************************************************************************************************************

Private Function LoadUserInfo(ByRef ao_Armdb As Object, ByVal al_U_Code As Long) As String
On Error GoTo ErrHandler
Const C_REQ As String = _
    "SELECT GPL.P_First_Name + ' '+ GPL.P_Name as User_Name " & _
    "FROM GEN_Systems_Users GSU " & _
    "INNER JOIN GEN_People GPL ON (GSU.P_Code=GPL.P_Code) " & _
    "WHERE GSU.U_Code=$U_Code$"

Dim ls_Req As String
Dim ll_Cursor As Long
    
    ls_Req = ReplacePlaceHolder(C_REQ, "$U_Code$", al_U_Code)
    ll_Cursor = mo_Tools.OpenSQLSafe(ao_Armdb, ls_Req, 1)
    LoadUserInfo = ao_Armdb.GetFields(ll_Cursor, "User_Name")
    Call ao_Armdb.Close(ll_Cursor)
    Exit Function
    
ErrHandler:
    If ll_Cursor <> 0 Then Call ao_Armdb.Close(ll_Cursor)
    Call ErrorHandler("LoadUserInfo()")
End Function

Private Sub DrawSelImage(ByVal ao_Image As StdPicture, ByVal ao_Canvas As PictureBox, Optional ByVal as_Message As String = IMAGE_CLICK_MSG)
Dim lf_AspectRatioX As Double
Dim lf_AspectRatioY As Double
Dim lf_Width As Double
Dim lf_Height As Double

  Set ao_Canvas.Picture = Nothing
  If ao_Image Is Nothing Then
    If as_Message <> "" Then
      'Call PrintMessage(ao_Canvas, as_Message)
    End If
    Exit Sub
  End If
  
  lf_Width = ao_Canvas.ScaleX(ao_Image.Width, vbHimetric, vbTwips)
  lf_Height = ao_Canvas.ScaleY(ao_Image.Height, vbHimetric, vbTwips)
  
  If (lf_Height > ao_Canvas.ScaleHeight) Or (lf_Width > ao_Canvas.ScaleWidth) Then
    lf_AspectRatioX = ao_Canvas.ScaleWidth / lf_Width
    lf_AspectRatioY = ao_Canvas.ScaleHeight / lf_Height
    If lf_AspectRatioX < lf_AspectRatioY Then
      lf_Width = lf_Width * lf_AspectRatioX
      lf_Height = lf_Height * lf_AspectRatioX
    Else
      lf_Width = lf_Width * lf_AspectRatioY
      lf_Height = lf_Height * lf_AspectRatioY
    End If
  End If
  Call ao_Canvas.PaintPicture(ao_Image, (ao_Canvas.ScaleWidth - lf_Width) / 2, (ao_Canvas.ScaleHeight - lf_Height) / 2, lf_Width, lf_Height)
  'Call ao_Canvas.PaintPicture(ao_Image, 0, 0)
  'ao_Canvas.Picture = ao_Canvas.Image
  
End Sub

Private Function DeleteImage(ByVal al_IMG_Id As Long) As Boolean
Dim ls_PicName As String

  DeleteImage = False
  If al_IMG_Id = 0 Then Exit Function
  ls_PicName = ms_PicPath & "IMG" & al_IMG_Id & ".jpg"
  If mo_FSO.FileExists(ls_PicName) Then
        Call mo_Tools.DeleteFile(mo_FSO, ls_PicName)
  End If
  DeleteImage = True
End Function

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK CUSTOM METHODS
' Change content of methods as you need, but do not add any new method or property here !
'**********************************************************************************************************************************
'**********************************************************************************************************************************

Private Function Load_A_COM_Custom() As Boolean
On Error GoTo ErrHandler

    Dim ll_Idx As Long
    
    Dim ls_DPC_RefRight As String
'ls_DPC_RefRight = Trim(GetAConfigData(mo_Db, "DPC_RefRight"))
   ' If InStr(1, SEP & ls_DPC_RefRight & SEP, SEP & ml_U_code & SEP) <= 0 Then
   '     Load_A_COM_Custom = False
   '     Exit Function
   ' End If
   
   ms_PicPath = prg.AppCache_Dir & DPC_IMAGE_CACHE
   
'    btn_Validate.Picture = LoadResPicture(RES_OK, 1)
'    btn_Quit.Picture = LoadResPicture(RES_QUIT, 1)
       
    Load_A_COM_Custom = True
    Exit Function
ErrHandler:
    Call ErrorHandler("Load_A_COM_Custom")
End Function

Private Sub UnLoad_A_COM_Custom()
On Error GoTo ErrHandler

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

Private Sub Init_Custom()
On Error GoTo ErrHandler
    Dim lo_Tab As MSComctlLib.Tab
    Dim lc_Cursor As Long
    Dim ll_Index As Integer
    Dim lv_Priority As Variant
    Dim ls_Request As String, ls_ReqTemp As String
            
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(1)
    lo_Tab.Caption = "#DPC_BaseType"
    lo_Tab.Key = "DPC_BaseType"
    lo_Tab.Tag = "lbl_TAB_DPC_BaseType"
                              
    Set lo_Tab = tbs_Main.Tabs(2)
    lo_Tab.Caption = "#CAD Export"
    lo_Tab.Key = "DPC_PrdCADExport"
    lo_Tab.Tag = "lbl_TAB_DPC_PrdCADExport"
    
    Set lo_Tab = tbs_Main.Tabs(3)
    lo_Tab.Caption = "#Bend. param"
    lo_Tab.Key = "DPC_PrdBendParam"
    lo_Tab.Tag = "lbl_TAB_DPC_PrdBendParam"
    
    Set lo_Tab = tbs_Main.Tabs(4)
    lo_Tab.Caption = "#Perf. param"
    lo_Tab.Key = "DPC_PrdPerfParam"
    lo_Tab.Tag = "lbl_TAB_DPC_PrdPerfParam"
    
    Set lo_Tab = tbs_Main.Tabs(5)
    lo_Tab.Caption = "#Cutout param"
    lo_Tab.Key = "DPC_PrdCutParam"
    lo_Tab.Tag = "lbl_TAB_DPC_PrdCutParam"
    
    ls_Request = "exec DPC_PrdDesc_cbo $Language_Code$, $CAT_Id$, 'X'"
    ls_Request = ReplacePlaceHolder(ls_Request, "$CAT_Id$", eDPCCategory.cgMetalCustomPanelTemplate)
    cbo_PrdCADExportPRD_Name.FirstBlankItem = True
    cbo_PrdCADExportPRD_Name.Request = ReplaceCommonPlaceholders(ls_Request)
    
    cbo_Perforation.FirstBlankItem = True
    cbo_Perforation.Request = ReplaceCommonPlaceholders("exec DPC_Perforation_lst2 $Language_Code$, NULL, NULL")
  
    cbo_bcp_cutout.FirstBlankItem = True
    cbo_bcp_cutout.Request = ReplaceCommonPlaceholders("exec DPC_CutType_cbo 3, $Language_Code$")
    
    ls_ReqTemp = "exec DPC_Formula_lst $DFO_Type$"
    ls_Request = ReplacePlaceHolder(ls_ReqTemp, "$DFO_Type$", eDPCFormulaType.ftPDFBendParam)
    For ll_Index = 0 To 11
        cbo_formula_bendparam(ll_Index).FirstBlankItem = True
        cbo_formula_bendparam(ll_Index).Request = ReplaceCommonPlaceholders(ls_Request)
    Next
    
    ls_Request = ReplacePlaceHolder(ls_ReqTemp, "$DFO_Type$", eDPCFormulaType.ftPDFCutParam)
    For ll_Index = 0 To 5
        cbo_formula_cutparam(ll_Index).FirstBlankItem = True
        cbo_formula_cutparam(ll_Index).Request = ReplaceCommonPlaceholders(ls_Request)
    Next
    
    ls_Request = ReplacePlaceHolder(ls_ReqTemp, "$DFO_Type$", eDPCFormulaType.ftPDFPerfParam)
    For ll_Index = 0 To 7
        cbo_formula_prfparam(ll_Index).FirstBlankItem = True
        cbo_formula_prfparam(ll_Index).Request = ReplaceCommonPlaceholders(ls_Request)
    Next
    
    ls_Request = ReplacePlaceHolder(ls_ReqTemp, "$DFO_Type$", eDPCFormulaType.ftPDFPRDBendParam)
    For ll_Index = 0 To 3
      cbo_PrdBendPR(ll_Index).FirstBlankItem = True
      cbo_PrdBendPR(ll_Index).Request = ReplaceCommonPlaceholders(ls_Request)
    Next
    
    ls_Request = ReplacePlaceHolder(ls_ReqTemp, "$DFO_Type$", eDPCFormulaType.ftPDFPerfParam)
    For ll_Index = 0 To 7
      cbo_PrdPerfBord(ll_Index).FirstBlankItem = True
      cbo_PrdPerfBord(ll_Index).Request = ReplaceCommonPlaceholders(ls_Request)
    Next
    
    ls_Request = ReplacePlaceHolder(ls_ReqTemp, "$DFO_Type$", eDPCFormulaType.ftPDFCutParam)
    For ll_Index = 0 To 5
      cbo_PrdCutFormula(ll_Index).FirstBlankItem = True
      cbo_PrdCutFormula(ll_Index).Request = ReplaceCommonPlaceholders(ls_Request)
    Next
    
    For ll_Index = 0 To 1
        grd_Main(ll_Index).AllowExcelExport = True
    Next
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("Init_Custom")
End Sub

Private Sub Load_ConfigInfo()
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim ll_frameIndex As Long
    
    ReDim mt_MainConfig(4)
    ReDim mt_DetailConfig(4)
        
    With mt_MainConfig(0)
        .FrameIndex = 0
        .IsMultiDetailView = True
        .CurrentDetailIndex = 0
        .Initialized = False
        .NameFrame = "DPC_BaseType"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 0
        .ToolbarID = 3003
        .RequestGrid = ReplacePlaceHolder("exec A_References_ML_lst " & eDPCReferenceML.rfBaseTypeBaeurer & ", $toolbar_language_code$", "$toolbar_language_code$", mo_Tools.SQLStr(tlb_Main(0).Language))
    End With
    
    With mt_MainConfig(1)
        .FrameIndex = 1
        .IsMultiDetailView = False
        .CurrentDetailIndex = 1
        .Initialized = False
        .NameFrame = "DPC_PrdBendParam"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 1
        .ToolbarID = 2991
        .RequestGrid = "EXEC DPC_PrdBendParam_lst NULL,$toolbar_language_code$"
    End With
    
    With mt_MainConfig(2)
        .FrameIndex = 2
        .IsMultiDetailView = False
        .CurrentDetailIndex = 2
        .Initialized = False
        .NameFrame = "DPC_PrdPerfParam"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 2
        .ToolbarID = 2991
        .RequestGrid = "EXEC DPC_PrdPerfParam_lst NULL,NULL,$toolbar_language_code$"
    End With
    
    With mt_MainConfig(3)
        .FrameIndex = 3
        .IsMultiDetailView = False
        .CurrentDetailIndex = 3
        .Initialized = False
        .NameFrame = "DPC_PrdCutParam"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 3
        .ToolbarID = 2991
        .RequestGrid = "EXEC DPC_PrdCutParam_lst NULL,NULL,$toolbar_language_code$"
    End With
    
    With mt_MainConfig(4)
        .FrameIndex = 4
        .IsMultiDetailView = False
        .CurrentDetailIndex = 4
        .Initialized = False
        .NameFrame = "DPC_PrdCADExport"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 4
        .ToolbarID = 2991
        .RequestGrid = "DPC_PrdCADExport_lst NULL,$toolbar_language_code$"
    End With
    
    With mt_DetailConfig(0)
        .FrameIndex = 0
        .NameFrame = "DPC_BaseType"
        .MainConfigIndex = 0
        .DetailKey = 0
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BaseType_sel $Key1$, $Language_Code$"
        .RequestAdd = ""
        .RequestUpd = ""
        .RequestDel = ""
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = ""
        .ToolbarIndex = 0
        .ToolbarID = 2992
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(-1 To -1)
        
        ReDim .ListFieldsToDisable(1)
        Set .ListFieldsToDisable(0) = txt_DetailKey(0)
        Set .ListFieldsToDisable(1) = txt_SPD_System
        
        .MainGridColumns = Array( _
            "RF_Code®©0®©1®©RF_Code®©#RF_Code", _
            "RF_Desc®©2500®©0®©RF_Desc®©#Base Type")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(1)
        .FrameIndex = 1
        .NameFrame = "DPC_PrdBendParam"
        .MainConfigIndex = 1
        .DetailKey = 1
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_PrdBendParam_sel2 $Key1$, $toolbar_language_code$"
        .RequestAdd = ""
        .RequestUpd = "exec DPC_PrdBendParam_upd $PRD_Id$, " & _
                      "$DFO_Id_CzPR$, $BBP_CzPR$, " & _
                      "$DFO_Id_DzPR$, $BBP_DzPR$, " & _
                      "$DFO_Id_EzPR$, $BBP_EzPR$, " & _
                      "$DFO_Id_FzPR$, $BBP_FzPR$, " & _
                      "$U_Code$"
        .RequestDel = "exec DPC_PrdBendParam_del $PRD_Id$, $U_Code$"
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = False
        .TableName = ""
        .ToolbarIndex = 1
        .ToolbarID = 2992
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(-1 To -1)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(0)
        
        .MainGridColumns = Array( _
            "PRD_Id®©0®©1®©PRD_Id®©#PRD_Id", _
            "PRD_Code®©600®©0®©PRD_Code®©#Code", _
            "SYS_Name®©1200®©0®©SYS_Name®©#System", _
            "PRD_Name®©2500®©0®©PRD_Name®©#Name", _
            "RPL_ModA®©600®©0®©RPL_ModA®©#Mod A", _
            "RPL_ModB®©600®©0®©RPL_ModB®©#Mod B", _
            "RPL_PanA®©600®©0®©RPL_PanA®©#Pan A", _
            "RPL_PanB®©600®©0®©RPL_PanB®©#Pan B", _
            "DFO_Formula_CzPR®©1200®©0®©DFO_Formula_CzPR®©#Formula CzPR", "BBP_CzPR®©500®©0®©BBP_CzPR®©#CzPR", _
            "DFO_Formula_DzPR®©1200®©0®©DFO_Formula_DzPR®©#Formula DzPR", "BBP_DzPR®©500®©0®©BBP_DzPR®©#DzPR", _
            "DFO_Formula_EzPR®©1200®©0®©DFO_Formula_EzPR®©#Formula EzPR", "BBP_EzPR®©500®©0®©BBP_EzPR®©#EzPR", _
            "DFO_Formula_FzPR®©1200®©0®©DFO_Formula_FzPR®©#Formula FzPR", "BBP_FzPR®©500®©0®©BBP_FzPR®©#FzPR" _
            )
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(2)
        .FrameIndex = 2
        .NameFrame = "DPC_PrdPerfParam"
        .MainConfigIndex = 2
        .DetailKey = 2
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_PrdPerfParam_sel2 $Key1$, $Key2$, $toolbar_language_code$"
        .RequestAdd = ""
        .RequestUpd = "exec DPC_PrdPerfParam_upd $PRD_Id$, $PRF_Id$," & _
                      "$DFO_Id_UnprfBordC2$, $BPP_UnprfBordC2$," & _
                      "$DFO_Id_UnprfBordD2$, $BPP_UnprfBordD2$," & _
                      "$DFO_Id_UnprfBordE2$, $BPP_UnprfBordE2$," & _
                      "$DFO_Id_UnprfBordF2$, $BPP_UnprfBordF2$," & _
                      "$DFO_Id_OverprfBordC2$, $BPP_OverprfBordC2$," & _
                      "$DFO_Id_OverprfBordD2$, $BPP_OverprfBordD2$," & _
                      "$DFO_Id_OverprfBordE2$, $BPP_OverprfBordE2$," & _
                      "$DFO_Id_OverprfBordF2$, $BPP_OverprfBordF2$," & _
                      "$U_Code$"
        .RequestDel = "exec DPC_PrdPerfParam_del $PRD_Id$, $PRF_Id$, $U_Code$"
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = False
        .TableName = ""
        .ToolbarIndex = 2
        .ToolbarID = 2992
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(-1 To -1)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(0)
        
        .MainGridColumns = Array( _
            "PRD_Id®©0®©1®©PRD_Id®©#PRD_Id", _
            "PRF_Id®©0®©1®©PRF_Id®©#PRF_Id", _
            "PRD_Code®©600®©0®©PRD_Code®©#Code", _
            "SYS_Name®©1200®©0®©SYS_Name®©#System", _
            "PRD_Name®©2500®©0®©PRD_Name®©#Name", _
            "PRF_Name®©1000®©0®©PRF_Name®©#Perforation", _
            "RPL_ModA®©600®©0®©RPL_ModA®©#Mod A", _
            "RPL_ModB®©600®©0®©RPL_ModB®©#Mod B", _
            "RPL_PanA®©600®©0®©RPL_PanA®©#Pan A", _
            "RPL_PanB®©600®©0®©RPL_PanB®©#Pan B", _
            "DFO_Formula_UnprfBordC2®©1200®©0®©DFO_Formula_UnprfBordC2®©#UnprfBordC", "BPP_UnprfBordC2®©500®©0®©BPP_UnprfBordC2®©#UnprfBordC", _
            "DFO_Formula_UnprfBordD2®©1200®©0®©DFO_Formula_UnprfBordD2®©#UnprfBordD", "BPP_UnprfBordD2®©500®©0®©BPP_UnprfBordD2®©#UnprfBordD", _
            "DFO_Formula_UnprfBordE2®©1200®©0®©DFO_Formula_UnprfBordE2®©#UnprfBordE", "BPP_UnprfBordE2®©500®©0®©BPP_UnprfBordE2®©#UnprfBordE", _
            "DFO_Formula_UnprfBordF2®©1200®©0®©DFO_Formula_UnprfBordF2®©#UnprfBordF", "BPP_UnprfBordF2®©500®©0®©BPP_UnprfBordF2®©#UnprfBordF", _
            "DFO_Formula_OverprfBordC2®©1200®©0®©DFO_Formula_OverprfBordC2®©#OverprfBordC", "BPP_OverprfBordC2®©500®©0®©BPP_OverprfBordC2®©#OverprfBordC", _
            "DFO_Formula_OverprfBordD2®©1200®©0®©DFO_Formula_OverprfBordD2®©#OverprfBordD", "BPP_OverprfBordD2®©500®©0®©BPP_OverprfBordD2®©#OverprfBordD", _
            "DFO_Formula_OverprfBordE2®©1200®©0®©DFO_Formula_OverprfBordE2®©#OverprfBordE", "BPP_OverprfBordE2®©500®©0®©BPP_OverprfBordE2®©#OverprfBordE", _
            "DFO_Formula_OverprfBordF2®©1200®©0®©DFO_Formula_OverprfBordF2®©#OverprfBordF", "BPP_OverprfBordF2®©500®©0®©BPP_OverprfBordF2®©#OverprfBordF" _
            )
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(3)
        .FrameIndex = 3
        .NameFrame = "DPC_PrdCutParam"
        .MainConfigIndex = 3
        .DetailKey = 3
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_PrdCutParam_sel2 $Key1$, $Key2$, $toolbar_language_code$"
        .RequestAdd = ""
        .RequestUpd = "exec DPC_PrdCutParam_upd $PRD_Id$, $CUT_Id$, " & _
                      "$DFO_Id_E_zM$, $BCP_E_zM$, " & _
                      "$DFO_Id_C_zL$, $BCP_C_zL$, " & _
                      "$DFO_Id_J_z$, $BCP_J_z$, " & _
                      "$DFO_Id_J_Hz$, $BCP_J_Hz$, " & _
                      "$DFO_Id_K_z$, $BCP_K_z$, " & _
                      "$DFO_Id_K_Hz$, $BCP_K_Hz$, " & _
                      "$U_Code$"
        .RequestDel = "exec DPC_PrdCutParam_del $PRD_Id$, $CUT_Id$, $U_Code$"
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = False
        .TableName = ""
        .ToolbarIndex = 3
        .ToolbarID = 2992
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(1)
        .ListFieldsMandatory(0) = Array(txt_PRD_CADFile, 57)
        .ListFieldsMandatory(1) = Array(txt_PRD_LayCADFile, 58)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(0)
        
        .MainGridColumns = Array( _
            "PRD_Id®©0®©1®©PRD_Id®©#PRD_Id", _
            "CUT_Id®©0®©1®©CUT_Id®©#CUT_Id", _
            "PRD_Code®©600®©0®©PRD_Code®©#Code", _
            "SYS_Name®©1200®©0®©SYS_Name®©#System", _
            "PRD_Name®©2500®©0®©PRD_Name®©#Name", _
            "CUT_Name®©1000®©0®©CUT_Name®©#Cutout", _
            "RPL_ModA®©600®©0®©RPL_ModA®©#Mod A", _
            "RPL_ModB®©600®©0®©RPL_ModB®©#Mod B", _
            "RPL_PanA®©600®©0®©RPL_PanA®©#Pan A", _
            "RPL_PanB®©600®©0®©RPL_PanB®©#Pan B", _
            "DFO_Formula_E_zM®©1200®©0®©DFO_Formula_E_zM®©#Formula E_zM", "BCP_E_zM®©500®©0®©BCP_E_zM®©#E_zM", _
            "DFO_Formula_C_zL®©1200®©0®©DFO_Formula_C_zL®©#Formula C_zL", "BCP_C_zL®©500®©0®©BCP_C_zL®©#C_zL", _
            "DFO_Formula_J_z®©1200®©0®©DFO_Formula_J_z®©#Formula J_z", "BCP_J_z®©500®©0®©BCP_J_z®©#J_z", _
            "DFO_Formula_J_Hz®©1200®©0®©DFO_Formula_J_Hz®©#Formula J_Hz", "BCP_J_Hz®©500®©0®©BCP_J_Hz®©#J_Hz", _
            "DFO_Formula_K_z®©1200®©0®©DFO_Formula_K_z®©#Formula K_z", "BCP_K_z®©500®©0®©BCP_K_z®©#K_z", _
            "DFO_Formula_K_Hz®©1200®©0®©DFO_Formula_K_Hz®©#Formula K_Hz", "BCP_K_Hz®©500®©0®©BCP_K_Hz®©#K_Hz" _
            )
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(4)
        .FrameIndex = 4
        .NameFrame = "DPC_PrdCADExport"
        .MainConfigIndex = 4
        .DetailKey = 4
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_PrdCADExport_sel $Key1$, $toolbar_language_code$"
        .RequestAdd = ""
        .RequestUpd = "exec DPC_PrdCADExport_upd $PRD_Id$, $PRD_IdGroup$, $PRD_CADFile$, $PRD_LayCADFile$, $U_Code$"
        .RequestDel = "exec DPC_PrdCADExport_del $PRD_Id$, $U_Code$"
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = False
        .TableName = ""
        .ToolbarIndex = 4
        .ToolbarID = 2992
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(1)
        .ListFieldsMandatory(0) = Array(txt_PRD_CADFile, 57)
        .ListFieldsMandatory(1) = Array(txt_PRD_LayCADFile, 58)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(0)
        
        .MainGridColumns = Array( _
            "PRD_Id®©0®©1®©PRD_Id®©#PRD_Id", _
            "PRD_Code®©600®©0®©PRD_Code®©#Code", _
            "SYS_Name®©1200®©0®©SYS_Name®©#System", _
            "PRD_Name®©2500®©0®©PRD_Name®©#Name", _
            "RPL_ModA®©600®©0®©RPL_ModA®©#Mod A", _
            "RPL_ModB®©600®©0®©RPL_ModB®©#Mod B", _
            "RPL_PanA®©600®©0®©RPL_PanA®©#Pan A", _
            "RPL_PanB®©600®©0®©RPL_PanB®©#Pan B", _
            "PRD_NameGroup®©2500®©0®©PRD_NameGroup®©#Group", _
            "PRD_CADFile®©2500®©0®©PRD_CADFile®©#CAD File", _
            "PRD_LayCADFile®©2500®©0®©PRD_LayCADFile®©#CAD Layout File" _
            )
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    For ll_Index = 0 To UBound(mt_MainConfig)
        mt_MainConfig(ll_Index).CurrentTvwSelMethod = eTvwSelMethod.etmNone
        ll_frameIndex = mt_MainConfig(ll_Index).FrameIndex
        cmd_TVReLoad(ll_frameIndex).Picture = mo_Tools.LoadIconFromA_Icons(ICON_RELOAD)
        Call SetTreeDelayedMode(ll_frameIndex, False)
    Next
        
    For ll_Index = 0 To UBound(mt_DetailConfig)
        
        mt_DetailConfig(ll_Index).DeleteMsg(0, 0) = "7200"
        mt_DetailConfig(ll_Index).DeleteMsg(0, 1) = "#Do you really want to delete this record?"
        mt_DetailConfig(ll_Index).UpdateMsg(0, 0) = "2133"
        mt_DetailConfig(ll_Index).UpdateMsg(0, 1) = "#You can not update this record."
        mt_DetailConfig(ll_Index).CheckAddUpdMsg(0, 0) = "2102"
        mt_DetailConfig(ll_Index).CheckAddUpdMsg(0, 1) = "#You cannot add this item because this record is already in the database."
        mt_DetailConfig(ll_Index).CheckDelMsg(0, 0) = "2103"
        mt_DetailConfig(ll_Index).CheckDelMsg(0, 1) = "#You cannot delete this record because there is some data link to it." & vbCrLf & "You must delete all the records attached to it before being able to delete this record."
        
        'mt_DetailConfig(ll_Index).AffectedCount = Array(1, 1, 1)
        If Not mt_DetailConfig(ll_Index).IsMultiDetailFrame Then
            Call InitFrameControls(mt_DetailConfig(ll_Index).InitControls)
        End If
    Next
    
    ReDim mt_SubdetailConfig(2)
    
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        mt_SubdetailConfig(ll_Index).DeleteMsg(0, 0) = "7200"
        mt_SubdetailConfig(ll_Index).DeleteMsg(0, 1) = "#Do you really want to delete this record?"
        mt_SubdetailConfig(ll_Index).UpdateMsg(0, 0) = "2133"
        mt_SubdetailConfig(ll_Index).UpdateMsg(0, 1) = "#You can not update this record."
        mt_SubdetailConfig(ll_Index).CheckAddUpdMsg(0, 0) = "2102"
        mt_SubdetailConfig(ll_Index).CheckAddUpdMsg(0, 1) = "#You cannot add this item because this record is already in the database."
        mt_SubdetailConfig(ll_Index).CheckDelMsg(0, 0) = "2103"
        mt_SubdetailConfig(ll_Index).CheckDelMsg(0, 1) = "#You cannot delete this record because there is some data link to it." & vbCrLf & "You must delete all the records attached to it before being able to delete this record."
        
        mt_SubdetailConfig(ll_Index).GridDelayMethod = egmLoadAlways
        ReDim mt_SubdetailConfig(ll_Index).DeletedRows(-1 To -1)
    Next
            
    With mt_SubdetailConfig(0)
        .FrameIndex = 0
        .NameFrame = "DPC_BaseTypePerfParam"
        .DetailConfigIndex = 0
        .Initialized = False
        
        .TabStribIndex = 0
        .TabIndex = 1
        .ShowInTabs = True
        
        .RequestView = "exec DPC_BaseTypePerfParam_lst $Key1$, $Language_Code$"
        .RequestAdd = "exec DPC_BaseTypePerfParam_ins $RF_Code$,$RPL_Thick$,$PRF_Id$,$DFO_Id_UnprfBordC$,$BPP_UnprfBordC$,$DFO_Id_UnprfBordD$,$BPP_UnprfBordD$,$DFO_Id_UnprfBordE$,$BPP_UnprfBordE$,$DFO_Id_UnprfBordF$,$BPP_UnprfBordF$,$DFO_Id_OverprfBordC$,$BPP_OverprfBordC$,$DFO_Id_OverprfBordD$,$BPP_OverprfBordD$,$DFO_Id_OverprfBordE$,$BPP_OverprfBordE$,$DFO_Id_OverprfBordF$,$BPP_OverprfBordF$,$U_Code$"
        .RequestUpd = "exec DPC_BaseTypePerfParam_upd $RF_Code$,$RPL_Thick$,$PRF_Id$,$DFO_Id_UnprfBordC$,$BPP_UnprfBordC$,$DFO_Id_UnprfBordD$,$BPP_UnprfBordD$,$DFO_Id_UnprfBordE$,$BPP_UnprfBordE$,$DFO_Id_UnprfBordF$,$BPP_UnprfBordF$,$DFO_Id_OverprfBordC$,$BPP_OverprfBordC$,$DFO_Id_OverprfBordD$,$BPP_OverprfBordD$,$DFO_Id_OverprfBordE$,$BPP_OverprfBordE$,$DFO_Id_OverprfBordF$,$BPP_OverprfBordF$,$U_Code$,$iConcurrency$"
        .RequestDel = "exec DPC_BaseTypePerfParam_del $RF_Code$,$RPL_Thick$,$PRF_Id$,$U_Code$,$iConcurrency$"
        
        .RequestCheckAdd = "select * from DPC_BaseTypePerfParam where SYS_BaeType=$RF_Code$ and RPL_Thick=$RPL_Thick$ and PRF_Id=$PRF_Id$"
        .RequestCheckUpdate = ""
        
        .TableName = ""
        .TableOrder = ""
        
        .ToolbarID = 2993
        .ToolbarIndex = 0
        .ToolbarFaces = Array("0", "1", "2", "3", "4")
        
        .GridColumns = Array( _
            "SYS_BaeType®©0®©1®©SYS_BaeType®©SYS_BaeType", _
            "RPL_Thick®©1000®©1®©RPL_Thick®©#MAT Thick", _
            "PRF_Id®©0®©1®©PRF_Id®©#PRF_Id", _
            "PRF_Name®©2000®©0®©PRF_Name®©#PRF_Name", _
            "DFO_Id_UnprfBordC®©0®©0®©DFO_Id_UnprfBordC®©#UnprfBordC", "DFO_Formula_UnprfBordC®©2200®©0®©DFO_Formula_UnprfBordC®©#Formula_UnprfBordC", "BPP_UnprfBordC®©700®©0®©BPP_UnprfBordC®©#UnprfBordC", _
            "DFO_Id_UnprfBordD®©0®©0®©DFO_Id_UnprfBordD®©#UnprfBordD", "DFO_Formula_UnprfBordD®©2200®©0®©DFO_Formula_UnprfBordD®©#Formula_UnprfBordD", "BPP_UnprfBordD®©700®©0®©BPP_UnprfBordD®©#UnprfBordD", _
            "DFO_Id_UnprfBordE®©0®©0®©DFO_Id_UnprfBordE®©#UnprfBordE", "DFO_Formula_UnprfBordE®©2200®©0®©DFO_Formula_UnprfBordE®©#Formula_UnprfBordE", "BPP_UnprfBordE®©700®©0®©BPP_UnprfBordE®©#UnprfBordE", _
            "DFO_Id_UnprfBordF®©0®©0®©DFO_Id_UnprfBordF®©#UnprfBordF", "DFO_Formula_UnprfBordF®©2200®©0®©DFO_Formula_UnprfBordF®©#Formula_UnprfBordF", "BPP_UnprfBordF®©700®©0®©BPP_UnprfBordF®©#UnprfBordF", _
            "DFO_Id_OverprfBordC®©0®©0®©DFO_Id_OverprfBordC®©#OverprfBordC", "DFO_Formula_OverprfBordC®©2200®©0®©DFO_Formula_OverprfBordC®©#Formula_OverprfBordC", "BPP_OverprfBordC®©700®©0®©BPP_OverprfBordC®©#OverprfBordC", _
            "DFO_Id_OverprfBordD®©0®©0®©DFO_Id_OverprfBordD®©#OverprfBordD", "DFO_Formula_OverprfBordD®©2200®©0®©DFO_Formula_OverprfBordD®©#Formula_OverprfBordD", "BPP_OverprfBordD®©700®©0®©BPP_OverprfBordD®©#OverprfBordD", _
            "DFO_Id_OverprfBordE®©0®©0®©DFO_Id_OverprfBordE®©#OverprfBordE", "DFO_Formula_OverprfBordE®©2200®©0®©DFO_Formula_OverprfBordE®©#Formula_OverprfBordE", "BPP_OverprfBordE®©700®©0®©BPP_OverprfBordE®©#OverprfBordE", _
            "DFO_Id_OverprfBordF®©0®©0®©DFO_Id_OverprfBordF®©#OverprfBordF", "DFO_Formula_OverprfBordF®©2200®©0®©DFO_Formula_OverprfBordF®©#Formula_OverprfBordF", "BPP_OverprfBordF®©700®©0®©BPP_OverprfBordF®©#OverprfBordF", _
            "RowStatus®©0®©0®©RowStatus®©#RowStatus", _
            "iConcurrency®©0®©0®©iConcurrency®©iConcurrency")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(9)
        .ListFieldsMandatory(0) = Array(txt_BPP_UnprfBordC, 39)
        .ListFieldsMandatory(1) = Array(txt_BPP_UnprfBordD, 40)
        .ListFieldsMandatory(2) = Array(txt_BPP_UnprfBordE, 43)
        .ListFieldsMandatory(3) = Array(txt_BPP_UnprfBordF, 44)
        .ListFieldsMandatory(4) = Array(txt_BPP_OverprfBordC, 49)
        .ListFieldsMandatory(5) = Array(txt_BPP_OverprfBordD, 50)
        .ListFieldsMandatory(6) = Array(txt_BPP_OverprfBordE, 51)
        .ListFieldsMandatory(7) = Array(txt_BPP_OverprfBordF, 52)
        .ListFieldsMandatory(8) = Array(cbo_Perforation, 59)
        .ListFieldsMandatory(9) = Array(txt_BPP_MatThick, 38)
        
        ReDim .ListFieldsToDisable(-1 To -1)
    End With

    With mt_SubdetailConfig(1)
        .FrameIndex = 1
        .NameFrame = "DPC_BaseTypeBendParam"
        .DetailConfigIndex = 0
        .Initialized = False
        
        .TabStribIndex = 0
        .TabIndex = 2
        .ShowInTabs = True
        
        .RequestView = "exec DPC_BaseTypeBendParam_lst $Key1$, $Language_Code$"
        .RequestAdd = "exec DPC_BaseTypeBendParam_ins $RF_Code$,$RPL_Thick$,$DFO_Id_Cy$,$BBP_Cy$,$DFO_Id_Cx$,$BBP_Cx$,$DFO_Id_Cz$,$BBP_Cz$,$DFO_Id_Dy$,$BBP_Dy$,$DFO_Id_Dx$,$BBP_Dx$,$DFO_Id_Dz$,$BBP_Dz$," & _
                      "$DFO_Id_Ey$,$BBP_Ey$,$DFO_Id_Ex$,$BBP_Ex$,$DFO_Id_Ez$,$BBP_Ez$,$DFO_Id_Fy$,$BBP_Fy$,$DFO_Id_Fx$,$BBP_Fx$,$DFO_Id_Fz$,$BBP_Fz$,$U_Code$"
        .RequestUpd = "exec DPC_BaseTypeBendParam_upd $RF_Code$,$RPL_Thick$,$DFO_Id_Cy$,$BBP_Cy$,$DFO_Id_Cx$,$BBP_Cx$,$DFO_Id_Cz$,$BBP_Cz$,$DFO_Id_Dy$,$BBP_Dy$,$DFO_Id_Dx$,$BBP_Dx$,$DFO_Id_Dz$,$BBP_Dz$," & _
                      "$DFO_Id_Ey$,$BBP_Ey$,$DFO_Id_Ex$,$BBP_Ex$,$DFO_Id_Ez$,$BBP_Ez$,$DFO_Id_Fy$,$BBP_Fy$,$DFO_Id_Fx$,$BBP_Fx$,$DFO_Id_Fz$,$BBP_Fz$,$U_Code$,$iConcurrency$"
        .RequestDel = "exec DPC_BaseTypeBendParam_del $RF_Code$,$RPL_Thick$,$U_Code$,$iConcurrency$"
        
        .RequestCheckAdd = "select * from DPC_BaseTypeBendParam where SYS_BaeType=$RF_Code$ and RPL_Thick=$RPL_Thick$"
        .RequestCheckUpdate = ""
        
        .TableName = ""
        .TableOrder = ""
        
        .ToolbarID = 2994
        .ToolbarIndex = 1
        .ToolbarFaces = Array("0", "1", "2", "3", "4")
        
        .GridColumns = Array( _
            "SYS_BaeType®©0®©1®©SYS_BaeType®©SYS_BaeType", _
            "RPL_Thick®©1000®©1®©RPL_Thick®©#MAT Thick", _
            "DFO_Id_Cy®©0®©0®©DFO_Id_Cy®©#Cy", "DFO_Formula_Cy®©1200®©0®©DFO_Formula_Cy®©#Formula_Cy", "BBP_Cy®©500®©0®©BBP_Cy®©#Cy", _
            "DFO_Id_Cx®©0®©0®©DFO_Id_Cx®©#Cx", "DFO_Formula_Cx®©1100®©0®©DFO_Formula_Cx®©#Formula_Cx", "BBP_Cx®©500®©0®©BBP_Cx®©#Cx", _
            "DFO_Id_Cz®©0®©0®©DFO_Id_Cz®©#Cz", "DFO_Formula_Cz®©1200®©0®©DFO_Formula_Cz®©#Formula_Cz", "BBP_Cz®©500®©0®©BBP_Cz®©#Cz", _
            "DFO_Id_Dy®©0®©0®©DFO_Id_Dy®©#Dy", "DFO_Formula_Dy®©1200®©0®©DFO_Formula_Dy®©#Formula_Dy", "BBP_Dy®©500®©0®©BBP_Dy®©#Dy", _
            "DFO_Id_Dx®©0®©0®©DFO_Id_Dx®©#Dx", "DFO_Formula_Dx®©1100®©0®©DFO_Formula_Dx®©#Formula_Dx", "BBP_Dx®©500®©0®©BBP_Dx®©#Dx", _
            "DFO_Id_Dz®©0®©0®©DFO_Id_Dz®©#Dz", "DFO_Formula_Dz®©1200®©0®©DFO_Formula_Dz®©#Formula_Dz", "BBP_Dz®©500®©0®©BBP_Dz®©#Dz", _
            "DFO_Id_Ey®©0®©0®©DFO_Id_Ey®©#Ey", "DFO_Formula_Ey®©1200®©0®©DFO_Formula_Ey®©#Formula_Ey", "BBP_Ey®©500®©0®©BBP_Ey®©#Ey", _
            "DFO_Id_Ex®©0®©0®©DFO_Id_Ex®©#Ex", "DFO_Formula_Ex®©1100®©0®©DFO_Formula_Ex®©#Formula_Ex", "BBP_Ex®©500®©0®©BBP_Ex®©#Ex", _
            "DFO_Id_Ez®©0®©0®©DFO_Id_Ez®©#Ez", "DFO_Formula_Ez®©1200®©0®©DFO_Formula_Ez®©#Formula_Ez", "BBP_Ez®©500®©0®©BBP_Ez®©#Ez", _
            "DFO_Id_Fy®©0®©0®©DFO_Id_Fy®©#Fy", "DFO_Formula_Fy®©1200®©0®©DFO_Formula_Fy®©#Formula_Fy", "BBP_Fy®©500®©0®©BBP_Fy®©#Fy", _
            "DFO_Id_Fx®©0®©0®©DFO_Id_Fx®©#Fx", "DFO_Formula_Fx®©1100®©0®©DFO_Formula_Fx®©#Formula_Fx", "BBP_Fx®©500®©0®©BBP_Fx®©#Fx", _
            "DFO_Id_Fz®©0®©0®©DFO_Id_Fz®©#Fz", "DFO_Formula_Fz®©1200®©0®©DFO_Formula_Fz®©#Formula_Fz", "BBP_Fz®©500®©0®©BBP_Fz®©#Fz", _
            "RowStatus®©0®©0®©RowStatus®©#RowStatus", _
            "iConcurrency®©0®©0®©iConcurrency®©iConcurrency")
        
        ReDim .ListFieldsDefaultValue(11)
        For ll_Index = 0 To 11
            .ListFieldsDefaultValue(ll_Index) = Array(txt_BendParam_Cnst(ll_Index), 0)
        Next
        
        ReDim .ListFieldsMandatory(12)
        .ListFieldsMandatory(0) = Array(txt_BBP_MatThick, 8)
        .ListFieldsMandatory(1) = Array(txt_BendParam_Cnst(0), 7)
        .ListFieldsMandatory(2) = Array(txt_BendParam_Cnst(1), 3)
        .ListFieldsMandatory(3) = Array(txt_BendParam_Cnst(2), 6)
        .ListFieldsMandatory(4) = Array(txt_BendParam_Cnst(3), 2)
        .ListFieldsMandatory(5) = Array(txt_BendParam_Cnst(4), 22)
        .ListFieldsMandatory(6) = Array(txt_BendParam_Cnst(5), 23)
        .ListFieldsMandatory(7) = Array(txt_BendParam_Cnst(6), 5)
        .ListFieldsMandatory(8) = Array(txt_BendParam_Cnst(7), 1)
        .ListFieldsMandatory(9) = Array(txt_BendParam_Cnst(8), 0)
        .ListFieldsMandatory(10) = Array(txt_BendParam_Cnst(9), 24)
        .ListFieldsMandatory(11) = Array(txt_BendParam_Cnst(10), 25)
        .ListFieldsMandatory(12) = Array(txt_BendParam_Cnst(11), 27)
        
        ReDim .ListFieldsToDisable(-1 To -1)
    End With

    With mt_SubdetailConfig(2)
        .FrameIndex = 2
        .NameFrame = "DPC_BaseTypeCutParam"
        .DetailConfigIndex = 0
        .Initialized = False
        
        .TabStribIndex = 0
        .TabIndex = 3
        .ShowInTabs = True
        
        .RequestView = "exec DPC_BaseTypeCutParam_lst $Key1$, $Language_Code$"
        
        'defined in custom db before
        .RequestAdd = "exec DPC_BaseTypeCutParam_ins $RF_Code$,$RPL_Thick$,$CUT_Id$,$DFO_Id_E_zM$,$BCP_E_zM$,$DFO_Id_C_zL$,$BCP_C_zL$," & _
                      "$DFO_Id_J_z$,$BCP_J_z$,$DFO_Id_J_Hz$,$BCP_J_Hz$,$DFO_Id_K_z$,$BCP_K_z$,$DFO_Id_K_Hz$,$BCP_K_Hz$,$U_Code$"
        .RequestUpd = "exec DPC_BaseTypeCutParam_upd $RF_Code$,$RPL_Thick$,$CUT_Id$,$DFO_Id_E_zM$,$BCP_E_zM$,$DFO_Id_C_zL$,$BCP_C_zL$," & _
                      "$DFO_Id_J_z$,$BCP_J_z$,$DFO_Id_J_Hz$,$BCP_J_Hz$,$DFO_Id_K_z$,$BCP_K_z$,$DFO_Id_K_Hz$,$BCP_K_Hz$,$U_Code$,$iConcurrency$"
        .RequestDel = "exec DPC_BaseTypeCutParam_del $RF_Code$,$RPL_Thick$,$CUT_Id$,$U_Code$,$iConcurrency$"
        
        .RequestCheckAdd = "select * from DPC_BaseTypeCutParam where SYS_BaeType=$RF_Code$ and RPL_Thick=$RPL_Thick$ and CUT_Id=$CUT_Id$"
        .RequestCheckUpdate = ""
        
        .TableName = ""
        .TableOrder = ""
        
        .ToolbarID = 2995
        .ToolbarIndex = 1
        .ToolbarFaces = Array("0", "1", "2", "3", "4")
        
        .GridColumns = Array( _
            "SYS_BaeType®©0®©1®©SYS_BaeType®©SYS_BaeType", _
            "RPL_Thick®©1000®©1®©RPL_Thick®©#MAT Thick", _
            "CUT_Id®©0®©1®©CUT_Id®©#CUT_Id", _
            "CUT_Name®©2000®©0®©CUT_Name®©#CUT_Name", _
            "DFO_Id_E_zM®©0®©0®©DFO_Id_E_zM®©#E_zM", "DFO_Formula_E_zM®©2200®©0®©DFO_Formula_E_zM®©#Formula_E_zM", "BCP_E_zM®©700®©0®©BCP_E_zM®©#E_zM", _
            "DFO_Id_C_zL®©0®©0®©DFO_Id_C_zL®©#C_zL", "DFO_Formula_C_zL®©2200®©0®©DFO_Formula_C_zL®©#Formula_C_zL", "BCP_C_zL®©700®©0®©BCP_C_zL®©#C_zL", _
            "DFO_Id_J_z®©0®©0®©DFO_Id_J_z®©#J_z", "DFO_Formula_J_z®©2200®©0®©DFO_Formula_J_z®©#Formula_J_z", "BCP_J_z®©700®©0®©BCP_J_z®©#J_z", _
            "DFO_Id_J_Hz®©0®©0®©DFO_Id_J_Hz®©#J_Hz", "DFO_Formula_J_Hz®©2200®©0®©DFO_Formula_J_Hz®©#Formula_J_Hz", "BCP_J_Hz®©700®©0®©BCP_J_Hz®©#J_Hz", _
            "DFO_Id_K_z®©0®©0®©DFO_Id_K_z®©#K_z", "DFO_Formula_K_z®©2200®©0®©DFO_Formula_K_z®©#Formula_K_z", "BCP_K_z®©700®©0®©BCP_K_z®©#K_z", _
            "DFO_Id_K_Hz®©0®©0®©DFO_Id_K_Hz®©#K_Hz", "DFO_Formula_K_Hz®©2200®©0®©DFO_Formula_K_Hz®©#Formula_K_Hz", "BCP_K_Hz®©700®©0®©BCP_K_Hz®©#K_Hz", _
            "RowStatus®©0®©0®©RowStatus®©#RowStatus", _
            "iConcurrency®©0®©0®©iConcurrency®©iConcurrency")
        
        ReDim .ListFieldsDefaultValue(5)
        For ll_Index = 0 To 5
            .ListFieldsDefaultValue(ll_Index) = Array(txt_CutParam_Cnst(ll_Index), 0)
        Next
        
        ReDim .ListFieldsMandatory(7)
        .ListFieldsMandatory(0) = Array(txt_BCP_MatThick, 13)
        .ListFieldsMandatory(1) = Array(txt_CutParam_Cnst(0), 14)
        .ListFieldsMandatory(2) = Array(txt_CutParam_Cnst(1), 18)
        .ListFieldsMandatory(3) = Array(txt_CutParam_Cnst(2), 12)
        .ListFieldsMandatory(4) = Array(txt_CutParam_Cnst(3), 41)
        .ListFieldsMandatory(5) = Array(txt_CutParam_Cnst(4), 26)
        .ListFieldsMandatory(6) = Array(txt_CutParam_Cnst(5), 35)
        .ListFieldsMandatory(7) = Array(cbo_bcp_cutout, 37)
        
        ReDim .ListFieldsToDisable(-1 To -1)
    End With


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

Private Function tlb_Main_CustomAction(Index As Integer, ByVal as_Role As String, as_Language As String) As Boolean
On Error GoTo ErrHandler
    
    Dim ll_MainIndex As Long
    
    tlb_Main_CustomAction = False
    ll_MainIndex = FindMainConfigByFrameIndex(Index)
    
    tlb_Main_CustomAction = False
    Select Case as_Role
    Case "X"
      If StrComp(mt_MainConfig(ll_MainIndex).NameFrame, "DPC_BaseType", vbTextCompare) = 0 Then
        If (grd_Main(mt_MainConfig(ll_MainIndex).FrameIndex).SelectedCount = 1) Then
          Call CopyBaseTypeRecord(grd_Main(mt_MainConfig(ll_MainIndex).FrameIndex).SelectedKey(0)(0))
        Else
          Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 666, "#Please select source Base Type record")
        End If
      End If
      tlb_Main_CustomAction = True
    End Select
    Exit Function
ErrHandler:
    Call ErrorHandler("tlb_Main_CustomAction")
End Function

Private Function tlb_detail_CustomAction(Index As Integer, ByVal as_Role As String, as_Language As String) As Boolean
On Error GoTo ErrHandler
    
Dim ll_FDA_Code As Long
Dim ll_DetailIndex As Long

    tlb_detail_CustomAction = False
    ll_DetailIndex = FindDetailConfigByFrameIndex(Index)
    Select Case as_Role
    End Select
    Exit Function
ErrHandler:
    Call ErrorHandler("tlb_detail_CustomAction")
End Function

Private Function tlb_Subdetail_CustomAction(Index As Integer, ByVal as_Role As String, as_Language As String) As Boolean
On Error GoTo ErrHandler
    
    Dim ll_SubdetailIndex As Long
    
    tlb_Subdetail_CustomAction = False
    ll_SubdetailIndex = FindSubDetailConfigByFrameIndex(Index)
    If as_Role = "O" Or as_Role = "P" Or as_Role = "g" Then
        tlb_Subdetail_CustomAction = True
        If grd_SubDetail(Index).SelectedCount <> 1 Then Exit Function
        
        Select Case as_Role
        Case "P"
        Case "g"
        End Select
    End If
    Exit Function
ErrHandler:
    Call ErrorHandler("tlb_Subdetail_CustomAction")
End Function

Private Function grd_Main_CustomAction(Index As Integer, ByVal ae_Action As eControlAction) As Boolean
On Error GoTo ErrHandler

Dim ll_MainIndex As Long
Dim ll_FDA_Code As Long

    grd_Main_CustomAction = False
    ll_MainIndex = FindMainConfigByFrameIndex(Index)
    If StrComp(mt_MainConfig(ll_MainIndex).NameFrame, "DPC_Ref", vbTextCompare) = 0 Then

    End If
    grd_Main_CustomAction = False
    Exit Function
ErrHandler:
    Call ErrorHandler("grd_Main_CustomAction")
End Function

Private Function Resize_Custom() As Boolean
On Error GoTo ErrHandler

    Resize_Custom = False
    Exit Function
ErrHandler:
    Call ErrorHandler("Resize_Custom")
End Function

Private Sub Item_CustomInit(ByVal al_DetailIndex As Long, ByVal av_Key As Variant, ByVal ae_Mode As eMode)
On Error GoTo ErrHandler

Const LIST_REQUEST_VEN = "exec DPC_Vendor_lst"
Const LIST2_REQUEST_VEN = "exec DPC_SysVendor_lst $SYS_Id$"

    Dim ll_DetailFrameIndex As Long
    Dim ls_Request As String
    Dim ll_Key As Integer
    Dim ll_Index As Integer
    
    ll_DetailFrameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
        
    If (ae_Mode = emAdd) Or (ae_Mode = emUpdate) Then
        If (mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_PrdBendParam") Then
          Call mo_Tools.EnableFrame(UserControl.Controls, fra_PrdBendParam, False)
        ElseIf (mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_PrdPerfParam") Then
          Call mo_Tools.EnableFrame(UserControl.Controls, fra_PrdPerfParam, False)
        ElseIf (mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_PrdCutParam") Then
          Call mo_Tools.EnableFrame(UserControl.Controls, fra_PrdCutParam, False)
        ElseIf (mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_PrdCADExport") Then
          Call mo_Tools.EnableFrame(UserControl.Controls, fra_PrdCADExport, False)
          Call mo_Tools.EnableFrame(UserControl.Controls, fra_PrdCADExport_Group, False)
          cbo_PrdCADExportPRD_Name.Enabled = True
        End If
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_CustomInit")
End Sub

Private Sub Item_CustomLoad(ByVal al_DetailIndex As Long, ByVal av_Key As Variant)
On Error GoTo ErrHandler

Dim ls_Request As String
Dim lo_Tree As ArmTreeView
Dim ll_MainConfigIndex As Long
Dim lsa_path() As String

    ll_MainConfigIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    
    If StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BaseType", vbTextCompare) = 0 Then
        txt_DetailKey(mt_DetailConfig(al_DetailIndex).DetailKey).Text = av_Key(0)
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_CustomLoad")
End Sub

Private Function Item_CustomCheck(ByVal al_DetailIndex As Long, ByVal ae_Mode As eMode) As Boolean
On Error GoTo ErrHandler
    Dim ll_MainConfigIndex As Long
    Dim ll_MainFrameIndex As Long
    Dim ll_RowIdx, ll_ColIdx
    
    Item_CustomCheck = False
    ll_MainConfigIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    If ll_MainConfigIndex <> -1 Then
        ll_MainFrameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
        If StrComp(mt_MainConfig(ll_MainConfigIndex).NameFrame, "DPC_BaseType", vbTextCompare) = 0 Then

        End If
        
    Else
        Select Case al_DetailIndex
        Case Else
        End Select
    End If
    Item_CustomCheck = True
    Exit Function
ErrHandler:
    Call ErrorHandler("Item_CustomCheck")
End Function

Private Sub Item_CustomLoadDefaultValue(ByVal al_DetailIndex As Long, ByRef av_ListFieldsDefaultValue As Variant)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long, ll_MainConfigIndex As Long
Dim lo_Tree As ArmTreeView
Dim ls_Code As String, ls_Desc As String

Dim ll_SubdetailConfig As Long
Dim ll_SubdetailFrame As Long
Dim ll_Idx As Long

    ll_MainConfigIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    
    If StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "", vbTextCompare) = 0 Then
    End If
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_CustomLoadDefaultValue")
End Sub

Private Function Item_CustomAddDB(ByVal al_DetailIndex As Long, ByVal ab_InTransaction As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim ls_Filename As String

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
                    
    If StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_System", vbTextCompare) = 0 And ab_InTransaction = True Then
        
    End If
    
    Item_CustomAddDB = True
    Exit Function
ErrHandler:
    Item_CustomAddDB = False
    Call ErrorHandler("Item_CustomAddDB")
End Function

Private Function Item_CustomUpdateDB(ByVal al_DetailIndex As Long, ByVal ab_InTransaction As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim ls_Request As String
Dim ll_RowIdx, ll_ColIdx As Long

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
        
    If StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_System", vbTextCompare) = 0 And ab_InTransaction = True Then
        
    End If
        
    Item_CustomUpdateDB = True
    Exit Function
ErrHandler:
    Item_CustomUpdateDB = False
    Call ErrorHandler("Item_CustomUpdateDB")
End Function

Private Function Item_CustomDeleteDB(ByVal al_DetailIndex As Long, ByVal ab_InTransaction As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Long

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    If Not ab_InTransaction Then
    
    End If
    Item_CustomDeleteDB = True
    Exit Function
ErrHandler:
    Item_CustomDeleteDB = False
    Call ErrorHandler("Item_CustomDeleteDB")
End Function

Private Sub Item_CustomLocal(ByVal al_DetailIndex As Long, ByVal ae_Mode As eMode)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim ll_MainIndex As Long
Dim ll_MainFrame As Long
Dim ll_PrevDetailIndex As Long
Dim ls_ImgId As String
Dim ls_Array() As String
Dim ll_Index As Long

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    ll_MainIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    
    If ll_MainIndex <> -1 Then
       ll_MainFrame = mt_MainConfig(ll_MainIndex).FrameIndex
       
       If ae_Mode = emAdd Then
           grd_Main(ll_MainFrame).SelectedLine(0, "Z_Creation") = Now
           grd_Main(ll_MainFrame).SelectedLine(0, "Z_Creator") = ml_U_Code
           grd_Main(ll_MainFrame).SelectedLine(0, "Z_Creator_Name") = ms_UserName
       End If
           
       If (ae_Mode = emAdd) Or (ae_Mode = emUpdate) Then
           grd_Main(ll_MainFrame).SelectedLine(0, "Id") = txt_DetailKey(ll_frameIndex).Text
           Select Case al_DetailIndex + 1
           End Select
       End If
    Else
    End If
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_CustomLocal")
End Sub

Private Sub SubItem_CustomInit(ByVal al_SubDetailIndex As Long, ByVal av_Key As Variant, ByVal ae_Mode As eMode)
On Error GoTo ErrHandler
    Dim ll_frameIndex As Long
    Dim ll_DetailIndex As Long
    Dim ll_Count As Long
    
    ll_DetailIndex = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
        

    If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BaseTypePerfParam" Then
        If (ae_Mode = eMode.emUpdate) Then
            txt_BPP_MatThick.Enabled = False
            cbo_Perforation.Enabled = False
        ElseIf (ae_Mode = eMode.emAdd) Then
            txt_BPP_MatThick.Enabled = True
            cbo_Perforation.Enabled = True
        End If
    ElseIf mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BaseTypeBendParam" Then
        If (ae_Mode = eMode.emUpdate) Then
            txt_BBP_MatThick.Enabled = False
        ElseIf (ae_Mode = eMode.emAdd) Then
            txt_BBP_MatThick.Enabled = True
        End If
    ElseIf mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BaseTypeCutParam" Then
        If (ae_Mode = eMode.emUpdate) Then
            txt_BCP_MatThick.Enabled = False
            cbo_bcp_cutout.Enabled = False
        ElseIf (ae_Mode = eMode.emAdd) Then
            txt_BCP_MatThick.Enabled = True
            cbo_bcp_cutout.Enabled = True
        End If
    End If
    
    If (ae_Mode = eMode.emAdd) Or (ae_Mode = eMode.emUpdate) Then
    
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("SubItem_CustomInit")
End Sub

Private Sub SubItem_CustomLoad(ByVal al_SubDetailIndex As Long)
On Error GoTo ErrHandler

Dim ll_Row As Long
Dim ls_Request As String
Dim ll_Cursor As Long
Dim lb_DelayedLoad As Boolean
Dim ll_DetailConfig As Long
Dim ll_DetailFrame As Long
Dim ll_GrdIdx As Integer

    ll_DetailConfig = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    ll_DetailFrame = mt_DetailConfig(ll_DetailConfig).FrameIndex

    If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BendingConfig" Or _
        mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_GasketConfig" Or _
        mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_SpacerConfig" Then
        
        If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BendingConfig" Then
            ls_Request = "exec DPC_SysDefault_lst $SYS_Id$," & eDPCSystemDefaultType.sdBending & ", $Language_code$"
            ll_GrdIdx = 0
        ElseIf mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_GasketConfig" Then
            ls_Request = "exec DPC_SysDefault_lst $SYS_Id$," & eDPCSystemDefaultType.sdGasket & ", $Language_code$"
            ll_GrdIdx = 3
        ElseIf mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_SpacerConfig" Then
            ls_Request = "exec DPC_SysDefault_lst $SYS_Id$," & eDPCSystemDefaultType.sdSpacer & ", $Language_code$"
            ll_GrdIdx = 4
        End If
        
        ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_DetailKey(ll_DetailFrame))
        ls_Request = ReplaceCommonPlaceholders(ls_Request)

        ll_Cursor = mo_Db.OpenSQL(ls_Request)
        ll_Row = 0
        
        While Not mo_Db.EOF(ll_Cursor)
            ReDim lv_Data(3)
            lv_Data(0) = ""         ' this is new
            If grd_SubDetail(ll_GrdIdx).AddLine(lv_Data) Then
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD_Order") = mo_Db.GetFields(ll_Cursor, "SYD_Order")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD1_Id") = mo_Db.GetFields(ll_Cursor, "SYD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD1_Id") = mo_Db.GetFields(ll_Cursor, "PRD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD1_Desc") = mo_Db.GetFields(ll_Cursor, "PRD_Name")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD1_Value") = mo_Db.GetFields(ll_Cursor, "SYD_Value")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "Conc1") = mo_Db.GetFields(ll_Cursor, "iConcurrency")
                    Call mo_Db.Next(ll_Cursor)
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD2_Id") = mo_Db.GetFields(ll_Cursor, "SYD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD2_Id") = mo_Db.GetFields(ll_Cursor, "PRD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD2_Desc") = mo_Db.GetFields(ll_Cursor, "PRD_Name")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD2_Value") = mo_Db.GetFields(ll_Cursor, "SYD_Value")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "Conc2") = mo_Db.GetFields(ll_Cursor, "iConcurrency")
                    Call mo_Db.Next(ll_Cursor)
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD3_Id") = mo_Db.GetFields(ll_Cursor, "SYD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD3_Id") = mo_Db.GetFields(ll_Cursor, "PRD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD3_Desc") = mo_Db.GetFields(ll_Cursor, "PRD_Name")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD3_Value") = mo_Db.GetFields(ll_Cursor, "SYD_Value")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "Conc3") = mo_Db.GetFields(ll_Cursor, "iConcurrency")
                    Call mo_Db.Next(ll_Cursor)
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD4_Id") = mo_Db.GetFields(ll_Cursor, "SYD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD4_Id") = mo_Db.GetFields(ll_Cursor, "PRD_Id")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "PRD4_Desc") = mo_Db.GetFields(ll_Cursor, "PRD_Name")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "SYD4_Value") = mo_Db.GetFields(ll_Cursor, "SYD_Value")
                    grd_SubDetail(ll_GrdIdx).SelectedLine(0, "Conc4") = mo_Db.GetFields(ll_Cursor, "iConcurrency")
                    Call grd_Subdetail_RowLoaded(ll_GrdIdx, ll_Row)
                    ll_Row = ll_Row + 1
            End If
            Call mo_Db.Next(ll_Cursor)
        Wend
        Call mo_Db.Close(ll_Cursor)
        
    ElseIf mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_MatThick" Then
        'mt_SubdetailConfig(al_SubDetailIndex).RequestView = mo_Tools.ReplacePlaceholderByControlValue("exec DPC_MatThick_lst2 $Key1$, $Key2$, $Language_Code$", cbo_MTH_MAT_Id)
    End If
                 
    Exit Sub
ErrHandler:

    If ll_Cursor > 0 Then
        Call mo_Db.Close(ll_Cursor)
    End If
    Call ErrorHandler("SubItem_CustomLoad")
End Sub

Private Sub SubItem_CustomLoadDefaultValue(ByVal al_SubDetailIndex As Long, ByRef av_ListFieldsDefaultValue As Variant)
On Error GoTo ErrHandler

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

Private Function SubItem_CustomCheck(ByVal al_SubDetailIndex As Long, ByVal ae_Mode As eMode) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim ll_Index As Long
Dim ll_RowIdx As Long
Dim ls_Filename As String
Dim lv_MsgReplaceInfo(0, 1) As String
    
    SubItem_CustomCheck = True
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    
    If StrComp(mt_SubdetailConfig(al_SubDetailIndex).NameFrame, "DPC_SysPrfDefault", vbTextCompare) = 0 Then


    End If
    
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_CustomCheck")
End Function

Private Function SubItem_CustomCheckDB(ByVal al_SubDetailIndex As Long, ByVal ae_Mode As eMode)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long

    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    If StrComp(mt_SubdetailConfig(al_SubDetailIndex).NameFrame, "", vbTextCompare) = 0 Then
    End If
    SubItem_CustomCheckDB = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_CustomCheckDB")
End Function

Private Function SubItem_CustomAdd(ByVal al_SubDetailIndex As Long, ByRef ab_CustomSaved As Boolean) As Boolean
On Error GoTo ErrHandler

Dim lb_OldInternalInit As Boolean
Dim ll_frameIndex As Long
Dim ll_Count As Long
Dim ll_DetailIndex As Long

    ab_CustomSaved = False
    lb_OldInternalInit = mb_InternalInit
    mb_InternalInit = True
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailIndex = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    
    If StrComp(mt_SubdetailConfig(al_SubDetailIndex).NameFrame, "DPC_BendingConfig", vbTextCompare) = 0 Then
        
    End If
    
    mb_InternalInit = lb_OldInternalInit
    SubItem_CustomAdd = True
    Exit Function
ErrHandler:
    mb_InternalInit = lb_OldInternalInit
    Call ErrorHandler("SubItem_CustomAdd")
End Function

Private Function SubItem_CustomUpdate(ByVal al_SubDetailIndex As Long, ByRef ab_CustomSaved As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Long

    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ab_CustomSaved = False
    SubItem_CustomUpdate = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_CustomUpdate")
End Function

Private Function SubItem_CustomDelete(ByVal al_SubDetailIndex As Long, ByRef ab_CustomSaved As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_frameIndex As Long
Dim ll_DetailConfig As Long
Dim ll_DetailFrame As Long
Dim ll_RowIdx As Long, ll_ColIdx As Long

    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailConfig = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    ll_DetailFrame = mt_DetailConfig(ll_DetailConfig).FrameIndex
        
    ab_CustomSaved = False
    SubItem_CustomDelete = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_CustomDelete")
End Function

Private Function SubItem_CustomDBBefore(ByVal al_SubDetailIndex As Long, ByVal ae_Mode As eMode, ByVal al_Index As Long, ByRef ab_CustomSaved As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_frameIndex As Long
Dim ll_DetailConfig As Long
Dim ll_DetailFrame As Long
Dim ll_RowIdx As Long, ll_ColIdx As Long, ll_ConcIdx As Long

    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailConfig = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    ll_DetailFrame = mt_DetailConfig(ll_DetailConfig).FrameIndex
    
    If StrComp(mt_SubdetailConfig(al_SubDetailIndex).NameFrame, "DPC_MatThick", vbTextCompare) = 0 Then
        If ae_Mode = eMode.emAdd Then
           
        ElseIf ae_Mode = eMode.emUpdate Then

        End If
    End If
        
    SubItem_CustomDBBefore = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_CustomDBBefore")
End Function

Private Function SubItem_CustomDBAfter(ByVal al_SubDetailIndex As Long, ByVal ae_Mode As eMode, ByVal al_Index As Long, ByRef ab_CustomSaved As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim ll_DetailConfig As Long
Dim ll_DetailFrame As Long
Dim ll_PageId As Long, ll_ZipTableIndex As Long
Dim ls_Filename As String

    SubItem_CustomDBAfter = False
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailConfig = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    ll_DetailFrame = mt_DetailConfig(ll_DetailConfig).FrameIndex
        
    SubItem_CustomDBAfter = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_CustomDBAfter")
End Function

Private Function IsItemInFilterCustom(ByVal al_DetailIndex As Long, ByRef ab_CheckDone As Boolean) As Boolean
On Error GoTo ErrHandler

    IsItemInFilterCustom = False
    ab_CheckDone = False
    Exit Function
ErrHandler:
    Call ErrorHandler("IsItemInFilterCustom")
End Function

Private Function IsItemSelectedInTreeCustom(ByVal al_DetailIndex As Long, ByRef ao_Tree As ArmTreeView, ByVal av_PathData As Variant, ByRef ab_CheckDone As Boolean) As Boolean
Dim ll_MainIndex As Long
Dim ll_MainFrameIndex As Long

    ab_CheckDone = False
    IsItemSelectedInTreeCustom = False
    
    ll_MainIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    ll_MainFrameIndex = mt_MainConfig(ll_MainIndex).FrameIndex
    
    If FindDetailConfigByName("") = al_DetailIndex Then
    End If
    Exit Function
ErrHandler:
    Call ErrorHandler("IsItemSelectedInTreeCustom")
End Function

Private Sub SetDisabledDetailControls()
On Error GoTo ErrHandler

Dim ll_MainIndex As Long
Dim ll_DetailIndex As Long

    ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainIndex)
    
    Select Case UCase(mt_MainConfig(ll_MainIndex).NameFrame)
    End Select
    Exit Sub
ErrHandler:
    Call ErrorHandler("SetDisabledDetailControls")
End Sub

' parameter is nothing if all driven combo request should be set,
'it is control reference, if just driven controls request for specific control should be set
Private Sub SetDrivenDetailControls(ByRef ao_Control As Object)
On Error GoTo ErrHandler

Dim ll_MainIndex As Long
Dim ll_DetailIndex As Long
Dim ls_Request As String

    ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainIndex)
    
    Select Case UCase(mt_MainConfig(ll_MainIndex).NameFrame)
    End Select
    Call SetDisabledDetailControls
    Exit Sub
ErrHandler:
    Call ErrorHandler("SetDrivenDetailControls")
End Sub

Private Sub UpdateMainToolbarCustom(ByVal al_MainIndex As Long)
On Error GoTo ErrHandler
Dim ll_frameIndex As Long
    
    ll_frameIndex = mt_MainConfig(al_MainIndex).FrameIndex
    
    If StrComp(mt_MainConfig(al_MainIndex).NameFrame, "DPC_System", vbTextCompare) = 0 Then
       
        If tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).Language = "E" Then
            tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).ButtonEnabled("B") = True
        Else
            tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).ButtonEnabled("A") = False
            tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).ButtonEnabled("B") = True
            tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).ButtonEnabled("C") = True
        End If
    Else
        tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).ButtonEnabled("A") = True
        tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).ButtonEnabled("B") = True
        tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).ButtonEnabled("C") = True
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("UpdateMainToolbarCustom")
End Sub

Private Sub UpdateDetailToolbarCustom(ByVal al_Detailndex As Long)
On Error GoTo ErrHandler
Dim ll_DetailFrameIndex As Long
Dim ll_MainFrameIndex As Long
Dim ll_MainIndex As Long

    ll_DetailFrameIndex = mt_DetailConfig(al_Detailndex).FrameIndex
    ll_MainIndex = mt_DetailConfig(al_Detailndex).MainConfigIndex
    If ll_MainIndex >= 0 Then
        ll_MainFrameIndex = mt_MainConfig(ll_MainIndex).FrameIndex
    
        If StrComp(mt_MainConfig(ll_MainIndex).NameFrame, "DPC_System", vbTextCompare) = 0 Or _
            StrComp(mt_MainConfig(ll_MainIndex).NameFrame, "DPC_SysCat", vbTextCompare) = 0 Or _
            StrComp(mt_MainConfig(ll_MainIndex).NameFrame, "DPC_Material", vbTextCompare) = 0 Then
            
            If tlb_Main(mt_MainConfig(ll_MainIndex).ToolbarIndex).Language = "E" Then
                tlb_Detail(mt_DetailConfig(al_Detailndex).ToolbarIndex).ButtonEnabled("B") = True
            Else
                tlb_Detail(mt_DetailConfig(al_Detailndex).ToolbarIndex).ButtonEnabled("A") = False
                tlb_Detail(mt_DetailConfig(al_Detailndex).ToolbarIndex).ButtonEnabled("B") = True
                tlb_Detail(mt_DetailConfig(al_Detailndex).ToolbarIndex).ButtonEnabled("C") = True
            End If
        Else
            tlb_Detail(mt_DetailConfig(al_Detailndex).ToolbarIndex).ButtonEnabled("A") = True
            tlb_Detail(mt_DetailConfig(al_Detailndex).ToolbarIndex).ButtonEnabled("B") = True
            tlb_Detail(mt_DetailConfig(al_Detailndex).ToolbarIndex).ButtonEnabled("C") = True
        End If
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("UpdateDetailToolbarCustom")
End Sub

Private Sub UpdateSubdetailToolbarCustom(ByVal al_Subdetailndex As Long)
    Exit Sub
ErrHandler:
    Call ErrorHandler("UpdateSubdetailToolbarCustom")
End Sub

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK 1.0
' please DO NOT change anything in this part of code
'**********************************************************************************************************************************
'**********************************************************************************************************************************

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK PROPERTIES
' please DO NOT change anything in this part of code
'**********************************************************************************************************************************
'**********************************************************************************************************************************

Public Property Let Visible(ByVal aVisible As Boolean)
    UserControl.Extender.Visible = aVisible
End Property

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

Public Property Let Top(ByVal aTop As Single)
    UserControl.Extender.Top = aTop
End Property
Public Property Get Top() As Single
    Top = UserControl.Extender.Top
End Property

Public Property Let Height(ByVal aHeight As Single)
    UserControl.Extender.Height = aHeight
End Property
Public Property Get Height() As Single
    Height = UserControl.Extender.Height
End Property

Public Property Let Left(ByVal aLeft As Single)
    UserControl.Extender.Left = aLeft
End Property
Public Property Get Left() As Single
    Left = UserControl.Extender.Left
End Property

Public Property Let Width(ByVal aWidth As Single)
    UserControl.Extender.Width = aWidth
End Property
Public Property Get Width() As Single
    Width = UserControl.Extender.Width
End Property

Public Sub Move(ByVal aLeft As Single, ByVal aTop As Single, ByVal aWidth As Single, ByVal aHeight As Single)
    Call UserControl.Extender.Move(aLeft, aTop, aWidth, aHeight)
End Sub
Public Property Let 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
    Initialized = mb_Initialized
End Property

Property Get ConnectString() As String
    ConnectString = m_ConnectString
End Property

Property Let LoginName(as_Login As String)
ms_LoginName = as_Login
End Property

Property Let U_Code(al_Code As Long)
ml_U_Code = al_Code
End Property

Property Let Language_Code(AString As String)
ms_Language_Code = AString
End Property

Public Property Set ArmDb(ByRef local_connection As Object)
    If Not (local_connection Is Nothing) Then
        Set mo_Db = local_connection
    End If
End Property

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

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

Private Function GetSeparatedStringElement(ByVal as_SeparatedString As String, ByVal as_Name As String) As String
On Error GoTo ErrHandler
    
    Dim lsa_Array() As String
    Dim ll_Idx As Long
    
    GetSeparatedStringElement = ""
    lsa_Array = Split(as_SeparatedString, SEP)
    ll_Idx = 0
    While ll_Idx < UBound(lsa_Array)
        If StrComp(as_Name, lsa_Array(ll_Idx), vbTextCompare) = 0 Then
            GetSeparatedStringElement = lsa_Array(ll_Idx + 1)
            Exit Function
        End If
        ll_Idx = ll_Idx + 3
    Wend
    Exit Function
ErrHandler:
    Call ErrorHandler("GetSeparatedStringElement")
End Function






Private Sub tbs_SubDetail_BeforeClick(Index As Integer, Cancel As Integer)
On Error GoTo ErrHandler
    
    If me_SubDetailMode <> eMode.emList And me_SubDetailMode <> eMode.emView Then Cancel = True
    
ErrHandler:
    Call LogMessage("tbs_SubDetail_BeforeClick")
End Sub

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

Dim ll_Index As Long

    If tbs_SubDetail(Index).SelectedItem Is Nothing Then Exit Sub
        
    Call mo_Tools.LockScreen(Me, True)
    
    ll_Index = FindSubDetailConfigByTabIndex(tbs_SubDetail(Index).SelectedItem.Index)
    Call ShowSubDetail(ll_Index)
    
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
ErrHandler:
    Call mo_Tools.LockScreen(Me, False)
    Call ErrorMessage("tbs_SubDetail_Click")
End Sub



'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK CONTROL EVENTS
' please DO NOT change anything in this part of code
'**********************************************************************************************************************************
'**********************************************************************************************************************************



Private Sub tlb_Main_action(Index As Integer, ByVal as_Role As String, as_Language As String)
On Error GoTo ErrHandler
    
    Dim ll_MainConfigIndex As Long, ll_frameIndex As Long, ll_DetailConfigIndex As Long, ll_MainFrameIndex As Long
    
    If Not tlb_Main(Index).Enabled Then Exit Sub
    
    Call mo_Tools.LockScreen(Me, True)
    
    If Not tlb_Main_CustomAction(Index, as_Role, as_Language) Then
        ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
        ll_frameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
        ll_DetailConfigIndex = FindDetailConfigByMainConfig(ll_MainConfigIndex)
        ll_MainFrameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
        Select Case as_Role
            Case "A"
                ' Want to Add
                Call Item_AddInit(ll_DetailConfigIndex)
                
            Case "B"
            ' Want to Update
                If grd_Main(ll_MainFrameIndex).SelectedCount = 1 Then
                    Call Item_UpdateInit(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex).CurrentKey)
                End If
            Case "C"
            ' Want to delete
                If grd_Main(ll_MainFrameIndex).SelectedCount = 1 Then
                    Call Item_DeleteInit(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex).CurrentKey)
                End If
            Case "L"
            ' Want to reload treeview and refresh the grid
                Call ReloadMainGrid
            Case "F"
                ' Want to reload grid according to treeview selection
                Call ReloadMainTreeview
            Case "Q"
                Call mo_Tools.ChangeCharset(UserControl.Controls, gl_CodePage, mo_Tools.GetCodePageFromLanguage(mo_Db, tlb_Main(ll_frameIndex).Language))
                Call ReloadMainGrid
                Call Init_Custom
                Call cbo_View_ComboItemSelected(Index)
            Case "G"
                Call ImportExcelData(ll_MainConfigIndex)
            Case "T"
                Call mo_Tools.LockScreen(Me, False)
                RaiseEvent quit
                Exit Sub
            Case Else
                Err.Raise ArmErr.InvalidArgument, "tlb_Main_action(" & Index & ")", "Unknown main toolbar role as_Role=" & as_Role
        End Select
    End If
    
    Call mo_Tools.LockScreen(Me, False)
    
    Exit Sub
ErrHandler:
    Call mo_Tools.UpdateError(True)
    Call mo_Tools.LockScreen(Me, False)

    Select Case Err.Number
    Case 202
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 202, "#The item you have added/updated couldn't be displayed with the current criteria set.", , vbInformation + vbOKOnly)
    Case ArmErr.SQLBadRowExpectedCount
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2138, "#The record you try to open has been deleted by an other user. Please refresh the grid.", , vbInformation)
    Case ArmErr.SQLBadRowAffectedCount
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2144, "#This record has been, modified by an other.Please exit from this screen and refresh the grid.", , vbInformation)
    Case Else
        Call LogMessage("tlb_list_action")
        ' user interface can be inconsistent, better to close application
        Call mo_Tools.UpdateError(False)
        Call MsgBox("Error occured, please contact IT. Application will now shutdown." & vbCrLf & Err.Source & vbCrLf & "Description: " & Err.Description, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
        End
    End Select
End Sub

Private Sub tlb_detail_action(Index As Integer, ByVal as_Role As String, as_Language As String)
On Error GoTo ErrHandler
    
    Dim ll_MainConfigIndex As Long, ll_MainFrameIndex As Long, ll_DetailConfigIndex As Long
    
    If Not tlb_Detail(Index).Enabled Then Exit Sub
    
    Call mo_Tools.LockScreen(Me, True)
    
    ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_MainFrameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
    ll_DetailConfigIndex = FindDetailConfigByMainConfig(ll_MainConfigIndex)
    
    If Not tlb_detail_CustomAction(Index, as_Role, as_Language) Then
        Select Case as_Role
            Case "A"
                ' Want to Add
                Call Item_AddInit(ll_DetailConfigIndex)
            Case "B"
                ' Want to Update
                Call Item_UpdateInit(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex).CurrentKey)
            Case "C"
                ' Want to delete
                Call Item_DeleteInit(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex).CurrentKey)
            Case "Y"
                Call GotoNextItem(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex))
            Case "Z"
                Call GotoPreviousItem(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex))
            Case "H"
                Select Case me_DetailMode
                Case emAdd
                    Call Item_Add(ll_DetailConfigIndex)
                Case emUpdate
                    Call Item_Update(ll_DetailConfigIndex)
                Case emDelete
                    If mo_Tools.ShowMsg(mo_Db, ms_Language_Code, mt_DetailConfig(ll_DetailConfigIndex).DeleteMsg(0, 0), mt_DetailConfig(ll_DetailConfigIndex).DeleteMsg(0, 1), , vbExclamation + vbDefaultButton2 + vbYesNo) = vbYes Then
                        Call Item_Delete(ll_DetailConfigIndex)
                    End If
                End Select
            Case "I"
                Call Item_ReInit(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex).CurrentKey)
            Case "F"
                Call Item_ViewInit(ll_DetailConfigIndex, grd_Main(ll_MainFrameIndex).CurrentKey)
            Case "T"
                If mt_DetailConfig(ll_DetailConfigIndex).MainConfigIndex <> -1 Then
                    Call SetMode(emList)
                Else
                    ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
                    mt_MainConfig(ll_MainConfigIndex).CurrentDetailIndex = mt_DetailConfig(ll_DetailConfigIndex).PreviousDetailIndex
                    Call SetMode(me_DetailMode)
                End If
                
                If mc_Item <> 0 Then
                    Call mo_Db.Close(mc_Item)
                    mc_Item = 0
                End If

            Case Else
                Err.Raise ArmErr.InvalidArgument, "tlb_detail_action(" & Index & ")", "Unknown detail toolbar role as_Role=" & as_Role
        End Select
    End If
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
ErrHandler:
    Call mo_Tools.UpdateError(True)
    Call mo_Tools.LockScreen(Me, False)

    Select Case Err.Number
    Case 202
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 202, "#The item you have added/updated couldn't be displayed with the current criteria set.", , vbInformation + vbOKOnly)
    Case ArmErr.SQLBadRowExpectedCount
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2138, "#The record you try to open has been deleted by an other user. Please refresh the grid.", , vbInformation)
    Case ArmErr.SQLBadRowAffectedCount
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2144, "#This record has been, modified by an other.Please exit from this screen and refresh the grid.", , vbInformation)
    Case Else
        Call LogMessage("tlb_Detail_action")
        Call mo_Tools.UpdateError(False)
        Call MsgBox("Error occured, please contact IT. Application will now shutdown." & vbCrLf & Err.Source & vbCrLf & "Description: " & Err.Description, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
        End
    End Select
End Sub

Private Sub tlb_Subdetail_action(Index As Integer, ByVal as_Role As String, as_Language As String)
On Error GoTo ErrHandler
    
    Dim ll_SubdetailIndex As Long
    
    If Not tlb_SubDetail(Index).Enabled Then Exit Sub
    
    Call mo_Tools.LockScreen(Me, True)
    
    ll_SubdetailIndex = FindSubDetailConfigByFrameIndex(Index)
    
    If Not tlb_Subdetail_CustomAction(Index, as_Role, as_Language) Then
        Select Case as_Role
            Case "A"
            ' Want to Add
                Call SubItem_AddInit(ll_SubdetailIndex)
            Case "B"
            ' Want to Update
                Call SubItem_UpdateInit(ll_SubdetailIndex)
            Case "C"
            ' Want to delete
                Call SubItem_DeleteInit(ll_SubdetailIndex)
            Case "Y"
                Call SwapRows(Index, True)
            Case "Z"
                Call SwapRows(Index, False)
            Case "H"
                Select Case me_SubDetailMode
                Case emAdd
                    If SubItem_Add(ll_SubdetailIndex) Then
                        Call SubItem_AddInit(ll_SubdetailIndex)
                    End If
                Case emUpdate
                    If SubItem_Update(ll_SubdetailIndex) Then
                        'go back to the detail screen
                        Call SetModeSubDetail(ll_SubdetailIndex, emList)
                    End If
                Case emDelete
                    If SubItem_Delete(ll_SubdetailIndex) Then
                        'go back to the detail screen
                        Call SetModeSubDetail(ll_SubdetailIndex, emList)
                    End If
                End Select
            Case "F"
                Call grd_SubDetail(Index).Refresh
            Case "T"
                Call SetModeSubDetail(Index, emList)
            Case "I"
                Select Case me_SubDetailMode
                Case emAdd
                    Call SubItem_AddInit(ll_SubdetailIndex)
                Case emUpdate
                    Call SubItem_UpdateInit(ll_SubdetailIndex)
                End Select
            Case "X"
                If grd_SubDetail(Index).SelectedCount = 1 Then
                    If mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9947, "#Are you sure you want to copy selected item to new version ?", , vbYesNo) = vbYes Then
                        Call SubItem_AddInit(ll_SubdetailIndex)
                        Call SubItem_CopySubItem(ll_SubdetailIndex)
                    End If
                End If
            Case Else
                Err.Raise ArmErr.InvalidArgument, "tlb_Subdetail_action(" & Index & ")", "Unknown subdetail toolbar role as_Role=" & as_Role
        End Select
    End If
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
ErrHandler:
    Call mo_Tools.UpdateError(True)
    Call mo_Tools.LockScreen(Me, False)

    Select Case Err.Number
    Case 202
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 202, "#The item you have added/updated couldn't be displayed with the current criteria set.", , vbInformation + vbOKOnly)
    Case ArmErr.SQLBadRowExpectedCount
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2138, "#The record you try to open has been deleted by an other user. Please refresh the grid.", , vbInformation)
    Case ArmErr.SQLBadRowAffectedCount
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2144, "#This record has been, modified by an other.Please exit from this screen and refresh the grid.", , vbInformation)
    Case Else
        Call LogMessage("tlb_Detail_action")
        Call mo_Tools.UpdateError(False)
        Call MsgBox("Error occured, please contact IT. Application will now shutdown." & vbCrLf & Err.Source & vbCrLf & "Description: " & Err.Description, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
        End
    End Select
End Sub

Private Sub tbs_Main_Click()
On Error GoTo ErrHandler

Dim ll_Index As Long

    If tbs_Main.SelectedItem Is Nothing Then Exit Sub
    
    Call mo_Tools.LockScreen(Me, True)
    
    ll_Index = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    Call InitMainFrame(ll_Index)
    Call SetMode(emList)
    
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
ErrHandler:
    Call mo_Tools.LockScreen(Me, False)
    Call ErrorMessage("tbs_Main_Click")
End Sub

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

Dim ll_Index As Long

    Call mo_Tools.LockScreen(Me, True)
    
     If Not cbo_View(Index).SelectedItem Is Nothing Then
        ll_Index = FindMainConfigByFrameIndex(Index)
        Call LoadTreeView(ll_Index, tvw_Main(Index), GetTreeViewInfo(mt_MainConfig(ll_Index).mTreeViewInfos, mt_MainConfig(ll_Index).ViewCode, cbo_View(Index).SelectedItem.Key))
        If tvw_Main(Index).Count > 0 Then
            Set tvw_Main(Index).SelectedItem = tvw_Main(Index).Nodes(1)
            Call tvw_Main_NodeClick(Index, tvw_Main(Index).SelectedItem)
        Else
            Call tvw_Main_NodeClick(Index, Nothing)
        End If
        Call SetTreeDelayedMode(Index, False)
    End If
    
CleanUp:
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
    
ErrHandler:
    Call LogMessage("cbo_Views_ComboItemSelected")
    Call mo_Tools.LockScreen(Me, False)
    Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2116, "#Unable to load the combo " & " type of view.", , vbInformation + vbOKOnly)
End Sub

Private Sub cmd_TVReLoad_Click(Index As Integer)
On Error GoTo ErrHandler
    
    Call cbo_View_ComboItemSelected(Index)
    Exit Sub
ErrHandler:
    Call ErrorMessage("cmd_TVReLoad_Click")
End Sub

Private Sub tvw_Main_NodeClick(Index As Integer, ByVal Node As MSComctlLib.Node)
On Error GoTo ErrHandler
    
    Dim ll_DetailIndex As Long, ll_MainIndex As Long
    
    If mb_InternalInit Then Exit Sub
    
    'Call mo_Tools.LockScreen(Me,True)
    Screen.MousePointer = vbHourglass
    
    Dim lv_Requests As Variant, lb_DelayedLoad As Boolean
    
    Call grd_Main(Index).ClearGrid
    ll_MainIndex = FindMainConfigByFrameIndex(Index)
    ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainIndex)
    
    lv_Requests = ApplyTVFilters(ll_MainIndex, tvw_Main(Index).SelectedNodeRequest)
    
    If (Node Is Nothing) Then
        mt_MainConfig(ll_MainIndex).CurrentTvwSelMethod = etmNone
    Else
        If (tvw_Main(Index).NodeInfo(Node).ml_Level = tvw_Main(Index).Levels - 1) Then
            mt_MainConfig(ll_MainIndex).CurrentTvwSelMethod = eTvwSelMethod.etmNode
        Else
            mt_MainConfig(ll_MainIndex).CurrentTvwSelMethod = eTvwSelMethod.etmBranch
        End If
    End If
    
    Select Case mt_MainConfig(ll_MainIndex).GridDelayMethod
    Case egmDelayedAlways
        lb_DelayedLoad = True
    Case egmDelayedExceptLastLevel
        If Node Is Nothing Then
            lb_DelayedLoad = True
        Else
            lb_DelayedLoad = (tvw_Main(Index).NodeInfo(Node).ml_Level < tvw_Main(Index).Levels - 1)
        End If
    Case egmLoadAlways
        lb_DelayedLoad = False
    Case Else
        lb_DelayedLoad = True
    End Select
    
    If grd_Main(Index).Cols = 0 Then
        If Not grd_Main(Index).SetColumns(mt_DetailConfig(ll_DetailIndex).MainGridColumns) Then
            Err.Raise ArmErr.CompFncFailed, "grd_Main", "Method SetColumns failed."
        End If
        Call mo_Tools.LoadLabelsCursor(mo_Db, mc_ScreenLabels, UserControl.Controls, fra_MainItem(Index), SCREEN_NAME, ms_Language_Code)
    ElseIf mt_MainConfig(ll_MainIndex).IsMultiDetailView Then
        If Not grd_Main(Index).SetColumns(mt_DetailConfig(ll_DetailIndex).MainGridColumns) Then
            Err.Raise ArmErr.CompFncFailed, "grd_Main", "Method SetColumns failed."
        End If
        Call mo_Tools.LoadLabelsCursor(mo_Db, mc_ScreenLabels, UserControl.Controls, fra_MainItem(Index), SCREEN_NAME, ms_Language_Code)
    End If
    
    mt_MainConfig(ll_MainIndex).GridDelayed = lb_DelayedLoad
    
    If Not grd_Main(Index).Load(lv_Requests, False, , , lb_DelayedLoad) Then
        Err.Raise ArmErr.CompFncFailed, "grd_Main", "Method Load failed: " & lv_Requests(0)
    End If
    Call UpdateMainToolbarCustom(ll_MainIndex)
    'Call mo_Tools.LockScreen(Me,False)
    Screen.MousePointer = vbDefault
    Exit Sub

ErrHandler:
    Call LogMessage("tvw_Main_NodeClick")
    'Call mo_Tools.LockScreen(Me,False)
    Screen.MousePointer = vbDefault
    Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2142, "#There is a problem while loading data.", , vbInformation + vbOKOnly)
End Sub

Private Sub tbs_MainTabFilter_Click(Index As Integer)
On Error GoTo ErrHandler
    
    Call SetTreeDelayedMode(Index, True)
    Exit Sub
ErrHandler:
    Call ErrorMessage("tbs_MainTabFilter_Click")
End Sub


Private Sub grd_Main_ItemSelected(Index As Integer)
On Error GoTo ErrHandler
    
    Dim ll_MainIndex As Long
    Dim ll_DetailIndex As Long
    Dim lb_Locked As Boolean
    
    If grd_Main(Index).SelectedCount <> 1 Then Exit Sub
    
    Call mo_Tools.LockScreen(Me, True)
    lb_Locked = True
    
    If grd_Main_CustomAction(Index, eControlAction.caDoubleClick) Then
        Call mo_Tools.LockScreen(Me, False)
        lb_Locked = False
        Exit Sub
    End If
    
    ll_MainIndex = FindMainConfigByFrameIndex(Index)
    ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainIndex)
    Call Item_ViewInit(ll_DetailIndex, grd_Main(Index).CurrentKey)
    Call mo_Tools.LockScreen(Me, False)
    lb_Locked = False
    Exit Sub
ErrHandler:
    If lb_Locked Then
        Call mo_Tools.LockScreen(Me, False)
    End If
    Select Case Err.Number
        Case ArmErr.SQLBadRowExpectedCount
            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2138, "#The record you try to open has been deleted by an other user. Please refresh the grid.", , vbInformation)
        Case Else
            Call LogMessage("grd_Main_ItemSelected")
            'MsgBox mo_Tools.MsgText(mo_Db,ms_Language_Code,2143, "#There is a problem while doing this action. Please double check your entry."), vbInformation, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision
            Call MsgBox("Error occured, please contact IT. Application will now shutdown." & vbCrLf & Err.Source & vbCrLf & "Description: " & Err.Description, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
            End
    End Select
End Sub

Private Sub grd_Main_RowColChange(Index As Integer)
On Error GoTo ErrHandler
Dim ll_MainIndex As Long

    ll_MainIndex = FindMainConfigByFrameIndex(Index)
    mt_MainConfig(ll_MainIndex).GridDelayed = False
    Call UpdateMainToolbarCustom(ll_MainIndex)
    Exit Sub
ErrHandler:
    Call ErrorMessage("grd_Main_RowColChange")
End Sub

Private Sub grd_Subdetail_ItemSelected(Index As Integer)
On Error GoTo ErrHandler
        
    If (me_SubDetailMode = emList) And tlb_SubDetail(Index).Visible And tlb_SubDetail(Index).Enabled Then
        Call tlb_Subdetail_action(Index, "B", ms_Language_Code)
    End If
    Exit Sub
ErrHandler:
    Call ErrorMessage("grd_Subdetail_ItemSelected")
End Sub

Private Sub grd_Subdetail_RowColChange(Index As Integer)
On Error GoTo ErrHandler
Dim ll_SubdetailIndex As Long

    ll_SubdetailIndex = FindSubDetailConfigByFrameIndex(Index)
    Call UpdateSubdetailToolbarCustom(ll_SubdetailIndex)
    Exit Sub
ErrHandler:
    Call ErrorMessage("grd_Main_RowColChange")
End Sub

Private Sub grd_Subdetail_RowLoaded(Index As Integer, ByVal al_Row As Long)
On Error GoTo ErrHandler
Dim lv_Row As Variant
Dim ll_Idx As Long, ll_Count As Long
Dim ll_SubdetailIndex As Long

    ll_Count = grd_SubDetail(Index).Cols - 1
    ReDim lv_Row(ll_Count)
    For ll_Idx = 0 To ll_Count
        lv_Row(ll_Idx) = grd_SubDetail(Index).Data(al_Row, ll_Idx)
    Next
    ll_SubdetailIndex = FindSubDetailConfigByFrameIndex(Index)
    
    'MW REDIM >>
    Call SafeRedimPreserve(mt_SubdetailConfig(ll_SubdetailIndex).DeletedRows, al_Row)
    
    'If UBound(mt_SubdetailConfig(ll_SubdetailIndex).DeletedRows) = -1 Then
    '    ReDim mt_SubdetailConfig(ll_SubdetailIndex).DeletedRows(al_Row)
    'Else
    '    ReDim Preserve mt_SubdetailConfig(ll_SubdetailIndex).DeletedRows(al_Row)
    'End If
    'MW <<
    
    mt_SubdetailConfig(ll_SubdetailIndex).DeletedRows(al_Row) = lv_Row
    
    Dim lo_Column As ArmColumn
    Set lo_Column = grd_SubDetail(Index).Columns("Status")
    If Not lo_Column Is Nothing Then
        If lo_Column.GetData(al_Row) = 1 Then
            grd_SubDetail(Index).LineColor(al_Row) = &H1111FF
        ElseIf lo_Column.GetData(al_Row) = 2 Then
            grd_SubDetail(Index).LineColor(al_Row) = &H11FFC0
        End If
    End If
    Exit Sub
ErrHandler:
    Call ErrorMessage("grd_Subdetail_RowLoaded")
End Sub

Private Sub ImportExcelData(ByVal la_MainConfigIndex As Integer)
On Error GoTo ErrHandler

Dim ls_filePath As String

    dlg_Common.Filter = "XLS files (*.xls)|*.xls"
    dlg_Common.CancelError = False
    Call dlg_Common.ShowOpen
    
    If dlg_Common.FileName <> "" Then
        
        ls_filePath = dlg_Common.FileName
        Screen.MousePointer = vbHourglass

        Call Process_File(ls_filePath, la_MainConfigIndex)
        Screen.MousePointer = vbDefault
    End If

    Exit Sub
ErrHandler:
    Call ErrorMessage("ImportExcelData")
End Sub

Private Sub Process_File(ByRef as_filePath As String, ByVal la_MainConfigIndex As Integer)
On Error GoTo ErrHandler
    
    Exit Sub
ErrHandler:
    Call ErrorMessage("Process_File")
End Sub

Private Function ConvertDate(ByVal ae_TableType As eTableType, ByVal as_Date As String) As Date
On Error GoTo ErrHandler

Dim ls_Date() As String

    ConvertDate = 0
    If Trim(as_Date) <> "" Then
        Select Case ae_TableType
        Case Else
            Err.Raise ArmErr.InvalidValue, "ae_TableType", "Invalid table type value: " & ae_TableType
        End Select
    End If
    Exit Function
ErrHandler:
    Call ErrorHandler("ConvertDate")
End Function


'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK METHODS
' please DO NOT change anything in this part of code
'**********************************************************************************************************************************
'**********************************************************************************************************************************

Public Function Load_A_COM() As Boolean

Dim ll_Index As Long
Dim lo_Control As Object

On Error GoTo ErrHandler
    
    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
    
    If Not mo_Tools.HasSecurityAlias(ms_LoginName, "DPC_REF_PDFGENERATOR") Then
        Exit Function
    End If
    
    mb_InternalInit = False
    ms_DecimalSeparator = Format(0, ".")
    mc_ScreenLabels = 0
    mc_Toolbars = 0
    mc_Item = 0
    
    Call mo_Tools.Load_A_ComControls(UserControl.Controls, mo_Db, ms_Language_Code)
    
    ReDim mt_MainConfig(-1 To -1)
    ReDim mt_DetailConfig(-1 To -1)
    ReDim mt_SubdetailConfig(-1 To -1)
    
    Dim sBuffer As String
    Dim nBufferLen As Long
    nBufferLen = 255
    sBuffer = String$(nBufferLen, vbNullChar)
    nBufferLen = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, sBuffer, nBufferLen)
    If nBufferLen > 0 Then
        ms_ThousandSeparator = Left$(sBuffer, nBufferLen - 1)
    End If
        
    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
    ms_NetworkBoardID = mo_Tools.GetMACAddress()
    
    mb_Initialized = Load_A_COM_Custom
    Load_A_COM = mb_Initialized
    Exit Function
ErrHandler:
    Load_A_COM = False
    Call ErrorMessage("Load_A_COM")
End Function

Public Function Unload_A_COM() As Boolean
    
On Error GoTo ErrHandler
    
    Dim ll_Index As Long
    
    Call UnLoad_A_COM_Custom
    
    If mc_ScreenLabels <> 0 Then
        Call mo_Db.Close(mc_ScreenLabels)
        mc_ScreenLabels = 0
    End If
    
    If mc_Toolbars <> 0 Then
        mo_Db.Close (mc_Toolbars)
        mc_Toolbars = 0
    End If
    
    If (Not mt_SubdetailConfig) <> -1 Then 'test if array exists
        For ll_Index = 0 To UBound(mt_SubdetailConfig)
            ReDim mt_SubdetailConfig(ll_Index).DeletedRows(-1 To -1)
        Next
    End If
    
    Call mo_Tools.Unload_A_ComControls(UserControl.Controls)
    
    ReDim mt_MainConfig(-1 To -1)
    ReDim mt_DetailConfig(-1 To -1)
    ReDim mt_SubdetailConfig(-1 To -1)
    
    Set mo_Db = Nothing
    Set mo_Tools = Nothing
    Set mo_FSO = Nothing
    Set mo_Sys = Nothing
    Set mo_WshNetwork = Nothing
    
    mb_Initialized = False
    Unload_A_COM = True
    Exit Function
ErrHandler:
    Unload_A_COM = False
    Call ErrorMessage("Unload_A_Com")
End Function

Public Sub Resize()
On Error GoTo ErrHandler

Dim ll_Index As Long

    If Not Resize_Custom Then
        For ll_Index = 0 To UBound(mt_MainConfig)
            Call ResizeMain(ll_Index)
        Next
        For ll_Index = 0 To UBound(mt_DetailConfig)
            Call ResizeDetail(ll_Index)
        Next
        For ll_Index = 0 To UBound(mt_SubdetailConfig)
            Call ResizeSubdetail(ll_Index)
        Next
    End If
    Exit Sub
ErrHandler:
    Call ErrorMessage("Resize")
End Sub

Private Sub ResizeMain(ByVal al_MainIndex As Long)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long

    If Width < 0 Or Height < 0 Then Exit Sub
    
    ll_frameIndex = mt_MainConfig(al_MainIndex).FrameIndex
    Call tbs_Main.Move(0, 0, Width)
    
    Call fra_MainItem(ll_frameIndex).Move(0, tbs_Main.Height, Width, Height)
    Call tlb_Main(ll_frameIndex).Move(tvw_Main(ll_frameIndex).Left + tvw_Main(ll_frameIndex).Width + FRM_SPACE_HOR, 2 * FRM_SPACE_VER)
    Call grd_Main(ll_frameIndex).Move(tvw_Main(ll_frameIndex).Left + tvw_Main(ll_frameIndex).Width + FRM_SPACE_HOR, tlb_Main(ll_frameIndex).Top + tlb_Main(ll_frameIndex).Height + FRM_SPACE_VER)
    Call fra_MainFilter(ll_frameIndex).Move(0, 0, fra_MainFilter(ll_frameIndex).Width, fra_MainItem(ll_frameIndex).Height - 3 * FRM_SPACE_VER)
    
    If fra_MainItem(ll_frameIndex).Height - tvw_Main(ll_frameIndex).Top - 3 * FRM_SPACE_VER > 0 Then
        tvw_Main(ll_frameIndex).Height = fra_MainItem(ll_frameIndex).Height - tvw_Main(ll_frameIndex).Top - 3 * FRM_SPACE_VER
    End If
    
    If tbs_MainTabFilter(ll_frameIndex).Tabs.Count > 1 Then
        If Height - tbs_MainTabFilter(ll_frameIndex).Height - 2 * FRM_SPACE_VER > 0 Then
            tvw_Main(ll_frameIndex).Height = Height - tbs_MainTabFilter(ll_frameIndex).Height - 2 * FRM_SPACE_VER
        End If
        Call tbs_MainTabFilter(ll_frameIndex).Move(0, fra_MainFilter(ll_frameIndex).Height - tbs_MainTabFilter(ll_frameIndex).Height, fra_MainFilter(ll_frameIndex).Width)
    Else
        tbs_MainTabFilter(ll_frameIndex).Visible = False
    End If
    If fra_MainItem(ll_frameIndex).Height - grd_Main(ll_frameIndex).Top - 3 * FRM_SPACE_VER > 0 Then
        grd_Main(ll_frameIndex).Height = fra_MainItem(ll_frameIndex).Height - grd_Main(ll_frameIndex).Top - 3 * FRM_SPACE_VER
    End If
    If fra_MainItem(ll_frameIndex).Width - grd_Main(ll_frameIndex).Left - FRM_SPACE_HOR > 0 Then
        grd_Main(ll_frameIndex).Width = fra_MainItem(ll_frameIndex).Width - grd_Main(ll_frameIndex).Left - FRM_SPACE_HOR
    End If
    Call cmd_TVReLoad(ll_frameIndex).Move(tvw_Main(ll_frameIndex).Left, tvw_Main(ll_frameIndex).Top)
    Exit Sub
ErrHandler:
    Call ErrorHandler("ResizeMain")
End Sub

Private Sub ResizeDetail(ByVal al_DetailIndex As Long)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long

    If Width < 0 Or Height < 0 Then Exit Sub
    
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    Call fra_DetailItem(ll_frameIndex).Move(0, tbs_Main.Top + tbs_Main.Height + FRM_SPACE_VER, UserControl.Width, UserControl.Height - tbs_Main.Top - tbs_Main.Height - FRM_SPACE_VER)
    Exit Sub
ErrHandler:
    Call ErrorHandler("ResizeDetail")
End Sub

Private Sub ResizeSubdetail(ByVal al_SubDetailIndex As Long)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim ll_tbsIndex As Long
Dim ll_SubDetailFilter As Integer

    If Width < 0 Or Height < 0 Then Exit Sub
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
        
    If mt_SubdetailConfig(al_SubDetailIndex).ShowInTabs = True Then
        ll_tbsIndex = mt_SubdetailConfig(al_SubDetailIndex).TabStribIndex
        Call tbs_SubDetail(ll_tbsIndex).Move(tbs_SubDetail(ll_tbsIndex).Left, tbs_SubDetail(ll_tbsIndex).Top, UserControl.Width - tbs_SubDetail(ll_tbsIndex).Left - 100)
        Call fra_SubDetail(ll_frameIndex).Move(tbs_SubDetail(ll_tbsIndex).Left, tbs_SubDetail(ll_tbsIndex).Top + tbs_SubDetail(ll_tbsIndex).Height, tbs_SubDetail(ll_tbsIndex).Width, UserControl.Height - fra_SubDetail(ll_frameIndex).Top - 5 * FRM_SPACE_VER)
    End If
    
    Call tlb_SubDetail(ll_frameIndex).Move(fra_SubDetail(ll_frameIndex).Width - tlb_SubDetail(ll_frameIndex).Width - FRM_SPACE_HOR, 2 * FRM_SPACE_VER)
    Call fra_SubDetailItem(ll_frameIndex).Move(FRM_SPACE_HOR, FRM_SPACE_VER, tlb_SubDetail(ll_frameIndex).Left - 2 * FRM_SPACE_HOR)
    
    ll_SubDetailFilter = 0
    'If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_GroupParam" Then
    '    ll_SubDetailFilter = cbo_GRP_Type_Filter.Height + 2 * FRM_SPACE_VER
    '    Call cbo_GRP_Type_Filter.Move(5 * FRM_SPACE_HOR, 2 * FRM_SPACE_VER)
    'End If
    Call grd_SubDetail(ll_frameIndex).Move(FRM_SPACE_HOR, 2 * FRM_SPACE_VER + ll_SubDetailFilter, tlb_SubDetail(ll_frameIndex).Left - 2 * FRM_SPACE_HOR, fra_SubDetail(ll_frameIndex).Height - tlb_SubDetail(ll_frameIndex).Height - 3 * FRM_SPACE_VER - ll_SubDetailFilter)
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("ResizeSubdetail")
End Sub

Public Function Init_control() As Boolean
Dim ll_Index As Long

On Error GoTo ErrHandler

    If mb_Initialized Then
        Call Load_ConfigInfo
        Call Init_Custom
        
        Call mo_Tools.ChangeCharset(UserControl.Controls, mo_Tools.GetCodePageFromLanguage(mo_Db, ms_Language_Code))
        mc_ScreenLabels = mo_Tools.LoadLabels(mo_Db, UserControl.Controls, Me, SCREEN_NAME, ms_Language_Code)
        ms_UserName = LoadUserInfo(mo_Db, ml_U_Code)
        
        If tbs_Main.Tabs.Count > 1 Then
            Call tbs_Main.Move(0, 0, Width)
            tbs_Main.Visible = True
        End If
        Set tbs_Main.SelectedItem = tbs_Main.Tabs(1)
            
        Init_control = True
    End If
    
    Exit Function
ErrHandler:
    Init_control = False
    Call ErrorMessage("Init_control")
End Function

Private Sub InitMainFrame(ByVal al_ConfigIndex As Long)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim ls_ToolbarInfo As String

    If al_ConfigIndex < 0 Then Exit Sub
    If mt_MainConfig(al_ConfigIndex).Initialized Then Exit Sub
    
    ll_frameIndex = mt_MainConfig(al_ConfigIndex).FrameIndex
    
    Call ResizeMain(al_ConfigIndex)
    
    Call LoadToolbar(tlb_Main(ll_frameIndex), mt_MainConfig(al_ConfigIndex).ToolbarID)
    
    tlb_Main(ll_frameIndex).Language = ms_Language_Code
    
    Call tlb_Main(ll_frameIndex).DisplayFace(mt_MainConfig(al_ConfigIndex).ToolbarFace)
        
    Call InitTreeView(al_ConfigIndex)
    mt_MainConfig(al_ConfigIndex).Initialized = True
    Exit Sub
ErrHandler:
    Call ErrorMessage("InitMainFrame")
End Sub

Private Sub InitTreeView(ByVal al_ConfigIndex As Long)
On Error GoTo ErrHandler

Const VIEW_REQUEST = "exec TreeView_View_t_lst $ViewCode$,$Language_Code$"
    
    Dim ls_Request As String
    Dim ll_frameIndex As Long
    
    If al_ConfigIndex < 0 Then Exit Sub
    ll_frameIndex = mt_MainConfig(al_ConfigIndex).FrameIndex
    
    ls_Request = ReplacePlaceHolder(VIEW_REQUEST, "$ViewCode$", mo_Tools.SQLStr(mt_MainConfig(al_ConfigIndex).ViewCode))
    ls_Request = ReplacePlaceHolder(ls_Request, "$Language_Code$", mo_Tools.SQLStr(ms_Language_Code))
    
    cbo_View(ll_frameIndex).Request = ls_Request
    Call cbo_View(ll_frameIndex).Load
    
    If cbo_View(ll_frameIndex).Count = 0 Then
        cbo_View(ll_frameIndex).Visible = False
        If mt_MainConfig(ll_frameIndex).GridDelayMethod = egmDelayedAlways Then
            grd_Main(ll_frameIndex).Visible = False
        Else
            Call ReloadMainGrid
        End If
    Else
        Dim ll_Idx As Long, ll_Count As Long
        ll_Count = cbo_View(ll_frameIndex).Count - 1
        ReDim mt_MainConfig(al_ConfigIndex).mTreeViewInfos(ll_Count)
        For ll_Idx = 0 To ll_Count
            mt_MainConfig(al_ConfigIndex).mTreeViewInfos(ll_Idx).Loaded = False
            mt_MainConfig(al_ConfigIndex).mTreeViewInfos(ll_Idx).TreeViewCode = cbo_View(ll_frameIndex).ComboItems(ll_Idx + 1).Key
        Next
        
        Call cbo_View(ll_frameIndex).SearchItem("X", "TV_Default", 0)
    End If
    Exit Sub
ErrHandler:
    Call ErrorMessage("InitMainFrame")
End Sub

Private Sub InitDetailFrame(ByVal al_DetailConfigIndex As Long)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long, ll_Index As Long, ll_TlbIndex As Long

    If mt_DetailConfig(al_DetailConfigIndex).IsMultiDetailFrame Then
        Call InitMultiDetailFrame(al_DetailConfigIndex)
    End If
    
    If mt_DetailConfig(al_DetailConfigIndex).Initialized Then Exit Sub
    
    Call ResizeDetail(al_DetailConfigIndex)
    ll_frameIndex = mt_DetailConfig(al_DetailConfigIndex).FrameIndex
    ll_TlbIndex = mt_DetailConfig(al_DetailConfigIndex).ToolbarIndex
        
    Call InitMandatoryLabels(mt_DetailConfig(al_DetailConfigIndex).ListFieldsMandatory)
    
    If tlb_Detail(ll_TlbIndex).ButtonsString = "" Then
        Call LoadToolbar(tlb_Detail(ll_TlbIndex), mt_DetailConfig(al_DetailConfigIndex).ToolbarID)
    End If
    
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If mt_SubdetailConfig(ll_Index).ShowInTabs = True And mt_SubdetailConfig(ll_Index).TabIndex = 1 Then
            Call ShowSubDetail(ll_Index)
        End If
        If mt_SubdetailConfig(ll_Index).DetailConfigIndex = al_DetailConfigIndex Then
            Call InitSubdetailFrame(ll_Index)
            If mt_SubdetailConfig(ll_Index).ShowInTabs = True Then
                If tbs_SubDetail(mt_SubdetailConfig(ll_Index).TabStribIndex).Tabs(mt_SubdetailConfig(ll_Index).TabIndex).Caption = "" Then
                    tbs_SubDetail(mt_SubdetailConfig(ll_Index).TabStribIndex).Tabs(mt_SubdetailConfig(ll_Index).TabIndex).Caption = fra_SubDetail(mt_SubdetailConfig(ll_Index).FrameIndex).Caption
                    fra_SubDetail(mt_SubdetailConfig(ll_Index).FrameIndex).Caption = ""
                End If
            End If
        End If
    Next
    If Not IsArray(mt_DetailConfig(al_DetailConfigIndex).RequestAdd) Then mt_DetailConfig(al_DetailConfigIndex).RequestAdd = Array(mt_DetailConfig(al_DetailConfigIndex).RequestAdd)
    If Not IsArray(mt_DetailConfig(al_DetailConfigIndex).RequestUpd) Then mt_DetailConfig(al_DetailConfigIndex).RequestUpd = Array(mt_DetailConfig(al_DetailConfigIndex).RequestUpd)
    If Not IsArray(mt_DetailConfig(al_DetailConfigIndex).RequestDel) Then mt_DetailConfig(al_DetailConfigIndex).RequestDel = Array(mt_DetailConfig(al_DetailConfigIndex).RequestDel)
    mt_DetailConfig(al_DetailConfigIndex).Initialized = True
    Exit Sub
ErrHandler:
    Call ErrorHandler("InitDetailFrame")
End Sub

Private Sub InitSubdetailFrame(ByVal al_SubDetailIndex As Long)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long, ll_Index As Long
Dim lo_Label As Label

    If mt_SubdetailConfig(al_SubDetailIndex).Initialized Then Exit Sub
    
    Call ResizeSubdetail(al_SubDetailIndex)
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
        
    Call ResizeSubdetail(al_SubDetailIndex)
    
    fra_SubDetailItem(ll_frameIndex).Visible = False
    
    Call InitMandatoryLabels(mt_SubdetailConfig(al_SubDetailIndex).ListFieldsMandatory)
    
    Call LoadToolbar(tlb_SubDetail(ll_frameIndex), mt_SubdetailConfig(al_SubDetailIndex).ToolbarID)
    
    If Not IsEmpty(mt_SubdetailConfig(al_SubDetailIndex).GridColumns) Then
        If Not grd_SubDetail(ll_frameIndex).SetColumns(mt_SubdetailConfig(al_SubDetailIndex).GridColumns) Then
            Err.Raise ArmErr.InvalidValue, "SetColumns failed for main grid in " & mt_SubdetailConfig(al_SubDetailIndex).NameFrame
        End If
        Call mo_Tools.LoadLabelsCursor(mo_Db, mc_ScreenLabels, UserControl.Controls, fra_SubDetail(ll_frameIndex), SCREEN_NAME, ms_Language_Code)
    End If
    mt_SubdetailConfig(al_SubDetailIndex).Initialized = True
    Exit Sub
ErrHandler:
    Call ErrorHandler("InitSubdetailFrame")
End Sub

Private Sub LoadDetailListView(al_List As ListView, ByVal ls_Req_List As String, ByVal as_Req_Fill As String, ByVal as_ID_Column As String, ByVal as_Name_Column As String)
On Error GoTo ErrHandler
    
    Dim ls_Request As String
    Dim ll_Cursor As Long
        
    ls_Request = ReplacePlaceHolder(ls_Req_List, "$Language_Code$", mo_Tools.SQLStr(ms_Language_Code))
    ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
    Debug.Assert (ll_Cursor <> 0)
    
    al_List.ListItems.Clear
    
    Dim ll_Index As Long
    ll_Index = 1
    While Not mo_Db.EOF(ll_Cursor)
        Call al_List.ListItems.Add(ll_Index, "ID" & mo_Db.GetFields(ll_Cursor, as_ID_Column), mo_Db.GetFields(ll_Cursor, as_Name_Column))
        ll_Index = ll_Index + 1
        Call mo_Db.Next(ll_Cursor)
    Wend
        
    mo_Db.Close (ll_Cursor)
    
    If as_Req_Fill <> "" Then
        
        ls_Request = ReplacePlaceHolder(as_Req_Fill, "$Language_Code$", mo_Tools.SQLStr(ms_Language_Code))
        ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
        
        Dim ll_Key
        While Not mo_Db.EOF(ll_Cursor)
            ll_Key = mo_Db.GetFields(ll_Cursor, as_ID_Column)
            
            For ll_Index = 1 To al_List.ListItems.Count
                If al_List.ListItems.Item(ll_Index).Key = "ID" & ll_Key Then
                    al_List.ListItems.Item(ll_Index).Checked = True
                End If
            Next
            Call mo_Db.Next(ll_Cursor)
        Wend
        mo_Db.Close (ll_Cursor)
    End If
    
    Exit Sub
ErrHandler:
    Call ErrorMessage("LoadDetailListView")
End Sub

Private Sub SaveDetailListCommon(ByVal al_DetailIndex As Long)
On Error GoTo ErrHandler

Const DELETE_REQUEST_SYS = "exec DPC_SysVendor_del $SYS_Id$"
Const INSERT_REQUEST_SYS = "exec DPC_SysVendor_ins $SYS_Id$,$VEN_Id$,$Z_Creator$"

Dim ls_Request As String
Dim ls_Request2 As String
Dim ll_frameIndex As Long

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex

    If (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_System", vbTextCompare) = 0) Then
        
        'Call SaveDetailListView(lv_SysVendor, DELETE_REQUEST_SYS, INSERT_REQUEST_SYS, txt_DetailKey(ll_frameIndex).Text, "VEN_Id")
    
    End If

    Exit Sub
ErrHandler:
    Call ErrorMessage("SaveDetailListCommon")
End Sub

Private Sub SaveDetailListView(al_List As ListView, ByVal as_Req_Del As String, ByVal as_Req_Ins As String, ByVal ai_SYS_Id As Integer, ByVal as_ID_Column As String)
On Error GoTo ErrHandler
    
    Dim ls_Request As String
    Dim ll_Cursor As Long
        
    ls_Request = ReplacePlaceHolder(as_Req_Del, "$SYS_Id$", mo_Tools.SqlInt(ai_SYS_Id))
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request)

    Dim ll_Index As Long
    Dim ls_ID As String
    For ll_Index = 1 To al_List.ListItems.Count
        If al_List.ListItems(ll_Index).Checked = True Then
            ls_ID = Replace(al_List.ListItems(ll_Index).Key, "ID", "")
            ls_Request = ReplacePlaceHolder(as_Req_Ins, "$SYS_Id$", mo_Tools.SqlInt(ai_SYS_Id))
            ls_Request = ReplacePlaceHolder(ls_Request, "$" & as_ID_Column & "$", ls_ID)
            ls_Request = ReplacePlaceHolder(ls_Request, "$Z_Creator$", mo_Tools.SqlInt(ml_U_Code))
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request)
        End If
    Next
                    
    Exit Sub
ErrHandler:
    Call ErrorMessage("SaveDetailListView")
End Sub

Private Function GenerateNameListView(al_List As ListView) As String
On Error GoTo ErrHandler

Dim ll_Idx As Long
Dim ll_Name As String

    ll_Name = ""
    GenerateNameListView = ""
    
    For ll_Idx = 1 To al_List.ListItems.Count
        If al_List.ListItems(ll_Idx).Checked = True Then
            ll_Name = ll_Name + al_List.ListItems(ll_Idx).Text
            ll_Name = ll_Name & ","
        End If
    Next
    
    GenerateNameListView = ll_Name
    
    Exit Function
ErrHandler:
    Call ErrorHandler("GenerateNameListView")
End Function

Private Function GetInitControlProperty(ByVal al_DetailIndex As Long, ByRef ao_Control As Object, ByVal ae_ControlIndex As eControlPropertyIndex) As Variant
On Error GoTo ErrHandler

Dim lv_InitControls As Variant
Dim ll_Idx As Long

    lv_InitControls = mt_DetailConfig(al_DetailIndex).InitControls
    For ll_Idx = 0 To UBound(lv_InitControls)
        If lv_InitControls(ll_Idx)(0) Is ao_Control Then
            GetInitControlProperty = lv_InitControls(ll_Idx)(ae_ControlIndex)
        End If
    Next
    Exit Function
ErrHandler:
    Call ErrorHandler("GetInitControlProperty")
End Function

Private Sub InitFrameControls(ByRef av_InitControls As Variant)
On Error GoTo ErrHandler

Dim lo_Control As Control
Dim ll_Index As Long
Dim ls_Request As String

    If Not IsArray(av_InitControls) Then Exit Sub
    mb_InternalInit = True
    For ll_Index = 0 To UBound(av_InitControls)
        Set lo_Control = av_InitControls(ll_Index)(0)
        
        lo_Control.Tag = av_InitControls(ll_Index)(1)
        lo_Control.Visible = av_InitControls(ll_Index)(2)
        Select Case UCase(TypeName(lo_Control))
            Case "ARMCOMBOBOX"
                If UBound(av_InitControls(ll_Index)) >= 3 Then
                    ls_Request = av_InitControls(ll_Index)(3)
                    ls_Request = ReplaceCommonPlaceholders(ls_Request)
                    lo_Control.Request = ls_Request
                End If
            Case "TEXTBOX", "ARMPICKER"
                If UBound(av_InitControls(ll_Index)) >= 4 Then
                    lo_Control.MaxLength = av_InitControls(ll_Index)(4)
                End If
            Case "A_CALOCX"
            Case "LABEL", "CHECKBOX"
                lo_Control.Caption = "#" & lo_Control.Tag
        End Select
    Next
    mb_InternalInit = False
    Exit Sub
ErrHandler:
    mb_InternalInit = False
    Call ErrorHandler("InitFrameControls")
End Sub

Private Sub InitMultiDetailFrame(ByVal al_DetailConfigIndex As Long)
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
    
    ll_frameIndex = mt_DetailConfig(al_DetailConfigIndex).FrameIndex
    
    Call ResetFrameControls(fra_DetailItem(ll_frameIndex))
    Call InitFrameControls(mt_DetailConfig(al_DetailConfigIndex).InitControls)
    Call mo_Tools.LoadLabelsCursor(mo_Db, mc_ScreenLabels, UserControl.Controls, fra_DetailItem(ll_frameIndex), SCREEN_NAME, ms_Language_Code)
    Call InitMandatoryLabels(mt_DetailConfig(al_DetailConfigIndex).ListFieldsMandatory)
    Exit Sub
ErrHandler:
    Call ErrorHandler("InitMultiDetailFrame")
End Sub

Private Sub InitMandatoryLabels(ByRef av_ListFieldsMandatory As Variant)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim lo_Label As Label

    For ll_Index = 0 To UBound(av_ListFieldsMandatory)
        If av_ListFieldsMandatory(ll_Index)(1) >= 0 Then
            Set lo_Label = lbl_label(av_ListFieldsMandatory(ll_Index)(1))
            lo_Label.FontBold = True
        End If
    Next
    Exit Sub
ErrHandler:
    Call ErrorHandler("InitMandatoryLabels")
End Sub

Private Function GetSelectedRootNode(ByRef ao_Tree As ArmTreeView) As MSComctlLib.Node
On Error GoTo ErrHandler

Dim lo_Node  As Object

    Set GetSelectedRootNode = Nothing
    Set lo_Node = ao_Tree.SelectedItem
    If Not (lo_Node Is Nothing) Then
        While Not (lo_Node.Parent Is Nothing)
            Set lo_Node = lo_Node.Parent
        Wend
    End If
    Set GetSelectedRootNode = lo_Node
    Exit Function
ErrHandler:
    Call ErrorHandler("GetSelectedRootNode")
End Function

Private Sub SetMode(ByVal ae_Mode As eMode, Optional al_DetailConfigIndex As Long = -1)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim ll_MainFrameIndex As Long
Dim ll_DetailFrameIndex As Long
Dim ll_DetailConfigIndex As Long
Dim ll_MainConfigIndex As Long
Dim ll_TlbIndex As Long
Dim le_SubdetailMode As eMode
Dim ls_ToolbarFace As String

    If al_DetailConfigIndex = -1 Then
        ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
        ll_MainFrameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
        ll_DetailConfigIndex = FindDetailConfigByMainConfig(ll_MainConfigIndex)
    Else
        ll_DetailConfigIndex = al_DetailConfigIndex
    End If
    
    ll_DetailFrameIndex = mt_DetailConfig(ll_DetailConfigIndex).FrameIndex
    ll_TlbIndex = mt_DetailConfig(ll_DetailConfigIndex).ToolbarIndex
    
    Select Case ae_Mode
    Case emView
        ls_ToolbarFace = mt_DetailConfig(ll_DetailConfigIndex).ToolbarFaces(0)
        le_SubdetailMode = emView
    Case emAdd
        ls_ToolbarFace = mt_DetailConfig(ll_DetailConfigIndex).ToolbarFaces(1)
        le_SubdetailMode = emList
    Case emUpdate
        ls_ToolbarFace = mt_DetailConfig(ll_DetailConfigIndex).ToolbarFaces(2)
        le_SubdetailMode = emList
    Case emDelete
        ls_ToolbarFace = mt_DetailConfig(ll_DetailConfigIndex).ToolbarFaces(3)
        le_SubdetailMode = emView
    Case Else
        le_SubdetailMode = emNone
        ls_ToolbarFace = ""
        ll_TlbIndex = -1
    End Select
    
    If ls_ToolbarFace <> "" Then
        If Not tlb_Detail(ll_TlbIndex).DisplayFace(ls_ToolbarFace) Then
            Err.Raise ArmErr.CompFncFailed, "tlb_Detail", "DisplayFace method failed for face: '" & ls_ToolbarFace & "'"
        End If
    End If
    
    For ll_Index = 0 To tlb_Detail.Count - 1
        tlb_Detail(ll_Index).Visible = (ll_Index = ll_TlbIndex)
        tlb_Detail(ll_Index).Enabled = (ll_Index = ll_TlbIndex)
    Next
    
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If mt_SubdetailConfig(ll_Index).DetailConfigIndex = ll_DetailConfigIndex Then
            Call SetModeSubDetail(mt_SubdetailConfig(ll_Index).FrameIndex, le_SubdetailMode)
        End If
    Next
    
    Select Case ae_Mode
    Case emList
        tbs_Main.Enabled = True
        For ll_Index = 0 To fra_DetailItem.Count - 1
            fra_DetailItem(ll_Index).Visible = False
        Next
        For ll_Index = 0 To fra_MainItem.Count - 1
            If ll_Index = ll_MainFrameIndex Then
                fra_MainItem(ll_Index).Zorder
                fra_MainItem(ll_Index).Visible = True
            Else
                fra_MainItem(ll_Index).Visible = False
            End If
        Next
    Case Else
        tbs_Main.Enabled = False
        For ll_Index = 0 To fra_MainItem.Count - 1
            fra_MainItem(ll_Index).Visible = False
        Next
        For ll_Index = 0 To fra_DetailItem.Count - 1
            If ll_Index = ll_DetailFrameIndex Then
                fra_DetailItem(ll_Index).Zorder
                fra_DetailItem(ll_Index).Visible = True
            Else
                fra_DetailItem(ll_Index).Visible = False
            End If
        Next
    End Select
    me_OldDetailMode = me_DetailMode
    me_DetailMode = ae_Mode
    Exit Sub
ErrHandler:
    Call ErrorHandler("SetMode")
End Sub

Private Sub ShowSubDetail(ByVal al_SubDetailConfigIndex As Long)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim ll_DetailFrameIndex As Long
Dim ll_DetailConfigIndex As Long
    
    ll_DetailConfigIndex = mt_SubdetailConfig(al_SubDetailConfigIndex).DetailConfigIndex
    ll_DetailFrameIndex = mt_DetailConfig(ll_DetailConfigIndex).FrameIndex
    
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If ll_Index = al_SubDetailConfigIndex Then
            fra_SubDetail(mt_SubdetailConfig(ll_Index).FrameIndex).Zorder
            fra_SubDetail(mt_SubdetailConfig(ll_Index).FrameIndex).Visible = True
        ElseIf mt_SubdetailConfig(ll_Index).DetailConfigIndex = ll_DetailConfigIndex Then
            fra_SubDetail(mt_SubdetailConfig(ll_Index).FrameIndex).Visible = False
        End If
    Next
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("SetMode")
End Sub

Private Sub SetModeSubDetail(ByVal al_SubDetailIndex As Long, ByVal ae_Mode As eMode)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim ll_frameIndex As Long
Dim ll_DetailIndex As Long
Dim ls_ToolbarFace As String
Dim ll_SubDetailFilter As Integer

    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailIndex = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    
    ll_SubDetailFilter = 0
    If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_GroupParam" Then
        If (ae_Mode = emList) Or (ae_Mode = emView) Then
            'cbo_GRP_Type_Filter.Visible = True
            'cbo_GRP_Type_Filter.Enabled = True
            
            'If cbo_GRP_Type_Filter.SelectedItem Is Nothing Then
            '    Call cbo_GRP_Type_Filter.SearchItem(cbo_GRP_Type_Filter.ComboItems(1).Key)
            'End If
    
            'lbl_label(88).Visible = True
            'll_SubDetailFilter = cbo_GRP_Type_Filter.Height
            'Call cbo_GRP_Type_Filter.Move(lbl_label(88).Width + FRM_SPACE_HOR, 2 * FRM_SPACE_VER)
            'Call lbl_label(88).Move(FRM_SPACE_HOR, 2 * FRM_SPACE_VER)
        Else
            'cbo_GRP_Type_Filter.Visible = False
            'lbl_label(88).Visible = False
        End If
    End If
        
    If (ae_Mode = emList) Or (ae_Mode = emView) Then
        fra_SubDetailItem(ll_frameIndex).Visible = False
        grd_SubDetail(ll_frameIndex).Top = 2 * FRM_SPACE_VER + ll_SubDetailFilter
        grd_SubDetail(ll_frameIndex).Height = fra_SubDetail(ll_frameIndex).Height - 3 * FRM_SPACE_VER - ll_SubDetailFilter
    Else
        grd_SubDetail(ll_frameIndex).Top = fra_SubDetailItem(ll_frameIndex).Top + fra_SubDetailItem(ll_frameIndex).Height + FRM_SPACE_VER
        grd_SubDetail(ll_frameIndex).Height = fra_SubDetail(ll_frameIndex).Height - fra_SubDetailItem(ll_frameIndex).Height - 4 * FRM_SPACE_VER
        fra_SubDetailItem(ll_frameIndex).Visible = True
    End If
    
    ls_ToolbarFace = ""
    If UBound(mt_SubdetailConfig(al_SubDetailIndex).ToolbarFaces) = 4 Then
        Select Case ae_Mode
        Case emView
            ls_ToolbarFace = mt_SubdetailConfig(al_SubDetailIndex).ToolbarFaces(0)
        Case emList
            ls_ToolbarFace = mt_SubdetailConfig(al_SubDetailIndex).ToolbarFaces(1)
        Case emAdd
            ls_ToolbarFace = mt_SubdetailConfig(al_SubDetailIndex).ToolbarFaces(2)
        Case emUpdate
            ls_ToolbarFace = mt_SubdetailConfig(al_SubDetailIndex).ToolbarFaces(3)
        Case emDelete
            ls_ToolbarFace = mt_SubdetailConfig(al_SubDetailIndex).ToolbarFaces(4)
        End Select
    End If
    
    If ls_ToolbarFace = "" Then
        tlb_SubDetail(ll_frameIndex).Visible = False
    Else
        Call tlb_SubDetail(ll_frameIndex).DisplayFace(ls_ToolbarFace)
        tlb_SubDetail(ll_frameIndex).Visible = True
    End If
    
    grd_SubDetail(ll_frameIndex).Enabled = (ae_Mode = emAdd) Or (ae_Mode = emView) Or (ae_Mode = emList)
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If mt_SubdetailConfig(ll_Index).DetailConfigIndex = ll_DetailIndex Then
            tlb_SubDetail(ll_Index).Enabled = (ll_Index = ll_frameIndex) Or ((ae_Mode = emView) Or (ae_Mode = emList))
        End If
    Next
    tlb_Detail(mt_DetailConfig(ll_DetailIndex).ToolbarIndex).Enabled = (ae_Mode = emView) Or (ae_Mode = emList)
    Call fra_SubDetail(ll_frameIndex).Refresh
    me_SubDetailMode = ae_Mode
    Exit Sub
ErrHandler:
    Call ErrorHandler("SetModeSubDetail")
End Sub

Private Sub ResetFrameControls(ByRef ao_Frame As Frame)
On Error GoTo ErrHandler

Dim lo_Control As Control

    mb_InternalInit = True
    For Each lo_Control In UserControl.Controls
    
        If mo_Tools.HasContainer(lo_Control, ao_Frame) Then
            If StrComp(lo_Control.Name, "chk_Repositioning", vbTextCompare) <> 0 Then
                Select Case UCase(TypeName(lo_Control))
                    Case "ARMCOMBOBOX"
                        Call lo_Control.Clear
                        lo_Control.Tag = ""
                        lo_Control.Request = ""
                        lo_Control.Visible = False
                    Case "ARMPICKER"
                        Call lo_Control.Clear
                        lo_Control.Tag = ""
                        lo_Control.Visible = False
                    Case "CHECKBOX"
                        lo_Control.Value = Unchecked
                        lo_Control.Tag = ""
                        lo_Control.Caption = ""
                        lo_Control.Visible = False
                    Case "TEXTBOX"
                        lo_Control.Tag = ""
                        lo_Control.Text = ""
                        lo_Control.Visible = False
                    Case "A_CALOCX"
                        Call lo_Control.reinit_cal
                        lo_Control.Tag = ""
                        lo_Control.Visible = False
                    Case "LABEL"
                        lo_Control.Tag = ""
                        lo_Control.Caption = ""
                        lo_Control.FontBold = False
                        lo_Control.Visible = False
                End Select
            End If
        End If
    Next
    mb_InternalInit = False
    Exit Sub
ErrHandler:
    mb_InternalInit = False
    Call ErrorHandler("ResetFrameControls")
End Sub

Private Sub UpdateDrivenComboRequest(ByRef ao_Combo As Object, ByVal al_DetailIndex As Long, ByVal ab_ForceClear As Boolean)
On Error GoTo ErrHandler

Dim ls_Request As String

    If ab_ForceClear Then Call ao_Combo.Clear
    
    ls_Request = GetInitControlProperty(al_DetailIndex, ao_Combo, eControlPropertyIndex.cpiRequest)
    ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_DetailItem(mt_DetailConfig(al_DetailIndex).FrameIndex))
    ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
    ls_Request = ReplaceCommonPlaceholders(ls_Request)
    ao_Combo.Request = ls_Request
    Exit Sub
ErrHandler:
    Call ErrorHandler("UpdateDrivenComboRequest")
End Sub

Private Sub LoadToolbar(ByRef ao_Toolbar As Object, ByVal al_Id As Long)
On Error GoTo ErrHandler

Dim ls_Request As String
Dim ls_ToolbarInfo As String

    ' no toolbar definition ID, do not load anything
    If (al_Id = 0) Or (ms_ToolbarRequest = "") Then Exit Sub
    'load all definition strings only once and keep it in cursor
    If mc_Toolbars = 0 Then
        ls_Request = ReplacePlaceHolder(ms_ToolbarRequest, "$Module$", mo_Tools.SQLStr(MODULE_NAME))
        mc_Toolbars = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
    End If
    
    If mo_Db.Find(mc_Toolbars, "Id", al_Id) < 0 Then
        Err.Raise ArmErr.InvalidValue, ao_Toolbar.Name, "Toolbar not found in toolbars_definitions ID:" & al_Id
    End If
    
    ls_ToolbarInfo = mo_Db.GetFields(mc_Toolbars, "info")
    If Not ao_Toolbar.SetToolbarInfoStringParameters(ls_ToolbarInfo, Left(ls_ToolbarInfo, 3)) Then
        Err.Raise ArmErr.InvalidValue, ao_Toolbar.Name, "SetToolbarInfoStringParameters failed for toolbar ID:" & al_Id
    End If
    Call ao_Toolbar.DisplayFace("0")
    Exit Sub
ErrHandler:
    Call ErrorHandler("LoadToolbar")
End Sub

Private Function FindSubDetailConfigByName(ByVal as_SubdetailName As String) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long

    FindSubDetailConfigByName = -1
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If StrComp(mt_SubdetailConfig(ll_Index).NameFrame, as_SubdetailName, vbTextCompare) = 0 Then
            FindSubDetailConfigByName = ll_Index
            Exit Function
        End If
    Next
    Exit Function
ErrHandler:
    Call ErrorHandler("FindSubDetailConfigByName")
End Function

Private Function FindSubDetailConfigByFrameIndex(ByVal al_FrameIndex As Long) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long

    FindSubDetailConfigByFrameIndex = -1
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If mt_SubdetailConfig(ll_Index).FrameIndex = al_FrameIndex Then
            FindSubDetailConfigByFrameIndex = ll_Index
            Exit Function
        End If
    Next
    Exit Function
ErrHandler:
    Call ErrorHandler("FindSubDetailConfigByFrameIndex")
End Function


Private Function FindMainConfigByFrameIndex(ByVal al_FrameIndex As Long) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long

    FindMainConfigByFrameIndex = -1
    For ll_Index = 0 To UBound(mt_MainConfig)
        If mt_MainConfig(ll_Index).FrameIndex = al_FrameIndex Then
            FindMainConfigByFrameIndex = ll_Index
            Exit Function
        End If
    Next
    Exit Function
ErrHandler:
    Call ErrorHandler("FindMainConfigByFrameIndex")
End Function

Private Function FindMainConfigByName(ByVal as_Name As String) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long

    FindMainConfigByName = -1
    For ll_Index = 0 To UBound(mt_MainConfig)
        If StrComp(mt_MainConfig(ll_Index).NameFrame, as_Name, vbTextCompare) = 0 Then
            FindMainConfigByName = ll_Index
            Exit Function
        End If
    Next
    Exit Function
ErrHandler:
    Call ErrorHandler("FindMainConfigByName")
End Function

Private Function FindDetailConfigByFrameIndex(ByVal al_FrameIndex As Long) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long

    FindDetailConfigByFrameIndex = -1
    For ll_Index = 0 To UBound(mt_DetailConfig)
        If mt_DetailConfig(ll_Index).FrameIndex = al_FrameIndex Then
            FindDetailConfigByFrameIndex = ll_Index
            Exit Function
        End If
    Next
    Err.Raise ArmErr.InvalidValue, "al_FrameIndex=" & al_FrameIndex, "Detail config index not found."
    Exit Function
ErrHandler:
    Call ErrorHandler("FindDetailConfigByFrameIndex")
End Function

Private Function FindSubDetailConfigByTabIndex(ByVal al_TabIndex As Long) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long

    FindSubDetailConfigByTabIndex = -1
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If mt_SubdetailConfig(ll_Index).TabIndex = al_TabIndex Then
            FindSubDetailConfigByTabIndex = ll_Index
            Exit Function
        End If
    Next
    Exit Function
ErrHandler:
    Call ErrorHandler("FindSubDetailConfigByTabIndex")
End Function

Private Function FindDetailConfigByName(ByVal as_Name As String) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long

    FindDetailConfigByName = -1
    For ll_Index = 0 To UBound(mt_DetailConfig)
        If StrComp(mt_DetailConfig(ll_Index).NameFrame, as_Name, vbTextCompare) = 0 Then
            FindDetailConfigByName = ll_Index
            Exit Function
        End If
    Next
    Err.Raise ArmErr.InvalidValue, "as_Name=" & as_Name, "Detail config index not found."
    Exit Function
ErrHandler:
    Call ErrorHandler("FindDetailConfigByName")
End Function

Private Function FindDetailConfigByMainConfig(ByVal al_MainIndex As Long) As Long
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim lo_ComboItem As Object
Dim ll_frameIndex As Long
'Dim le_DocumentType  As eDocumentType

    FindDetailConfigByMainConfig = -1
    ll_frameIndex = mt_MainConfig(al_MainIndex).FrameIndex
    If mt_MainConfig(al_MainIndex).IsMultiDetailView Then
        FindDetailConfigByMainConfig = mt_MainConfig(al_MainIndex).CurrentDetailIndex
        Exit Function
    Else
        For ll_Index = 0 To UBound(mt_DetailConfig)
            If mt_DetailConfig(ll_Index).MainConfigIndex = al_MainIndex Then
                FindDetailConfigByMainConfig = ll_Index
                Exit Function
            End If
        Next
    End If
    Err.Raise ArmErr.InvalidValue, "al_MainIndex=" & al_MainIndex, "Detail config index not found."
    Exit Function
ErrHandler:
    Call ErrorHandler("FindDetailConfigByMainConfig")
End Function

'to check if our current position in treeview will allow us to display added/updated item in grid
Private Function IsItemSelectedInTree(ByVal al_DetailIndex As Long, ByRef ao_Tree As ArmTreeView, ByVal av_PathData As Variant) As Boolean
On Error GoTo ErrHandler
    
Dim ll_SelLevel As Long, ll_IdxLvl As Long
Dim lo_Node As Object
Dim lb_CheckDone As Boolean


    IsItemSelectedInTree = IsItemSelectedInTreeCustom(al_DetailIndex, ao_Tree, av_PathData, lb_CheckDone)
    If lb_CheckDone Then Exit Function
    
    IsItemSelectedInTree = False
    
    Set lo_Node = ao_Tree.SelectedItem
    If lo_Node Is Nothing Then Exit Function
    If Not IsArray(av_PathData) Then Exit Function
    
    ll_SelLevel = lo_Node.Tag.ml_Level
    
    If ll_SelLevel > UBound(av_PathData) Then
        IsItemSelectedInTree = False
        Exit Function
    End If
    
    For ll_IdxLvl = ll_SelLevel To 0 Step -1
        If lo_Node Is Nothing Then Exit Function
        If Not IsArray(av_PathData(ll_IdxLvl)) Then
            Err.Raise ArmErr.InvalidValue, "av_PathData(ll_IdxLvl)", "Path data element is not an array: " & ll_IdxLvl
        End If
        If StrComp(lo_Node.Tag.IDValue, av_PathData(ll_IdxLvl)(0), vbTextCompare) <> 0 Then
            Exit Function
        End If
        Set lo_Node = lo_Node.Parent
    Next
    IsItemSelectedInTree = True
    Exit Function
ErrHandler:
    Call ErrorHandler("IsItemSelectedInTree")
End Function

' Return true if have created the node
' TODO : Manage the third parameter...
Private Function FindInTreeView(ByRef ao_Tree As ArmTreeView, ByVal av_PathData As Variant, ByVal ab_AutoCreate As Boolean, ByVal ab_Expand As Boolean) As Node
On Error GoTo ErrHandler

Dim lb_Internal As Boolean
Dim lo_Node As Object
Dim ll_LvlIdx As Long, ll_DataIdx As Long
Dim ls_Key As String, ls_Desc As String
    
    Set FindInTreeView = Nothing
    lb_Internal = mb_InternalInit
    mb_InternalInit = True
    Set lo_Node = Nothing
    For ll_LvlIdx = 0 To UBound(av_PathData)
        If Not IsArray(av_PathData(ll_LvlIdx)) Then
            Err.Raise ArmErr.InvalidValue, "av_PathData(ll_LvlIdx)", "Path data element is not an array"
        End If
        
        If UBound(av_PathData(ll_LvlIdx)) = 1 Then
            ls_Key = av_PathData(ll_LvlIdx)(0)
            ls_Desc = av_PathData(ll_LvlIdx)(1)
        ElseIf UBound(av_PathData(ll_LvlIdx)) > 1 Then
            ls_Key = av_PathData(ll_LvlIdx)(0)
            ls_Desc = av_PathData(ll_LvlIdx)(2)
        Else
            Err.Raise ArmErr.InvalidValue, "av_PathData(ll_LvlIdx)", "Invalid count of path data elements"
        End If
        
        If ao_Tree.Find(ls_Key, 0, lo_Node, ll_LvlIdx) Then
            Set lo_Node = ao_Tree.SelectedItem
        Else
            If ab_AutoCreate Then
                'TODO add additional data from detail tree into main tree data
                Set lo_Node = ao_Tree.AddNode(lo_Node, ls_Key, ls_Desc, 1, 2, LoadTypeChildsDemand)
                If lo_Node Is Nothing Then
                    Err.Raise ArmErr.CompFncFailed, "ao_Tree.AddNode", "Function failed to create node"
                End If
                For ll_DataIdx = 1 To UBound(av_PathData(ll_LvlIdx))
                    Call lo_Node.Tag.SetData(ll_DataIdx, av_PathData(ll_LvlIdx)(ll_DataIdx))
                Next
                lo_Node.Selected = True
            Else
                GoTo CleanUp
            End If
        End If
        If (Not lo_Node.Expanded) And (ll_LvlIdx <> UBound(av_PathData)) Then
            If Not ab_Expand Then GoTo CleanUp
            Call ao_Tree.ExpandNode(lo_Node)
        End If
    Next
    
    Set FindInTreeView = lo_Node
        
CleanUp:
    Set lo_Node = Nothing
    mb_InternalInit = lb_Internal
    Exit Function
ErrHandler:
    Set lo_Node = Nothing
    mb_InternalInit = lb_Internal
    Call ErrorHandler("FindInTreeView")
End Function

Private Function GetCurrentPathData(ByRef ao_Controls As Variant, ByVal as_Path As String) As Variant
On Error GoTo ErrHandler

    Dim ls_Pattern As String, las_Tag() As String, las_Paths() As String, lv_pathData As Variant, lv_CheckData As Variant
    Dim ll_IdxPath As Long, ll_CountPath As Long, ll_Idx As Long, ll_ItemIdx As Long
    Dim lo_Control As Control
    Dim ll_Pos As Long, ls_PatternIndex As String, ls_ControlIndex As String
    
        las_Paths = Split(as_Path, SEP)
        ll_CountPath = UBound(las_Paths) + 1
        ReDim lv_pathData(ll_CountPath - 1)
        
        For Each lo_Control In ao_Controls
            For ll_IdxPath = 0 To ll_CountPath - 1
                ls_Pattern = las_Paths(ll_IdxPath)
                ' hardcoded first node of tree contain node all
                If StrComp(ls_Pattern, "ALL", vbTextCompare) = 0 Then
                    lv_pathData(ll_IdxPath) = Array(-1, "#All")
                End If
                ' hardcoded key value for tree search (maybe when data loaded from A_Reference)
                If IsNumeric(ls_Pattern) Then
                    lv_pathData(ll_IdxPath) = Array(ls_Pattern, "#Unknown")
                End If
                
                ls_PatternIndex = ""
                ll_Pos = InStr(1, ls_Pattern, "(")
                If ll_Pos > 0 Then
                    ls_PatternIndex = Mid(ls_Pattern, ll_Pos + 1, Len(ls_Pattern) - ll_Pos - 1)
                    ls_Pattern = Left(ls_Pattern, ll_Pos - 1)
                End If
                ls_ControlIndex = ""
On Error Resume Next    ' is there other way how correctly retrieve index of control if it is in control array ?
                ls_ControlIndex = CStr(lo_Control.Index)
On Error GoTo ErrHandler
                If (StrComp(ls_Pattern, lo_Control.Name, vbTextCompare) = 0) And _
                   (StrComp(ls_PatternIndex, ls_ControlIndex, vbTextCompare) = 0) Then
                    Select Case UCase(TypeName(lo_Control))
                        Case "ARMCOMBOBOX"
                            lv_pathData(ll_IdxPath) = Array(mo_Tools.GetComboKey(lo_Control), lo_Control.Text)
                            Exit For
                        Case "ARMPICKER"
                            lv_pathData(ll_IdxPath) = Array(lo_Control.ItemCode, lo_Control.ItemDescription)
                            Exit For
                        Case "TEXTBOX"
                            lv_pathData(ll_IdxPath) = Array(lo_Control.Text, lo_Control.Text)
                            Exit For
                        Case "ARMTREEVIEW"
                            Dim ll_LevelCount As Long
                            Dim ll_LevelIndex As Long
                            Dim ll_DataIndex As Long
                            Dim lv_LevelData As Variant
                            Dim lv_NodeData As Variant
                            Dim lo_Node As Object
                            
                            If Not (lo_Control.SelectedItem Is Nothing) Then
                                ll_LevelCount = lo_Control.SelectedItem.Tag.ml_Level + 1
                                ReDim lv_LevelData(ll_LevelCount - 1)
                                Set lo_Node = lo_Control.SelectedItem
                                ll_LevelIndex = ll_LevelCount - 1
                                While (Not (lo_Node Is Nothing)) And (ll_LevelIndex >= 0)
                                    If lo_Node.Tag.length >= 0 Then
                                        ReDim lv_NodeData(lo_Node.Tag.length)
                                        For ll_DataIndex = 0 To UBound(lv_NodeData)
                                            lv_NodeData(ll_DataIndex) = lo_Node.Tag.GetData(ll_DataIndex)
                                        Next
                                        lv_LevelData(ll_LevelIndex) = lv_NodeData
                                    Else
                                        lv_LevelData(ll_LevelIndex) = Array(lo_Node.Tag.IDValue, "", lo_Node.Tag.TextValue)
                                    End If
                                    Set lo_Node = lo_Node.Parent
                                    ll_LevelIndex = ll_LevelIndex - 1
                                Wend
                                If SafeUbound(lv_pathData) = -1 Then    'MW REDIM
                                    ReDim lv_pathData(UBound(lv_pathData) + ll_LevelCount - 1)
                                Else
                                    ReDim Preserve lv_pathData(UBound(lv_pathData) + ll_LevelCount - 1)
                                End If
                                For ll_LevelIndex = 0 To UBound(lv_LevelData)
                                    lv_pathData(ll_IdxPath + ll_LevelIndex) = lv_LevelData(ll_LevelIndex)
                                Next
                                ll_IdxPath = ll_IdxPath + ll_LevelCount - 1
                            End If
                        Case "ARMCHECKVIEW"
                            lv_CheckData = Array("", "")
                            If lo_Control.RoleList("EDIT").CheckedCount > 0 Then
                                ReDim lv_CheckData(lo_Control.RoleList("EDIT").CheckedCount * 2 - 1)
                                ll_ItemIdx = 0
                                For ll_Idx = 1 To lo_Control.RoleList("EDIT").Count
                                    If lo_Control.RoleList("EDIT").Items(ll_Idx).CurrentChecked Then
                                        lv_CheckData(ll_ItemIdx * 2) = lo_Control.RoleList("EDIT").Items(ll_Idx).GetData(0)
                                        lv_CheckData(ll_ItemIdx * 2 + 1) = lo_Control.RoleList("EDIT").Items(ll_Idx).GetData(1)
                                        ll_ItemIdx = ll_ItemIdx + 1
                                    End If
                                Next
                            End If
                            lv_pathData(ll_IdxPath) = lv_CheckData
                            Exit For
                    End Select
                End If
            Next ll_IdxPath
        Next lo_Control
        Set lo_Control = Nothing
        GetCurrentPathData = lv_pathData
    Exit Function

ErrHandler:
    Set lo_Control = Nothing
    Call ErrorHandler("GetCurrentPathData")

End Function

Private Sub InitItemDetailKey(ByVal al_DetailIndex As Long)
On Error GoTo ErrHandler

    Dim ll_frameIndex As Long
    
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    'replace the holders (from the frame record)
    If mt_DetailConfig(al_DetailIndex).TableName <> "" Then
        txt_DetailKey(ll_frameIndex).Text = mo_Tools.GetNextID(mo_Db, mt_DetailConfig(al_DetailIndex).TableName)
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("InitItemDetailKey")
End Sub

Private Function Item_CheckMandatory(ByVal av_ListFieldsMandatory As Variant) As Boolean
On Error GoTo ErrHandler
    
    Dim lIdx As Long, lCount As Long
    Dim lv_MsgReplaceInfo(0, 1) As String
    Dim lo_Control As Object
    Dim ls_LabelCaption As String
    Dim ll_CtrlIndex As Long
    Dim lb_Found As Boolean
    Dim ls_Tags() As String
    
    If Not IsArray(av_ListFieldsMandatory) Then
        Item_CheckMandatory = True
        Exit Function
    End If
    
    lCount = UBound(av_ListFieldsMandatory, 1)
    
    For lIdx = 0 To lCount
            Set lo_Control = av_ListFieldsMandatory(lIdx)(0)
            If av_ListFieldsMandatory(lIdx)(1) >= 0 Then
                ls_LabelCaption = lbl_label(av_ListFieldsMandatory(lIdx)(1)).Caption
            Else
                ls_LabelCaption = ""
            End If
            Select Case UCase(TypeName(lo_Control))
                Case "FRAME", "LABEL", "MSFLEXGRID", "TOOLBARCONTROL"
                    ' Do nothing !
                
                Case "TEXTBOX"
                    If lo_Control.Visible And (lo_Control.Text = "") Then
                        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2120, "The field $LabelCaption$ is mandatory.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                        Exit Function
                    End If
                    ls_Tags = Split(lo_Control.Tag, SEP)
                    If lo_Control.Visible And UBound(ls_Tags) > 0 And (lo_Control.Text <> "") Then
                        If ls_Tags(1) = "F" And IsNumeric(lo_Control.Text) = False Then
                            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2131, "The field $LabelCaption$ must be numeric.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                            Exit Function
                        End If
                        If ls_Tags(1) = "N" And mo_Tools.IsIntValue(lo_Control.Text) = False Then
                            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2121, "The field $LabelCaption$ must be numeric with not decimal.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                            Exit Function
                        End If
                    End If
                Case "ARMCHECKVIEW"
                     If lo_Control.Visible And (lo_Control.RoleList("EDIT").CheckedCount = 0) Then
                        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2120, "The field $LabelCaption$ is mandatory.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                        Call lo_Control.SetFocus
                        Exit Function
                      End If
                Case "A_CALOCX"
                    If lo_Control.Visible And (lo_Control.date_courte = "") Then
                        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2120, "The field $LabelCaption$ is mandatory.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                        Exit Function
                    End If
                Case "ARMGRID", "ARMCHECKVIEW", "COMMANDBUTTON", "ARMTREEVIEW", "LISTBOX", "PICTUREBOX", "TABSTRIP"
                Case "OPTIONBUTTON", "CHECKBOX"
                    'probably array of controls
                Case "OBJECT"
                    lb_Found = False
                    For ll_CtrlIndex = 0 To lo_Control.Count - 1
                        If UCase(TypeName(lo_Control(ll_CtrlIndex))) = "CHECKBOX" Then
                            If lo_Control(ll_CtrlIndex).Value = vbChecked Then
                                lb_Found = True
                                Exit For
                            End If
                        ElseIf UCase(TypeName(lo_Control(ll_CtrlIndex))) = "OPTIONBUTTON" Then
                            If lo_Control(ll_CtrlIndex).Value Then
                                lb_Found = True
                                Exit For
                            End If
                        Else
                            ' unknown array ???
                            lb_Found = True
                            Exit For
                        End If
                    Next
                    If Not lb_Found Then
                        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2120, "The field $LabelCaption$ is mandatory.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                        Exit Function
                    End If
                Case "ARMCOMBOBOX"
                    If lo_Control.Visible And (lo_Control.SelectedItem Is Nothing) Then
                        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2120, "The field $LabelCaption$ is mandatory.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                        Exit Function
                    End If
                Case "ARMPICKER"
                    If lo_Control.Visible And (CStr(lo_Control.ItemCode) = "") Then
                        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2120, "The field $LabelCaption$ is mandatory.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                        Exit Function
                    End If
                Case "LISTVIEW"
                     If lo_Control.Visible And (GetCheckedCount(lo_Control) = 0) Then
                        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2120, "The field $LabelCaption$ is mandatory.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                        Exit Function
                      End If
                Case Else
                    Debug.Print "Item_CheckMandatory " & UCase(TypeName(lo_Control))
            End Select
    Next

    Item_CheckMandatory = True

    Exit Function
ErrHandler:
    Call ErrorHandler("Item_CheckMandatory")
    
End Function

Private Function Item_CheckValues(ByRef ao_Frame As Frame)
On Error GoTo ErrHandler

Dim lo_Control As Control
Dim lsa_Columns() As String
Dim lv_MsgReplaceInfo(0, 1) As String
Dim ls_LabelCaption As String

    Item_CheckValues = False
    
    For Each lo_Control In UserControl.Controls
    
        If mo_Tools.HasContainer(lo_Control, ao_Frame) Then
            Select Case UCase(TypeName(lo_Control))
                Case "TEXTBOX"
                    If Trim(lo_Control.Tag) <> "" And Trim(lo_Control.Text) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If UBound(lsa_Columns) >= 2 Then
                            
                            ls_LabelCaption = mo_Tools.GetLabelCaption(UserControl.Controls, ao_Frame, lsa_Columns(2))
                            
                            If lsa_Columns(1) = "F" And IsNumeric(lo_Control.Text) = False Then
                                Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2131, "The field $LabelCaption$ must be numeric.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                                Exit Function
                            End If
                            
                            If lsa_Columns(1) = "N" And mo_Tools.IsIntValue(lo_Control.Text) = False Then
                                Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 2121, "The field $LabelCaption$ must be numeric with not decimal.", Array("$LabelCaption$", ls_LabelCaption), vbInformation)
                                Exit Function
                            End If
                        End If
                    End If
            End Select
        End If
    Next
    Item_CheckValues = True
    Exit Function
ErrHandler:
    Item_CheckValues = False
    Call ErrorHandler("Item_CheckValues")
End Function

Private Sub Item_Clear(ByVal al_DetailIndex As Long)
On Error GoTo ErrHandler

Dim ll_Index As Long

    Call mo_Tools.ClearFrame(UserControl.Controls, fra_DetailItem(mt_DetailConfig(al_DetailIndex).FrameIndex))
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If (mt_SubdetailConfig(ll_Index).DetailConfigIndex = al_DetailIndex) And (mt_SubdetailConfig(ll_Index).RequestView <> "") Then
            ReDim mt_SubdetailConfig(ll_Index).DeletedRows(-1 To -1)
        End If
    Next
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_Clear")
End Sub

Private Sub Item_Load(ByVal al_DetailIndex As Long, ByVal av_Key As Variant)
On Error GoTo ErrHandler

Dim ls_Req As String
Dim ll_frameIndex As Long

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    
    ls_Req = mt_DetailConfig(al_DetailIndex).RequestView
    ls_Req = ReplaceKeyPlaceholders(ls_Req, av_Key)
    ls_Req = ReplaceLanguagePlaceholderFromToolbar(ls_Req)
    ls_Req = ReplaceCommonPlaceholders(ls_Req)
    'load data
    If mc_Item > 0 Then
        Call mo_Db.Close(mc_Item)
        mc_Item = 0
    End If
    
    If ls_Req <> "" Then
        mc_Item = mo_Tools.OpenSQLSafe(mo_Db, ls_Req, 1)
    End If
   
    Call LoadFrameDataFromCursor(mo_Db, mc_Item, fra_DetailItem(ll_frameIndex))
    
    Call Item_CustomLoad(al_DetailIndex, av_Key)
    Exit Sub
ErrHandler:
    If mc_Item <> 0 Then Call mo_Db.Close(mc_Item)
    mc_Item = 0
    Call ErrorHandler("Item_Load")
End Sub

Private Sub Item_ViewInit(ByVal al_DetailIndex As Long, ByVal av_Key As Variant)
On Error GoTo ErrHandler
    
    Dim ll_frameIndex As Long
    Dim ls_Req As String
    
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    
    Call InitDetailFrame(al_DetailIndex)
        
    If mt_DetailConfig(al_DetailIndex).ClearControlsBeforeInit = True Then

        'clear the frame record and disable frames
        Call mo_Tools.ClearFrame(UserControl.Controls, fra_DetailItem(ll_frameIndex))
    End If
    
    
    Call Item_Load(al_DetailIndex, av_Key)
    Call SubItem_Load(al_DetailIndex, av_Key)
    
    Call mo_Tools.EnableFrame(UserControl.Controls, fra_DetailItem(ll_frameIndex), False)
    
    'change screen mode
    Call SetMode(emView, al_DetailIndex)
    
    Call UpdateDetailToolbarCustom(al_DetailIndex)
    
    Call Item_CustomInit(al_DetailIndex, av_Key, emView)
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_ViewInit")
End Sub

Private Sub Item_ReInit(ByVal al_DetailConfigIndex As Long, ByVal av_Key As Variant)
On Error GoTo ErrHandler

    Dim ll_frameIndex As Integer
    
    ll_frameIndex = mt_DetailConfig(al_DetailConfigIndex).FrameIndex
    Select Case me_DetailMode
    Case emAdd
        Call Item_AddInit(al_DetailConfigIndex)
    Case emUpdate
        Call Item_UpdateInit(al_DetailConfigIndex, av_Key)
    Case Else
        Err.Raise ArmErr.InvalidArgument, "me_DetailMode", "Invalid mode: " & me_DetailMode
    End Select
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_ReInit")
End Sub

Private Sub Item_AddInit(ByVal al_DetailConfigIndex As Long)
On Error GoTo ErrHandler

    Dim ll_frameIndex As Integer
    
    ll_frameIndex = mt_DetailConfig(al_DetailConfigIndex).FrameIndex
    
    Call InitDetailFrame(al_DetailConfigIndex)
    
    'clear the frame record
    Call Item_Clear(al_DetailConfigIndex)
    
    Call mo_Tools.EnableFrame(UserControl.Controls, fra_DetailItem(ll_frameIndex), True)
    
    Call DisableFrameParts(mt_DetailConfig(al_DetailConfigIndex).ListFieldsToDisable)
    
    'load default values
    Call Item_LoadDefaultValue(al_DetailConfigIndex, mt_DetailConfig(al_DetailConfigIndex).ListFieldsDefaultValue)
    
    Call SetDrivenDetailControls(Nothing)

    'Change screen mode
    Call SetMode(emAdd, al_DetailConfigIndex)
    
    Call Item_CustomInit(al_DetailConfigIndex, Empty, emAdd)
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_AddInit")
End Sub

Private Function Item_Add(ByVal al_DetailIndex As Long) As Boolean
On Error GoTo ErrHandler
    
    Dim ll_frameIndex As Long
    Dim ll_MainIndex As Long
    Dim ll_MainFrameIndex As Long
    
    Item_Add = False
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    ll_MainIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    If ll_MainIndex <> -1 Then
        ll_MainFrameIndex = mt_MainConfig(ll_MainIndex).FrameIndex
    End If
    'check the data validity -> Item_Check
    If Not Item_CheckMandatory(mt_DetailConfig(al_DetailIndex).ListFieldsMandatory) Then Exit Function
    
    If Not Item_CheckValues(fra_DetailItem(ll_frameIndex)) Then Exit Function
    
    'check the custom data validity -> Item_CheckCustom
    If Not Item_CustomCheck(al_DetailIndex, eMode.emAdd) Then Exit Function
    
    'update data on the db ->
    If Not Item_AddDB(al_DetailIndex) Then Exit Function
    
    If ll_MainIndex <> -1 Then
        Call Item_AddLocal(UserControl.Controls, fra_DetailItem(ll_frameIndex), tvw_Main(ll_MainFrameIndex), grd_Main(ll_MainFrameIndex), chk_Repositioning(ll_frameIndex).Value = vbChecked)
    End If
    
    Call Item_CustomLocal(al_DetailIndex, eMode.emAdd)
    
    If ll_MainIndex <> -1 Then
        'go back to the detail screen
        Call Item_ExitToGrid(ll_MainIndex, al_DetailIndex)
        Call SetMode(emList)
    Else
        ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
        mt_MainConfig(ll_MainIndex).CurrentDetailIndex = mt_DetailConfig(al_DetailIndex).PreviousDetailIndex
        Call SetMode(me_OldDetailMode)
        'Call SetMode(emAdd)
    End If
    Item_Add = True
    
    Exit Function
ErrHandler:
    Call ErrorHandler("Item_Add")
End Function

Private Function Item_CheckAddDB(ByVal al_DetailIndex As Long) As Boolean
On Error GoTo ErrHandler
    
    Dim lc_Cursor As Long
    Dim ls_Request As String
    Dim ll_Index As Long, ll_Count As Long, ll_frameIndex As Long
    
    Item_CheckAddDB = False
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    ls_Request = mt_DetailConfig(al_DetailIndex).RequestCheckAdd
    If ls_Request <> "" Then
        ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_DetailItem(ll_frameIndex))
        ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        ' HERE WE CHECK THE DATA INTEGRITY (UNICITY)
        ' ll_Count indicates if the data already  exists
        lc_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
        ll_Count = mo_Db.RowCount(lc_Cursor)
        Call mo_Db.Close(lc_Cursor)
        
        If ll_Count > 0 Then
            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, mt_DetailConfig(al_DetailIndex).CheckAddUpdMsg(0, 0), mt_DetailConfig(al_DetailIndex).CheckAddUpdMsg(0, 1), , vbInformation + vbOKOnly)
            Exit Function
        End If
    End If
    Item_CheckAddDB = True
    Exit Function
ErrHandler:
    If lc_Cursor <> 0 Then Call mo_Db.Close(lc_Cursor)
    Call ErrorHandler("Item_CheckAddDB")
End Function

Private Function Item_AddDB(ByVal al_DetailIndex As Long) As Boolean
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_Index As Long, ll_frameIndex As Long, ll_Count As Long
    Dim lb_InTransaction As Boolean
    
    Item_AddDB = False
    lb_InTransaction = False
    
    If Not Item_CheckAddDB(al_DetailIndex) Then Exit Function
    
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    
    'replace the holders (from the frame record)
    Call InitItemDetailKey(al_DetailIndex)
    
    'handle transaction
    If mt_DetailConfig(al_DetailIndex).UseTransaction Then
        Call mo_Tools.BeginTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_AddDB")
        lb_InTransaction = True
    End If
    
    ll_Count = UBound(mt_DetailConfig(al_DetailIndex).RequestAdd)
    For ll_Index = 0 To ll_Count
        'get the request from the ClassInfo
        ls_Request = mt_DetailConfig(al_DetailIndex).RequestAdd(ll_Index)
        If ls_Request <> "" Then
            ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_DetailItem(ll_frameIndex))
            ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, IIf(ll_Index = ll_Count, mt_DetailConfig(al_DetailIndex).AffectedCount(0), -1))
        End If
    Next
    
    If lb_InTransaction Then Call Item_CustomAddDB(al_DetailIndex, lb_InTransaction)
    
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If mt_SubdetailConfig(ll_Index).DetailConfigIndex = al_DetailIndex Then
            Call SaveSubDetailGrid(ll_Index)
        End If
    Next
    
    If lb_InTransaction Then
        Call mo_Tools.CommitTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_AddDB")
        lb_InTransaction = False
    End If
    
    Call Item_CustomAddDB(al_DetailIndex, lb_InTransaction)
    
    Item_AddDB = True
    Exit Function
    
ErrHandler:
    If lb_InTransaction Then
        Call mo_Tools.RollbackTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_AddDB")
    End If
    Call ErrorHandler("Item_AddDB")
End Function

Private Function Item_AddLocal(ByRef aControls As Variant, ByRef aContainer As Object, ByRef ao_Tree As ArmTreeView, ByRef ao_grid As ArmGrid, ByVal ab_Repositioning As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_MainIndex As Long, ll_DetailIndex As Long
Dim ll_MainFrame As Long, ll_DetailFrame As Long
Dim av_PathData As Variant
Dim ls_path As String
Dim lo_Node As Object

    Item_AddLocal = False
    'change the data locally
    ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_MainFrame = mt_MainConfig(ll_MainIndex).FrameIndex
    ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainIndex)
    ll_DetailFrame = mt_DetailConfig(ll_DetailIndex).FrameIndex
    

    If mt_MainConfig(ll_MainIndex).CurrentTvwSelMethod = eTvwSelMethod.etmNone Then
        Call UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emAdd, False, "", False)
        Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emAdd)
        Item_AddLocal = True
        Exit Function
    End If
    ls_path = Trim(cbo_View(ll_MainFrame).SelectedItem.GetData(2))
    If ls_path = "" Then
        Call UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emAdd, False, "", False)
        Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emAdd)
        Item_AddLocal = True
        Exit Function
    End If
    av_PathData = GetCurrentPathData(UserControl.Controls, ls_path)
    If Not IsItemInFilter(ll_DetailIndex) Then
        Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emAdd)
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 7204, "#Updated item cannot be displayed with current filter")
        'Err.Raise 202, "Item_AddLocal", "Updated item cannot be displayed with current filter"
        Item_AddLocal = False
        Exit Function
    End If
    If IsItemSelectedInTree(ll_DetailIndex, tvw_Main(ll_MainFrame), av_PathData) Then
        ' item is in current filter do not need to reposition just update grid
        If UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emAdd, False, "", False) Then
            Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emAdd)
            Item_AddLocal = True
            Exit Function
        End If
    End If
    If ab_Repositioning And IsArray(av_PathData) Then
        Set lo_Node = FindInTreeView(ao_Tree, av_PathData, True, True)
        If Not (lo_Node Is Nothing) Then
            Call tvw_Main_NodeClick(CInt(ll_MainFrame), lo_Node)
            If mt_MainConfig(ll_MainIndex).GridDelayed Then
                If Not ao_grid.Execute Then
                    Err.Raise ArmErr.CompFncFailed, "grd_Main(" & ll_MainFrame & ").Execute", "Method Execute failed: " & ao_grid.Requests(0)
                End If
                 mt_MainConfig(ll_MainIndex).GridDelayed = False
            End If
            Call ao_grid.SearchKey(True, txt_DetailKey(ll_DetailFrame).Text)
        End If
    Else
        Set lo_Node = ao_Tree.SelectedItem
        Call FindInTreeView(ao_Tree, av_PathData, True, False)
        Set ao_Tree.SelectedItem = lo_Node
        'don't do anything, item is not added localy to tree because tree do not filter it
    End If
    Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emAdd)
    Item_AddLocal = True
    Exit Function
ErrHandler:
    Call ErrorHandler("Item_AddLocal")
End Function

Private Sub Item_UpdateInit(ByVal al_DetailIndex As Long, ByVal av_Key As Variant)
On Error GoTo ErrHandler

    Dim ll_frameIndex As Long
    
    If IsEmpty(av_Key) Then Exit Sub
    
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    
    If me_DetailMode <> emView Then
        Call InitDetailFrame(al_DetailIndex)
    End If
    
    Call mo_Tools.EnableFrame(UserControl.Controls, fra_DetailItem(ll_frameIndex), True)
    
    Call DisableFrameParts(mt_DetailConfig(al_DetailIndex).ListFieldsToDisable)
        
    If me_DetailMode = emView Then
        ' do nothing, data are already in controls we are going from view to update
    ElseIf me_DetailMode = emUpdate Then
        ' ml_Cursor contain already loaded data, this means reinit, from update to update
        Call LoadFrameDataFromCursor(mo_Db, mc_Item, fra_DetailItem(ll_frameIndex))
        Call Item_CustomLoad(al_DetailIndex, av_Key)
        ' reload subgrid, this cannot be redo locally
        Call SubItem_Load(al_DetailIndex, av_Key)
    Else
        'clear the frame record and disable frames
        Call mo_Tools.ClearFrame(UserControl.Controls, fra_DetailItem(ll_frameIndex))
        Call Item_Load(al_DetailIndex, av_Key)
        Call SubItem_Load(al_DetailIndex, av_Key)
    End If
    
    Call SetDrivenDetailControls(Nothing)
    
    'Change screen mode
    Call SetMode(emUpdate, al_DetailIndex)
    
    Call Item_CustomInit(al_DetailIndex, av_Key, emUpdate)
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_UpdateInit")
End Sub

Private Function Item_Update(ByVal al_DetailIndex As Long) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Integer, ll_MainFrameIndex As Long
Dim ll_MainIndex As Long
    
    Item_Update = False
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    ll_MainIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    If ll_MainIndex <> -1 Then
        ll_MainFrameIndex = mt_MainConfig(ll_MainIndex).FrameIndex
    End If
    
    'check the data validity -> Item_Check
    If Not Item_CheckMandatory(mt_DetailConfig(al_DetailIndex).ListFieldsMandatory) Then Exit Function
    
    If Not Item_CheckValues(fra_DetailItem(ll_frameIndex)) Then Exit Function
        
    'check the custom data validity -> Item_CheckCustom
    If Not Item_CustomCheck(al_DetailIndex, eMode.emUpdate) Then Exit Function
    
    'update data on the db ->
    If Not Item_UpdateDB(al_DetailIndex) Then Exit Function
    'if success then update the data locally ->
    If ll_MainIndex <> -1 Then
        Call Item_UpdateLocal(UserControl.Controls, fra_DetailItem(ll_frameIndex), tvw_Main(ll_MainFrameIndex), grd_Main(ll_MainFrameIndex), chk_Repositioning(ll_frameIndex).Value = vbChecked)
    End If
    
    Call Item_CustomLocal(al_DetailIndex, eMode.emUpdate)
        
    If ll_MainIndex <> -1 Then
        'go back to the detail screen
        Call Item_ExitToGrid(ll_MainIndex, al_DetailIndex)
        Call SetMode(emList)
    Else
        ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
        mt_MainConfig(ll_MainIndex).CurrentDetailIndex = mt_DetailConfig(al_DetailIndex).PreviousDetailIndex
        Call SetMode(me_OldDetailMode)
    End If

    Item_Update = True
    Exit Function
ErrHandler:
    Call ErrorHandler("Item_Update")
End Function

Private Function Item_CheckUpdateDB(ByVal al_DetailIndex As Long) As Boolean
On Error GoTo ErrHandler

    'START Check unicity ************
    Dim ls_Request As String
    Dim lc_Cursor As Long
    Dim ll_Count As Long
    Dim ll_frameIndex As Long
    
    Item_CheckUpdateDB = False
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    ls_Request = mt_DetailConfig(al_DetailIndex).RequestCheckUpdate
    If ls_Request <> "" Then
        ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_DetailItem(ll_frameIndex))
        ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        lc_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
        
        ll_Count = mo_Db.RowCount(lc_Cursor)
        Call mo_Db.Close(lc_Cursor)
        
        If ll_Count > 0 Then
            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, mt_DetailConfig(al_DetailIndex).CheckAddUpdMsg(0, 0), mt_DetailConfig(al_DetailIndex).CheckAddUpdMsg(0, 1), , vbInformation + vbOKOnly)
            Exit Function
        End If
    End If
    'END Check unicity ************
    Item_CheckUpdateDB = True
    Exit Function
ErrHandler:
    Item_CheckUpdateDB = False
    If lc_Cursor <> 0 Then Call mo_Db.Close(lc_Cursor)
    Call ErrorHandler("Item_CheckUpdateDB")
End Function

Private Function Item_UpdateDB(ByVal al_DetailIndex As Long) As Boolean
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_frameIndex As Long
    Dim ll_Index As Long, ll_Count As Long
    Dim lb_InTransaction As Boolean
    
    Item_UpdateDB = False
    
    lb_InTransaction = False
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    
    If Not Item_CheckUpdateDB(al_DetailIndex) Then Exit Function
    
    'handle transaction
    If mt_DetailConfig(al_DetailIndex).UseTransaction Then
        Call mo_Tools.BeginTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_UpdateDB")
        lb_InTransaction = True
    End If
    
    ll_Count = UBound(mt_DetailConfig(al_DetailIndex).RequestUpd)
    For ll_Index = 0 To ll_Count
        'get the request from the ClassInfo
        ls_Request = mt_DetailConfig(al_DetailIndex).RequestUpd(ll_Index)
        If ls_Request <> "" Then
        'replace the holders (from the frame record)
            ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_DetailItem(ll_frameIndex))
            ls_Request = ReplacePlaceHolder(ls_Request, "$iConcurrency$", mo_Db.GetFields(mc_Item, "iConcurrency"))
            ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            ' first sql request should affect just 1 row from main table, other may update linked tables - 0..N records
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, IIf(ll_Index = 0, mt_DetailConfig(al_DetailIndex).AffectedCount(1), -1))
        End If
    Next
    
    If lb_InTransaction Then Call Item_CustomUpdateDB(al_DetailIndex, lb_InTransaction)
    
    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If mt_SubdetailConfig(ll_Index).DetailConfigIndex = al_DetailIndex Then
            Call SaveSubDetailGrid(ll_Index)
        End If
    Next
    
    If lb_InTransaction Then
        Call mo_Tools.CommitTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_UpdateDB")
        lb_InTransaction = False
    End If
    
    Call Item_CustomUpdateDB(al_DetailIndex, lb_InTransaction)
    
    Item_UpdateDB = True
    
    Exit Function
ErrHandler:
    Item_UpdateDB = False
    If lb_InTransaction Then
        Call mo_Tools.RollbackTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_UpdateDB")
    End If
    Call ErrorHandler("Item_UpdateDB")
End Function

Private Function Item_UpdateLocal(ByRef aControls As Variant, ByRef aContainer As Object, ByRef ao_Tree As ArmTreeView, ByRef ao_grid As ArmGrid, ByVal ab_Repositioning As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_MainIndex As Long, ll_DetailIndex As Long
Dim ll_MainFrame As Long, ll_DetailFrame As Long
Dim av_PathData As Variant
Dim ls_path As String
Dim lo_Node As Object

    Item_UpdateLocal = False
    'change the data locally
    ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_MainFrame = mt_MainConfig(ll_MainIndex).FrameIndex
    ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainIndex)
    ll_DetailFrame = mt_DetailConfig(ll_DetailIndex).FrameIndex
    

    If mt_MainConfig(ll_MainIndex).CurrentTvwSelMethod = eTvwSelMethod.etmNone Then
        Call UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emUpdate, False, "", False)
        Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emUpdate)
        Item_UpdateLocal = True
        Exit Function
    End If
    
    ls_path = Trim(cbo_View(ll_MainFrame).SelectedItem.GetData(2))
    If ls_path = "" Then
        Call UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emUpdate, False, "", False)
        Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emUpdate)
        Item_UpdateLocal = True
        Exit Function
    End If
    av_PathData = GetCurrentPathData(UserControl.Controls, ls_path)
    If Not IsItemInFilter(ll_DetailIndex) Then
        Call UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emDelete, False, "", False)
        Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emUpdate)
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 7204, "Updated item cannot be displayed with current filter")
        Item_UpdateLocal = False
        Exit Function
    End If
    If IsItemSelectedInTree(ll_DetailIndex, tvw_Main(ll_MainFrame), av_PathData) Then
        ' item is in current filter do not need to reposition just update grid
        If UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emUpdate, False, "", False) Then
            Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emUpdate)
            Item_UpdateLocal = True
            Exit Function
        End If
    End If
    If ab_Repositioning And IsArray(av_PathData) Then
        Set lo_Node = FindInTreeView(ao_Tree, av_PathData, True, True)
        Call tvw_Main_NodeClick(CInt(ll_MainFrame), lo_Node)
        If mt_MainConfig(ll_MainIndex).GridDelayed Then
            If Not ao_grid.Execute Then
                Err.Raise ArmErr.CompFncFailed, "grd_Main(" & ll_MainFrame & ").Execute", "Method Execute failed: " & ao_grid.Requests(0)
            End If
             mt_MainConfig(ll_MainIndex).GridDelayed = False
        End If
        Call ao_grid.SearchKey(True, txt_DetailKey(ll_DetailFrame).Text)
    Else
        Set lo_Node = ao_Tree.SelectedItem
        Call FindInTreeView(ao_Tree, av_PathData, True, False)
        Set ao_Tree.SelectedItem = lo_Node
        ' do not reposition tree, just delete item from grid
        Call UpdateGridByFrame(ao_grid, fra_DetailItem(ll_DetailFrame), emDelete, False, "", False)
    End If
    Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), txt_DetailKey(ll_DetailFrame).Text, emUpdate)
    Item_UpdateLocal = True
    Exit Function
ErrHandler:
    Call ErrorHandler("Item_UpdateLocal")
End Function


Private Sub Item_DeleteInit(ByVal al_DetailIndex As Long, ByVal av_Key As Variant)
On Error GoTo ErrHandler

    If IsEmpty(av_Key) Then Exit Sub
    
    Dim ll_frameIndex As Integer
    
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    
    If me_DetailMode <> emView Then
        Call InitDetailFrame(al_DetailIndex)
    End If
    
    
    If me_DetailMode <> emView Then
        'clear the frame record and disable frames
        Call mo_Tools.ClearFrame(UserControl.Controls, fra_DetailItem(ll_frameIndex))
        Call Item_Load(al_DetailIndex, av_Key)
        Call SubItem_Load(al_DetailIndex, av_Key)
    End If
    
    If Not Item_CheckDeleteDB(al_DetailIndex) Then Exit Sub
    
    Call mo_Tools.EnableFrame(UserControl.Controls, fra_DetailItem(ll_frameIndex), False)
        
    'change screen mode
    Call SetMode(emDelete)
    
    Call Item_CustomInit(al_DetailIndex, av_Key, emDelete)
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_DeleteInit")
End Sub

Private Function Item_Delete(ByVal al_DetailIndex As Long) As Boolean

On Error GoTo ErrHandler

    Dim ll_frameIndex As Long
    Dim ll_MainFrameIndex As Long
    Dim ll_MainIndex As Long
    
    Item_Delete = False
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    ll_MainIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    ll_MainFrameIndex = mt_MainConfig(ll_MainIndex).FrameIndex
    
    'check the custom data validity -> Item_CheckCustom
    If Not Item_CustomCheck(al_DetailIndex, eMode.emDelete) Then Exit Function
    
    'delete data on the db
    If Not Item_DeleteDB(al_DetailIndex) Then Exit Function
    
    'if success then delete the data locally ->
    Call Item_DeleteLocal(UserControl.Controls, fra_DetailItem(ll_frameIndex), tvw_Main(ll_MainFrameIndex), grd_Main(ll_MainFrameIndex), chk_Repositioning(ll_frameIndex).Value = vbChecked)
    Call Item_CustomLocal(al_DetailIndex, eMode.emDelete)
    
    If ll_MainIndex <> -1 Then
        'go back to the detail screen
        Call Item_ExitToGrid(ll_MainIndex, al_DetailIndex)
        Call SetMode(emList)
    Else
        ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
        mt_MainConfig(ll_MainIndex).CurrentDetailIndex = mt_DetailConfig(al_DetailIndex).PreviousDetailIndex
        Call SetMode(me_OldDetailMode)
    End If

    Item_Delete = True
    Exit Function
ErrHandler:
    Call ErrorHandler("Item_Delete")
End Function

Private Function Item_CheckDeleteDB(ByVal al_DetailConfigIndex As Long) As Boolean
On Error GoTo ErrHandler
    
    Dim ls_Request As String
    Dim lc_Cursor As Long
    Dim ll_Count As Long
    Dim ll_frameIndex As Long
    
    Item_CheckDeleteDB = False
    
    ll_frameIndex = mt_DetailConfig(al_DetailConfigIndex).FrameIndex
    ls_Request = mt_DetailConfig(al_DetailConfigIndex).RequestCheckDelete
    
    If ls_Request <> "" Then
        ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_DetailItem(ll_frameIndex))
        ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        ' THIS IS NOT AN ERROR
        ' WE CHECK IS USER IS ALLOWED TO DELETE THIS DATA
        ' A DATA CAN'T BE DELETE IF IT HAVE SOME DEPENDANCIES, LIKE ATTACHMENT
        ' Li_Count is the count of dependancies
        lc_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
        ll_Count = mo_Db.RowCount(lc_Cursor)
        Call mo_Db.Close(lc_Cursor)
        If ll_Count > 0 Then
            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, mt_DetailConfig(al_DetailConfigIndex).CheckDelMsg(0, 0), mt_DetailConfig(al_DetailConfigIndex).CheckDelMsg(0, 1), , vbInformation + vbOKOnly)
            Exit Function
        End If
    End If
    Item_CheckDeleteDB = True
    Exit Function
ErrHandler:
    If lc_Cursor <> 0 Then Call mo_Db.Close(lc_Cursor)
    Call ErrorHandler("Item_CheckDelete")
End Function

Private Function Item_DeleteDB(ByVal al_DetailIndex As Long) As Boolean

On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_frameIndex As Long, ll_Count As Long
    Dim ll_Index As Long
    Dim lb_InTransaction As Boolean
    
    Item_DeleteDB = False
    
    lb_InTransaction = False
    
    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex

    Call Item_CustomDeleteDB(al_DetailIndex, lb_InTransaction)
    
    'handle transaction
    If mt_DetailConfig(al_DetailIndex).UseTransaction Then
        Call mo_Tools.BeginTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_DeleteDB")
        lb_InTransaction = True
    End If

    If lb_InTransaction Then Call Item_CustomDeleteDB(al_DetailIndex, lb_InTransaction)
    
    ll_Count = UBound(mt_DetailConfig(al_DetailIndex).RequestDel)
    For ll_Index = 0 To ll_Count
    
        'get the request from the al_DetailIndex
        ls_Request = mt_DetailConfig(al_DetailIndex).RequestDel(ll_Index)
        'replace the holders (from the frame record)
        ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_DetailItem(ll_frameIndex))
        ls_Request = ReplacePlaceHolder(ls_Request, "$iConcurrency$", mo_Db.GetFields(mc_Item, "iConcurrency"))
        ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        ' last delete commant should delete (mark deleted) 1 row from main table, other sql request delete 0..N links
        Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, IIf(ll_Index = ll_Count, mt_DetailConfig(al_DetailIndex).AffectedCount(2), -1))
    Next
    
    If lb_InTransaction Then
        Call mo_Tools.CommitTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_DeleteDB")
        lb_InTransaction = False
    End If
    
    Item_DeleteDB = True
    Exit Function
    
ErrHandler:
    Item_DeleteDB = False
    If lb_InTransaction Then
        Call mo_Tools.RollbackTran(mo_Db, ml_U_Code, SCREEN_NAME, "Item_DeleteDB")
    End If
    Call ErrorHandler("Item_DeleteDB")
End Function

Private Function Item_DeleteLocal(ByRef aControls As Variant, ByRef aContainer As Object, ByRef ao_Tree As ArmTreeView, ByVal ao_grid As ArmGrid, ByVal ab_Repositioning As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_MainIndex As Long, ll_DetailIndex As Long
Dim ll_MainFrame As Long, ll_DetailFrame As Long
Dim ls_Key As String

    'change the data locally
    ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_MainFrame = mt_MainConfig(ll_MainIndex).FrameIndex
    ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainIndex)
    ll_DetailFrame = mt_DetailConfig(ll_DetailIndex).FrameIndex
    ls_Key = txt_DetailKey(ll_DetailFrame).Text
    
    Call UpdateLocalComboboxes(GetDetailKeyFieldName(ll_DetailIndex), ls_Key, emDelete)
    
    If Not ao_grid.DeleteSelectedLines Then
        Err.Raise ArmErr.CompFncFailed, "ao_grid", "DeleteSelectedLines failed"
    End If
    
    If Not ab_Repositioning Then
        Item_DeleteLocal = True
        Exit Function
    End If
    
    Item_DeleteLocal = True
    Exit Function
    
ErrHandler:
    Call ErrorHandler("Item_DeleteLocal")
End Function

Private Sub SubItem_Load(ByVal al_DetailIndex As Long, ByVal av_Key As Variant)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim lb_DelayedLoad As Boolean
Dim ls_Req As String

    For ll_Index = 0 To UBound(mt_SubdetailConfig)
        If (mt_SubdetailConfig(ll_Index).DetailConfigIndex = al_DetailIndex) Then
        
            ReDim mt_SubdetailConfig(ll_Index).DeletedRows(-1 To -1)
            Call grd_SubDetail(ll_Index).ClearGrid
            lb_DelayedLoad = (mt_SubdetailConfig(ll_Index).GridDelayMethod = egmDelayedAlways)
            
            Call SubItem_CustomLoad(ll_Index)
            
            If (mt_SubdetailConfig(ll_Index).RequestView <> "") Then
                ls_Req = mt_SubdetailConfig(ll_Index).RequestView
                ls_Req = ReplaceKeyPlaceholders(ls_Req, av_Key)
                ls_Req = ReplaceLanguagePlaceholderFromToolbar(ls_Req)
                ls_Req = ReplaceCommonPlaceholders(ls_Req)
                If Not grd_SubDetail(ll_Index).Load(ls_Req, True, , , lb_DelayedLoad) Then
                    Err.Raise ArmErr.CompFncFailed, "grd_SubDetail(" & ll_Index & ").Load", "Grid load failed: " & ls_Req
                End If
            End If
        End If
    Next
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("SubItem_Load")
End Sub

Private Sub SubItem_AddInit(ByVal al_SubDetaiIndex As Long)
On Error GoTo ErrHandler

    Dim ll_frameIndex As Integer
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetaiIndex).FrameIndex
   
    Call InitSubdetailFrame(al_SubDetaiIndex)
    
    'clear the frame record
    Call mo_Tools.ClearFrame(UserControl.Controls, fra_SubDetailItem(ll_frameIndex))
    
    Call mo_Tools.EnableFrame(UserControl.Controls, fra_SubDetailItem(ll_frameIndex), True)
    
    Call DisableFrameParts(mt_SubdetailConfig(al_SubDetaiIndex).ListFieldsToDisable)
    'load default values
    Call SubItem_LoadDefaultValue(al_SubDetaiIndex, mt_SubdetailConfig(al_SubDetaiIndex).ListFieldsDefaultValue)
    
    'Change screen mode
    Call SetModeSubDetail(al_SubDetaiIndex, emAdd)
    
    Call SubItem_CustomInit(al_SubDetaiIndex, "", emAdd)
    Exit Sub
ErrHandler:
    Call ErrorHandler("SubItem_AddInit")
End Sub

Private Function SubItem_Add(ByVal al_SubDetailIndex As Long) As Boolean
On Error GoTo ErrHandler

Dim ll_frameIndex As Long
Dim lb_CustomSaved As Boolean
        
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
        'check the data validity -> Item_Check
    If Not Item_CheckMandatory(mt_SubdetailConfig(al_SubDetailIndex).ListFieldsMandatory) Then Exit Function
    
    If Not Item_CheckValues(fra_SubDetailItem(ll_frameIndex)) Then Exit Function
    
    If Not SubItem_CustomCheck(al_SubDetailIndex, eMode.emAdd) Then Exit Function
    
    If Not SubItem_CheckAddDB(al_SubDetailIndex) Then Exit Function
    
    If Not SubItem_CustomAdd(al_SubDetailIndex, lb_CustomSaved) Then Exit Function
    
   ' first check if some custom code for database update executed, if yes, then framework do not need to do action
    If Not lb_CustomSaved Then
        'update data on the db ->
        'If me_DetailMode = emUpdate Then
        '    If Not SubItem_AddDB(al_SubdetailIndex) Then Exit Function
        'End If
            
        If Not UpdateGridByFrame(grd_SubDetail(ll_frameIndex), fra_SubDetailItem(ll_frameIndex), emAdd, True, mt_SubdetailConfig(al_SubDetailIndex).TableOrder, True) Then Exit Function
    End If
    
    SubItem_Add = True
    
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_Add")
End Function

Private Function SubItem_CheckAddDB(ByVal al_SubDetailIndex As Long) As Boolean
On Error GoTo ErrHandler
    Dim ls_Request As String
    Dim lc_Cursor As Long, ll_frameIndex As Long, ll_DetailFrameIndex As Long
    Dim ll_Count As Integer
    
    SubItem_CheckAddDB = False
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailFrameIndex = mt_DetailConfig(mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex).FrameIndex
    ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestCheckAdd
    If ls_Request <> "" Then
        ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_DetailKey(ll_DetailFrameIndex))
        ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_SubDetailItem(ll_frameIndex))
        ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        
        ' HERE WE CHECK THE DATA INTEGRITY (UNICITY)
        ' li_Count indicates if the data already  exists
        lc_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
        ll_Count = mo_Db.RowCount(lc_Cursor)
        Call mo_Db.Close(lc_Cursor)
        
        If ll_Count > 0 Then
            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, mt_SubdetailConfig(al_SubDetailIndex).CheckAddUpdMsg(0, 0), mt_SubdetailConfig(al_SubDetailIndex).CheckAddUpdMsg(0, 1), , vbInformation + vbOKOnly)
            Exit Function
        End If
    End If
    SubItem_CheckAddDB = SubItem_CustomCheckDB(al_SubDetailIndex, emAdd)
    Exit Function
ErrHandler:
    If lc_Cursor <> 0 Then Call mo_Db.Close(lc_Cursor)
    Call ErrorHandler("SubItem_CheckAddDB")
End Function

Private Function SubItem_AddDB(ByVal al_SubDetailIndex As Long, ByVal al_RowIndex As Long) As Boolean
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_frameIndex As Long, ll_DetailFrameIndex As Long
    Dim lb_CustomSaved As Boolean
    
    SubItem_AddDB = False
        
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailFrameIndex = mt_DetailConfig(mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex).FrameIndex
    
    If mt_SubdetailConfig(al_SubDetailIndex).TableName <> "" Then
        txt_SubDetailKey(ll_frameIndex).Text = mo_Tools.GetNextID(mo_Db, mt_SubdetailConfig(al_SubDetailIndex).TableName)
    Else
        txt_SubDetailKey(ll_frameIndex).Text = ""
    End If
    
    
    lb_CustomSaved = False
    If Not SubItem_CustomDBBefore(al_SubDetailIndex, emAdd, al_RowIndex, lb_CustomSaved) Then Exit Function
    
    If Not lb_CustomSaved Then
        'get the request from the ClassInfo
        ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestAdd
        
        If ls_Request <> "" Then
            ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_DetailKey(ll_DetailFrameIndex))
            ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_SubDetailKey(ll_frameIndex))
            If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_GroupParam" Then
                ls_Request = ReplaceRequestByGridData2(grd_SubDetail(ll_frameIndex), ls_Request, al_RowIndex, mt_SubdetailConfig(al_SubDetailIndex).TableName)
            Else
                ls_Request = ReplaceRequestByGridData(grd_SubDetail(ll_frameIndex), ls_Request, al_RowIndex, mt_SubdetailConfig(al_SubDetailIndex).TableName)
            End If
            ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request)
            grd_SubDetail(ll_frameIndex).Data(al_RowIndex, "iConcurrency") = 1
            grd_SubDetail(ll_frameIndex).Data(al_RowIndex, STATUS_COLUMN) = ""    ' reset status flag
        End If
        If Not SubItem_CustomDBAfter(al_SubDetailIndex, emAdd, al_RowIndex, lb_CustomSaved) Then Exit Function
    End If
    
    SubItem_AddDB = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_AddDB")
End Function

Private Sub SubItem_UpdateInit(ByVal al_SubDetailIndex As Long)
On Error GoTo ErrHandler
    
    Dim ll_frameIndex As Long
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex

    If grd_SubDetail(ll_frameIndex).SelectedCount <> 1 Then Exit Sub
    
    Call InitSubdetailFrame(al_SubDetailIndex)
        
    Call mo_Tools.EnableFrame(UserControl.Controls, fra_SubDetailItem(ll_frameIndex), True)
    
    Call DisableFrameParts(mt_SubdetailConfig(al_SubDetailIndex).ListFieldsToDisable)
        
    'clear the frame record and disable frames
    Call mo_Tools.ClearFrame(UserControl.Controls, fra_SubDetailItem(ll_frameIndex))
    
    Call LoadFrameDataFromGrid(grd_SubDetail(ll_frameIndex), fra_SubDetailItem(ll_frameIndex))
    
    'Change screen mode
    Call SetModeSubDetail(al_SubDetailIndex, emUpdate)
    
    Call SubItem_CustomInit(al_SubDetailIndex, "", emUpdate)
    Exit Sub
ErrHandler:
    Call ErrorHandler("Subitem_UpdateInit")
End Sub

Private Function SubItem_Update(ByVal al_SubDetailIndex As Long) As Boolean
On Error GoTo ErrHandler
    
    Dim ll_frameIndex As Long
    Dim lb_CustomSaved As Boolean
    
    SubItem_Update = False
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    
    'check the data validity -> Item_Check
    If Not Item_CheckMandatory(mt_SubdetailConfig(al_SubDetailIndex).ListFieldsMandatory) Then Exit Function
    
    If Not Item_CheckValues(fra_SubDetailItem(ll_frameIndex)) Then Exit Function
    
    If Not SubItem_CustomCheck(al_SubDetailIndex, eMode.emUpdate) Then Exit Function
    
    If Not SubItem_CheckUpdateDB(al_SubDetailIndex) Then Exit Function
    
    If Not SubItem_CustomUpdate(al_SubDetailIndex, lb_CustomSaved) Then Exit Function
    
    If Not lb_CustomSaved Then
        'If me_DetailMode = emUpdate Then
            'update data on the db ->
        '    If Not SubItem_UpdateDB(al_SubdetailIndex) Then Exit Function
        'End If
        
        'if success then Add the data locally ->
        If Not UpdateGridByFrame(grd_SubDetail(ll_frameIndex), fra_SubDetailItem(ll_frameIndex), emUpdate, True, mt_SubdetailConfig(al_SubDetailIndex).TableOrder, True) Then Exit Function
    End If
   
    SubItem_Update = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_Update")
End Function

Private Function SubItem_CheckUpdateDB(ByVal al_SubDetailIndex As Long) As Boolean
On Error GoTo ErrHandler
    Dim ls_Request As String
    Dim lc_Cursor As Long, ll_frameIndex As Long, ll_DetailFrameIndex As Long
    Dim ll_Count As Long
    
    SubItem_CheckUpdateDB = False
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailFrameIndex = mt_DetailConfig(mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex).FrameIndex
    ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestCheckUpdate
    If ls_Request <> "" Then
        ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_DetailKey(ll_DetailFrameIndex))
        ls_Request = mo_Tools.ReplaceRequestByFrameData(ls_Request, UserControl.Controls, fra_SubDetailItem(ll_frameIndex))
        ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        lc_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
        
        ll_Count = mo_Db.RowCount(lc_Cursor)
        Call mo_Db.Close(lc_Cursor)
        
        If (ll_Count > 0) Then
            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, mt_SubdetailConfig(al_SubDetailIndex).CheckAddUpdMsg(0, 0), mt_SubdetailConfig(al_SubDetailIndex).CheckAddUpdMsg(0, 1), , vbInformation + vbOKOnly)
            Exit Function
        End If
    End If
    SubItem_CheckUpdateDB = SubItem_CustomCheckDB(al_SubDetailIndex, emUpdate)
    Exit Function
ErrHandler:
    If lc_Cursor <> 0 Then Call mo_Db.Close(lc_Cursor)
    Call ErrorHandler("SubItem_CheckUpdateDB")
End Function

Private Function SubItem_UpdateDB(ByVal al_SubDetailIndex As Long, ByVal al_RowIndex As Long) As Boolean
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_frameIndex As Long, ll_DetailFrameIndex As Long
    Dim lb_CustomSaved As Boolean
    
    SubItem_UpdateDB = False
            
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailFrameIndex = mt_DetailConfig(mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex).FrameIndex
    
    lb_CustomSaved = False
    If Not SubItem_CustomDBBefore(al_SubDetailIndex, emUpdate, al_RowIndex, lb_CustomSaved) Then Exit Function
    If Not lb_CustomSaved Then
        'get the request from the ClassInfo
        ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestUpd
        If ls_Request <> "" Then
            ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_DetailKey(ll_DetailFrameIndex))
            If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BaseTypeBendParam" Or _
                mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BaseTypeCutParam" Then
                ls_Request = ReplaceRequestByGridData2(grd_SubDetail(ll_frameIndex), ls_Request, al_RowIndex, mt_SubdetailConfig(al_SubDetailIndex).TableName)
            Else
                ls_Request = ReplaceRequestByGridData(grd_SubDetail(ll_frameIndex), ls_Request, al_RowIndex, mt_SubdetailConfig(al_SubDetailIndex).TableName)
            End If
            ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
            grd_SubDetail(ll_frameIndex).Data(al_RowIndex, "iConcurrency") = Val(grd_SubDetail(ll_frameIndex).Data(al_RowIndex, "iConcurrency")) + 1
            grd_SubDetail(ll_frameIndex).Data(al_RowIndex, STATUS_COLUMN) = ""    ' reset status flag
        End If
        If Not SubItem_CustomDBAfter(al_SubDetailIndex, emUpdate, al_RowIndex, lb_CustomSaved) Then Exit Function
    End If
    
    SubItem_UpdateDB = True
    Exit Function
ErrHandler:
    SubItem_UpdateDB = False
    Call ErrorHandler("SubItem_UpdateDB")
End Function

Private Sub SubItem_DeleteInit(ByVal al_SubDetailIndex As Long)
On Error GoTo ErrHandler

    Dim ll_frameIndex As Long
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex

    If grd_SubDetail(ll_frameIndex).SelectedCount <> 1 Then Exit Sub
    
    If Not SubItem_CheckDeleteDB(al_SubDetailIndex) Then Exit Sub
    
    'clear the frame record and disable frames
    Call mo_Tools.ClearFrame(UserControl.Controls, fra_SubDetailItem(ll_frameIndex))
    
            
    Call InitSubdetailFrame(al_SubDetailIndex)
        
    Call LoadFrameDataFromGrid(grd_SubDetail(ll_frameIndex), fra_SubDetailItem(ll_frameIndex))
    
    Call mo_Tools.EnableFrame(UserControl.Controls, fra_SubDetailItem(ll_frameIndex), False)
    
    'change screen mode
    Call SetModeSubDetail(al_SubDetailIndex, emDelete)
    
    Call SubItem_CustomInit(al_SubDetailIndex, "", emDelete)
    Exit Sub
ErrHandler:
    Call ErrorHandler("SubItem_DeleteInit")
End Sub

Private Function SubItem_Delete(ByVal al_SubDetailIndex As Long) As Boolean

On Error GoTo ErrHandler

    Dim ll_frameIndex As Long
    Dim lb_CustomSaved As Boolean
    
    SubItem_Delete = False
    'TODO: disable subdetail grid when in add,update,delete mode
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    If grd_SubDetail(ll_frameIndex).SelectedCount = 0 Then Exit Function
    
    If Not SubItem_CustomCheck(al_SubDetailIndex, eMode.emDelete) Then Exit Function
    
    If Not SubItem_CustomDelete(al_SubDetailIndex, lb_CustomSaved) Then Exit Function
    
    If Not lb_CustomSaved Then
        'delete data on the db
        'If me_DetailMode = emUpdate Then
        '    If Not SubItem_DeleteDB(al_SubdetailIndex) Then Exit Function
        'End If
        
        'if success then delete the data locally ->
        If Not UpdateGridByFrame(grd_SubDetail(ll_frameIndex), fra_SubDetailItem(ll_frameIndex), emDelete, False, mt_SubdetailConfig(al_SubDetailIndex).TableOrder, True) Then Exit Function
        
    End If
    
    SubItem_Delete = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_Delete")
End Function

Private Function SubItem_CheckDeleteDB(ByVal al_SubDetailIndex As Long) As Boolean
On Error GoTo ErrHandler
    
    Dim ls_Request As String
    Dim lc_Cursor As Long
    Dim ll_Count As Long, ll_frameIndex As Long
    
    SubItem_CheckDeleteDB = False
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestCheckDelete
    If ls_Request <> "" Then
        ls_Request = ReplaceRequestByGridData(grd_SubDetail(ll_frameIndex), ls_Request, grd_SubDetail(ll_frameIndex).Row, mt_SubdetailConfig(al_SubDetailIndex).TableName)
        ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        ' THIS IS NOT AN ERROR
        ' WE CHECK IS USER IS ALLOWED TO DELETE THIS DATA
        ' A DATA CAN'T BE DELETE IF IT HAVE SOME DEPENDANCIES
        ' ll_Count is the count of dependancies
        lc_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
        ll_Count = mo_Db.RowCount(lc_Cursor)
        Call mo_Db.Close(lc_Cursor)
        If ll_Count > 0 Then
            Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, mt_SubdetailConfig(al_SubDetailIndex).CheckDelMsg(0, 0), mt_SubdetailConfig(al_SubDetailIndex).CheckDelMsg(0, 1), , vbInformation + vbOKOnly)
            Exit Function
        End If
    End If
    SubItem_CheckDeleteDB = SubItem_CustomCheckDB(al_SubDetailIndex, emDelete)
    Exit Function
ErrHandler:
    If lc_Cursor <> 0 Then Call mo_Db.Close(lc_Cursor)
    Call ErrorHandler("SubItem_CheckDeleteDB")
End Function

Private Function SubItem_DeleteDB(ByVal al_SubDetailIndex As Long, ByVal al_RowIndex As Long) As Boolean

On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_frameIndex As Long, ll_DetailFrameIndex As Long
    Dim lb_CustomSaved As Boolean
    Dim ll_KeyIdx As Long
       
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailFrameIndex = mt_DetailConfig(mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex).FrameIndex
    
    lb_CustomSaved = False
    If Not SubItem_CustomDBBefore(al_SubDetailIndex, emDelete, al_RowIndex, lb_CustomSaved) Then Exit Function
    If Not lb_CustomSaved Then
        'get the request from the ClassInfo
        ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestDel
        If ls_Request <> "" Then
            'replace the holders (from the frame record)
            ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_DetailKey(ll_DetailFrameIndex))
            ls_Request = ReplaceRequestByGridStoredData(grd_SubDetail(ll_frameIndex), mt_SubdetailConfig(al_SubDetailIndex).DeletedRows, ls_Request, al_RowIndex, mt_SubdetailConfig(al_SubDetailIndex).TableName)
            ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
        End If
        If Not SubItem_CustomDBAfter(al_SubDetailIndex, emDelete, al_RowIndex, lb_CustomSaved) Then Exit Function
    End If
    SubItem_DeleteDB = True
    
    Exit Function
ErrHandler:
    SubItem_DeleteDB = False
    Call ErrorHandler("SubItem_DeleteDB")
End Function

Private Function SubItem_CopySubItem(ByVal al_SubDetailIndex As Long) As Boolean
On Error GoTo ErrHandler
    
    Dim ll_frameIndex As Long
    
    SubItem_CopySubItem = False
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    
    Call LoadFrameDataFromGrid(grd_SubDetail(ll_frameIndex), fra_SubDetailItem(ll_frameIndex))
   
    SubItem_CopySubItem = True
    Exit Function
ErrHandler:
    Call ErrorHandler("SubItem_CopySubItem")
End Function

Private Function GetDetailKeyFieldName(ByVal al_DetailIndex As Long) As String
On Error GoTo ErrHandler

Dim ll_MainIndex As Long
Dim ll_MainFrameIndex As Long
Dim ll_Idx As Long

    GetDetailKeyFieldName = ""
    ll_MainIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    ll_MainFrameIndex = mt_MainConfig(ll_MainIndex).FrameIndex
    For ll_Idx = 0 To grd_Main(ll_MainFrameIndex).Cols - 1
        If grd_Main(ll_MainFrameIndex).Columns(ll_Idx).Key Then
            GetDetailKeyFieldName = grd_Main(ll_MainFrameIndex).Columns(ll_Idx).FieldName
            Exit Function
        End If
    Next
    Exit Function
ErrHandler:
    Call ErrorHandler("GetDetailKeyFieldName")
End Function

Private Function DeleteNode(ByRef ao_TreeView As ArmTreeView, ByRef ao_Node As Node) As Node
On Error GoTo ErrHandler

    Dim lo_Node As Node, lo_parentNode As Node, lo_PreviousNode As Node

    Set lo_Node = ao_Node
    
    While Not lo_Node Is Nothing
        Call lo_Node.Tag.SetData(3, Val(lo_Node.Tag.GetData(3)) - 1)
        Set lo_Node = lo_Node.Parent
    Wend
    
    Set lo_Node = ao_Node
    Do While (lo_Node.Tag.GetData(3) = 0)
        Set lo_parentNode = lo_Node.Parent
        Set lo_PreviousNode = lo_Node.Previous
        Call ao_TreeView.RemoveNode(lo_Node)
        Set lo_Node = lo_parentNode
        If lo_Node Is Nothing Then Exit Do
    Loop
    Set ao_Node = Nothing

    Set DeleteNode = IIf(lo_parentNode Is Nothing, lo_PreviousNode, lo_parentNode)
    Exit Function
    
ErrHandler:
    If (Not lo_Node Is Nothing) Then Set lo_Node = Nothing
    If (Not lo_parentNode Is Nothing) Then Set lo_parentNode = Nothing
    If (Not lo_PreviousNode Is Nothing) Then Set lo_PreviousNode = Nothing
    Call ErrorHandler("DeleteNode")

End Function

'to check if updated or added item conform filter
'(there is no filter at this time but it is prepared)
Private Function IsItemInFilter(ByVal al_DetailIndex As Long) As Boolean
On Error GoTo ErrHandler

Dim lb_CheckDone As Boolean

    IsItemInFilter = IsItemInFilterCustom(al_DetailIndex, lb_CheckDone)
    If lb_CheckDone Then Exit Function
    
    IsItemInFilter = True
    Exit Function
ErrHandler:
    Call ErrorHandler("IsItemInFilter")
End Function

Private Sub Item_ExitToGrid(ByVal al_MainIndex As Long, ByVal al_DetailIndex As Long)
On Error GoTo ErrHandler
    
    If mc_Item > 0 Then
        Call mo_Db.Close(mc_Item)
        mc_Item = 0
    End If
    Call UpdateMainToolbarCustom(al_MainIndex)
    Exit Sub

ErrHandler:
    Call ErrorHandler("Item_ExitToGrid")
   
End Sub

Private Sub GotoPreviousItem(ByVal al_DetailIndex As Long, ByRef ao_grid As ArmGrid)
On Error GoTo ErrHandler
    
    If ao_grid.PreviousItem Then
        Call UpdateDetailToolbarCustom(al_DetailIndex)
    Else
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 927, "#No more previous item", , vbInformation)
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("GotoPreviousItem")
End Sub

Private Sub GotoNextItem(ByVal al_DetailIndex As Long, ByRef ao_grid As ArmGrid)
On Error GoTo ErrHandler

    If ao_grid.NextItem Then
        Call UpdateDetailToolbarCustom(al_DetailIndex)
    Else
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 928, "#No more next item", , vbInformation)
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("GotoNextItem")
End Sub

Private Sub Controls_LoadDefaultValue(ByRef av_ListFieldsDefaultValue As Variant)
On Error GoTo ErrHandler

    Dim ll_Idx As Long, ll_Count As Long
    Dim lv_Params As Variant
    Dim lo_Control As Object
    Dim ls_Value As String

    ll_Count = UBound(av_ListFieldsDefaultValue)

    For ll_Idx = 0 To ll_Count
            Set lo_Control = av_ListFieldsDefaultValue(ll_Idx)(0)
            Select Case UCase(TypeName(lo_Control))
                Case "FRAME", "LABEL", "MSFLEXGRID", "TOOLBARCONTROL"
                    ' Do nothing !
                Case "TEXTBOX"
                    lo_Control.Text = av_ListFieldsDefaultValue(ll_Idx)(1)
                Case "A_CALOCX"
                    ls_Value = av_ListFieldsDefaultValue(ll_Idx)(1)
                    If StrComp(ls_Value, "Date") = 0 Then
                        lo_Control.date_courte = Format(Date, "dd\/mm\/yyyy")
                    ElseIf StrComp(Left(ls_Value, 5), "Date+") = 0 Then
                        lo_Control.date_courte = Format(Date + CLng(Mid(ls_Value, 6)), "dd\/mm\/yyyy")
                    ElseIf StrComp(Left(ls_Value, 5), "Date-") = 0 Then
                        lo_Control.date_courte = Format(Date - CLng(Mid(ls_Value, 6)), "dd\/mm\/yyyy")
                    Else
                        lo_Control.date_courte = ls_Value
                    End If
                Case "ARMGRID", "ARMCHECKVIEW", "COMMANDBUTTON", "ARMTREEVIEW", "LISTBOX", "PICTUREBOX", "TABSTRIP"
                
                Case "OPTIONBUTTON", "CHECKBOX"
                    lo_Control.Value = av_ListFieldsDefaultValue(ll_Idx)(1)
                Case "ARMCOMBOBOX"
                    lv_Params = Split(av_ListFieldsDefaultValue(ll_Idx)(1), SEP)
                    If Not lo_Control.SearchItem(lv_Params(0)) Then
                        If UBound(lv_Params) >= 1 Then
                            Call lo_Control.AddItem(Array(lv_Params(0), lv_Params(1)))
                        Else
                            Call lo_Control.Load ' load only once and remember found default value. Do not use any hardcoded default value
                            If lo_Control.SearchItem(lv_Params(0)) Then
                                av_ListFieldsDefaultValue(ll_Idx)(1) = lv_Params(0) & SEP & lo_Control.Text
                            End If
                        End If
                    End If
                Case "ARMPICKER"
                    lv_Params = Split(av_ListFieldsDefaultValue(ll_Idx)(1), SEP)
                    lo_Control.ItemCode = lv_Params(0)
                    If UBound(lv_Params) >= 1 Then
                        lo_Control.ItemDescription = lv_Params(1)
                    End If
                                    
                Case Else
                    Debug.Print "Controls_LoadDefaultValue " & UCase(TypeName(lo_Control))
            End Select
    Next
    Set lo_Control = Nothing
    Exit Sub
ErrHandler:
    Call ErrorHandler("Controls_LoadDefaultValue")
End Sub

Private Sub Item_LoadDefaultValue(ByVal al_DetailIndex As Long, ByRef av_ListFieldsDefaultValue As Variant)
On Error GoTo ErrHandler

    Call Controls_LoadDefaultValue(av_ListFieldsDefaultValue)
    Call Item_CustomLoadDefaultValue(al_DetailIndex, av_ListFieldsDefaultValue)
    Exit Sub
ErrHandler:
    Call ErrorHandler("Item_LoadDefaultValue")
End Sub

Private Sub SubItem_LoadDefaultValue(ByVal al_SubDetailIndex As Long, ByRef av_ListFieldsDefaultValue As Variant)
On Error GoTo ErrHandler

    Call Controls_LoadDefaultValue(av_ListFieldsDefaultValue)
    Call SubItem_CustomLoadDefaultValue(al_SubDetailIndex, av_ListFieldsDefaultValue)
    Exit Sub
ErrHandler:
    Call ErrorHandler("SubItem_LoadDefaultValue")
End Sub

Private Function GetTreeViewInfo(ByRef aTVInfos() As TTreeViewInfo, ByVal AScreenName As String, ByVal aTVCode As String) As TTreeViewInfo
On Error GoTo ErrHandler
    Dim lIdx As Long, lCount As Long
    Dim lTreeView As TTreeViewInfo, lFound As Boolean
    
    ' Search in the array
    lCount = UBound(aTVInfos)
    lFound = False
    For lIdx = 0 To lCount
        If aTVInfos(lIdx).TreeViewCode = aTVCode Then
            If Not aTVInfos(lIdx).Loaded Then
                aTVInfos(lIdx) = GetTreeViewInfoFromDB(AScreenName, aTVCode)
            End If
            lTreeView = aTVInfos(lIdx)
            lFound = True
            Exit For
        End If
    Next
    
    If Not lFound Then
        Call Err.Raise(ArmErr.InvalidArgument, "TreeviewInfo", "TreeViewInfo not found. AScreenName=" & AScreenName & " aTVCode=" & aTVCode)
    End If
    
    GetTreeViewInfo = lTreeView
    Exit Function
ErrHandler:
    Call ErrorHandler("GetTreeViewInfo")

End Function

Private Function ApplyTVFilters(ByVal al_MainIndex As Long, ByVal av_Request As Variant) As Variant
On Error GoTo ErrHandler
    Dim lv_Requests As Variant
    
    If IsArray(av_Request) Then
        ReDim lv_Requests(UBound(av_Request))
        Dim ll_Idx As Long, ll_Count As Long
        ll_Count = UBound(lv_Requests)
        For ll_Idx = 0 To ll_Count
            lv_Requests(ll_Idx) = ReplaceFiltersHolders(al_MainIndex, av_Request(ll_Idx))
            lv_Requests(ll_Idx) = ReplaceTreeviewHolders(al_MainIndex, lv_Requests(ll_Idx))
            lv_Requests(ll_Idx) = ReplaceLanguagePlaceholderFromToolbar(lv_Requests(ll_Idx))
            lv_Requests(ll_Idx) = ReplaceCommonPlaceholders(lv_Requests(ll_Idx))
        Next
    Else
        ReDim lv_Requests(0)
        lv_Requests(0) = ReplaceFiltersHolders(al_MainIndex, av_Request)
        lv_Requests(0) = ReplaceTreeviewHolders(al_MainIndex, lv_Requests(0))
        lv_Requests(0) = ReplaceLanguagePlaceholderFromToolbar(lv_Requests(0))
        lv_Requests(0) = ReplaceCommonPlaceholders(lv_Requests(0))
    End If

    ApplyTVFilters = lv_Requests
    Exit Function
ErrHandler:
    Call ErrorHandler("ApplyTVFilters")
End Function

Private Function ApplyFilters(ByVal al_MainIndex As Long, ByVal as_Request As String) As Variant
On Error GoTo ErrHandler
    Dim lv_Requests As Variant
    
    ReDim lv_Requests(0)
    lv_Requests(0) = ReplaceFiltersHolders(al_MainIndex, as_Request)
    lv_Requests(0) = ReplaceLanguagePlaceholderFromToolbar(lv_Requests(0))
    lv_Requests(0) = ReplaceCommonPlaceholders(lv_Requests(0))
    ApplyFilters = lv_Requests
    Exit Function
ErrHandler:
    Call ErrorHandler("ApplyFilters")
End Function

Private Function ReplaceFiltersHolders(ByVal al_MainIndex As Long, ByVal as_Request As String) As String
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_frameIndex As Long

    ll_frameIndex = mt_MainConfig(al_MainIndex).FrameIndex
    ls_Request = mo_Tools.ReplaceRequestByFrameData(as_Request, UserControl.Controls, fra_MainFilter(ll_frameIndex))
    ReplaceFiltersHolders = ls_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceFiltersHolders")
End Function

Private Function ReplaceTreeviewHolders(ByVal al_MainIndex As Long, ByVal as_Request As String) As String
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_frameIndex As Long

    ll_frameIndex = mt_MainConfig(al_MainIndex).FrameIndex
    ls_Request = mo_Tools.ReplacePlaceholderByControlValue(as_Request, tbs_MainTabFilter(ll_frameIndex))
    ReplaceTreeviewHolders = ls_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceTreeviewHolders")
End Function

Private Sub ReloadMainGrid()
On Error GoTo ErrHandler

Dim ll_frameIndex As Long, ll_MainConfigIndex As Long

    ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_frameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
    
    
    If mt_MainConfig(ll_MainConfigIndex).CurrentTvwSelMethod = eTvwSelMethod.etmNone Then
        grd_Main(ll_frameIndex).Requests = ApplyFilters(ll_MainConfigIndex, mt_MainConfig(ll_MainConfigIndex).RequestGrid)
    Else
        If tvw_Main(ll_frameIndex).Checkboxes = True Then
            grd_Main(ll_frameIndex).Requests = ApplyTVFilters(ll_MainConfigIndex, tvw_Main(ll_frameIndex).CheckedNodesRequests)
        Else
            grd_Main(ll_frameIndex).Requests = ApplyTVFilters(ll_MainConfigIndex, tvw_Main(ll_frameIndex).SelectedNodeRequest)
        End If
        
        mt_MainConfig(ll_frameIndex).CurrentTvwSelMethod = IIf(tvw_Main(ll_frameIndex).Checkboxes, eTvwSelMethod.etmCheckBoxes, eTvwSelMethod.etmBranch)
    End If
    
    If grd_Main(ll_frameIndex).Cols = 0 Then
        Dim ll_DetailIndex As Long
        ll_DetailIndex = FindDetailConfigByMainConfig(ll_MainConfigIndex)
        If Not grd_Main(ll_frameIndex).SetColumns(mt_DetailConfig(ll_DetailIndex).MainGridColumns) Then
            Err.Raise ArmErr.CompFncFailed, "grd_Main", "Method SetColumns failed."
        End If
        Call mo_Tools.LoadLabelsCursor(mo_Db, mc_ScreenLabels, UserControl.Controls, fra_MainItem(ll_frameIndex), SCREEN_NAME, ms_Language_Code)
    End If
    
    If grd_Main(ll_frameIndex).Execute = False Then
        Err.Raise ArmErr.CompFncFailed, "grd_Main(" & ll_frameIndex & ").Execute", "Load grid failed"
    End If
    grd_Main(ll_frameIndex).Visible = True
    Call UpdateMainToolbarCustom(ll_MainConfigIndex)
    Exit Sub
ErrHandler:
    Call ErrorHandler("ReloadMainGrid")
    
End Sub

Private Sub ReloadMainTreeview()
On Error GoTo ErrHandler
    
    mb_InternalInit = True
    Dim lb_Grid As Boolean
    Dim ll_frameIndex As Long, ll_MainConfigIndex As Long

    ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_frameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
   
    If mt_MainConfig(ll_MainConfigIndex).CurrentTvwSelMethod <> eTvwSelMethod.etmNone Then
        tvw_Main(ll_frameIndex).Refresh
    End If
    Call ReloadMainGrid
    
    mb_InternalInit = False
    
    Exit Sub
ErrHandler:
    mb_InternalInit = False
    Call ErrorHandler("ReloadMainTreeview")
End Sub

Public Sub AddDroppedCheckItems(ByRef ao_chkview As ArmCheckView)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim ll_Count As Long
Dim lo_ItemInfo As ArmItemInfo

    ll_Count = ao_chkview.RoleList("VIEW").Count
    For ll_Index = 1 To ll_Count
        If ao_chkview.RoleList("EDIT").GetItem(ao_chkview.RoleList("VIEW").GetKey(ll_Index)) Is Nothing Then
            Set lo_ItemInfo = ao_chkview.RoleList("VIEW").Items(ll_Index)
            Call ao_chkview.RoleList("EDIT").AddItemInfo(Array(lo_ItemInfo.GetData(0), lo_ItemInfo.GetData(1), 1), True, True)
        End If
    Next
    Call ao_chkview.RoleList("EDIT").DisplayList
    Exit Sub
ErrHandler:
    Call ErrorHandler("AddDroppedCheckItems")
End Sub

Public Sub RemoveDroppedCheckItems(ByRef ao_chkview As ArmCheckView)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim ll_Count As Long
Dim lo_ItemInfo As ArmItemInfo

    ll_Count = ao_chkview.RoleList("EDIT").Count
    For ll_Index = ll_Count To 1 Step -1
        Set lo_ItemInfo = ao_chkview.RoleList("EDIT").Items(ll_Index)
        If UBound(lo_ItemInfo.Data) > 1 Then
            Call ao_chkview.RoleList("EDIT").Items.Remove(ll_Index)
        End If
        Set lo_ItemInfo = Nothing
    Next
    Call ao_chkview.RoleList("EDIT").DisplayList
    Exit Sub
ErrHandler:
    Call ErrorHandler("RemoveDroppedCheckItems")
End Sub

Private Sub LoadListView(ByVal ao_Listview As MSComctlLib.ListView, ByVal as_Request As String)
On Error GoTo ErrHandler

Dim ll_Cursor As Long
Dim lo_item As MSComctlLib.ListItem
Dim lo_SubItem As MSComctlLib.ListSubItem
Dim ll_Index As Long

    Call ao_Listview.ListItems.Clear
    ll_Cursor = mo_Db.OpenSQL(as_Request)
    If ll_Cursor > 0 Then
        While Not mo_Db.EOF(ll_Cursor)
            Set lo_item = ao_Listview.ListItems.Add(, "KEY" & mo_Db.GetFields(ll_Cursor, 0), mo_Db.GetFields(ll_Cursor, 1))
            If mo_Db.FieldCount(ll_Cursor) > 2 Then
                For ll_Index = 2 To mo_Db.FieldCount(ll_Cursor) - 1
                    Set lo_SubItem = lo_item.ListSubItems.Add(, , mo_Db.GetFields(ll_Cursor, ll_Index))
                Next
            End If
            Call mo_Db.Next(ll_Cursor)
        Wend
        Call mo_Db.Close(ll_Cursor)
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("LoadListView")
End Sub

Private Sub CheckListView(ByVal ao_Listview As MSComctlLib.ListView, ByVal as_Request As String)
On Error GoTo ErrHandler

Dim ll_Cursor As Long
Dim lo_item As MSComctlLib.ListItem
Dim lo_NewItem As MSComctlLib.ListItem
Dim ls_ItemKey As String, ls_ItemText As String

    For Each lo_item In ao_Listview.ListItems
        lo_item.Checked = False
        lo_item.Tag = ""
    Next lo_item
    ll_Cursor = mo_Db.OpenSQL(as_Request)
    If ll_Cursor > 0 Then
        While Not mo_Db.EOF(ll_Cursor)
            For Each lo_item In ao_Listview.ListItems
                If StrComp(lo_item.Key, "KEY" & mo_Db.GetFields(ll_Cursor, 0), vbTextCompare) = 0 Then
                    ls_ItemText = lo_item.Text
                    ls_ItemKey = lo_item.Key
                    Call ao_Listview.ListItems.Remove(lo_item.Index)
                    Set lo_NewItem = ao_Listview.ListItems.Add(1, ls_ItemKey, ls_ItemText)
                    lo_NewItem.Checked = True
                    lo_NewItem.Tag = "X"
                    Exit For
                End If
            Next lo_item
            Call mo_Db.Next(ll_Cursor)
        Wend
        Call mo_Db.Close(ll_Cursor)
    End If
    Call ao_Listview.Refresh
    Exit Sub
ErrHandler:
    Call ErrorHandler("CheckListView")
End Sub

Private Sub SaveListView(ByVal al_DetailIndex As Long, ByVal ao_Listview As MSComctlLib.ListView, ByVal as_CheckRequest As String, ByVal as_UnCheckRequest As String, ByVal as_KeyHolder As String)
On Error GoTo ErrHandler

Dim lo_item As MSComctlLib.ListItem
Dim ls_Req As String


    as_CheckRequest = mo_Tools.ReplaceRequestByFrameData(as_CheckRequest, UserControl.Controls, fra_DetailItem(mt_DetailConfig(al_DetailIndex).FrameIndex))
    as_CheckRequest = ReplaceLanguagePlaceholderFromToolbar(as_CheckRequest)
    as_CheckRequest = ReplaceCommonPlaceholders(as_CheckRequest)
    
    as_UnCheckRequest = mo_Tools.ReplaceRequestByFrameData(as_UnCheckRequest, UserControl.Controls, fra_DetailItem(mt_DetailConfig(al_DetailIndex).FrameIndex))
    as_UnCheckRequest = ReplaceLanguagePlaceholderFromToolbar(as_UnCheckRequest)
    as_UnCheckRequest = ReplaceCommonPlaceholders(as_UnCheckRequest)
    
    For Each lo_item In ao_Listview.ListItems
        If IIf(lo_item.Checked, "X", "") <> lo_item.Tag Then
            If lo_item.Checked Then
                ls_Req = as_CheckRequest
            Else
                ls_Req = as_UnCheckRequest
            End If
            ls_Req = ReplacePlaceHolder(ls_Req, as_KeyHolder, mo_Tools.SqlInt(Mid(lo_item.Key, 4)))
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
        End If
    Next
    Exit Sub
ErrHandler:
    Call ErrorHandler("SaveListView")
End Sub

Private Function GetCheckedCount(ByRef ao_Listview As MSComctlLib.ListView) As Long
On Error GoTo ErrHandler

Dim lo_item As MSComctlLib.ListItem
Dim ll_Count As Long

    ll_Count = 0
    For Each lo_item In ao_Listview.ListItems
        If lo_item.Checked Then ll_Count = ll_Count + 1
    Next
    GetCheckedCount = ll_Count
    Exit Function
ErrHandler:
    Call ErrorHandler("GetCheckedCount")
End Function

Private Function CustomReplacePlaceholder(ByRef as_Request As String, ByVal as_PlaceHolder As String, ByVal as_DefaultValue As String) As Boolean
On Error GoTo ErrHandler

    CustomReplacePlaceholder = False
    Exit Function
ErrHandler:
    Call ErrorHandler("CustomReplacePlaceholder")
End Function

Private Function ReplacePlaceHolder(ByVal as_Request As String, ByVal as_PlaceHolder As String, ByVal as_DefaultValue As String) As String
On Error GoTo ErrHandler
    
    If Not CustomReplacePlaceholder(as_Request, as_PlaceHolder, as_DefaultValue) Then
        as_Request = Replace(as_Request, as_PlaceHolder, as_DefaultValue, , , vbTextCompare)
    End If
    ReplacePlaceHolder = as_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplacePlaceholder")
End Function

Private Function ReplaceKeyPlaceholders(ByVal as_Request As String, ByVal av_Key As Variant) As String
On Error GoTo ErrHandler

Dim ll_Index As Long

    If Not IsArray(av_Key) Then av_Key = Array(av_Key)
    
    For ll_Index = 0 To UBound(av_Key)
        as_Request = ReplacePlaceHolder(as_Request, "$Key" & (ll_Index + 1) & "$", mo_Tools.SQLStr(av_Key(ll_Index)))
    Next
    ReplaceKeyPlaceholders = as_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceKeyPlaceholders")
End Function

Private Function ReplaceLanguagePlaceholderFromToolbar(ByVal as_Request As String) As String
On Error GoTo ErrHandler
Dim ll_frameIndex As Long, ll_MainIndex As Long

    ll_MainIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_frameIndex = mt_MainConfig(ll_MainIndex).FrameIndex
    ReplaceLanguagePlaceholderFromToolbar = ReplacePlaceHolder(as_Request, "$toolbar_language_code$", mo_Tools.SQLStr(tlb_Main(ll_frameIndex).Language))
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceLanguagePlaceholderFromToolbar")
End Function

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

    as_Request = ReplacePlaceHolder(as_Request, "$language_code$", mo_Tools.SQLStr(ms_Language_Code))
    as_Request = ReplacePlaceHolder(as_Request, "$Z_Creator$", mo_Tools.SqlInt(ml_U_Code))
    as_Request = ReplacePlaceHolder(as_Request, "$U_Code$", mo_Tools.SqlInt(ml_U_Code))
    as_Request = ReplacePlaceHolder(as_Request, "$Z_Last_Upd_User$", mo_Tools.SqlInt(ml_U_Code))
    as_Request = ReplacePlaceHolder(as_Request, "$LoginName$", mo_Tools.SQLStr(ms_LoginName))
    as_Request = ReplacePlaceHolder(as_Request, "$UserName$", mo_Tools.SQLStr(ms_UserName))
    as_Request = ReplacePlaceHolder(as_Request, "$ComputerName$", mo_Tools.SQLStr(ms_ComputerName))
    as_Request = ReplacePlaceHolder(as_Request, "$NetworkBoardID$", mo_Tools.SQLStr(ms_NetworkBoardID))
    ReplaceCommonPlaceholders = as_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceCommonPlaceholders")
End Function

Private Function UpdateGridByFrame(ByVal ao_grid As Object, ByVal ao_Frame As Frame, ae_Mode As eMode, ByVal ab_UpdateStatus As Boolean, ByVal as_OrderField As String, ByVal ab_AddToEnd As Boolean) As Boolean
On Error GoTo ErrHandler

Dim lo_Control As Control
Dim lsa_Columns() As String
Dim lsa_Value() As String
    
    UpdateGridByFrame = False
    
    If ae_Mode = emAdd Then
        If (ao_grid.Rows = 0) Or ab_AddToEnd Then
            If Not ao_grid.AddLine("") Then
                Err.Raise ArmErr.CompFncFailed, ao_grid.Name, "Method AddLine failed"
            End If
            ao_grid.Row = ao_grid.Rows - 1
        Else
            If Not ao_grid.InsertLine(0) Then
                Err.Raise ArmErr.CompFncFailed, ao_grid.Name, "Method InsertLine failed"
            End If
            ao_grid.Row = 0
        End If
        If as_OrderField <> "" Then
            For Each lo_Control In UserControl.Controls
                If mo_Tools.HasContainer(lo_Control, ao_Frame) And (lo_Control.Tag <> "") Then
                    lsa_Value = Split(lo_Control.Tag, SEP)
                    If (StrComp(TypeName(lo_Control), "TEXTBOX", vbTextCompare) = 0) And _
                       (StrComp(lsa_Value(0), as_OrderField, vbTextCompare) = 0) Then
                        If ao_grid.Row > 0 Then
                            lo_Control.Text = ao_grid.Data(ao_grid.Rows - 2, as_OrderField) + 1
                        Else
                            lo_Control.Text = 1
                        End If
                        Exit For
                    End If
                End If
            Next
        End If
        ao_grid.CurrentLine("iConcurrency") = 1
    End If
    
    ' one row must be selected !
    If ao_grid.SelectedCount <> 1 Then
        Exit Function
    End If
    
    'update iConcurrency automatically
    'If ae_Mode = emUpdate Then
    '    ao_Grid.SelectedLine(0, "iConcurrency") = Val(ao_Grid.SelectedLine(0, "iConcurrency")) + 1
    'End If
    
    If ab_UpdateStatus Then
        If ae_Mode = emAdd Then
            ao_grid.SelectedLine(0, STATUS_COLUMN) = "A"
        ElseIf ae_Mode = emUpdate Then
            If ao_grid.SelectedLine(0, STATUS_COLUMN) <> "A" Then
                ao_grid.SelectedLine(0, STATUS_COLUMN) = "U"
            End If
        ElseIf ae_Mode = emDelete Then
            Call ao_grid.DeleteSelectedLines
        Else
            Exit Function
        End If
    Else
        If ae_Mode = emDelete Then
            Call ao_grid.DeleteSelectedLines
            UpdateGridByFrame = True
            Exit Function
        End If
    End If
    
    For Each lo_Control In UserControl.Controls
    
        If mo_Tools.HasContainer(lo_Control, ao_Frame) And (lo_Control.Tag <> "") Then
            lsa_Value = Split(lo_Control.Tag, SEP)
            Select Case UCase(TypeName(lo_Control))
                Case "ARMCOMBOBOX"
                    If UBound(lsa_Value) >= 0 Then ao_grid.SelectedLine(0, lsa_Value(0)) = mo_Tools.GetComboKey(lo_Control)
                    If UBound(lsa_Value) >= 1 Then ao_grid.SelectedLine(0, lsa_Value(1)) = lo_Control.Text
                Case "ARMPICKER"
                    If UBound(lsa_Value) >= 0 Then ao_grid.SelectedLine(0, lsa_Value(0)) = lo_Control.ItemCode
                    If UBound(lsa_Value) >= 1 Then ao_grid.SelectedLine(0, lsa_Value(1)) = lo_Control.ItemDescription
                Case "CHECKBOX"
                    Dim lo_Column As ArmColumn
                    Set lo_Column = ao_grid.Columns(lsa_Value(0))
                    If Not (lo_Column Is Nothing) Then
                        If lo_Column.FieldType = DBTYPE_BMP Then
                            If lo_Control.Value = vbChecked Then
                                ao_grid.SelectedLine(0, lsa_Value(0)) = "CHECK"
                            Else
                                ao_grid.SelectedLine(0, lsa_Value(0)) = "UNCHECK"
                            End If
                        Else
                            If lo_Control.Value = vbChecked Then
                                ao_grid.SelectedLine(0, lsa_Value(0)) = "X"
                            Else
                                ao_grid.SelectedLine(0, lsa_Value(0)) = ""
                            End If
                        End If
                    End If
                Case "TEXTBOX"
                    lsa_Columns = Split(lo_Control.Tag, SEP)
                    If UBound(lsa_Columns) > 0 Then
                      Select Case UCase(lsa_Columns(1))
                      Case "N", "F"
                        If IsNumeric(lo_Control.Text) Then
                            ao_grid.SelectedLine(0, lsa_Value(0)) = CDbl(lo_Control.Text)
                        End If
                      Case Else
                        ao_grid.SelectedLine(0, lsa_Value(0)) = lo_Control.Text
                      End Select
                    Else
                        ao_grid.SelectedLine(0, lsa_Value(0)) = lo_Control.Text
                    End If
                Case "A_CALOCX"
                    ao_grid.SelectedLine(0, lsa_Value(0)) = lo_Control.date_sql
            End Select
        End If
    Next
    UpdateGridByFrame = True
    Exit Function
ErrHandler:
    Call ErrorHandler("UpdateGridByFrame")
End Function

Private Function ReplaceRequestByGridData(ByVal ao_grid As ArmGrid, ByVal as_Request As String, ByVal al_Row As Long, ByVal as_Table As String) As String
On Error GoTo ErrHandler

Dim ll_ColIndex As Long
Dim ls_Data As String
    
    For ll_ColIndex = 0 To ao_grid.Cols - 1
'        If ao_Grid.Columns(ll_ColIndex).Key And (as_Table <> "") And (ao_Grid.Data(al_Row, STATUS_COLUMN) = "A") Then
'            ls_Data = mo_Tools.SqlInt(ao_Grid.Data(al_Row, ll_ColIndex))
'            If (ls_Data = "0") Or (ls_Data = "NULL") And (as_Table <> "") Then
'                ls_Data = mo_Db.SQLNextID(as_Table)
'                If ls_Data = "" Then
'                    Err.Raise ArmErr.CompFncFailed, "mo_Db.SQLNextID", "SQLNextID failed for: " & as_Table
'                End If
'            End If
'        Else
        Select Case ao_grid.Columns(ll_ColIndex).FieldType
        Case DBTYPE_I4
            ls_Data = mo_Tools.SqlInt(ao_grid.Data(al_Row, ll_ColIndex))
        Case DBTYPE_R4, DBTYPE_R8
            ls_Data = mo_Tools.SqlDbl(ao_grid.Data(al_Row, ll_ColIndex))
        Case DBTYPE_DATE
            ls_Data = mo_Tools.SqlDate(ao_grid.Data(al_Row, ll_ColIndex))
        Case DBTYPE_BMP
            Select Case UCase(ao_grid.Data(al_Row, ll_ColIndex))
            Case "CHECK"
                ls_Data = mo_Tools.SQLStr("X")
            Case "UNCHECK"
                ls_Data = mo_Tools.SQLStr("")
            End Select
        Case Else
            ls_Data = mo_Tools.SQLStr(ao_grid.Data(al_Row, ll_ColIndex))
        End Select
        as_Request = ReplacePlaceHolder(as_Request, "$" & ao_grid.Columns(ll_ColIndex).Name & "$", ls_Data)
    Next
    ReplaceRequestByGridData = as_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceRequestByGridData")
End Function

Private Function ReplaceRequestByGridData2(ByVal ao_grid As ArmGrid, ByVal as_Request As String, ByVal al_Row As Long, ByVal as_Table As String) As String
On Error GoTo ErrHandler

Dim ll_ColIndex As Long
Dim ls_Data As String
    
    For ll_ColIndex = 0 To ao_grid.Cols - 1
        Select Case ao_grid.Columns(ll_ColIndex).FieldType
        Case DBTYPE_I4
            ls_Data = mo_Tools.SqlInt(ao_grid.Data(al_Row, ll_ColIndex))
            If InStr(1, ao_grid.Columns(ll_ColIndex).Name, "DFO_Id", vbTextCompare) > 0 And ls_Data = "0" Then
                ls_Data = "Null"
            End If
        Case DBTYPE_R4, DBTYPE_R8
            ls_Data = mo_Tools.SqlDbl(ao_grid.Data(al_Row, ll_ColIndex))
        Case DBTYPE_DATE
            ls_Data = mo_Tools.SqlDate(ao_grid.Data(al_Row, ll_ColIndex))
        Case DBTYPE_BMP
            Select Case UCase(ao_grid.Data(al_Row, ll_ColIndex))
            Case "CHECK"
                ls_Data = mo_Tools.SQLStr("X")
            Case "UNCHECK"
                ls_Data = mo_Tools.SQLStr("")
            End Select
        Case Else
            ls_Data = mo_Tools.SQLStr(ao_grid.Data(al_Row, ll_ColIndex))
            If InStr(1, ao_grid.Columns(ll_ColIndex).Name, "DFO_Id", vbTextCompare) > 0 And ls_Data = "''" Then
                ls_Data = "Null"
            End If
        End Select
        as_Request = ReplacePlaceHolder(as_Request, "$" & ao_grid.Columns(ll_ColIndex).Name & "$", ls_Data)
    Next
    ReplaceRequestByGridData2 = as_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceRequestByGridData2")
End Function

Private Function ReplaceRequestByGridStoredData(ByVal ao_grid As ArmGrid, ByVal ao_data As Variant, ByVal as_Request As String, ByVal al_Row As Long, ByVal as_Table As String) As String
On Error GoTo ErrHandler

Dim ll_ColIndex As Long
Dim ls_Data As String
    
    For ll_ColIndex = 0 To ao_grid.Cols - 1
        Select Case ao_grid.Columns(ll_ColIndex).FieldType
        Case DBTYPE_I4
            ls_Data = mo_Tools.SqlInt(ao_data(al_Row)(ll_ColIndex))
        Case DBTYPE_R4, DBTYPE_R8
            ls_Data = mo_Tools.SqlDbl(ao_data(al_Row)(ll_ColIndex))
        Case DBTYPE_DATE
            ls_Data = mo_Tools.SqlDate(ao_data(al_Row)(ll_ColIndex))
        Case DBTYPE_BMP
            Select Case UCase(ao_data(al_Row)(ll_ColIndex))
            Case "CHECK"
                ls_Data = mo_Tools.SQLStr("X")
            Case "UNCHECK"
                ls_Data = mo_Tools.SQLStr("")
            End Select
        Case Else
            ls_Data = mo_Tools.SQLStr(ao_data(al_Row)(ll_ColIndex))
        End Select
        as_Request = ReplacePlaceHolder(as_Request, "$" & ao_grid.Columns(ll_ColIndex).Name & "$", ls_Data)
    Next
    ReplaceRequestByGridStoredData = as_Request
    Exit Function
ErrHandler:
    Call ErrorHandler("ReplaceRequestByGridStoredData")
End Function

Private Sub LoadFrameDataFromCursor(ByVal ao_Db As ArmDb, ByVal al_Cursor As Long, ByVal ao_Frame As Frame)
On Error GoTo ErrHandler

Dim lo_Control As Control
Dim lsa_Columns() As String
Dim lv_ComboData As Variant
Dim ll_Index As Long


   mb_InternalInit = True
    For Each lo_Control In UserControl.Controls
    
        If mo_Tools.HasContainer(lo_Control, ao_Frame) Then
            Select Case UCase(TypeName(lo_Control))
                Case "ARMCOMBOBOX"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If (StrComp(mo_Db.GetFields(al_Cursor, lsa_Columns(0)), "", vbTextCompare) <> 0) And _
                            (StrComp(mo_Db.GetFields(al_Cursor, lsa_Columns(0)), "0", vbTextCompare) <> 0) Then
                            If UBound(lsa_Columns) >= 1 Then
                                If Not lo_Control.SearchItem(mo_Db.GetFields(al_Cursor, lsa_Columns(0))) Then
                                    ReDim lv_ComboData(UBound(lsa_Columns))
                                    For ll_Index = 0 To UBound(lsa_Columns)
                                        lv_ComboData(ll_Index) = mo_Db.GetFields(al_Cursor, lsa_Columns(ll_Index))
                                    Next
                                    If lo_Control.AddItem(lv_ComboData, True) Is Nothing Then
                                        Err.Raise ArmErr.CompFncFailed, lo_Control.Name, "Function AddItem failed"
                                    End If
                                End If
                            Else
                                Call lo_Control.SearchItem(mo_Db.GetFields(al_Cursor, lsa_Columns(0)))
                            End If
                        End If
                    End If
                Case "ARMPICKER"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If (StrComp(mo_Db.GetFields(al_Cursor, lsa_Columns(0)), "", vbTextCompare) <> 0) And _
                            (StrComp(mo_Db.GetFields(al_Cursor, lsa_Columns(0)), "0", vbTextCompare) <> 0) Then
                            If UBound(lsa_Columns) >= 1 Then
                                lo_Control.ItemCode = mo_Db.GetFields(al_Cursor, lsa_Columns(0))
                                lo_Control.ItemDescription = mo_Db.GetFields(al_Cursor, lsa_Columns(1))
                            End If
                        End If
                    End If
                Case "CHECKBOX"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If UCase(mo_Db.GetFields(al_Cursor, lsa_Columns(0))) = "X" Then
                            lo_Control.Value = vbChecked
                        Else
                            lo_Control.Value = vbUnchecked
                        End If
                    End If
                Case "TEXTBOX"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        lo_Control.Text = mo_Db.GetFields(al_Cursor, lsa_Columns(0))
                    End If
                Case "A_CALOCX"
                    If Trim(lo_Control.Tag) <> "" Then
                        If CDbl(mo_Db.GetFields(al_Cursor, lo_Control.Tag)) = 0 Then
                            Call lo_Control.reinit_cal
                        Else
                            lo_Control.date_courte = Format(mo_Db.GetFields(al_Cursor, lo_Control.Tag), "dd\/mm\/yyyy")
                        End If
                    End If
            End Select
        End If
    Next
    mb_InternalInit = False
    Exit Sub
ErrHandler:
    mb_InternalInit = False
    Call ErrorHandler("LoadFrameDataFromCursor")
End Sub

Private Sub SaveSubDetailGrid(ByVal al_SubDetailIndex As Long)
On Error GoTo ErrHandler

Dim ll_Index As Long, ll_KeyIdx As Long
Dim ls_Request As String
Dim ll_SubDetailFrameIndex As Long, ll_DetailFrameIndex As Long, ll_KeyCount As Long
Dim le_Mode As eMode
Dim lv_Key As Variant, lv_Data As Variant

    ll_SubDetailFrameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailFrameIndex = mt_DetailConfig(mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex).FrameIndex
    
    If Not grd_SubDetail(ll_SubDetailFrameIndex) Is Nothing Then
        For ll_Index = 0 To grd_SubDetail(ll_SubDetailFrameIndex).Rows - 1
            ls_Request = ""
            Select Case grd_SubDetail(ll_SubDetailFrameIndex).Data(ll_Index, STATUS_COLUMN)
            Case "A"
                ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestAdd
                le_Mode = emAdd
                Call SubItem_AddDB(al_SubDetailIndex, ll_Index)
            Case "U"
                ls_Request = mt_SubdetailConfig(al_SubDetailIndex).RequestUpd
                le_Mode = emUpdate
                Call SubItem_UpdateDB(al_SubDetailIndex, ll_Index)
            'Case "D"
            '    ls_Request = mt_SubdetailConfig(al_SubdetailIndex).RequestDel
            '    le_Mode = emDelete
            Case Else
                le_Mode = emNone
            End Select
            'If le_Mode <> emNone Then Call SubItem_CustomBeforeSave(al_SubdetailIndex, le_Mode, ll_Index)
            'If ls_Request <> "" Then
            '    ls_Request = mo_Tools.ReplacePlaceholderByControlValue(ls_Request, txt_DetailKey(ll_DetailFrameIndex))
            '    ls_Request = ReplaceRequestByGridData(grd_Subdetail(ll_SubDetailFrameIndex), ls_Request, ll_Index, mt_SubdetailConfig(al_SubdetailIndex).TableName)
            '    ls_Request = ReplaceLanguagePlaceholderFromToolbar(ls_Request)
            '    ls_Request = ReplaceCommonPlaceholders(ls_Request)
            '    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
            '    grd_Subdetail(ll_SubDetailFrameIndex).Data(ll_Index, "iConcurrency") = Val(grd_Subdetail(ll_SubDetailFrameIndex).Data(ll_Index, "iConcurrency")) + 1
            '    'grd_Subdetail(ll_SubDetailFrameIndex).Data(ll_Index, STATUS_COLUMN) = ""    ' reset status flag
            'End If
            'If le_Mode <> emNone Then Call SubItem_CustomAfterSave(al_SubdetailIndex, le_Mode, ll_Index)
        Next
        ' find all records which have been deleted acording key. Compare original stored rows key with key of rows in grid
        If UBound(mt_SubdetailConfig(al_SubDetailIndex).DeletedRows) >= 0 Then
            ' calculate number of key columns
            ll_KeyCount = GetGridKeyCount(grd_SubDetail(ll_SubDetailFrameIndex))
            ' if there is no key, we cannot delete row
            If ll_KeyCount > 0 Then
                lv_Key = GetGridKeyIndexArray(grd_SubDetail(ll_SubDetailFrameIndex))
                ReDim lv_Data(ll_KeyCount - 1)
                ' compare stored rows to grid
                For ll_Index = 0 To UBound(mt_SubdetailConfig(al_SubDetailIndex).DeletedRows)
                    ' fill array of key values for each row in stored rows collection
                    For ll_KeyIdx = 0 To UBound(lv_Key)
                        lv_Data(ll_KeyIdx) = mt_SubdetailConfig(al_SubDetailIndex).DeletedRows(ll_Index)(lv_Key(ll_KeyIdx))
                    Next
                    ' search key in grid, if not found delete record from database
                    If Not SearchGrid(grd_SubDetail(ll_SubDetailFrameIndex), lv_Key, lv_Data, False) Then
                        Call SubItem_DeleteDB(al_SubDetailIndex, ll_Index)
                    End If
                Next
            End If
        End If
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("SaveSubDetailGrid")
End Sub


Private Function GetGridKeyIndexArray(ByVal ao_grid As ArmGrid) As Variant
On Error GoTo ErrHandler

Dim lv_KeyIndex As Variant
Dim ll_Count As Long
Dim ll_Index As Long
Dim ll_KeyIdx As Long

    ll_Count = GetGridKeyCount(ao_grid)
    ReDim lv_KeyIndex(ll_Count - 1)
    ll_KeyIdx = 0
    ' create array of key indexes
    For ll_Index = 0 To ao_grid.Cols - 1
        If ao_grid.Columns(ll_Index).Key Then
            lv_KeyIndex(ll_KeyIdx) = ll_Index
            ll_KeyIdx = ll_KeyIdx + 1
        End If
    Next
    GetGridKeyIndexArray = lv_KeyIndex
    Exit Function
ErrHandler:
    Call ErrorHandler("GetGridKeyIndexArray")
End Function

Private Function GetGridKeyCount(ByVal ao_grid As ArmGrid) As Long
On Error GoTo ErrHandler

Dim ll_KeyCount As Long
Dim ll_Index As Long

    ll_KeyCount = 0
    For ll_Index = 0 To ao_grid.Cols - 1
        If ao_grid.Columns(ll_Index).Key Then
            ll_KeyCount = ll_KeyCount + 1
        End If
    Next
    GetGridKeyCount = ll_KeyCount
    Exit Function
ErrHandler:
    Call ErrorHandler("GetGridKeyCount")
End Function

Private Sub LoadFrameDataFromGrid(ByVal ao_grid As ArmGrid, ByVal ao_Frame As Frame)
On Error GoTo ErrHandler

Dim lo_Control As Control
Dim lsa_Columns() As String
Dim lv_ComboData As Variant
Dim ll_Index As Long
   
   mb_InternalInit = True
    If ao_grid.SelectedCount <> 1 Then
        Debug.Assert True
        mb_InternalInit = False
        Exit Sub
    End If
    
    For Each lo_Control In UserControl.Controls
    
        If mo_Tools.HasContainer(lo_Control, ao_Frame) Then
            Select Case UCase(TypeName(lo_Control))
                Case "ARMCOMBOBOX"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If UBound(lsa_Columns) >= 1 Then
                            If Not lo_Control.SearchItem(ao_grid.CurrentLine(lsa_Columns(0))) Then
                                ReDim lv_ComboData(UBound(lsa_Columns))
                                For ll_Index = 0 To UBound(lsa_Columns)
                                    lv_ComboData(ll_Index) = ao_grid.CurrentLine(lsa_Columns(ll_Index))
                                Next
                                If lo_Control.AddItem(lv_ComboData, True) Is Nothing Then
                                    Err.Raise ArmErr.CompFncFailed, lo_Control.Name, "Function AddItem failed"
                                End If
                            End If
                        Else
                            Call lo_Control.SearchItem(ao_grid.CurrentLine(lsa_Columns(0)))
                        End If
                    End If
                Case "ARMPICKER"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If UBound(lsa_Columns) >= 1 Then
                            lo_Control.ItemCode = ao_grid.CurrentLine(lsa_Columns(0))
                            lo_Control.ItemDescription = ao_grid.CurrentLine(lsa_Columns(1))
                        End If
                    End If
                Case "CHECKBOX"
                    If Trim(lo_Control.Tag) <> "" Then
                        If (StrComp(ao_grid.CurrentLine(lo_Control.Tag), "X", vbTextCompare) = 0) Or _
                           (StrComp(ao_grid.CurrentLine(lo_Control.Tag), "CHECK", vbTextCompare) = 0) Then
                            lo_Control.Value = vbChecked
                        Else
                            lo_Control.Value = vbUnchecked
                        End If
                    End If
                Case "TEXTBOX"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If UBound(lsa_Columns) >= 1 Then
                            lo_Control.Text = ao_grid.CurrentLine(lsa_Columns(0))
                        Else
                            lo_Control.Text = ao_grid.CurrentLine(lo_Control.Tag)
                        End If
                    End If
                Case "A_CALOCX"
                    If Trim(lo_Control.Tag) <> "" Then
                        If CDbl(ao_grid.CurrentLine(lo_Control.Tag)) = 0 Then
                            Call lo_Control.reinit_cal
                        Else
                            lo_Control.date_courte = Format(ao_grid.CurrentLine(lo_Control.Tag), "dd\/mm\/yyyy")
                        End If
                    End If
            End Select
        End If
    Next
    mb_InternalInit = False
    Exit Sub
ErrHandler:
    mb_InternalInit = False
    Call ErrorHandler("LoadFrameDataFromGrid")
End Sub

Private Sub SwapRows(ByVal al_FrameIndex As Long, ByVal ab_Down As Boolean)
On Error GoTo ErrHandler

Dim ll_Row1 As Long, ll_Row2 As Long
Dim ls_OrderValue As String, ls_OrderField As String
Dim ll_SubdetailIndex As Long, ll_frameIndex As Long
Dim lo_Grid As ArmGrid

    ll_SubdetailIndex = FindSubDetailConfigByFrameIndex(al_FrameIndex)
    Set lo_Grid = grd_SubDetail(al_FrameIndex)
    ls_OrderField = mt_SubdetailConfig(ll_SubdetailIndex).TableOrder
    
    If lo_Grid.SelectedCount <> 1 Then Exit Sub
    ll_Row1 = lo_Grid.Row
    If ab_Down Then
        If ll_Row1 = lo_Grid.Rows - 1 Then Exit Sub
        ll_Row2 = ll_Row1 + 1
    Else
        If ll_Row1 = 0 Then Exit Sub
        ll_Row2 = ll_Row1 - 1
    End If
    lo_Grid.Row = ll_Row2
    ls_OrderValue = lo_Grid.Data(ll_Row1, ls_OrderField)
    lo_Grid.Data(ll_Row1, ls_OrderField) = lo_Grid.Data(ll_Row2, ls_OrderField)
    lo_Grid.Data(ll_Row2, ls_OrderField) = ls_OrderValue
    Call lo_Grid.SwapLines(ll_Row1, ll_Row2)
    
    If lo_Grid.Data(ll_Row1, STATUS_COLUMN) <> "A" Then lo_Grid.Data(ll_Row1, STATUS_COLUMN) = "U"
    If lo_Grid.Data(ll_Row2, STATUS_COLUMN) <> "A" Then lo_Grid.Data(ll_Row2, STATUS_COLUMN) = "U"
    'if detail is in view mode, save changes immediatelly to database
    If me_DetailMode = emView Then
        Call SaveSubDetailGrid(ll_SubdetailIndex)
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("SwapRows")
End Sub


Private Function SelectValue(ByVal as_Request As String) As Variant
On Error GoTo ErrHandler
Dim ll_Cursor As Long

  ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, as_Request)
  If ll_Cursor > 0 Then
    If mo_Db.RowCount(ll_Cursor) = 1 Then
      SelectValue = mo_Db.GetFields(ll_Cursor, 0)
    End If
    Call mo_Db.Close(ll_Cursor)
  End If
  Exit Function
ErrHandler:
  Call mo_Db.Close(ll_Cursor)
  Call ErrorHandler("SelectValue as_Request=" & as_Request)
End Function

Private Sub UpdateLocalComboboxes(ByVal as_Key As String, ByVal av_Value As Variant, ByVal ae_Mode As eMode)
On Error GoTo ErrHandler

Dim lo_Control As Object
Dim lsa_Fields() As String

    If as_Key = "" Then Exit Sub
    For Each lo_Control In UserControl.Controls
    
        If StrComp(TypeName(lo_Control), "ArmCombobox", vbTextCompare) = 0 Then
            If lo_Control.Tag <> "" Then
                lsa_Fields = Split(lo_Control.Tag, SEP)
                If StrComp(lsa_Fields(0), as_Key, vbTextCompare) = 0 Then
                    Call lo_Control.Clear
                End If
            End If
        End If
    Next
    Exit Sub
ErrHandler:
    Call ErrorHandler("UpdateLocalComboboxes")
End Sub

Private Function SearchGrid(ByRef ao_grid As ArmGrid, ByVal av_columns As Variant, ByVal av_Data As Variant, ByVal ab_Select As Boolean) As Boolean
On Error GoTo ErrHandler

Dim ll_RowIdx As Long, ll_ColIdx As Long
Dim lb_Found As Boolean

    lb_Found = False
    For ll_RowIdx = 0 To ao_grid.Rows - 1
        lb_Found = True
        For ll_ColIdx = 0 To UBound(av_columns)
            If StrComp(av_Data(ll_ColIdx), ao_grid.Data(ll_RowIdx, av_columns(ll_ColIdx)), vbTextCompare) <> 0 Then
                lb_Found = False
                Exit For
            End If
        Next
        If lb_Found Then Exit For
    Next
    If lb_Found And ab_Select Then
        ao_grid.Row = ll_RowIdx
    End If
    SearchGrid = lb_Found
    Exit Function
ErrHandler:
    Call ErrorHandler("SearchGrid")
End Function

Private Function GetColIndex(ByRef ao_grid As ArmGrid, ByVal as_ColumnName As String) As Long
On Error GoTo ErrHandler

Dim ll_ColIdx As Long

    For ll_ColIdx = 0 To ao_grid.Cols - 1
        If StrComp(as_ColumnName, ao_grid.Columns(ll_ColIdx).FieldName, vbTextCompare) = 0 Then
            GetColIndex = ll_ColIdx
            Exit Function
        End If
    Next
    GetColIndex = -1
    Exit Function
ErrHandler:
    Call ErrorHandler("GetColIndex")
End Function

Private Function GetTreeViewPath(ByVal ao_Tree As ArmTreeView, ByVal al_DataIndex As Long, ByVal as_Separator As String) As String
On Error GoTo ErrHandler

Dim as_Path As String
Dim lo_Node As MSComctlLib.Node
    
    as_Path = ""
    Set lo_Node = ao_Tree.SelectedItem
    While Not (lo_Node Is Nothing)
    
        If as_Path <> "" Then as_Path = as_Separator & as_Path
        as_Path = lo_Node.Tag.GetData(al_DataIndex) & as_Path
        Set lo_Node = lo_Node.Parent
    Wend
    GetTreeViewPath = as_Path
    Exit Function
ErrHandler:
    Call ErrorHandler("GetTreeViewPath")
End Function

Private Sub DisableFrameParts(ByVal av_ListFieldsToDisable As Variant)
On Error GoTo ErrHandler
    
    Dim lIdx As Long, lCount As Long
    Dim lParams As Variant
    
    If Not IsArray(av_ListFieldsToDisable) Then Exit Sub
    lCount = UBound(av_ListFieldsToDisable)
    
    For lIdx = 0 To lCount
            Select Case UCase(TypeName(av_ListFieldsToDisable(lIdx)))
                Case "FRAME", "LABEL", "MSFLEXGRID", "TOOLBARCONTROL"
                    ' Do nothing !
                
                Case "TEXTBOX"
                        av_ListFieldsToDisable(lIdx).Locked = True
                        av_ListFieldsToDisable(lIdx).BackColor = CL_COLOR_DISABLED
                        
                Case "ARMGRID", "ARMCHECKVIEW"
                                    
                Case "OPTIONBUTTON", "COMMANDBUTTON", "ARMCOMBOBOX", "ARMPICKER", "A_CALOCX", "ARMTREEVIEW", "LISTBOX", "PICTUREBOX", "TABSTRIP", "CHECKBOX"
                    av_ListFieldsToDisable(lIdx).Enabled = False
                    
                Case Else
                    Debug.Print "DisableFrameParts " & UCase(TypeName(av_ListFieldsToDisable(lIdx)))
            End Select
    Next
    Exit Sub
ErrHandler:
    Call ErrorHandler("DisableFrameParts")
End Sub

Private Sub SetTreeDelayedMode(ByVal al_FrameIndex As Long, ByVal ab_Delayed As Boolean)
On Error GoTo ErrHandler
Dim ll_MainConfigIndex As Long
    
    ll_MainConfigIndex = FindMainConfigByFrameIndex(al_FrameIndex)
    If mt_MainConfig(ll_MainConfigIndex).CurrentTvwSelMethod = eTvwSelMethod.etmNone Then
        tvw_Main(al_FrameIndex).Visible = False
        cmd_TVReLoad(al_FrameIndex).Visible = False
        grd_Main(al_FrameIndex).Visible = Not ab_Delayed
    Else
        tvw_Main(al_FrameIndex).Visible = Not ab_Delayed
        cmd_TVReLoad(al_FrameIndex).Visible = ab_Delayed
        mt_MainConfig(ll_MainConfigIndex).TreeDelayed = ab_Delayed
        grd_Main(al_FrameIndex).Visible = Not ab_Delayed
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("SetTreeDelayedMode")
End Sub

Private Function GetModeFromRole(ByVal as_Role As String) As eMode
On Error GoTo ErrHandler

    GetModeFromRole = emView
    
    Select Case as_Role
    Case "A"
        GetModeFromRole = emAdd
    Case "B"
        GetModeFromRole = emUpdate
    Case "C"
        GetModeFromRole = emDelete
    End Select
    Exit Function
ErrHandler:
    Call ErrorHandler("GetModeFromRole")
End Function

Private Function LoadTreeView(ByVal al_MainIndex As Long, ByRef aTV As ArmTreeView, ByRef aTreeViewInfo As TTreeViewInfo) As Boolean
On Error GoTo ErrorHandler
    
    Call aTV.Clear
    
    If aTreeViewInfo.Levels > 0 Then
      aTV.Levels = aTreeViewInfo.Levels
      aTV.StartDemandLevel = 1
      aTV.SelectedImages = aTreeViewInfo.SelectedImages
      aTV.Images = aTreeViewInfo.Images
      aTV.NodeRequests = ApplyTVFilters(al_MainIndex, aTreeViewInfo.NodeRequest)
      aTV.GridRequests = aTreeViewInfo.GridRequest
      
      If Not aTV.LoadTree(LoadTypeChildsDemand) Then
          Call Err.Raise(ArmErr.CompFncFailed, "aTV.LoadTree", "")
      End If
    End If
    Exit Function
ErrorHandler:
    Call ErrorHandler("LoadTreeView")
End Function

Private Function GetTreeViewInfoFromDB(ByVal AScreenName As String, ByVal aTVCode As String) As TTreeViewInfo
On Error GoTo ErrHandler

    Dim lTreeView As TTreeViewInfo
    Dim lRequest As String
    Dim lCurs As Long, lIdx As Long, lCount As Long
    
    ' Get the data from the DB
    lRequest = "EXEC Treeview_Parameters_lst '" & AScreenName & "', '" & aTVCode & "'"
    lCurs = mo_Tools.OpenSQLSafe(mo_Db, lRequest)
    
    lCount = mo_Db.RowCount(lCurs) - 1
    
    If lCount < 0 Then
        Call Err.Raise(ArmErr.InvalidValue, lRequest, "AScreenName=" & AScreenName & " lCount=" & lCount)
    End If
    
    ReDim lTreeView.NodeRequest(lCount)
    ReDim lTreeView.GridRequest(lCount)
    ReDim lTreeView.ExcelRequest(lCount)
    ReDim lTreeView.FindRequest(lCount)
    ReDim lTreeView.CountRequest(lCount)
    ReDim lTreeView.Images(lCount)
    ReDim lTreeView.SelectedImages(lCount)
    
    Dim lLevel As Long
    For lIdx = 0 To lCount
        lLevel = mo_Db.GetFields(lCurs, "TV_Level")
        lTreeView.NodeRequest(lLevel) = ReplaceCommonPlaceholders(mo_Db.GetFields(lCurs, "TV_NodeRequest"))
        lTreeView.GridRequest(lLevel) = mo_Db.GetFields(lCurs, "TV_GridRequest")
        lTreeView.Images(lLevel) = mo_Db.GetFields(lCurs, "TV_Images")
        lTreeView.SelectedImages(lLevel) = mo_Db.GetFields(lCurs, "TV_SelectedImages")
        mo_Db.Next (lCurs)
    Next
    
    lTreeView.TreeViewCode = aTVCode
    lTreeView.Levels = lCount + 1
    lTreeView.Loaded = True
    GetTreeViewInfoFromDB = lTreeView
    
    Call mo_Db.Close(lCurs)
    Exit Function
ErrHandler:
    Call mo_Db.Close(lCurs)
    Call ErrorHandler("GetTreeViewInfoFromDB")
End Function

' ************************************************************************************
' FRAMEWORK DB-ACCESS FUNCTIONS
' please do not change this code
' ************************************************************************************

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

' display standard error message
Private Sub ErrorMessage(ByVal as_Fct As String)
    Dim ls_ErrSource As String
    Dim ls_errDescription As String
    ls_ErrSource = as_Fct & SEP1 & Err.Source
    ls_errDescription = Err.Description
    
    Call LogMessage(SCREEN_NAME & " exception raised. Err.Number:" & Err.Number & ", Err.Source:" & ls_ErrSource & ", Err.Description " & ls_errDescription & ".", "E", False)
    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

' logs message to database
Private Sub LogMessage(ByVal as_LogMsg As String, Optional ByVal as_LogType As String = "E", Optional ab_ExitOnException As Boolean = False)
    Dim ll_errNumber As Long
    Dim ls_errDescription As String, ls_ErrSource As String
    
    ll_errNumber = Err.Number
    ls_errDescription = Err.Description
    ls_ErrSource = Err.Source

On Error GoTo ErrHandler

Const LOG_REQUEST As String = "EXEC A_log_ins $UCODE$,$LOGTYPE$,$MSG$,$APP$"
    Dim ls_Req As String
    Dim ll_Cursor As Long
    Dim ls_Source As String, ls_Msg As String
    
    ls_Source = SCREEN_NAME & " " & App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision
    ls_Msg = as_LogMsg & SEP1 & ll_errNumber & " : " & ls_errDescription & " - " & ls_ErrSource
    
    ls_Req = ReplacePlaceHolder(LOG_REQUEST, "$UCODE$", CStr(ml_U_Code))
    ls_Req = ReplacePlaceHolder(ls_Req, "$LOGTYPE$", mo_Tools.SQLStr(as_LogType))
    ls_Req = ReplacePlaceHolder(ls_Req, "$MSG$", Left(Trim(mo_Tools.SQLStr(ls_Msg)), 4000))
    ls_Req = ReplacePlaceHolder(ls_Req, "$APP$", Left(Trim(mo_Tools.SQLStr(ls_Source)), 50))
    
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
    
    Err.Number = ll_errNumber
    Err.Description = ls_errDescription
    Err.Source = ls_ErrSource
    Exit Sub
    
ErrHandler:
    If ab_ExitOnException Then
        Call MsgBox("A fatal error occured. Unable to log error into database, the application will be close. Please report the following message to your IT support: " & vbCrLf & _
            "Number:" & Err.Number & vbCrLf & "Description:" & Err.Description, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
        End
    End If
    Err.Number = ll_errNumber
    Err.Description = ls_errDescription
    Err.Source = ls_ErrSource
End Sub

' ************************************************************************************
' *************************** INTERNATIONAL FUNCTIONS ********************************
' ************************************************************************************

Private Function HasRightInA_Config(ByVal as_CFG_Key As String)
On Error GoTo ErrHandler

Dim ls_CFG_Value As String
Dim lsa_Login() As String
Dim ll_Idx As Long

    HasRightInA_Config = False
    ls_CFG_Value = CStr(SelectValue("SELECT CFG_Value FROM A_Config WHERE CFG_Key=" & mo_Tools.SQLStr(as_CFG_Key)))
    If ls_CFG_Value <> "" Then
        lsa_Login = Split(ls_CFG_Value, SEP)
        For ll_Idx = 0 To UBound(lsa_Login)
            If StrComp(ms_LoginName, lsa_Login(ll_Idx), vbTextCompare) = 0 Then
                HasRightInA_Config = True
                Exit Function
            End If
        Next
    End If
  Exit Function
ErrHandler:
  Call ErrorHandler("HasRightInA_Config as_CFG_Key=" & as_CFG_Key)
End Function

Private Function MapNetworkDrive(ByRef ao_WshNetwork As Object, ByVal as_drive As String, ByVal as_remotePath As String, ByVal as_User As String, ByVal as_pass As String) As Boolean
On Error GoTo ErrorHandler
    If Trim(as_User) = "" Then
        Call mo_WshNetwork.MapNetworkDrive(as_drive, as_remotePath, False)
    Else
        Call mo_WshNetwork.MapNetworkDrive(as_drive, as_remotePath, False, as_User, as_pass)
    End If
    MapNetworkDrive = True
    Exit Function
ErrorHandler:
    ' mapping failed
    Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9855, "#Application cannot map drive $DRIVE$ to $PATH$." & vbCrLf & "$ERROR$" & vbCrLf & "Try it manually or call application support please.", Array("$DRIVE$", as_drive, "$PATH$", as_remotePath, "$ERROR$", Err.Number & " - " & Err.Description))
End Function

Private Function NetworkDriveExists(ByRef ao_WshNetwork As Object, ByVal as_drive As String) As Boolean
On Error GoTo ErrorHandler

    Dim lo_Drives As Object
    Dim ll_Index As Long
    NetworkDriveExists = False
    
    Set lo_Drives = ao_WshNetwork.EnumNetworkDrives
    For ll_Index = 0 To lo_Drives.Count - 1 Step 2
        If lo_Drives.Item(ll_Index) = as_drive Then
            ' drive exists
            NetworkDriveExists = True
            Exit Function
        End If
    Next

    Exit Function
ErrorHandler:
    Call ErrorHandler("NetworkDriveExists")
End Function

Private Function LoadBaeurerReferenceText(ByVal ae_Reference As eDPCBaeurerReference, ByVal as_Code As String, Optional ByVal av_Param As Variant = Empty) As String
On Error GoTo ErrHandler

Dim lo_Baeurer As New DPC_Interface
Dim ls_Text As String

  LoadBaeurerReferenceText = ""
  Set lo_Baeurer.Tools = mo_Tools
  Set lo_Baeurer.ArmDb = mo_Db
  lo_Baeurer.U_Code = ml_U_Code
  Call lo_Baeurer.Load_A_COM
  If lo_Baeurer.Bae_LoadBaeurerReferenceText(ae_Reference, as_Code, av_Param, ls_Text) Then
    LoadBaeurerReferenceText = ls_Text
  Else
    Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9849, "#Record not found")
  End If
  Call lo_Baeurer.Unload_A_COM
  Set lo_Baeurer = Nothing
  Exit Function
ErrHandler:
  Call ErrorHandler("LoadBaeurerReferenceText")
End Function

Private Sub CopyBaseTypeRecord(ByVal al_BaseType_Src As Long)
On Error GoTo ErrHandler

Dim ll_BaseType_Dst As Long
Dim ls_Req As String
Dim lb_InTransaction As Boolean

  lb_InTransaction = False
  ll_BaseType_Dst = Val(InputBox("Enter destination base type", "Base Type:", ""))
  ls_Req = "SELECT RF_Code FROM A_References_ML WHERE GR_Code=$GR_Code$ AND RF_Code=$RF_Code$ AND Language_Code='E'"
  ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$GR_Code$", mo_Tools.SqlInt(eDPCReferenceML.rfBaseTypeBaeurer))
  ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$RF_Code$", mo_Tools.SqlInt(ll_BaseType_Dst))
  ls_Req = ReplaceCommonPlaceholders(ls_Req)
  
  ll_BaseType_Dst = Val(mo_Tools.SelectValue(mo_Db, ls_Req))
  If (ll_BaseType_Dst = 0) Then
      Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 666, "#Destination Base Type not found !")
      Exit Sub
  End If
  If (ll_BaseType_Dst = al_BaseType_Src) Then
      Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 666, "#Source Base Type and destination base type cannot be equal !")
      Exit Sub
  End If
      
  If mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 666, "Are you sure to copy source Base Type " & al_BaseType_Src & " to destination: " & ll_BaseType_Dst, , VbMsgBoxStyle.vbYesNo) Then
    Call mo_Tools.BeginBatchTran(mo_Db, ml_U_Code, "DPC_BaeType", "CopyBaseType")
    lb_InTransaction = True
    
    
    ls_Req = "exec DPC_BaseTypeBendParam_del2 $BaseType_Dst$, $U_Code$"
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Dst$", mo_Tools.SqlInt(ll_BaseType_Dst))
    ls_Req = ReplaceCommonPlaceholders(ls_Req)
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
    
    ls_Req = "exec DPC_BaseTypePerfParam_del2 $BaseType_Dst$, $U_Code$"
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Dst$", mo_Tools.SqlInt(ll_BaseType_Dst))
    ls_Req = ReplaceCommonPlaceholders(ls_Req)
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
    
    ls_Req = "exec DPC_BaseTypeCutParam_del2 $BaseType_Dst$, $U_Code$"
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Dst$", mo_Tools.SqlInt(ll_BaseType_Dst))
    ls_Req = ReplaceCommonPlaceholders(ls_Req)
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
    
    
    ls_Req = "exec DPC_BaseTypeBendParam_cpy $BaseType_Src$, $BaseType_Dst$, $U_Code$"
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Src$", mo_Tools.SqlInt(al_BaseType_Src))
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Dst$", mo_Tools.SqlInt(ll_BaseType_Dst))
    ls_Req = ReplaceCommonPlaceholders(ls_Req)
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
    
    ls_Req = "exec DPC_BaseTypePerfParam_cpy $BaseType_Src$, $BaseType_Dst$, $U_Code$"
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Src$", mo_Tools.SqlInt(al_BaseType_Src))
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Dst$", mo_Tools.SqlInt(ll_BaseType_Dst))
    ls_Req = ReplaceCommonPlaceholders(ls_Req)
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
    
    ls_Req = "exec DPC_BaseTypeCutParam_cpy $BaseType_Src$, $BaseType_Dst$, $U_Code$"
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Src$", mo_Tools.SqlInt(al_BaseType_Src))
    ls_Req = mo_Tools.ReplacePlaceHolder(ls_Req, "$BaseType_Dst$", mo_Tools.SqlInt(ll_BaseType_Dst))
    ls_Req = ReplaceCommonPlaceholders(ls_Req)
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Req)
    
    Call mo_Tools.CommitBatchTran(mo_Db, ml_U_Code, "DPC_BaeType", "CopyBaseType")
    lb_InTransaction = False
  End If
  
  Exit Sub
ErrHandler:
  If (lb_InTransaction) Then
    Call mo_Tools.RollbackBatchTran(mo_Db, ml_U_Code, "DPC_BaeType", "CopyBaseType")
  End If
  Call ErrorHandler("CopyBaseTypeRecord")
End Sub

