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_BOR 
   ClientHeight    =   9600
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   15270
   ScaleHeight     =   9600
   ScaleWidth      =   15270
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Rerolling Detail"
      Height          =   255
      Index           =   9
      Left            =   13890
      TabIndex        =   363
      Top             =   4395
      Width           =   1095
      Begin VB.TextBox txt_BRR_WghPnt1 
         Height          =   375
         Left            =   11040
         TabIndex        =   379
         Tag             =   "BRR_WghPnt1®©N"
         Top             =   4080
         Width           =   735
      End
      Begin VB.TextBox txt_BRR_WghPnt2 
         Height          =   375
         Left            =   11040
         TabIndex        =   383
         Tag             =   "BRR_WghPnt2®©N"
         Top             =   4560
         Width           =   735
      End
      Begin VB.TextBox txt_BRR_WghPnt3 
         Height          =   375
         Left            =   11040
         TabIndex        =   387
         Tag             =   "BRR_WghPnt3®©N"
         Top             =   5040
         Width           =   735
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   9
         Left            =   10920
         TabIndex        =   388
         TabStop         =   0   'False
         Tag             =   "BRR_Id"
         Top             =   1080
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BRR_QtyMin 
         Height          =   405
         Left            =   3960
         TabIndex        =   373
         Tag             =   "BRR_QtyMin®©N"
         Top             =   3000
         Width           =   1095
      End
      Begin VB.TextBox txt_BRR_QtyMax 
         Height          =   375
         Left            =   6360
         TabIndex        =   374
         Tag             =   "BRR_QtyMax®©N"
         Top             =   3000
         Width           =   1095
      End
      Begin VB.TextBox txt_BRR_CutAMin 
         Height          =   375
         Left            =   3960
         TabIndex        =   369
         Tag             =   "BRR_CutAMin®©F"
         Top             =   2040
         Width           =   1095
      End
      Begin VB.TextBox txt_BRR_CutAMax 
         Height          =   375
         Left            =   6360
         TabIndex        =   370
         Tag             =   "BRR_CutAMax®©F"
         Top             =   2040
         Width           =   1095
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   16
         Left            =   9960
         TabIndex        =   378
         Top             =   4080
         Width           =   855
      End
      Begin VB.TextBox txt_BRR_CutBMin 
         Height          =   375
         Left            =   3960
         TabIndex        =   371
         Tag             =   "BRR_CutBMin®©F"
         Top             =   2520
         Width           =   1095
      End
      Begin VB.TextBox txt_BRR_CutBMax 
         Height          =   375
         Left            =   6360
         TabIndex        =   372
         Tag             =   "BRR_CutBMax®©F"
         Top             =   2520
         Width           =   1095
      End
      Begin VB.TextBox txt_BRR_ThsMin 
         Height          =   375
         Left            =   3960
         TabIndex        =   367
         Tag             =   "BRR_ThsMin®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txt_BRR_ThsMax 
         Height          =   375
         Left            =   6360
         TabIndex        =   368
         Tag             =   "BRR_ThsMax®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   15
         Left            =   9960
         TabIndex        =   382
         Top             =   4560
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   14
         Left            =   9960
         TabIndex        =   386
         Top             =   5040
         Width           =   855
      End
      Begin VB.TextBox txt_BRR_MAT_Name 
         Height          =   375
         Left            =   10920
         TabIndex        =   364
         Tag             =   "MAT_Name"
         Top             =   1560
         Visible         =   0   'False
         Width           =   1335
      End
      Begin MSComctlLib.ListView lv_Materials 
         Height          =   2415
         Index           =   2
         Left            =   120
         TabIndex        =   365
         Top             =   1440
         Width           =   2535
         _ExtentX        =   4471
         _ExtentY        =   4260
         View            =   2
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   14
         Left            =   1920
         TabIndex        =   376
         Tag             =   "BRR_KostSt1®©KostSt1_Desc"
         Top             =   4080
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   14
         Left            =   4800
         TabIndex        =   377
         Tag             =   "BRR_AgId1®©AgId1_Desc"
         Top             =   4080
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_Perf 
         Height          =   345
         Index           =   2
         Left            =   3960
         TabIndex        =   366
         Tag             =   "PRF_Id®©PRF_Name"
         Top             =   1080
         Width           =   3495
         _ExtentX        =   6165
         _ExtentY        =   609
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   9
         Left            =   120
         TabIndex        =   389
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   8
         Left            =   3960
         TabIndex        =   375
         Tag             =   "BRR_Priority®©BRR_Priority"
         Top             =   3480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   15
         Left            =   1920
         TabIndex        =   380
         Tag             =   "BRR_KostSt2®©KostSt2_Desc"
         Top             =   4560
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   16
         Left            =   1920
         TabIndex        =   384
         Tag             =   "BRR_KostSt3®©KostSt3_Desc"
         Top             =   5040
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   15
         Left            =   4800
         TabIndex        =   381
         Tag             =   "BRR_AgId2®©AgId2_Desc"
         Top             =   4560
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   16
         Left            =   4800
         TabIndex        =   385
         Tag             =   "BRR_AgId3®©AgId3_Desc"
         Top             =   5040
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   9
         Left            =   10320
         TabIndex        =   403
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   82
         Left            =   11040
         TabIndex        =   568
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   3720
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Perf"
         Height          =   255
         Index           =   133
         Left            =   3000
         TabIndex        =   402
         Tag             =   "lbl_BOR_Perf_Prf"
         Top             =   1200
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Material"
         Height          =   255
         Index           =   132
         Left            =   120
         TabIndex        =   401
         Tag             =   "lbl_BOR_Perf_Mat"
         Top             =   1080
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMin"
         Height          =   255
         Index           =   131
         Left            =   3000
         TabIndex        =   400
         Tag             =   "lbl_BOR_Perf_QtyMin"
         Top             =   3120
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMax"
         Height          =   255
         Index           =   130
         Left            =   5400
         TabIndex        =   399
         Tag             =   "lbl_BOR_Perf_QtyMax"
         Top             =   3120
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AMin"
         Height          =   255
         Index           =   129
         Left            =   3000
         TabIndex        =   398
         Tag             =   "lbl_BOR_Perf_AMin"
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AMax"
         Height          =   255
         Index           =   128
         Left            =   5400
         TabIndex        =   397
         Tag             =   "lbl_BOR_Perf_AMax"
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   127
         Left            =   3000
         TabIndex        =   396
         Tag             =   "lbl_BOR_Perf_Priority"
         Top             =   3600
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   126
         Left            =   3840
         TabIndex        =   395
         Tag             =   "lbl_BOR_Perf_AgId"
         Top             =   4200
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   125
         Left            =   480
         TabIndex        =   394
         Tag             =   "lbl_CostCentre"
         Top             =   4200
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BMin"
         Height          =   255
         Index           =   124
         Left            =   3000
         TabIndex        =   393
         Tag             =   "lbl_BOR_Perf_BMin"
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BMax"
         Height          =   255
         Index           =   123
         Left            =   5400
         TabIndex        =   392
         Tag             =   "lbl_BOR_Perf_BMax"
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ThsMin"
         Height          =   255
         Index           =   42
         Left            =   3000
         TabIndex        =   391
         Tag             =   "lbl_BOR_Perf_ThsMin"
         Top             =   1680
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ThsMax"
         Height          =   255
         Index           =   40
         Left            =   5400
         TabIndex        =   390
         Tag             =   "lbl_BOR_Perf_ThsMax"
         Top             =   1680
         Width           =   975
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Rerolling Main"
      Height          =   252
      Index           =   9
      Left            =   120
      TabIndex        =   356
      Top             =   4320
      Width           =   1332
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   1095
         Index           =   9
         Left            =   0
         TabIndex        =   358
         Top             =   360
         Width           =   2895
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   9
         Left            =   240
         TabIndex        =   357
         Top             =   2280
         Width           =   1215
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   9
         Left            =   3120
         TabIndex        =   359
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   9
         Left            =   120
         TabIndex        =   360
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   9
         Left            =   120
         TabIndex        =   361
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   9
         Left            =   3120
         TabIndex        =   362
         Tag             =   "grd_M_BRR"
         Top             =   1560
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Cutting Detail"
      Height          =   255
      Index           =   8
      Left            =   13800
      TabIndex        =   315
      Top             =   3915
      Width           =   1215
      Begin VB.TextBox txt_BOC_WghPnt1 
         Height          =   375
         Left            =   11040
         TabIndex        =   329
         Tag             =   "BOC_WghPnt1®©N"
         Top             =   4080
         Width           =   735
      End
      Begin VB.TextBox txt_BOC_WghPnt2 
         Height          =   375
         Left            =   11040
         TabIndex        =   333
         Tag             =   "BOC_WghPnt2®©N"
         Top             =   4560
         Width           =   735
      End
      Begin VB.TextBox txt_BOC_WghPnt3 
         Height          =   375
         Left            =   11040
         TabIndex        =   337
         Tag             =   "BOC_WghPnt3®©N"
         Top             =   5040
         Width           =   735
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   8
         Left            =   10320
         TabIndex        =   339
         TabStop         =   0   'False
         Tag             =   "BOC_Id"
         Top             =   1080
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOC_QtyMin 
         Height          =   405
         Left            =   6720
         TabIndex        =   323
         Tag             =   "BOC_QtyMin®©N"
         Top             =   3000
         Width           =   1095
      End
      Begin VB.TextBox txt_BOC_QtyMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   324
         Tag             =   "BOC_QtyMax®©N"
         Top             =   3000
         Width           =   1095
      End
      Begin VB.TextBox txt_BOC_CutAMin 
         Height          =   375
         Left            =   6720
         TabIndex        =   319
         Tag             =   "BOC_CutAMin®©F"
         Top             =   2040
         Width           =   1095
      End
      Begin VB.TextBox txt_BOC_CutAMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   320
         Tag             =   "BOC_CutAMax®©F"
         Top             =   2040
         Width           =   1095
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   11
         Left            =   9960
         TabIndex        =   328
         Top             =   4080
         Width           =   855
      End
      Begin VB.TextBox txt_BOC_CutBMin 
         Height          =   375
         Left            =   6720
         TabIndex        =   321
         Tag             =   "BOC_CutBMin®©F"
         Top             =   2520
         Width           =   1095
      End
      Begin VB.TextBox txt_BOC_CutBMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   322
         Tag             =   "BOC_CutBMax®©F"
         Top             =   2520
         Width           =   1095
      End
      Begin VB.TextBox txt_BOC_ThsMin 
         Height          =   375
         Left            =   6720
         TabIndex        =   317
         Tag             =   "BOC_ThsMin®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txt_BOC_ThsMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   318
         Tag             =   "BOC_ThsMax®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   10
         Left            =   9960
         TabIndex        =   332
         Top             =   4560
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   9
         Left            =   9960
         TabIndex        =   336
         Top             =   5040
         Width           =   855
      End
      Begin VB.TextBox txt_BOC_MAT_Name 
         Height          =   375
         Left            =   10320
         TabIndex        =   338
         Tag             =   "MAT_Name"
         Top             =   1560
         Visible         =   0   'False
         Width           =   1335
      End
      Begin MSComctlLib.ListView lv_Materials 
         Height          =   2415
         Index           =   1
         Left            =   120
         TabIndex        =   316
         Top             =   1320
         Width           =   2535
         _ExtentX        =   4471
         _ExtentY        =   4260
         View            =   2
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   9
         Left            =   1920
         TabIndex        =   326
         Tag             =   "BOC_KostSt1®©KostSt1_Desc"
         Top             =   4080
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   9
         Left            =   4800
         TabIndex        =   327
         Tag             =   "BOC_AgId1®©AgId1_Desc"
         Top             =   4080
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   8
         Left            =   120
         TabIndex        =   340
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   7
         Left            =   6720
         TabIndex        =   325
         Tag             =   "BOC_Priority®©BOC_Priority"
         Top             =   3480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   10
         Left            =   1920
         TabIndex        =   330
         Tag             =   "BOC_KostSt2®©KostSt2_Desc"
         Top             =   4560
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   11
         Left            =   1920
         TabIndex        =   334
         Tag             =   "BOC_KostSt3®©KostSt3_Desc"
         Top             =   5040
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   10
         Left            =   4800
         TabIndex        =   331
         Tag             =   "BOC_AgId2®©AgId2_Desc"
         Top             =   4560
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   11
         Left            =   4800
         TabIndex        =   335
         Tag             =   "BOC_AgId3®©AgId3_Desc"
         Top             =   5040
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   8
         Left            =   10320
         TabIndex        =   353
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   81
         Left            =   11040
         TabIndex        =   567
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   3720
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Material"
         Height          =   255
         Index           =   122
         Left            =   120
         TabIndex        =   352
         Tag             =   "lbl_BOR_Perf_Mat"
         Top             =   1080
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMin"
         Height          =   255
         Index           =   121
         Left            =   5640
         TabIndex        =   351
         Tag             =   "lbl_BOR_Perf_QtyMin"
         Top             =   3120
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMax"
         Height          =   255
         Index           =   120
         Left            =   8160
         TabIndex        =   350
         Tag             =   "lbl_BOR_Perf_QtyMax"
         Top             =   3120
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AMin"
         Height          =   255
         Index           =   119
         Left            =   5640
         TabIndex        =   349
         Tag             =   "lbl_BOR_Perf_AMin"
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AMax"
         Height          =   255
         Index           =   118
         Left            =   8160
         TabIndex        =   348
         Tag             =   "lbl_BOR_Perf_AMax"
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   117
         Left            =   5640
         TabIndex        =   347
         Tag             =   "lbl_BOR_Perf_Priority"
         Top             =   3600
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   116
         Left            =   3840
         TabIndex        =   346
         Tag             =   "lbl_BOR_Perf_AgId"
         Top             =   4200
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   115
         Left            =   480
         TabIndex        =   345
         Tag             =   "lbl_CostCentre"
         Top             =   4200
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BMin"
         Height          =   255
         Index           =   114
         Left            =   5640
         TabIndex        =   344
         Tag             =   "lbl_BOR_Perf_BMin"
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BMax"
         Height          =   255
         Index           =   113
         Left            =   8160
         TabIndex        =   343
         Tag             =   "lbl_BOR_Perf_BMax"
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ThsMin"
         Height          =   255
         Index           =   112
         Left            =   5640
         TabIndex        =   342
         Tag             =   "lbl_BOR_Perf_ThsMin"
         Top             =   1680
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ThsMax"
         Height          =   255
         Index           =   111
         Left            =   8160
         TabIndex        =   341
         Tag             =   "lbl_BOR_Perf_ThsMax"
         Top             =   1680
         Width           =   975
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Cutting Main"
      Height          =   252
      Index           =   8
      Left            =   120
      TabIndex        =   306
      Top             =   3960
      Width           =   1212
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   8
         Left            =   240
         TabIndex        =   310
         Top             =   2280
         Width           =   1215
      End
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   1095
         Index           =   8
         Left            =   0
         TabIndex        =   307
         Top             =   360
         Width           =   2895
         Begin Project1.ArmCombobox cbo_MAT_Filter 
            Height          =   345
            Index           =   1
            Left            =   120
            TabIndex        =   308
            Tag             =   "MAT_Id®©MAT_Name"
            Top             =   600
            Width           =   2655
            _ExtentX        =   4683
            _ExtentY        =   609
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Material filter"
            Height          =   255
            Index           =   110
            Left            =   120
            TabIndex        =   309
            Tag             =   "lbl_BOR_Mat_Filter"
            Top             =   360
            Width           =   2175
         End
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   8
         Left            =   3120
         TabIndex        =   311
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   8
         Left            =   120
         TabIndex        =   312
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   8
         Left            =   120
         TabIndex        =   313
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   8
         Left            =   3000
         TabIndex        =   314
         Tag             =   "grd_M_BOC"
         Top             =   1680
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_ProgressBar 
      Caption         =   "Progress"
      Height          =   255
      Left            =   13680
      TabIndex        =   258
      Top             =   5160
      Visible         =   0   'False
      Width           =   1095
      Begin MSComctlLib.ProgressBar prb_Progress 
         Height          =   255
         Left            =   240
         TabIndex        =   259
         Top             =   720
         Width           =   4455
         _ExtentX        =   7858
         _ExtentY        =   450
         _Version        =   393216
         Appearance      =   1
      End
      Begin VB.Label lbl_ProgressMsg 
         Caption         =   "Msg ..."
         Height          =   255
         Left            =   240
         TabIndex        =   260
         Top             =   360
         Width           =   4455
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "#DataImport"
      Height          =   255
      Index           =   10
      Left            =   13680
      TabIndex        =   255
      Top             =   4800
      Width           =   1095
      Begin VB.TextBox txt_DetailKey 
         Height          =   285
         Index           =   10
         Left            =   10080
         TabIndex        =   256
         TabStop         =   0   'False
         Top             =   1320
         Visible         =   0   'False
         Width           =   615
      End
      Begin Project1.ArmGrid grd_DataImport 
         Height          =   3135
         Left            =   240
         TabIndex        =   213
         Tag             =   "grd_DataImport"
         Top             =   1440
         Width           =   9615
         _ExtentX        =   16960
         _ExtentY        =   5530
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   10
         Left            =   240
         TabIndex        =   212
         Top             =   600
         Width           =   5415
         _ExtentX        =   9551
         _ExtentY        =   1217
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   10
         Left            =   10080
         TabIndex        =   257
         TabStop         =   0   'False
         Top             =   1680
         Visible         =   0   'False
         Width           =   495
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Packing Detail"
      Height          =   360
      Index           =   7
      Left            =   13590
      TabIndex        =   234
      Top             =   3435
      Width           =   1350
      Begin VB.TextBox txt_BOK_WghPnt1 
         Height          =   375
         Left            =   10560
         TabIndex        =   193
         Tag             =   "BOK_WghPnt1®©N"
         Top             =   3480
         Width           =   735
      End
      Begin VB.TextBox txt_BOK_WghPnt2 
         Height          =   375
         Left            =   10560
         TabIndex        =   197
         Tag             =   "BOK_WghPnt2®©N"
         Top             =   3960
         Width           =   735
      End
      Begin VB.TextBox txt_BOK_WghPnt3 
         Height          =   375
         Left            =   10560
         TabIndex        =   201
         Tag             =   "BOK_WghPnt3®©N"
         Top             =   4440
         Width           =   735
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   22
         Left            =   9480
         TabIndex        =   200
         Top             =   4440
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   21
         Left            =   9480
         TabIndex        =   196
         Top             =   3960
         Width           =   855
      End
      Begin VB.TextBox txt_BOK_QtyMax 
         Height          =   375
         Left            =   9240
         TabIndex        =   184
         Tag             =   "BOK_QtyMax®©F"
         Top             =   2160
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOK_QtyMin 
         Height          =   375
         Left            =   6960
         TabIndex        =   182
         Tag             =   "BOK_QtyMin®©F"
         Top             =   2160
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOK_PkgQty 
         Height          =   375
         Left            =   4440
         TabIndex        =   181
         Tag             =   "BOK_PkgQty®©F"
         Top             =   2160
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_Packing 
         Height          =   345
         Index           =   1
         Left            =   1800
         TabIndex        =   170
         Tag             =   "PKG_Id®©PKG_Name"
         Top             =   1200
         Width           =   3375
         _ExtentX        =   5953
         _ExtentY        =   609
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   6
         Left            =   9480
         TabIndex        =   192
         Top             =   3480
         Width           =   855
      End
      Begin VB.TextBox txt_BOK_WghMax 
         Height          =   375
         Left            =   4440
         TabIndex        =   186
         Tag             =   "BOK_WghMax®©F"
         Top             =   2640
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOK_PkgHMax 
         Height          =   375
         Left            =   9240
         TabIndex        =   180
         Tag             =   "BOK_PkgHMax®©F"
         Top             =   1680
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOK_PkgBMax 
         Height          =   375
         Left            =   6960
         TabIndex        =   179
         Tag             =   "BOK_PkgBMax®©F"
         Top             =   1680
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOK_PkgAMax 
         Height          =   405
         Left            =   4440
         TabIndex        =   178
         Tag             =   "BOK_PkgAMax®©F"
         Top             =   1680
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   7
         Left            =   9120
         TabIndex        =   235
         TabStop         =   0   'False
         Tag             =   "BOK_Id"
         Top             =   480
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   6
         Left            =   4440
         TabIndex        =   191
         Tag             =   "BOK_AgId1®©AgId1_Desc"
         Top             =   3480
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   7
         Left            =   120
         TabIndex        =   149
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_PRF_Class 
         Height          =   345
         Index           =   3
         Left            =   1800
         TabIndex        =   174
         Tag             =   "PRF_Class®©PRF_Class"
         Top             =   1680
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   6
         Left            =   1800
         TabIndex        =   176
         Tag             =   "BOK_Priority®©BOK_Priority"
         Top             =   2160
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   6
         Left            =   1800
         TabIndex        =   188
         Tag             =   "BOK_KostSt1®©KostSt1_Desc"
         Top             =   3480
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   21
         Left            =   1800
         TabIndex        =   194
         Tag             =   "BOK_KostSt2®©KostSt2_Desc"
         Top             =   3960
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   22
         Left            =   1800
         TabIndex        =   198
         Tag             =   "BOK_KostSt3®©KostSt3_Desc"
         Top             =   4440
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   21
         Left            =   4440
         TabIndex        =   195
         Tag             =   "BOK_AgId2®©AgId2_Desc"
         Top             =   3960
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   22
         Left            =   4440
         TabIndex        =   199
         Tag             =   "BOK_AgId3®©AgId3_Desc"
         Top             =   4440
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   7
         Left            =   10320
         TabIndex        =   237
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   80
         Left            =   10560
         TabIndex        =   566
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   3120
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMax"
         Height          =   255
         Index           =   142
         Left            =   8280
         TabIndex        =   425
         Tag             =   "lbl_BOK_QtyMax"
         Top             =   2280
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMin"
         Height          =   255
         Index           =   141
         Left            =   5880
         TabIndex        =   424
         Tag             =   "lbl_BOK_QtyMin"
         Top             =   2280
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PkgQty"
         Height          =   255
         Index           =   140
         Left            =   3360
         TabIndex        =   423
         Tag             =   "lbl_BOK_PkgQty"
         Top             =   2280
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Packing"
         Height          =   255
         Index           =   139
         Left            =   240
         TabIndex        =   422
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   104
         Left            =   240
         TabIndex        =   298
         Tag             =   "lbl_BOK_KostSt"
         Top             =   3600
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   77
         Left            =   240
         TabIndex        =   251
         Tag             =   "lbl_BOK_Priority"
         Top             =   2280
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   64
         Left            =   3840
         TabIndex        =   242
         Tag             =   "lbl_BOK_AgId"
         Top             =   3600
         Width           =   735
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#WghMax"
         Height          =   255
         Index           =   63
         Left            =   3360
         TabIndex        =   241
         Tag             =   "lbl_BOK_WghMax"
         Top             =   2760
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PkgHMax"
         Height          =   255
         Index           =   62
         Left            =   8280
         TabIndex        =   240
         Tag             =   "lbl_BOK_PkgHMax"
         Top             =   1800
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PkgBMax"
         Height          =   255
         Index           =   61
         Left            =   5760
         TabIndex        =   239
         Tag             =   "lbl_BOK_PkgBMax"
         Top             =   1800
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PkgAMax"
         Height          =   255
         Index           =   60
         Left            =   3360
         TabIndex        =   238
         Tag             =   "lbl_BOK_PkgAMax"
         Top             =   1800
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PRF Class"
         Height          =   255
         Index           =   58
         Left            =   240
         TabIndex        =   236
         Tag             =   "lbl_BOK_PRF_Class"
         Top             =   1800
         Width           =   1455
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Inlay Detail"
      Height          =   420
      Index           =   6
      Left            =   13695
      TabIndex        =   225
      Top             =   2925
      Width           =   1125
      Begin VB.TextBox txt_BOI_WghPnt1 
         Height          =   375
         Left            =   10440
         TabIndex        =   151
         Tag             =   "BOI_WghPnt1®©N"
         Top             =   4920
         Width           =   735
      End
      Begin VB.TextBox txt_BOI_WghPnt2 
         Height          =   375
         Left            =   10440
         TabIndex        =   155
         Tag             =   "BOI_WghPnt2®©N"
         Top             =   5400
         Width           =   735
      End
      Begin VB.TextBox txt_BOI_WghPnt3 
         Height          =   375
         Left            =   10440
         TabIndex        =   159
         Tag             =   "BOI_WghPnt3®©N"
         Top             =   5880
         Width           =   735
      End
      Begin MSComctlLib.ListView lv_CUT_Name 
         Height          =   1935
         Left            =   6600
         TabIndex        =   128
         Top             =   1320
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   3413
         View            =   2
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin MSComctlLib.ListView lv_INL_Name 
         Height          =   1932
         Left            =   3480
         TabIndex        =   127
         Top             =   1320
         Width           =   3012
         _ExtentX        =   5318
         _ExtentY        =   3413
         View            =   2
         LabelEdit       =   1
         LabelWrap       =   0   'False
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         FullRowSelect   =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   0
      End
      Begin MSComctlLib.ListView lv_PBordDesc 
         Height          =   1935
         Left            =   360
         TabIndex        =   126
         Top             =   1320
         Width           =   2895
         _ExtentX        =   5106
         _ExtentY        =   3413
         View            =   2
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin VB.TextBox txt_BOI_CUT_Name 
         Height          =   375
         Left            =   10440
         TabIndex        =   418
         Tag             =   "CUT_Name"
         Top             =   2520
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOI_INL_Name 
         Height          =   375
         Left            =   10440
         TabIndex        =   417
         Tag             =   "INL_Name"
         Top             =   2040
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOI_RPL_PBordDesc 
         Height          =   375
         Left            =   10440
         TabIndex        =   416
         Tag             =   "RPL_PBordDesc"
         Top             =   1560
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_PIN_Deliv 
         Height          =   345
         Left            =   1680
         TabIndex        =   130
         Tag             =   "PIN_Deliv®©PIN_DelivDesc"
         Top             =   3960
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PIN_Purch 
         Height          =   345
         Left            =   1680
         TabIndex        =   129
         Tag             =   "PIN_Purch®©PIN_PurchDesc"
         Top             =   3480
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   609
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   20
         Left            =   9360
         TabIndex        =   158
         Top             =   5880
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   19
         Left            =   9360
         TabIndex        =   154
         Top             =   5400
         Width           =   855
      End
      Begin VB.TextBox txt_BOI_FHMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   144
         Tag             =   "BOI_FHMax®©F"
         Top             =   4320
         Width           =   1095
      End
      Begin VB.TextBox txt_BOI_EHBMax 
         Height          =   375
         Left            =   6720
         TabIndex        =   143
         Tag             =   "BOI_EHBMax®©F"
         Top             =   4320
         Width           =   1095
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   5
         Left            =   9360
         TabIndex        =   150
         Top             =   4920
         Width           =   855
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   6
         Left            =   9120
         TabIndex        =   226
         TabStop         =   0   'False
         Tag             =   "BOI_Id"
         Top             =   480
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOI_PanAMax 
         Height          =   405
         Left            =   6720
         TabIndex        =   136
         Tag             =   "BOI_PanAMax®©F"
         Top             =   3360
         Width           =   1095
      End
      Begin VB.TextBox txt_BOI_PanBMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   138
         Tag             =   "BOI_PanBMax®©F"
         Top             =   3360
         Width           =   1095
      End
      Begin VB.TextBox txt_BOI_CHMax 
         Height          =   375
         Left            =   6720
         TabIndex        =   140
         Tag             =   "BOI_CHMax®©F"
         Top             =   3840
         Width           =   1095
      End
      Begin VB.TextBox txt_BOI_DHMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   142
         Tag             =   "BOI_DHMax®©F"
         Top             =   3840
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   5
         Left            =   4320
         TabIndex        =   148
         Tag             =   "BOI_AgId1®©AgId1_Desc"
         Top             =   4920
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   6
         Left            =   120
         TabIndex        =   125
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_PRF_Class 
         Height          =   345
         Index           =   2
         Left            =   4440
         TabIndex        =   132
         Tag             =   "PRF_Class®©PRF_Class"
         Top             =   3480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   5
         Left            =   4440
         TabIndex        =   134
         Tag             =   "BOI_Priority®©BOI_Priority"
         Top             =   3960
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   5
         Left            =   1680
         TabIndex        =   146
         Tag             =   "BOI_KostSt1®©KostSt1_Desc"
         Top             =   4920
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   19
         Left            =   1680
         TabIndex        =   152
         Tag             =   "BOI_KostSt2®©KostSt2_Desc"
         Top             =   5400
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   20
         Left            =   1680
         TabIndex        =   156
         Tag             =   "BOI_KostSt3®©KostSt3_Desc"
         Top             =   5880
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   19
         Left            =   4320
         TabIndex        =   153
         Tag             =   "BOI_AgId2®©AgId2_Desc"
         Top             =   5400
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   20
         Left            =   4320
         TabIndex        =   157
         Tag             =   "BOI_AgId3®©AgId3_Desc"
         Top             =   5880
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   6
         Left            =   10320
         TabIndex        =   232
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   73
         Left            =   10440
         TabIndex        =   565
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   4560
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#CUT Name"
         Height          =   255
         Index           =   138
         Left            =   6600
         TabIndex        =   421
         Tag             =   "lbl_BOI_CUT_Name"
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#INL Name"
         Height          =   255
         Index           =   137
         Left            =   3600
         TabIndex        =   420
         Tag             =   "lbl_BOI_INL_Name"
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PBordDesc"
         Height          =   255
         Index           =   136
         Left            =   360
         TabIndex        =   419
         Tag             =   "lbl_BOI_PBordDesc"
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PIN_Deliv"
         Height          =   255
         Index           =   135
         Left            =   240
         TabIndex        =   415
         Tag             =   "lbl_PIN_Deliv"
         Top             =   4080
         Width           =   1215
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PIN_Purch"
         Height          =   255
         Index           =   134
         Left            =   240
         TabIndex        =   414
         Tag             =   "lbl_PIN_Purch"
         Top             =   3600
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#FHMax"
         Height          =   255
         Index           =   53
         Left            =   8040
         TabIndex        =   411
         Tag             =   "lbl_Inl_FHMax"
         Top             =   4440
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#EHBMax"
         Height          =   255
         Index           =   52
         Left            =   5640
         TabIndex        =   409
         Tag             =   "lbl_Inl_EHBMax"
         Top             =   4440
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   103
         Left            =   240
         TabIndex        =   297
         Tag             =   "lbl_CostCentre"
         Top             =   5040
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   76
         Left            =   3480
         TabIndex        =   250
         Tag             =   "lbl_Inl_Priority"
         Top             =   4080
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PRF Class"
         Height          =   255
         Index           =   59
         Left            =   3480
         TabIndex        =   233
         Tag             =   "lbl_Inl_PRF_Class"
         Top             =   3600
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PanAMax"
         Height          =   255
         Index           =   57
         Left            =   5640
         TabIndex        =   231
         Tag             =   "lbl_Inl_PanAMax"
         Top             =   3480
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PanBMax"
         Height          =   255
         Index           =   56
         Left            =   8040
         TabIndex        =   230
         Tag             =   "lbl_Inl_PanBMax"
         Top             =   3480
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#CHMax"
         Height          =   255
         Index           =   55
         Left            =   5640
         TabIndex        =   229
         Tag             =   "lbl_Inl_CHMax"
         Top             =   3960
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#DHMax"
         Height          =   255
         Index           =   49
         Left            =   8040
         TabIndex        =   228
         Tag             =   "lbl_Inl_DHMax"
         Top             =   3960
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   46
         Left            =   3600
         TabIndex        =   227
         Tag             =   "lbl_Inl_AgId"
         Top             =   5040
         Width           =   735
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Packing Main"
      Height          =   252
      Index           =   7
      Left            =   120
      TabIndex        =   219
      Top             =   3600
      Width           =   1092
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   495
         Index           =   7
         Left            =   0
         TabIndex        =   221
         Top             =   960
         Width           =   2895
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   7
         Left            =   240
         TabIndex        =   220
         Top             =   2280
         Width           =   1215
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   7
         Left            =   3120
         TabIndex        =   222
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   7
         Left            =   120
         TabIndex        =   223
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   7
         Left            =   120
         TabIndex        =   224
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   7
         Left            =   3120
         TabIndex        =   292
         Tag             =   "grd_M_BOK"
         Top             =   1440
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Inlay Main"
      Height          =   252
      Index           =   6
      Left            =   120
      TabIndex        =   211
      Top             =   3240
      Width           =   972
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   495
         Index           =   6
         Left            =   0
         TabIndex        =   215
         Top             =   960
         Width           =   2895
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   6
         Left            =   240
         TabIndex        =   214
         Top             =   2280
         Width           =   1215
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   6
         Left            =   3120
         TabIndex        =   216
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   6
         Left            =   120
         TabIndex        =   217
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   6
         Left            =   120
         TabIndex        =   218
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   6
         Left            =   3120
         TabIndex        =   291
         Tag             =   "grd_M_BOI"
         Top             =   1440
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Gasket Detail"
      Height          =   255
      Index           =   5
      Left            =   13680
      TabIndex        =   190
      Top             =   2640
      Width           =   1095
      Begin VB.TextBox txt_BOG_WghPnt1 
         Height          =   375
         Left            =   10560
         TabIndex        =   189
         Tag             =   "BOG_WghPnt1®©N"
         Top             =   3240
         Width           =   735
      End
      Begin VB.TextBox txt_BOG_WghPnt2 
         Height          =   375
         Left            =   10560
         TabIndex        =   407
         Tag             =   "BOG_WghPnt2®©N"
         Top             =   3720
         Width           =   735
      End
      Begin VB.TextBox txt_BOG_WghPnt3 
         Height          =   375
         Left            =   10560
         TabIndex        =   413
         Tag             =   "BOG_WghPnt3®©N"
         Top             =   4200
         Width           =   735
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   18
         Left            =   9480
         TabIndex        =   412
         Top             =   4200
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   17
         Left            =   9480
         TabIndex        =   406
         Top             =   3720
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   4
         Left            =   9480
         TabIndex        =   187
         Top             =   3240
         Width           =   855
      End
      Begin VB.OptionButton opt_Type 
         Height          =   375
         Index           =   1
         Left            =   3360
         TabIndex        =   98
         Tag             =   "BOG_Type®©2"
         Top             =   1560
         Width           =   255
      End
      Begin VB.OptionButton opt_Type 
         Height          =   375
         Index           =   0
         Left            =   1800
         TabIndex        =   97
         Tag             =   "BOG_Type®©1"
         Top             =   1560
         Value           =   -1  'True
         Width           =   255
      End
      Begin VB.TextBox txt_BOG_PanBMax 
         Height          =   375
         Left            =   9120
         TabIndex        =   173
         Tag             =   "BOG_PanBMax®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txt_BOG_PanAMax 
         Height          =   405
         Left            =   6720
         TabIndex        =   171
         Tag             =   "BOG_PanAMax®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   5
         Left            =   9120
         TabIndex        =   202
         TabStop         =   0   'False
         Tag             =   "BOG_Id"
         Top             =   480
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   4
         Left            =   4440
         TabIndex        =   185
         Tag             =   "BOG_AgId1®©AgId1_Desc"
         Top             =   3240
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   5
         Left            =   120
         TabIndex        =   96
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_PRF_Class 
         Height          =   345
         Index           =   1
         Left            =   1800
         TabIndex        =   175
         Tag             =   "PRF_Class®©PRF_Class"
         Top             =   2040
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   4
         Left            =   1800
         TabIndex        =   177
         Tag             =   "BOG_Priority®©BOG_Priority"
         Top             =   2520
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   4
         Left            =   1800
         TabIndex        =   183
         Tag             =   "BOG_KostSt1®©KostSt1_Desc"
         Top             =   3240
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   17
         Left            =   1800
         TabIndex        =   404
         Tag             =   "BOG_KostSt2®©KostSt2_Desc"
         Top             =   3720
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   18
         Left            =   1800
         TabIndex        =   408
         Tag             =   "BOG_KostSt3®©KostSt3_Desc"
         Top             =   4200
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   17
         Left            =   4440
         TabIndex        =   405
         Tag             =   "BOG_AgId2®©AgId2_Desc"
         Top             =   3720
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   18
         Left            =   4440
         TabIndex        =   410
         Tag             =   "BOG_AgId3®©AgId3_Desc"
         Top             =   4200
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   5
         Left            =   10320
         TabIndex        =   205
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   72
         Left            =   10560
         TabIndex        =   564
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   2880
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   102
         Left            =   240
         TabIndex        =   296
         Tag             =   "lbl_CostCentre"
         Top             =   3360
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Spacer"
         Height          =   255
         Index           =   79
         Left            =   3600
         TabIndex        =   169
         Tag             =   "lbl_Gask_Spacer"
         Top             =   1680
         Width           =   1215
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Gasket"
         Height          =   255
         Index           =   78
         Left            =   2040
         TabIndex        =   167
         Tag             =   "lbl_Gask_Gasket"
         Top             =   1680
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   75
         Left            =   240
         TabIndex        =   249
         Tag             =   "lbl_Gask_Priority"
         Top             =   2640
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   54
         Left            =   3720
         TabIndex        =   208
         Tag             =   "lbl_Gask_AgId"
         Top             =   3360
         Width           =   735
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PanBMax"
         Height          =   255
         Index           =   51
         Left            =   8160
         TabIndex        =   207
         Tag             =   "lbl_Gask_PanBMax"
         Top             =   1680
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PanAMax"
         Height          =   255
         Index           =   50
         Left            =   5640
         TabIndex        =   206
         Tag             =   "lbl_Gask_PanAMax"
         Top             =   1680
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Type"
         Height          =   255
         Index           =   48
         Left            =   240
         TabIndex        =   204
         Tag             =   "lbl_Gask_Type"
         Top             =   1680
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#PRF Class"
         Height          =   255
         Index           =   47
         Left            =   240
         TabIndex        =   203
         Tag             =   "lbl_Gask_PRF_Class"
         Top             =   2160
         Width           =   1455
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Gasket Main"
      Height          =   252
      Index           =   5
      Left            =   240
      TabIndex        =   163
      Top             =   2880
      Width           =   1212
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   5
         Left            =   240
         TabIndex        =   165
         Top             =   2280
         Width           =   1215
      End
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   495
         Index           =   5
         Left            =   0
         TabIndex        =   164
         Top             =   960
         Width           =   2895
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   5
         Left            =   3120
         TabIndex        =   166
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   5
         Left            =   120
         TabIndex        =   168
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   5
         Left            =   120
         TabIndex        =   172
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   5
         Left            =   3120
         TabIndex        =   290
         Tag             =   "grd_M_BOG"
         Top             =   1440
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Coating Detail"
      Height          =   255
      Index           =   4
      Left            =   13800
      TabIndex        =   124
      Top             =   2280
      Width           =   1215
      Begin VB.TextBox txt_BOA_WghPnt1 
         Height          =   375
         Left            =   10560
         TabIndex        =   111
         Tag             =   "BOA_WghPnt1®©N"
         Top             =   3960
         Width           =   735
      End
      Begin VB.TextBox txt_BOA_WghPnt2 
         Height          =   375
         Left            =   10560
         TabIndex        =   115
         Tag             =   "BOA_WghPnt2®©N"
         Top             =   4440
         Width           =   735
      End
      Begin VB.TextBox txt_BOA_WghPnt3 
         Height          =   375
         Left            =   10560
         TabIndex        =   119
         Tag             =   "BOA_WghPnt3®©N"
         Top             =   4920
         Width           =   735
      End
      Begin Project1.ArmCombobox cbo_BOA_BndVis 
         Height          =   345
         Left            =   1800
         TabIndex        =   103
         Tag             =   "BOA_BndVis®©BOA_BndVis_Desc"
         Top             =   2520
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   13
         Left            =   9480
         TabIndex        =   118
         Top             =   4920
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   12
         Left            =   9480
         TabIndex        =   114
         Top             =   4440
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   3
         Left            =   9480
         TabIndex        =   110
         Top             =   3960
         Width           =   855
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   3
         Left            =   1800
         TabIndex        =   105
         Tag             =   "BOA_Priority®©BOA_Priority"
         Top             =   3480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_COA_Type 
         Height          =   345
         Left            =   1800
         TabIndex        =   104
         Tag             =   "COA_Type®©COA_Type_Desc"
         Top             =   3000
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOA_CoSid 
         Height          =   345
         Left            =   1800
         TabIndex        =   101
         Tag             =   "BOA_CoSid®©BOA_Side_Desc"
         Top             =   2040
         Width           =   1815
         _ExtentX        =   6165
         _ExtentY        =   609
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   4
         Left            =   9120
         TabIndex        =   131
         TabStop         =   0   'False
         Tag             =   "BOA_Id"
         Top             =   480
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BOA_PanAMax 
         Height          =   375
         Left            =   5400
         TabIndex        =   100
         Tag             =   "BOA_PanAMax®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txt_BOA_PanBMax 
         Height          =   375
         Left            =   5400
         TabIndex        =   102
         Tag             =   "BOA_PanBMax®©F"
         Top             =   2040
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   3
         Left            =   4440
         TabIndex        =   108
         Tag             =   "BOA_AgId1®©AgId1_Desc"
         Top             =   3960
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_PRF_Class 
         Height          =   345
         Index           =   0
         Left            =   1800
         TabIndex        =   99
         Tag             =   "PRF_Class®©PRF_Class"
         Top             =   1560
         Width           =   1815
         _ExtentX        =   6165
         _ExtentY        =   609
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   4
         Left            =   120
         TabIndex        =   88
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   3
         Left            =   1800
         TabIndex        =   106
         Tag             =   "BOA_KostSt1®©KostSt1_Desc"
         Top             =   3960
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   12
         Left            =   1800
         TabIndex        =   112
         Tag             =   "BOA_KostSt2®©KostSt2_Desc"
         Top             =   4440
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   13
         Left            =   1800
         TabIndex        =   116
         Tag             =   "BOA_KostSt3®©KostSt3_Desc"
         Top             =   4920
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   12
         Left            =   4440
         TabIndex        =   113
         Tag             =   "BOA_AgId2®©AgId2_Desc"
         Top             =   4440
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   13
         Left            =   4440
         TabIndex        =   117
         Tag             =   "BOA_AgId3®©AgId3_Desc"
         Top             =   4920
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   4
         Left            =   10320
         TabIndex        =   141
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   71
         Left            =   10560
         TabIndex        =   563
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   3600
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   101
         Left            =   240
         TabIndex        =   295
         Tag             =   "lbl_CostCentre"
         Top             =   4080
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   74
         Left            =   240
         TabIndex        =   248
         Tag             =   "lbl_Coat_Priority"
         Top             =   3600
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Visible Side"
         Height          =   255
         Index           =   45
         Left            =   240
         TabIndex        =   160
         Tag             =   "lbl_Coat_HasVSide"
         Top             =   2640
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#COA Type"
         Height          =   255
         Index           =   43
         Left            =   240
         TabIndex        =   147
         Tag             =   "lbl_COA_Type"
         Top             =   3120
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Coating Side"
         Height          =   255
         Index           =   38
         Left            =   240
         TabIndex        =   145
         Tag             =   "lbl_Coat_Side"
         Top             =   2160
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Perf Class"
         Height          =   255
         Index           =   44
         Left            =   240
         TabIndex        =   139
         Tag             =   "lbl_Coat_Prf"
         Top             =   1680
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AMax"
         Height          =   255
         Index           =   41
         Left            =   4440
         TabIndex        =   137
         Tag             =   "lbl_Coat_AMax"
         Top             =   1680
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BMax"
         Height          =   255
         Index           =   39
         Left            =   4440
         TabIndex        =   135
         Tag             =   "lbl_Coat_BMax"
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   33
         Left            =   3720
         TabIndex        =   133
         Tag             =   "lbl_Coat_AgId"
         Top             =   4080
         Width           =   855
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Coating Main"
      Height          =   252
      Index           =   4
      Left            =   240
      TabIndex        =   107
      Top             =   2520
      Width           =   1212
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   495
         Index           =   4
         Left            =   0
         TabIndex        =   120
         Top             =   960
         Width           =   2895
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   4
         Left            =   240
         TabIndex        =   109
         Top             =   2280
         Width           =   1215
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   4
         Left            =   3120
         TabIndex        =   121
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   4
         Left            =   120
         TabIndex        =   122
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   4
         Left            =   120
         TabIndex        =   123
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   4
         Left            =   3120
         TabIndex        =   289
         Tag             =   "grd_M_BOA"
         Top             =   1440
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "PunchNotch Detail"
      Height          =   330
      Index           =   3
      Left            =   13800
      TabIndex        =   84
      Top             =   1890
      Width           =   1305
      Begin VB.TextBox txt_BPN_WghPnt1 
         Height          =   375
         Left            =   11040
         TabIndex        =   452
         Tag             =   "BPN_WghPnt1®©N"
         Top             =   6000
         Width           =   735
      End
      Begin VB.TextBox txt_BPN_WghPnt2 
         Height          =   375
         Left            =   11040
         TabIndex        =   457
         Tag             =   "BPN_WghPnt2®©N"
         Top             =   6480
         Width           =   735
      End
      Begin VB.TextBox txt_BPN_WghPnt3 
         Height          =   375
         Left            =   11040
         TabIndex        =   461
         Tag             =   "BPN_WghPnt3®©N"
         Top             =   6960
         Width           =   735
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   24
         Left            =   9840
         TabIndex        =   460
         Top             =   6960
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   23
         Left            =   9840
         TabIndex        =   456
         Top             =   6480
         Width           =   855
      End
      Begin VB.TextBox txt_BPN_DMax 
         Height          =   405
         Left            =   6360
         TabIndex        =   444
         Tag             =   "BPN_DMax®©F"
         Top             =   4920
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_KMax 
         Height          =   405
         Left            =   3960
         TabIndex        =   442
         Tag             =   "BPN_KMax®©F"
         Top             =   4920
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_JMax 
         Height          =   405
         Left            =   1560
         TabIndex        =   440
         Tag             =   "BPN_JMax®©F"
         Top             =   4920
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_CutBMax 
         Height          =   405
         Left            =   8640
         TabIndex        =   437
         Tag             =   "BPN_CutBMax®©F"
         Top             =   4440
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_CutBMin 
         Height          =   405
         Left            =   6360
         TabIndex        =   436
         Tag             =   "BPN_CutBMin®©F"
         Top             =   4440
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_CutAMax 
         Height          =   405
         Left            =   3960
         TabIndex        =   434
         Tag             =   "BPN_CutAMax®©F"
         Top             =   4440
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_CutAMin 
         Height          =   405
         Left            =   1560
         TabIndex        =   433
         Tag             =   "BPN_CutAMin®©F"
         Top             =   4440
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_MAT_Name 
         Height          =   375
         Left            =   9840
         TabIndex        =   430
         Tag             =   "MAT_Name"
         Top             =   2400
         Visible         =   0   'False
         Width           =   1335
      End
      Begin VB.TextBox txt_BPN_PRF_Name 
         Height          =   375
         Left            =   9840
         TabIndex        =   429
         Tag             =   "PRF_Name"
         Top             =   1920
         Visible         =   0   'False
         Width           =   1335
      End
      Begin VB.TextBox txt_BPN_SYS_Name 
         Height          =   375
         Left            =   9840
         TabIndex        =   428
         Tag             =   "SYS_Name"
         Top             =   1440
         Visible         =   0   'False
         Width           =   1335
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   2
         Left            =   9840
         TabIndex        =   451
         Top             =   6000
         Width           =   855
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   3
         Left            =   9840
         TabIndex        =   85
         TabStop         =   0   'False
         Tag             =   "BPN_Id"
         Top             =   480
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_QtyMin 
         Height          =   405
         Left            =   6360
         TabIndex        =   447
         Tag             =   "BPN_QtyMin®©F"
         Top             =   5400
         Width           =   1095
      End
      Begin VB.TextBox txt_BPN_QtyMax 
         Height          =   375
         Left            =   8640
         TabIndex        =   448
         Tag             =   "BPN_QtyMax®©F"
         Top             =   5400
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   2
         Left            =   4680
         TabIndex        =   450
         Tag             =   "BPN_AgId1®©AgId1_Desc"
         Top             =   6000
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_Cutout 
         Height          =   345
         Left            =   1560
         TabIndex        =   78
         Tag             =   "CUT_Id®©CUT_Name"
         Top             =   3960
         Width           =   3135
         _ExtentX        =   5530
         _ExtentY        =   609
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   3
         Left            =   120
         TabIndex        =   77
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   2
         Left            =   1560
         TabIndex        =   446
         Tag             =   "BPN_Priority®©BPN_Priority"
         Top             =   5400
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   2
         Left            =   1560
         TabIndex        =   449
         Tag             =   "BPN_KostSt1®©KostSt1_Desc"
         Top             =   6000
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmTreeView tvw_Detail 
         Height          =   2415
         Index           =   1
         Left            =   240
         TabIndex        =   426
         Top             =   1320
         Width           =   3255
         _ExtentX        =   5741
         _ExtentY        =   4260
      End
      Begin MSComctlLib.ListView lv_Materials 
         Height          =   2415
         Index           =   3
         Left            =   6960
         TabIndex        =   427
         Top             =   1320
         Width           =   2775
         _ExtentX        =   4895
         _ExtentY        =   4260
         View            =   2
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   23
         Left            =   1560
         TabIndex        =   453
         Tag             =   "BPN_KostSt2®©KostSt2_Desc"
         Top             =   6480
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   24
         Left            =   1560
         TabIndex        =   458
         Tag             =   "BPN_KostSt3®©KostSt3_Desc"
         Top             =   6960
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   23
         Left            =   4680
         TabIndex        =   455
         Tag             =   "BPN_AgId2®©AgId2_Desc"
         Top             =   6480
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   24
         Left            =   4680
         TabIndex        =   459
         Tag             =   "BPN_AgId3®©AgId3_Desc"
         Top             =   6960
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ArmTreeView tvw_Detail 
         Height          =   2415
         Index           =   2
         Left            =   3600
         TabIndex        =   454
         Top             =   1320
         Width           =   3255
         _ExtentX        =   5741
         _ExtentY        =   4260
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   3
         Left            =   11040
         TabIndex        =   93
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   70
         Left            =   11040
         TabIndex        =   562
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   5640
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#DMax"
         Height          =   255
         Index           =   150
         Left            =   5280
         TabIndex        =   445
         Tag             =   "lbl_BPN_DMax"
         Top             =   5040
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#KMax"
         Height          =   255
         Index           =   149
         Left            =   2880
         TabIndex        =   443
         Tag             =   "lbl_BPN_KMax"
         Top             =   5040
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#JMax"
         Height          =   255
         Index           =   148
         Left            =   240
         TabIndex        =   441
         Tag             =   "lbl_BPN_JMax"
         Top             =   5040
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#CutBMax"
         Height          =   255
         Index           =   147
         Left            =   7680
         TabIndex        =   439
         Tag             =   "lbl_BPN_CutBMax"
         Top             =   4560
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#CutBMin"
         Height          =   255
         Index           =   146
         Left            =   5280
         TabIndex        =   438
         Tag             =   "lbl_BPN_CutBMin"
         Top             =   4560
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#CutAMax"
         Height          =   255
         Index           =   145
         Left            =   2880
         TabIndex        =   435
         Tag             =   "lbl_BPN_CutAMax"
         Top             =   4560
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Materials"
         Height          =   255
         Index           =   144
         Left            =   7080
         TabIndex        =   432
         Tag             =   "lbl_BPN_Materials"
         Top             =   1080
         Width           =   1215
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Perforations"
         Height          =   255
         Index           =   143
         Left            =   3720
         TabIndex        =   431
         Tag             =   "lbl_BPN_Perforations"
         Top             =   1080
         Width           =   1215
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   100
         Left            =   240
         TabIndex        =   294
         Tag             =   "lbl_BPN_KostSt"
         Top             =   6000
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Systems"
         Height          =   255
         Index           =   32
         Left            =   240
         TabIndex        =   95
         Tag             =   "lbl_BPN_Systems"
         Top             =   1080
         Width           =   1215
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cut"
         Height          =   255
         Index           =   37
         Left            =   240
         TabIndex        =   92
         Tag             =   "lbl_BPN_CutName"
         Top             =   3960
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#CutAMin"
         Height          =   255
         Index           =   36
         Left            =   240
         TabIndex        =   91
         Tag             =   "lbl_BPN_CutAMin"
         Top             =   4560
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Qty Min"
         Height          =   255
         Index           =   35
         Left            =   5280
         TabIndex        =   90
         Tag             =   "lbl_BPN_QtyMin"
         Top             =   5520
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Qty Max"
         Height          =   255
         Index           =   34
         Left            =   7680
         TabIndex        =   89
         Tag             =   "lbl_BPN_QtyMax"
         Top             =   5520
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   31
         Left            =   240
         TabIndex        =   87
         Tag             =   "lbl_BPN_Priority"
         Top             =   5520
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   30
         Left            =   3840
         TabIndex        =   86
         Tag             =   "lbl_BPN_AgId"
         Top             =   6000
         Width           =   735
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "PunchNotch Main"
      Height          =   252
      Index           =   3
      Left            =   240
      TabIndex        =   76
      Top             =   2160
      Width           =   1452
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   3
         Left            =   240
         TabIndex        =   80
         Top             =   2280
         Width           =   1215
      End
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   1095
         Index           =   3
         Left            =   0
         TabIndex        =   79
         Top             =   360
         Width           =   2895
         Begin Project1.ArmCombobox cbo_MAT_Filter 
            Height          =   345
            Index           =   0
            Left            =   120
            TabIndex        =   254
            Tag             =   "MAT_Id®©MAT_Name"
            Top             =   600
            Width           =   2655
            _ExtentX        =   4683
            _ExtentY        =   609
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Material filter"
            Height          =   255
            Index           =   90
            Left            =   120
            TabIndex        =   253
            Tag             =   "lbl_BOR_Mat_Filter"
            Top             =   360
            Width           =   2175
         End
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   3
         Left            =   3120
         TabIndex        =   81
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   3
         Left            =   120
         TabIndex        =   82
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   3
         Left            =   120
         TabIndex        =   83
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   3
         Left            =   3120
         TabIndex        =   288
         Tag             =   "grd_M_BPN"
         Top             =   1440
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Perf Detail"
      Height          =   255
      Index           =   1
      Left            =   13800
      TabIndex        =   37
      Top             =   1200
      Width           =   1095
      Begin VB.TextBox txt_BOP_WghPnt3 
         Height          =   375
         Left            =   11040
         TabIndex        =   69
         Tag             =   "BOP_WghPnt3®©N"
         Top             =   5040
         Width           =   735
      End
      Begin VB.TextBox txt_BOP_WghPnt2 
         Height          =   375
         Left            =   11040
         TabIndex        =   65
         Tag             =   "BOP_WghPnt2®©N"
         Top             =   4560
         Width           =   735
      End
      Begin VB.TextBox txt_BOP_WghPnt1 
         Height          =   375
         Left            =   11040
         TabIndex        =   61
         Tag             =   "BOP_WghPnt1®©N"
         Top             =   4080
         Width           =   735
      End
      Begin MSComctlLib.ListView lv_Materials 
         Height          =   2415
         Index           =   0
         Left            =   3480
         TabIndex        =   39
         Top             =   1440
         Width           =   2535
         _ExtentX        =   4471
         _ExtentY        =   4260
         View            =   2
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin VB.TextBox txt_BOR_PRF_SYS_Name 
         Height          =   375
         Left            =   10920
         TabIndex        =   305
         Tag             =   "SYS_Name"
         Top             =   2040
         Visible         =   0   'False
         Width           =   1335
      End
      Begin VB.TextBox txt_BOR_PRF_MAT_Name 
         Height          =   375
         Left            =   10920
         TabIndex        =   304
         Tag             =   "MAT_Name"
         Top             =   1560
         Visible         =   0   'False
         Width           =   1335
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   8
         Left            =   9960
         TabIndex        =   68
         Top             =   5040
         Width           =   855
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   7
         Left            =   9960
         TabIndex        =   64
         Top             =   4560
         Width           =   855
      End
      Begin VB.TextBox txt_BOP_ThsMax 
         Height          =   375
         Left            =   9720
         TabIndex        =   43
         Tag             =   "BOP_ThsMax®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txt_BOP_ThsMin 
         Height          =   375
         Left            =   7320
         TabIndex        =   42
         Tag             =   "BOP_ThsMin®©F"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txt_BOP_BMax 
         Height          =   375
         Left            =   9720
         TabIndex        =   49
         Tag             =   "BOP_CutBMax®©F"
         Top             =   2520
         Width           =   1095
      End
      Begin VB.TextBox txt_BOP_BMin 
         Height          =   375
         Left            =   7320
         TabIndex        =   48
         Tag             =   "BOP_CutBMin®©F"
         Top             =   2520
         Width           =   1095
      End
      Begin Project1.ArmTreeView tvw_Detail 
         Height          =   2415
         Index           =   0
         Left            =   120
         TabIndex        =   38
         Top             =   1440
         Width           =   3255
         _ExtentX        =   5741
         _ExtentY        =   4260
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   0
         Left            =   1920
         TabIndex        =   57
         Tag             =   "BOP_KostSt1®©KostSt1_Desc"
         Top             =   4080
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin VB.CommandButton cmd_AgIdSearch 
         Caption         =   "..."
         Height          =   375
         Index           =   0
         Left            =   9960
         TabIndex        =   60
         Top             =   4080
         Width           =   855
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   0
         Left            =   4800
         TabIndex        =   59
         Tag             =   "BOP_AgId1®©AgId1_Desc"
         Top             =   4080
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin VB.TextBox txt_BOP_AMax 
         Height          =   375
         Left            =   9720
         TabIndex        =   47
         Tag             =   "BOP_CutAMax®©F"
         Top             =   2040
         Width           =   1095
      End
      Begin VB.TextBox txt_BOP_AMin 
         Height          =   375
         Left            =   7320
         TabIndex        =   45
         Tag             =   "BOP_CutAMin®©F"
         Top             =   2040
         Width           =   1095
      End
      Begin VB.TextBox txt_BOP_QtyMax 
         Height          =   375
         Left            =   9720
         TabIndex        =   53
         Tag             =   "BOP_QtyMax®©N"
         Top             =   3000
         Width           =   1095
      End
      Begin VB.TextBox txt_BOP_QtyMin 
         Height          =   405
         Left            =   7320
         TabIndex        =   51
         Tag             =   "BOP_QtyMin®©N"
         Top             =   3000
         Width           =   1095
      End
      Begin Project1.ArmCombobox cbo_Perf 
         Height          =   345
         Index           =   1
         Left            =   7320
         TabIndex        =   41
         Tag             =   "PRF_Id®©PRF_Name"
         Top             =   1080
         Width           =   3495
         _ExtentX        =   6165
         _ExtentY        =   609
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   1
         Left            =   10920
         TabIndex        =   40
         TabStop         =   0   'False
         Tag             =   "BOP_Id"
         Top             =   1080
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   1
         Left            =   120
         TabIndex        =   34
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   0
         Left            =   7320
         TabIndex        =   55
         Tag             =   "BOP_Priority®©BOP_Priority"
         Top             =   3480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   7
         Left            =   1920
         TabIndex        =   62
         Tag             =   "BOP_KostSt2®©KostSt2_Desc"
         Top             =   4560
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_KostSt_Filter 
         Height          =   345
         Index           =   8
         Left            =   1920
         TabIndex        =   66
         Tag             =   "BOP_KostSt3®©KostSt3_Desc"
         Top             =   5040
         Width           =   1815
         _ExtentX        =   3201
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   7
         Left            =   4800
         TabIndex        =   63
         Tag             =   "BOP_AgId2®©AgId2_Desc"
         Top             =   4560
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
         Height          =   345
         Index           =   8
         Left            =   4800
         TabIndex        =   67
         Tag             =   "BOP_AgId3®©AgId3_Desc"
         Top             =   5040
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   609
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   1
         Left            =   10320
         TabIndex        =   44
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Weighting points"
         Height          =   255
         Index           =   68
         Left            =   11040
         TabIndex        =   560
         Tag             =   "lbl_BOP_WghPnt"
         Top             =   3720
         Width           =   1335
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ThsMax"
         Height          =   255
         Index           =   109
         Left            =   8760
         TabIndex        =   303
         Tag             =   "lbl_BOR_Perf_ThsMax"
         Top             =   1680
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#ThsMin"
         Height          =   255
         Index           =   108
         Left            =   6360
         TabIndex        =   302
         Tag             =   "lbl_BOR_Perf_ThsMin"
         Top             =   1680
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BMax"
         Height          =   255
         Index           =   107
         Left            =   8760
         TabIndex        =   301
         Tag             =   "lbl_BOR_Perf_BMax"
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BMin"
         Height          =   255
         Index           =   106
         Left            =   6360
         TabIndex        =   300
         Tag             =   "lbl_BOR_Perf_BMin"
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Cost Centre"
         Height          =   255
         Index           =   99
         Left            =   480
         TabIndex        =   293
         Tag             =   "lbl_CostCentre"
         Top             =   4200
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AgId"
         Height          =   255
         Index           =   29
         Left            =   3840
         TabIndex        =   75
         Tag             =   "lbl_BOR_Perf_AgId"
         Top             =   4200
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Priority"
         Height          =   255
         Index           =   28
         Left            =   6360
         TabIndex        =   74
         Tag             =   "lbl_BOR_Perf_Priority"
         Top             =   3600
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AMax"
         Height          =   255
         Index           =   27
         Left            =   8760
         TabIndex        =   73
         Tag             =   "lbl_BOR_Perf_AMax"
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#AMin"
         Height          =   255
         Index           =   26
         Left            =   6360
         TabIndex        =   72
         Tag             =   "lbl_BOR_Perf_AMin"
         Top             =   2160
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMax"
         Height          =   255
         Index           =   25
         Left            =   8760
         TabIndex        =   58
         Tag             =   "lbl_BOR_Perf_QtyMax"
         Top             =   3120
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#QtyMin"
         Height          =   255
         Index           =   24
         Left            =   6360
         TabIndex        =   54
         Tag             =   "lbl_BOR_Perf_QtyMin"
         Top             =   3120
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Material"
         Height          =   255
         Index           =   23
         Left            =   3480
         TabIndex        =   52
         Tag             =   "lbl_BOR_Perf_Mat"
         Top             =   1080
         Width           =   1455
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Perf"
         Height          =   255
         Index           =   22
         Left            =   6360
         TabIndex        =   50
         Tag             =   "lbl_BOR_Perf_Prf"
         Top             =   1200
         Width           =   975
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#System"
         Height          =   255
         Index           =   21
         Left            =   120
         TabIndex        =   46
         Tag             =   "lbl_BOR_Perf_System"
         Top             =   1080
         Width           =   1575
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Bend Main"
      Height          =   252
      Index           =   2
      Left            =   240
      TabIndex        =   29
      Top             =   1800
      Width           =   972
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   1095
         Index           =   2
         Left            =   0
         TabIndex        =   31
         Top             =   360
         Width           =   2895
         Begin Project1.ArmCombobox cbo_System_Filter 
            Height          =   345
            Index           =   1
            Left            =   120
            TabIndex        =   246
            Tag             =   "SYS_Id®©SYS_Name"
            Top             =   600
            Width           =   2655
            _ExtentX        =   4683
            _ExtentY        =   609
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#System filter"
            Height          =   255
            Index           =   66
            Left            =   120
            TabIndex        =   245
            Tag             =   "lbl_BOR_Sys_Filter"
            Top             =   360
            Width           =   1575
         End
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   2
         Left            =   240
         TabIndex        =   30
         Top             =   2280
         Width           =   1215
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   2
         Left            =   3120
         TabIndex        =   32
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   2
         Left            =   120
         TabIndex        =   33
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   2
         Left            =   120
         TabIndex        =   35
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   2
         Left            =   3120
         TabIndex        =   287
         Tag             =   "grd_M_BOB"
         Top             =   1440
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "OperCost Detail"
      Height          =   405
      Index           =   0
      Left            =   13290
      TabIndex        =   18
      Top             =   735
      Width           =   1650
      Begin VB.Frame fra_SubDetail 
         Height          =   3495
         Index           =   0
         Left            =   120
         TabIndex        =   25
         Top             =   1200
         Width           =   10215
         Begin Project1.ArmGrid grd_SubDetail 
            Height          =   1215
            Index           =   0
            Left            =   240
            TabIndex        =   23
            Top             =   1320
            Width           =   5055
            _ExtentX        =   8916
            _ExtentY        =   2143
         End
         Begin VB.TextBox txt_SubDetailKey 
            Height          =   285
            Index           =   0
            Left            =   2760
            TabIndex        =   27
            TabStop         =   0   'False
            Tag             =   "RF_Code"
            Top             =   120
            Visible         =   0   'False
            Width           =   1215
         End
         Begin VB.Frame fra_SubDetailItem 
            Height          =   735
            Index           =   0
            Left            =   240
            TabIndex        =   26
            Top             =   480
            Width           =   8655
            Begin Project1.ArmCombobox cbo_KostSt 
               Height          =   345
               Left            =   1680
               TabIndex        =   22
               Tag             =   "BOC_KostSt®©BOC_KostSt_Desc"
               Top             =   240
               Width           =   6810
               _ExtentX        =   12012
               _ExtentY        =   609
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#AgId"
               Height          =   255
               Index           =   67
               Left            =   120
               TabIndex        =   247
               Tag             =   "lbl_CategCost_AgId"
               Top             =   360
               Width           =   1335
            End
         End
         Begin Project1.ToolbarControl tlb_SubDetail 
            Height          =   2730
            Index           =   0
            Left            =   9240
            TabIndex        =   24
            Top             =   360
            Width           =   690
            _ExtentX        =   1217
            _ExtentY        =   1217
         End
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   0
         Left            =   9120
         TabIndex        =   19
         TabStop         =   0   'False
         Tag             =   "RF_code"
         Top             =   480
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   0
         Left            =   120
         TabIndex        =   21
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   0
         Left            =   10320
         TabIndex        =   20
         TabStop         =   0   'False
         Top             =   480
         Visible         =   0   'False
         Width           =   495
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "Perf Main"
      Height          =   252
      Index           =   1
      Left            =   240
      TabIndex        =   12
      Top             =   1440
      Width           =   972
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   1
         Left            =   240
         TabIndex        =   14
         Top             =   3000
         Width           =   1215
      End
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   1935
         Index           =   1
         Left            =   0
         TabIndex        =   13
         Top             =   360
         Width           =   2895
         Begin Project1.ArmCombobox cbo_System_Filter 
            Height          =   345
            Index           =   0
            Left            =   120
            TabIndex        =   243
            Tag             =   "SYS_Id®©SYS_Name"
            Top             =   600
            Width           =   2655
            _ExtentX        =   4683
            _ExtentY        =   609
         End
         Begin Project1.ArmCombobox cbo_Vendor_Filter 
            Height          =   345
            Index           =   1
            Left            =   120
            TabIndex        =   570
            Tag             =   "VEN_Id®©VEN_Name"
            Top             =   1440
            Visible         =   0   'False
            Width           =   2655
            _ExtentX        =   4683
            _ExtentY        =   609
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#Vendor filter"
            Height          =   255
            Index           =   83
            Left            =   120
            TabIndex        =   569
            Tag             =   "lbl_BOR_Ven_Filter"
            Top             =   1080
            Visible         =   0   'False
            Width           =   1575
         End
         Begin VB.Label lbl_Label 
            Caption         =   "#System filter"
            Height          =   255
            Index           =   65
            Left            =   120
            TabIndex        =   244
            Tag             =   "lbl_BOR_Sys_Filter"
            Top             =   360
            Width           =   1575
         End
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   1
         Left            =   3120
         TabIndex        =   15
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   1
         Left            =   120
         TabIndex        =   16
         Top             =   2880
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   1
         Left            =   120
         TabIndex        =   17
         Top             =   2400
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   1
         Left            =   3120
         TabIndex        =   286
         Tag             =   "grd_M_BOP"
         Top             =   1560
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin VB.Frame fra_DetailItem 
      Caption         =   "Bend Detail"
      Height          =   252
      Index           =   2
      Left            =   13800
      TabIndex        =   8
      Tag             =   "DPC_SysCategory"
      Top             =   1560
      Width           =   1092
      Begin VB.TextBox txt_BOB_SYS_Name 
         Height          =   375
         Left            =   9000
         TabIndex        =   469
         TabStop         =   0   'False
         Tag             =   "SYS_Name"
         Top             =   1080
         Visible         =   0   'False
         Width           =   855
      End
      Begin MSComctlLib.TabStrip tbs_SubDetail 
         Height          =   375
         Index           =   0
         Left            =   360
         TabIndex        =   468
         Tag             =   "tbs_BOR_BND_D"
         Top             =   2520
         Width           =   12855
         _ExtentX        =   22675
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
            NumTabs         =   2
            BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               Caption         =   "#DPC_BOR_Bend_Spec"
               Key             =   "spc"
               ImageVarType    =   2
            EndProperty
            BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               Caption         =   "#DPC_BOR_Bend_Param"
               Key             =   "prm"
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
      Begin VB.TextBox txt_BOB_Name 
         Height          =   375
         Left            =   5400
         MaxLength       =   50
         TabIndex        =   465
         Tag             =   "BOB_Name"
         Top             =   1560
         Width           =   3495
      End
      Begin VB.Frame fra_SubDetail 
         Height          =   5415
         Index           =   2
         Left            =   1920
         TabIndex        =   267
         Top             =   3000
         Width           =   12615
         Begin VB.TextBox txt_SubDetailKey 
            Height          =   285
            Index           =   2
            Left            =   3240
            TabIndex        =   280
            TabStop         =   0   'False
            Tag             =   "BOE_Id"
            Top             =   120
            Visible         =   0   'False
            Width           =   1215
         End
         Begin VB.Frame fra_SubDetailItem 
            Height          =   3975
            Index           =   2
            Left            =   120
            TabIndex        =   268
            Top             =   120
            Width           =   11775
            Begin VB.TextBox txt_BOE_WghPnt1 
               Height          =   315
               Left            =   10320
               TabIndex        =   551
               Tag             =   "BOE_WghPnt1®©N"
               Top             =   2760
               Width           =   735
            End
            Begin VB.TextBox txt_BOE_WghPnt2 
               Height          =   315
               Left            =   10320
               TabIndex        =   555
               Tag             =   "BOE_WghPnt2®©N"
               Top             =   3120
               Width           =   735
            End
            Begin VB.TextBox txt_BOE_WghPnt3 
               Height          =   315
               Left            =   10320
               TabIndex        =   559
               Tag             =   "BOE_WghPnt3®©N"
               Top             =   3480
               Width           =   735
            End
            Begin VB.CommandButton cmd_AgIdSearch 
               Caption         =   "..."
               Height          =   375
               Index           =   26
               Left            =   9360
               TabIndex        =   558
               Top             =   3480
               Width           =   855
            End
            Begin VB.CommandButton cmd_AgIdSearch 
               Caption         =   "..."
               Height          =   375
               Index           =   25
               Left            =   9360
               TabIndex        =   554
               Top             =   3120
               Width           =   855
            End
            Begin VB.Frame frm_sub 
               Height          =   2175
               Index           =   3
               Left            =   8520
               TabIndex        =   501
               Top             =   120
               Width           =   2775
               Begin VB.TextBox txt_BOE_FHMax 
                  Height          =   315
                  Left            =   1800
                  TabIndex        =   541
                  Tag             =   "BOE_FHMax®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_FHMin 
                  Height          =   315
                  Left            =   960
                  TabIndex        =   540
                  Tag             =   "BOE_FHMin®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_FUZMax 
                  Height          =   315
                  Left            =   1800
                  TabIndex        =   543
                  Tag             =   "BOE_FUZMax®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_FUZMin 
                  Height          =   315
                  Left            =   960
                  TabIndex        =   542
                  Tag             =   "BOE_FUZMin®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_FSMin 
                  Height          =   315
                  Left            =   960
                  TabIndex        =   544
                  Tag             =   "BOE_FSMin®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_FSMax 
                  Height          =   315
                  Left            =   1800
                  TabIndex        =   545
                  Tag             =   "BOE_FSMax®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin Project1.ArmCombobox cbo_Bending 
                  Height          =   345
                  Index           =   3
                  Left            =   960
                  TabIndex        =   539
                  Tag             =   "BND_IdF®©BND_NameF"
                  Top             =   240
                  Width           =   1575
                  _ExtentX        =   2778
                  _ExtentY        =   609
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Bnd F"
                  Height          =   255
                  Index           =   164
                  Left            =   120
                  TabIndex        =   507
                  Tag             =   "lbl_BOE_BndF"
                  Top             =   240
                  Width           =   855
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Max"
                  Height          =   255
                  Index           =   163
                  Left            =   1920
                  TabIndex        =   506
                  Tag             =   "lbl_BOE_Max"
                  Top             =   720
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Min"
                  Height          =   255
                  Index           =   162
                  Left            =   1080
                  TabIndex        =   505
                  Tag             =   "lbl_BOE_Min"
                  Top             =   720
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#H"
                  Height          =   255
                  Index           =   161
                  Left            =   120
                  TabIndex        =   504
                  Tag             =   "lbl_BOE_H"
                  Top             =   1080
                  Width           =   495
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#U/Z"
                  Height          =   255
                  Index           =   160
                  Left            =   120
                  TabIndex        =   503
                  Tag             =   "lbl_BOE_UZ"
                  Top             =   1440
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#S"
                  Height          =   255
                  Index           =   159
                  Left            =   120
                  TabIndex        =   502
                  Tag             =   "lbl_BOE_S"
                  Top             =   1800
                  Width           =   495
               End
            End
            Begin VB.Frame frm_sub 
               Height          =   2535
               Index           =   1
               Left            =   2880
               TabIndex        =   477
               Top             =   120
               Width           =   2655
               Begin VB.TextBox txt_BOE_DHMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   524
                  Tag             =   "BOE_DHMax®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_DHMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   522
                  Tag             =   "BOE_DHMin®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_DFMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   527
                  Tag             =   "BOE_DFMax®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_DFMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   526
                  Tag             =   "BOE_DFMin®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_DUZMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   529
                  Tag             =   "BOE_DUZMax®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_DUZMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   528
                  Tag             =   "BOE_DUZMin®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_DSMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   530
                  Tag             =   "BOE_DSMin®©F"
                  Top             =   2040
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_DSMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   531
                  Tag             =   "BOE_DSMax®©F"
                  Top             =   2040
                  Width           =   735
               End
               Begin Project1.ArmCombobox cbo_Bending 
                  Height          =   345
                  Index           =   1
                  Left            =   840
                  TabIndex        =   520
                  Tag             =   "BND_IdD®©BND_NameD"
                  Top             =   240
                  Width           =   1695
                  _ExtentX        =   2990
                  _ExtentY        =   609
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Max"
                  Height          =   255
                  Index           =   158
                  Left            =   1800
                  TabIndex        =   495
                  Tag             =   "lbl_BOE_Max"
                  Top             =   720
                  Width           =   735
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Min"
                  Height          =   255
                  Index           =   157
                  Left            =   960
                  TabIndex        =   494
                  Tag             =   "lbl_BOE_Min"
                  Top             =   720
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#H"
                  Height          =   255
                  Index           =   156
                  Left            =   120
                  TabIndex        =   493
                  Tag             =   "lbl_BOE_H"
                  Top             =   1080
                  Width           =   495
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Bnd D"
                  Height          =   255
                  Index           =   155
                  Left            =   120
                  TabIndex        =   492
                  Tag             =   "lbl_BOE_BndD"
                  Top             =   240
                  Width           =   735
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#U/Z"
                  Height          =   255
                  Index           =   154
                  Left            =   120
                  TabIndex        =   491
                  Tag             =   "lbl_BOE_UZ"
                  Top             =   1800
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#f"
                  Height          =   255
                  Index           =   153
                  Left            =   120
                  TabIndex        =   490
                  Tag             =   "lbl_BOE_f"
                  Top             =   1440
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#S"
                  Height          =   255
                  Index           =   152
                  Left            =   120
                  TabIndex        =   489
                  Tag             =   "lbl_BOE_S"
                  Top             =   2160
                  Width           =   495
               End
            End
            Begin VB.TextBox txt_BOE_QtyMax 
               Height          =   285
               Left            =   8400
               TabIndex        =   547
               Tag             =   "BOE_QtyMax®©F"
               Top             =   2400
               Width           =   735
            End
            Begin VB.TextBox txt_BOE_QtyMin 
               Height          =   285
               Left            =   6600
               TabIndex        =   546
               Tag             =   "BOE_QtyMin®©F"
               Top             =   2400
               Width           =   735
            End
            Begin VB.CommandButton cmd_AgIdSearch 
               Caption         =   "..."
               Height          =   375
               Index           =   1
               Left            =   9360
               TabIndex        =   550
               Top             =   2760
               Width           =   855
            End
            Begin VB.TextBox txt_BOB_BOE_Id 
               Height          =   285
               Left            =   9720
               TabIndex        =   252
               TabStop         =   0   'False
               Tag             =   "BOE_Id"
               Top             =   2400
               Visible         =   0   'False
               Width           =   375
            End
            Begin VB.Frame frm_sub 
               Height          =   2175
               Index           =   2
               Left            =   5640
               TabIndex        =   276
               Top             =   120
               Width           =   2775
               Begin Project1.ArmCombobox cbo_Bending 
                  Height          =   345
                  Index           =   2
                  Left            =   960
                  TabIndex        =   532
                  Tag             =   "BND_IdE®©BND_NameE"
                  Top             =   240
                  Width           =   1575
                  _ExtentX        =   2778
                  _ExtentY        =   609
               End
               Begin VB.TextBox txt_BOE_ESMax 
                  Height          =   315
                  Left            =   1800
                  TabIndex        =   538
                  Tag             =   "BOE_ESMax®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_ESMin 
                  Height          =   315
                  Left            =   960
                  TabIndex        =   537
                  Tag             =   "BOE_ESMin®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_EUZMin 
                  Height          =   315
                  Left            =   960
                  TabIndex        =   535
                  Tag             =   "BOE_EUZMin®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_EUZMax 
                  Height          =   315
                  Left            =   1800
                  TabIndex        =   536
                  Tag             =   "BOE_EUZMax®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_EHMin 
                  Height          =   315
                  Left            =   960
                  TabIndex        =   533
                  Tag             =   "BOE_EHMin®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_EHMax 
                  Height          =   315
                  Left            =   1800
                  TabIndex        =   534
                  Tag             =   "BOE_EHMax®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#S"
                  Height          =   255
                  Index           =   16
                  Left            =   120
                  TabIndex        =   500
                  Tag             =   "lbl_BOE_S"
                  Top             =   1800
                  Width           =   495
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#U/Z"
                  Height          =   255
                  Index           =   13
                  Left            =   120
                  TabIndex        =   499
                  Tag             =   "lbl_BOE_UZ"
                  Top             =   1440
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#H"
                  Height          =   255
                  Index           =   10
                  Left            =   120
                  TabIndex        =   498
                  Tag             =   "lbl_BOE_H"
                  Top             =   1080
                  Width           =   495
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Min"
                  Height          =   255
                  Index           =   9
                  Left            =   1080
                  TabIndex        =   497
                  Tag             =   "lbl_BOE_Min"
                  Top             =   720
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Max"
                  Height          =   255
                  Index           =   8
                  Left            =   1920
                  TabIndex        =   496
                  Tag             =   "lbl_BOE_Max"
                  Top             =   720
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Bnd E"
                  Height          =   255
                  Index           =   14
                  Left            =   120
                  TabIndex        =   277
                  Tag             =   "lbl_BOE_BndE"
                  Top             =   240
                  Width           =   855
               End
            End
            Begin VB.Frame frm_sub 
               Height          =   2535
               Index           =   0
               Left            =   120
               TabIndex        =   269
               Top             =   120
               Width           =   2655
               Begin VB.TextBox txt_BOE_CSMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   518
                  Tag             =   "BOE_CSMax®©F"
                  Top             =   2040
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_CSMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   516
                  Tag             =   "BOE_CSMin®©F"
                  Top             =   2040
                  Width           =   735
               End
               Begin Project1.ArmCombobox cbo_Bending 
                  Height          =   345
                  Index           =   0
                  Left            =   840
                  TabIndex        =   508
                  Tag             =   "BND_IdC®©BND_NameC"
                  Top             =   240
                  Width           =   1695
                  _ExtentX        =   2990
                  _ExtentY        =   609
               End
               Begin VB.TextBox txt_BOE_CUZMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   513
                  Tag             =   "BOE_CUZMin®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_CUZMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   514
                  Tag             =   "BOE_CUZMax®©F"
                  Top             =   1680
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_CFMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   511
                  Tag             =   "BOE_CFMin®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_CFMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   512
                  Tag             =   "BOE_CFMax®©F"
                  Top             =   1320
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_CHMin 
                  Height          =   315
                  Left            =   840
                  TabIndex        =   509
                  Tag             =   "BOE_CHMin®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.TextBox txt_BOE_CHMax 
                  Height          =   315
                  Left            =   1680
                  TabIndex        =   510
                  Tag             =   "BOE_CHMax®©F"
                  Top             =   960
                  Width           =   735
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#S"
                  Height          =   255
                  Index           =   17
                  Left            =   120
                  TabIndex        =   471
                  Tag             =   "lbl_BOE_S"
                  Top             =   2160
                  Width           =   495
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#f"
                  Height          =   255
                  Index           =   2
                  Left            =   120
                  TabIndex        =   275
                  Tag             =   "lbl_BOE_f"
                  Top             =   1440
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#U/Z"
                  Height          =   255
                  Index           =   3
                  Left            =   120
                  TabIndex        =   274
                  Tag             =   "lbl_BOE_UZ"
                  Top             =   1800
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Bnd C"
                  Height          =   255
                  Index           =   6
                  Left            =   120
                  TabIndex        =   273
                  Tag             =   "lbl_BOE_BndC"
                  Top             =   240
                  Width           =   735
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#H"
                  Height          =   255
                  Index           =   7
                  Left            =   120
                  TabIndex        =   272
                  Tag             =   "lbl_BOE_H"
                  Top             =   1080
                  Width           =   495
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Min"
                  Height          =   255
                  Index           =   4
                  Left            =   960
                  TabIndex        =   271
                  Tag             =   "lbl_BOE_Min"
                  Top             =   720
                  Width           =   615
               End
               Begin VB.Label lbl_Label 
                  Caption         =   "#Max"
                  Height          =   255
                  Index           =   5
                  Left            =   1800
                  TabIndex        =   270
                  Tag             =   "lbl_BOE_Max"
                  Top             =   720
                  Width           =   735
               End
            End
            Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
               Height          =   345
               Index           =   1
               Left            =   3720
               TabIndex        =   549
               Tag             =   "BOE_AgId1®©AgId1_Desc"
               Top             =   2760
               Width           =   5535
               _ExtentX        =   9763
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_KostSt_Filter 
               Height          =   345
               Index           =   1
               Left            =   1200
               TabIndex        =   548
               Tag             =   "BOE_KostSt1®©KostSt1_Desc"
               Top             =   2760
               Width           =   1815
               _ExtentX        =   3201
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_KostSt_Filter 
               Height          =   345
               Index           =   25
               Left            =   1200
               TabIndex        =   552
               Tag             =   "BOE_KostSt2®©KostSt2_Desc"
               Top             =   3120
               Width           =   1815
               _ExtentX        =   3201
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_KostSt_Filter 
               Height          =   345
               Index           =   26
               Left            =   1200
               TabIndex        =   556
               Tag             =   "BOE_KostSt3®©KostSt3_Desc"
               Top             =   3480
               Width           =   1815
               _ExtentX        =   3201
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
               Height          =   345
               Index           =   25
               Left            =   3720
               TabIndex        =   553
               Tag             =   "BOE_AgId2®©AgId2_Desc"
               Top             =   3120
               Width           =   5535
               _ExtentX        =   9763
               _ExtentY        =   609
            End
            Begin Project1.ArmCombobox cbo_BOR_Perf_AgId 
               Height          =   345
               Index           =   26
               Left            =   3720
               TabIndex        =   557
               Tag             =   "BOE_AgId3®©AgId3_Desc"
               Top             =   3480
               Width           =   5535
               _ExtentX        =   9763
               _ExtentY        =   609
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Weighting points"
               Height          =   255
               Index           =   69
               Left            =   10320
               TabIndex        =   561
               Tag             =   "lbl_BOP_WghPnt"
               Top             =   2520
               Width           =   1335
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#QtyMax"
               Height          =   255
               Index           =   18
               Left            =   7440
               TabIndex        =   474
               Tag             =   "lbl_BOE_QtyMax"
               Top             =   2400
               Width           =   855
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Cost Centre"
               Height          =   255
               Index           =   105
               Left            =   120
               TabIndex        =   299
               Tag             =   "lbl_BOE_KostSt"
               Top             =   2760
               Width           =   1095
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#QtyMin"
               Height          =   255
               Index           =   98
               Left            =   5880
               TabIndex        =   284
               Tag             =   "lbl_BOE_QtyMin"
               Top             =   2400
               Width           =   855
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#AgNr"
               Height          =   255
               Index           =   20
               Left            =   3120
               TabIndex        =   278
               Tag             =   "lbl_BOE_AgNr"
               Top             =   2760
               Width           =   735
            End
         End
         Begin Project1.ToolbarControl tlb_SubDetail 
            Height          =   2445
            Index           =   2
            Left            =   11880
            TabIndex        =   71
            Top             =   240
            Width           =   690
            _ExtentX        =   1217
            _ExtentY        =   4313
         End
         Begin Project1.ArmGrid grd_SubDetail 
            Height          =   1215
            Index           =   2
            Left            =   120
            TabIndex        =   70
            Top             =   4080
            Width           =   12375
            _ExtentX        =   21828
            _ExtentY        =   2143
         End
      End
      Begin VB.Frame fra_SubDetail 
         Height          =   4815
         Index           =   1
         Left            =   480
         TabIndex        =   262
         Top             =   2880
         Width           =   975
         Begin VB.Frame fra_SubDetailItem 
            Height          =   2415
            Index           =   1
            Left            =   120
            TabIndex        =   264
            Top             =   120
            Width           =   9855
            Begin Project1.ArmCombobox cbo_Material 
               Height          =   345
               Index           =   1
               Left            =   120
               TabIndex        =   470
               Tag             =   "MAT_Id®©MAT_Name"
               Top             =   480
               Width           =   2415
               _ExtentX        =   4260
               _ExtentY        =   609
            End
            Begin VB.TextBox txt_BOS_ExtBnd 
               Height          =   315
               Left            =   6600
               TabIndex        =   485
               Tag             =   "BOS_ExtBnd®©F"
               Top             =   840
               Width           =   735
            End
            Begin VB.CheckBox chk_CDIsEqual 
               Height          =   315
               Left            =   6600
               TabIndex        =   486
               Tag             =   "BOS_CDIsEqual"
               Top             =   1200
               Width           =   375
            End
            Begin VB.TextBox txt_BOS_CutBMax 
               Height          =   315
               Left            =   4440
               TabIndex        =   483
               Tag             =   "BOS_CutBMax®©F"
               Top             =   1920
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_CutBMin 
               Height          =   315
               Left            =   3600
               TabIndex        =   482
               Tag             =   "BOS_CutBMin®©F"
               Top             =   1920
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_BOS_Id 
               Height          =   285
               Left            =   8760
               TabIndex        =   279
               TabStop         =   0   'False
               Tag             =   "BOS_Id"
               Top             =   480
               Visible         =   0   'False
               Width           =   375
            End
            Begin VB.TextBox txt_BOS_ABMin 
               Height          =   315
               Left            =   6600
               TabIndex        =   484
               Tag             =   "BOS_ABMin®©F"
               Top             =   480
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_CutAMax 
               Height          =   315
               Left            =   4440
               TabIndex        =   481
               Tag             =   "BOS_CutAMax®©F"
               Top             =   1560
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_CutAMin 
               Height          =   315
               Left            =   3600
               TabIndex        =   480
               Tag             =   "BOS_CutAMin®©F"
               Top             =   1560
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_ThsMax 
               Height          =   315
               Left            =   4440
               TabIndex        =   479
               Tag             =   "BOS_ThsMax®©F"
               Top             =   1200
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_ThsMin 
               Height          =   315
               Left            =   3600
               TabIndex        =   478
               Tag             =   "BOS_ThsMin®©F"
               Top             =   1200
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_PanBMax 
               Height          =   315
               Left            =   4440
               TabIndex        =   476
               Tag             =   "BOS_PanBMax®©F"
               Top             =   840
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_PanBMin 
               Height          =   315
               Left            =   3600
               TabIndex        =   475
               Tag             =   "BOS_PanBMin®©F"
               Top             =   840
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_PanAMax 
               Height          =   315
               Left            =   4440
               TabIndex        =   473
               Tag             =   "BOS_PanAMax®©F"
               Top             =   480
               Width           =   735
            End
            Begin VB.TextBox txt_BOS_PanAMin 
               Height          =   315
               Left            =   3600
               TabIndex        =   472
               Tag             =   "BOS_PanAMin®©F"
               Top             =   480
               Width           =   735
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Material"
               Height          =   255
               Index           =   94
               Left            =   120
               TabIndex        =   525
               Tag             =   "lbl_BOS_Material"
               Top             =   240
               Width           =   735
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#CDIsEqual"
               Height          =   255
               Index           =   12
               Left            =   5400
               TabIndex        =   523
               Tag             =   "lbl_BOS_CDIsEqual"
               Top             =   1200
               Width           =   975
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Ext Bnd"
               Height          =   255
               Index           =   0
               Left            =   5400
               TabIndex        =   521
               Tag             =   "lbl_BOS_ExtBnd"
               Top             =   840
               Width           =   975
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#CutB"
               Height          =   255
               Index           =   167
               Left            =   2640
               TabIndex        =   519
               Tag             =   "lbl_BOS_CutB"
               Top             =   1920
               Width           =   975
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Max"
               Height          =   255
               Index           =   166
               Left            =   4440
               TabIndex        =   517
               Tag             =   "lbl_BOS_Max"
               Top             =   240
               Width           =   735
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Min"
               Height          =   255
               Index           =   165
               Left            =   3600
               TabIndex        =   515
               Tag             =   "lbl_BOS_Min"
               Top             =   240
               Width           =   615
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#A-B Min"
               Height          =   255
               Index           =   97
               Left            =   5400
               TabIndex        =   283
               Tag             =   "lbl_BOS_ABMin"
               Top             =   480
               Width           =   975
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#CutA"
               Height          =   255
               Index           =   95
               Left            =   2640
               TabIndex        =   282
               Tag             =   "lbl_BOS_CutA"
               Top             =   1560
               Width           =   975
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#Ths"
               Height          =   255
               Index           =   93
               Left            =   2640
               TabIndex        =   281
               Tag             =   "lbl_BOS_Ths"
               Top             =   1200
               Width           =   975
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#PanB"
               Height          =   255
               Index           =   15
               Left            =   2640
               TabIndex        =   266
               Tag             =   "lbl_BOS_PanB"
               Top             =   840
               Width           =   975
            End
            Begin VB.Label lbl_Label 
               Caption         =   "#PanA"
               Height          =   255
               Index           =   11
               Left            =   2640
               TabIndex        =   265
               Tag             =   "lbl_BOS_PanA"
               Top             =   480
               Width           =   975
            End
         End
         Begin VB.TextBox txt_SubDetailKey 
            Height          =   285
            Index           =   1
            Left            =   2760
            TabIndex        =   263
            TabStop         =   0   'False
            Tag             =   "BOS_Id"
            Top             =   0
            Visible         =   0   'False
            Width           =   1215
         End
         Begin Project1.ArmGrid grd_SubDetail 
            Height          =   1935
            Index           =   1
            Left            =   120
            TabIndex        =   487
            Top             =   2640
            Width           =   9855
            _ExtentX        =   17383
            _ExtentY        =   3413
         End
         Begin Project1.ToolbarControl tlb_SubDetail 
            Height          =   2445
            Index           =   1
            Left            =   10080
            TabIndex        =   488
            Top             =   120
            Width           =   690
            _ExtentX        =   1217
            _ExtentY        =   4313
         End
      End
      Begin VB.TextBox txt_DetailKey 
         Height          =   375
         Index           =   2
         Left            =   10080
         TabIndex        =   9
         TabStop         =   0   'False
         Tag             =   "BOB_Id"
         Top             =   360
         Visible         =   0   'False
         Width           =   1095
      End
      Begin Project1.ToolbarControl tlb_Detail 
         Height          =   690
         Index           =   2
         Left            =   120
         TabIndex        =   56
         Top             =   240
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   1217
      End
      Begin Project1.ArmCombobox cbo_Cutout_KostSt 
         Height          =   345
         Index           =   1
         Left            =   5400
         TabIndex        =   464
         Tag             =   "BND_KostSt®©BND_KostSt"
         Top             =   1080
         Width           =   3495
         _ExtentX        =   6165
         _ExtentY        =   609
      End
      Begin Project1.ArmCombobox cbo_BOB_Priority 
         Height          =   345
         Index           =   1
         Left            =   5400
         TabIndex        =   467
         Tag             =   "BOB_Priority®©BOB_Priority"
         Top             =   2040
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
      End
      Begin Project1.ArmTreeView tvw_Detail 
         Height          =   1335
         Index           =   3
         Left            =   960
         TabIndex        =   462
         Top             =   1080
         Width           =   3255
         _ExtentX        =   5741
         _ExtentY        =   2355
      End
      Begin VB.CheckBox chk_Repositioning 
         Height          =   375
         Index           =   2
         Left            =   11280
         TabIndex        =   10
         TabStop         =   0   'False
         Top             =   360
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#Name"
         Height          =   255
         Index           =   151
         Left            =   4320
         TabIndex        =   466
         Tag             =   "lbl_BOB_Name"
         Top             =   1680
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#BOB Priority"
         Height          =   255
         Index           =   19
         Left            =   4320
         TabIndex        =   463
         Tag             =   "lbl_BOB_Priority"
         Top             =   2160
         Width           =   1095
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#KostSt"
         Height          =   255
         Index           =   92
         Left            =   4320
         TabIndex        =   261
         Tag             =   "lbl_BOB_KostSt"
         Top             =   1200
         Width           =   855
      End
      Begin VB.Label lbl_Label 
         Caption         =   "#System"
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   11
         Tag             =   "lbl_BOB_System"
         Top             =   1200
         Width           =   975
      End
   End
   Begin VB.Frame fra_MainItem 
      Caption         =   "OperCost Main"
      Height          =   252
      Index           =   0
      Left            =   240
      TabIndex        =   2
      Top             =   1080
      Width           =   1332
      Begin VB.Frame fra_MainFilter 
         Caption         =   "Frame1"
         Height          =   495
         Index           =   0
         Left            =   0
         TabIndex        =   7
         Top             =   960
         Width           =   2895
      End
      Begin VB.CommandButton cmd_TVReLoad 
         Caption         =   "Command1"
         Height          =   855
         Index           =   0
         Left            =   240
         TabIndex        =   4
         Top             =   2280
         Width           =   1215
      End
      Begin Project1.ToolbarControl tlb_Main 
         Height          =   690
         Index           =   0
         Left            =   3120
         TabIndex        =   3
         Top             =   480
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   1217
      End
      Begin Project1.ArmTreeView tvw_Main 
         Height          =   1215
         Index           =   0
         Left            =   120
         TabIndex        =   5
         Top             =   2160
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   2143
      End
      Begin Project1.ArmCombobox cbo_View 
         Height          =   345
         Index           =   0
         Left            =   120
         TabIndex        =   6
         Top             =   1680
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   609
      End
      Begin Project1.ArmGrid grd_Main 
         Height          =   1695
         Index           =   0
         Left            =   3120
         TabIndex        =   285
         Tag             =   "grd_M_OPR"
         Top             =   1440
         Width           =   2415
         _ExtentX        =   4260
         _ExtentY        =   2990
      End
   End
   Begin MSComctlLib.TabStrip tbs_Main 
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   120
      Width           =   4215
      _ExtentX        =   7435
      _ExtentY        =   661
      MultiRow        =   -1  'True
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   10
         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
         BeginProperty Tab6 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab7 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab8 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab9 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab10 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TabStrip tbs_MainTabFilter 
      Height          =   375
      Index           =   0
      Left            =   7200
      TabIndex        =   1
      Top             =   120
      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           =   1
      Left            =   8040
      TabIndex        =   28
      Top             =   120
      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            =   8880
      TabIndex        =   36
      Top             =   120
      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            =   9720
      TabIndex        =   94
      Top             =   120
      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            =   10560
      TabIndex        =   161
      Top             =   120
      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           =   5
      Left            =   11400
      TabIndex        =   162
      Top             =   120
      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           =   6
      Left            =   12240
      TabIndex        =   209
      Top             =   120
      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           =   7
      Left            =   13080
      TabIndex        =   210
      Top             =   120
      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            =   5640
      Top             =   120
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin MSComctlLib.TabStrip tbs_MainTabFilter 
      Height          =   375
      Index           =   8
      Left            =   9720
      TabIndex        =   354
      Top             =   600
      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           =   9
      Left            =   10560
      TabIndex        =   355
      Top             =   600
      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_BOR"
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
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
   
'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK VARIABLES
'**********************************************************************************************************************************
'**********************************************************************************************************************************

#If ENV = LIVE Then
    Dim mo_Db As Object
    Dim mo_Db_2 As Object
#Else
    Dim mo_Db As ARMSYSCOMLib.ArmDb
    Dim mo_Db_2 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 ms_BaeurerServer As String
Private ms_BaeurerDatabase As String
Private ms_BaeurerLoginName As String
Private ms_BaeurerPassword As String
Private ml_BaeurerFi_Nr As Long
Private ms_BaeurerSource As String
Private ms_BaeurerLang As String

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 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

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' 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_BOR"
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"
Private Const IMAGE_INFO_CONFIG_INDEX = 2

Private Const DATA_IMPORT_CONFIG_INDEX = 10

'Excel column names definitions
Private Const EX_SYS_NAME = "SYS_Name"
Private Const EX_PRF_NAME = "PRF_Name"
Private Const EX_MAT_NAME = "MAT_Name"
Private Const EX_BOP_QTY_MIN = "BOP_QtyMin"
Private Const EX_BOP_QTY_MAX = "BOP_QtyMax"
Private Const EX_BOP_BMIN = "BOP_BMin"
Private Const EX_BOP_BMAX = "BOP_BMax"
Private Const EX_BOP_PRIORITY = "BOP_Priority"
Private Const EX_BOP_AGID = "BOP_AgId"

'**********************************************************************************************************************************
'**********************************************************************************************************************************
' 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_BOR_OperCost = 1
    ttDPC_BOR_Perf = 2
    ttDPC_BOR_Bend = 3
    ttDPC_BOR_PunchNotch = 4
    ttDPC_BOR_Coating = 5
    ttDPC_BOR_Gasket = 6
    ttDPC_BOR_Inlay = 7
    ttDPC_BOR_Packing = 8
    ttDPC_BOR_Cutting = 9
    ttDPC_BOR_Rerolling = 10
End Enum

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

Private Type tBOR_Perf
    SYS_Id As Long
    PRF_Id As String
    MAT_Id As Long
    QtyMin As Long
    QtyMax As Long
    BMin As Double
    BMax As Double
    Priority As Integer
    AgId As Long
End Type

Private Type tBOR_Bend
    CAT_Id As Long
    PRD_IdPar As Boolean
    CUA_Id  As Boolean
    PCR_AMin    As Boolean
    PCR_AMax As Boolean
    PCR_BMin As Boolean
    PCR_BMax As Boolean
    MAT_Id As Boolean
    PCR_Thick As Boolean
    PCR_TMin    As Boolean
    PCR_TMax As Boolean
    PCR_IsPrf As Boolean
    PCR_GaCnt As Boolean
    PCR_CoSid As Boolean
End Type

Const TVI_STATE_NONE = 0
Const TVI_STATE_UNCHECKED = 7
Const TVI_STATE_CHECKED = 8
Const TVI_STATE_GRAYED = 9
'**********************************************************************************************************************************
'**********************************************************************************************************************************
' FRAMEWORK EVENTS
'**********************************************************************************************************************************
'**********************************************************************************************************************************

Public Event quit()

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

'**********************************************************************************************************************************
'**********************************************************************************************************************************
'**********************************************************************************************************************************
' 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


'**********************************************************************************************************************************
'**********************************************************************************************************************************
' 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_Connect() As String
    Dim ls_DPC_RefRight As String
    
    #If LIVE = 1 Then
        Set mo_Db_2 = CreateObject("ArmSysCOM.ArmDb")
    #Else
        Set mo_Db_2 = New ARMSYSCOMLib.ArmDb
    #End If
    
    ls_Connect = Split(mo_Tools.GetAConfigData("DPC_BaeurerConnection"), SEP)
    
    If UBound(ls_Connect) = 5 Then
        ms_BaeurerServer = ls_Connect(0)
        ms_BaeurerDatabase = ls_Connect(1)
        ms_BaeurerLoginName = ls_Connect(2)
        ms_BaeurerPassword = ls_Connect(3)
        ms_BaeurerSource = ls_Connect(4)
        ml_BaeurerFi_Nr = Val(ls_Connect(5))
        ms_BaeurerLang = "de_de"
    Else
      Err.Raise ArmErr.PropertyNotSet, "Split(mo_Tools.GetAConfigData(""DPC_BaeurerConnection"")", "Missing or invalid configuration"
    End If
  
    If Not mo_Db_2.Connect(ms_BaeurerServer, ms_BaeurerDatabase, ms_BaeurerLoginName, ms_BaeurerPassword, ms_BaeurerSource) Then
        Err.Raise ArmErr.CompFncFailed, "mo_Db_2.Connect", "Unable to connect to server:" & ms_BaeurerServer & " db:" & ms_BaeurerDatabase & " user:" & ms_BaeurerLoginName
    End If

    
'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
       
    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

    Set mo_Db_2 = Nothing
    
    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
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(1)
    lo_Tab.Caption = "#DPC_BOR_OperCost"
    lo_Tab.Key = "DPC_BOR_OperCost"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_OperCost"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(2)
    lo_Tab.Caption = "#DPC_BOR_Perf"
    lo_Tab.Key = "DPC_BOR_Perf"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Perf"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(3)
    lo_Tab.Caption = "#DPC_BOR_Rerolling"
    lo_Tab.Key = "DPC_BOR_Rerolling"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Rerolling"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(4)
    lo_Tab.Caption = "#DPC_BOR_Cutting"
    lo_Tab.Key = "DPC_BOR_Cutting"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Cutting"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(5)
    lo_Tab.Caption = "#DPC_BOR_PunchNotch"
    lo_Tab.Key = "DPC_BOR_PunchNotch"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_PunchNotch"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(6)
    lo_Tab.Caption = "#DPC_BOR_Bend"
    lo_Tab.Key = "DPC_BOR_Bend"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Bend"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(7)
    lo_Tab.Caption = "#DPC_BOR_Coating"
    lo_Tab.Key = "DPC_BOR_Coating"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Coating"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(8)
    lo_Tab.Caption = "#DPC_BOR_Gasket"
    lo_Tab.Key = "DPC_BOR_Gasket"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Gasket"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(9)
    lo_Tab.Caption = "#DPC_BOR_Inlay"
    lo_Tab.Key = "DPC_BOR_Inlay"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Inlay"
    
    ms_ToolbarRequest = "exec Toolbar_sel $Module$"
    Set lo_Tab = tbs_Main.Tabs(10)
    lo_Tab.Caption = "#DPC_BOR_Packing"
    lo_Tab.Key = "DPC_BOR_Packing"
    lo_Tab.Tag = "lbl_TAB_DPC_BOR_Packing"
        
    For ll_Index = 0 To 1
        cbo_System_Filter(ll_Index).Request = ReplacePlaceHolder("exec DPC_System_lst2 $Language_code$,NULL", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
        cbo_System_Filter(ll_Index).FirstBlankItem = True
    Next
    
    cbo_Vendor_Filter(1).Request = "exec DPC_Vendor_lst"
    
    For ll_Index = 0 To 1
        cbo_MAT_Filter(ll_Index).Request = ReplacePlaceHolder("exec DPC_Material_lst2 $Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
        cbo_MAT_Filter(ll_Index).FirstBlankItem = True
    Next
    
    For ll_Index = 1 To 2
        cbo_Perf(ll_Index).Request = ReplacePlaceHolder("exec DPC_Perforation_lst2 $Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    Next
    
    cbo_Cutout.Request = ReplacePlaceHolder("exec DPC_CutType_lst2 $Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    cbo_Cutout.FirstBlankItem = True
    For ll_Index = 1 To 1
        cbo_Cutout_KostSt(ll_Index).Request = ReplacePlaceHolder("exec DPC_BOR_OperCost_lst2 3", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    Next
    
    For ll_Index = 1 To 1
        cbo_Material(ll_Index).Request = ReplacePlaceHolder("exec DPC_Material_lst2 $Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    Next
    
    cbo_BOA_CoSid.Request = ReplacePlaceHolder("exec A_References_ML_Lst " & eDPCReferenceML.rfCoatingSideApp & ",$Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    cbo_BOA_BndVis.Request = ReplacePlaceHolder("exec A_References_ML_Lst " & eDPCReferenceML.rfCoatingBendingSide & ",$Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    cbo_COA_Type.Request = ReplacePlaceHolder("exec A_References_ML_Lst " & eDPCReferenceML.rfCoatingType & ",$Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    
    cbo_PIN_Purch.Request = ReplacePlaceHolder("exec A_References_ML_Lst " & eDPCReferenceML.rfInlayPurchaseType & ",$Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    cbo_PIN_Deliv.Request = ReplacePlaceHolder("exec A_References_ML_Lst " & eDPCReferenceML.rfInlayDeliveryKind & ",$Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
        
    For ll_Index = 0 To 3
        cbo_PRF_Class(ll_Index).Request = "select distinct PRF_Class, PRF_Class from DPC_Perforation"
    Next
    
    For ll_Index = 0 To 8
        lv_Priority = Array(1, 1)
        Call cbo_BOB_Priority(ll_Index).AddItem(lv_Priority)
        lv_Priority = Array(2, 2)
        Call cbo_BOB_Priority(ll_Index).AddItem(lv_Priority)
        lv_Priority = Array(3, 3)
        Call cbo_BOB_Priority(ll_Index).AddItem(lv_Priority)
    Next
    
    For ll_Index = 1 To 1
        cbo_Packing(ll_Index).Request = ReplacePlaceHolder("exec DPC_Packing_lst2 $Language_code$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
    Next
    
    For ll_Index = 0 To 3
        cbo_Bending(ll_Index).Request = ReplacePlaceHolder("exec DPC_Bending_lst $Language_code$,$BND_IsShr$,$BND_IsLng$,$BND_IsCus$", "$Language_code$", mo_Tools.SQLStr(ms_Language_Code))
        If ll_Index = 0 Or ll_Index = 1 Then
            cbo_Bending(ll_Index).Request = ReplacePlaceHolder(cbo_Bending(ll_Index).Request, "$BND_IsShr$", "NULL")
            cbo_Bending(ll_Index).Request = ReplacePlaceHolder(cbo_Bending(ll_Index).Request, "$BND_IsLng$", "X")
        Else
            cbo_Bending(ll_Index).Request = ReplacePlaceHolder(cbo_Bending(ll_Index).Request, "$BND_IsShr$", "X")
            cbo_Bending(ll_Index).Request = ReplacePlaceHolder(cbo_Bending(ll_Index).Request, "$BND_IsLng$", "NULL")
        End If
        cbo_Bending(ll_Index).Request = ReplacePlaceHolder(cbo_Bending(ll_Index).Request, "$BND_IsCus$", "NULL")
        Call cbo_Bending(ll_Index).Load
    Next
        
    grd_DataImport.SetColumns (Array( _
    "MSG_Id®©0®©1®©MSG_Id®©#MSG_Id", _
    "MSG_Text®©4500®©0®©MSG_Text®©#MSG_Text"))

    'toolbar position fix
    For ll_Index = 0 To 2
        tlb_SubDetail(ll_Index).Width = 672
    Next
    
    For ll_Index = 1 To 9
        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(9)
    ReDim mt_DetailConfig(10)
        
    With mt_MainConfig(0)
        .FrameIndex = 0
        .IsMultiDetailView = True
        .CurrentDetailIndex = 0
        .Initialized = False
        .NameFrame = "DPC_BOR_OperCost"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 0
        .ToolbarID = 2862
        .RequestGrid = "exec DPC_Operation_lst $Language_code$"
    End With
        
    With mt_MainConfig(1)
        .FrameIndex = 1
        .IsMultiDetailView = True
        .CurrentDetailIndex = 1
        .Initialized = False
        .NameFrame = "DPC_BOR_Perf"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 1
        .ToolbarID = 2865
        .RequestGrid = "exec DPC_BOR_Perf_lst $Language_code$,$VEN_Id$,$SYS_Id$," & eDPCBOROperation.ePerforation
    End With
        
    With mt_MainConfig(2)
        .FrameIndex = 2
        .IsMultiDetailView = True
        .CurrentDetailIndex = 2
        .Initialized = False
        .NameFrame = "DPC_BOR_Bend"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 2
        .ToolbarID = 2867
        .RequestGrid = "exec DPC_BOR_Bend_lst $Language_code$"
    End With
    
    With mt_MainConfig(3)
        .FrameIndex = 3
        .IsMultiDetailView = True
        .CurrentDetailIndex = 3
        .Initialized = False
        .NameFrame = "DPC_BOR_PunchNotch"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 3
        .ToolbarID = 2869
        .RequestGrid = "exec DPC_BOR_PunchNotch_lst $Language_code$,$MAT_Id$," & eDPCBOROperation.ePunchNotching
    End With
    
    With mt_MainConfig(4)
        .FrameIndex = 4
        .IsMultiDetailView = True
        .CurrentDetailIndex = 4
        .Initialized = False
        .NameFrame = "DPC_BOR_Coating"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 4
        .ToolbarID = 2871
        .RequestGrid = "exec DPC_BOR_Coating_lst $Language_code$"
    End With
    
    With mt_MainConfig(5)
        .FrameIndex = 5
        .IsMultiDetailView = True
        .CurrentDetailIndex = 5
        .Initialized = False
        .NameFrame = "DPC_BOR_Gasket"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 5
        .ToolbarID = 2873
        .RequestGrid = "exec DPC_BOR_Gasket_lst $Language_code$"
    End With
    
    With mt_MainConfig(6)
        .FrameIndex = 6
        .IsMultiDetailView = True
        .CurrentDetailIndex = 6
        .Initialized = False
        .NameFrame = "DPC_BOR_Inlay"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 6
        .ToolbarID = 2875
        .RequestGrid = "exec DPC_BOR_Inlay_lst $Language_code$"
    End With
    
    With mt_MainConfig(7)
        .FrameIndex = 7
        .IsMultiDetailView = True
        .CurrentDetailIndex = 7
        .Initialized = False
        .NameFrame = "DPC_BOR_Packing"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 7
        .ToolbarID = 2877
        .RequestGrid = "exec DPC_BOR_Packing_lst $Language_code$"
    End With
    
    With mt_MainConfig(8)
        .FrameIndex = 8
        .IsMultiDetailView = True
        .CurrentDetailIndex = 8
        .Initialized = False
        .NameFrame = "DPC_BOR_Cutting"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 8
        .ToolbarID = 2938
        .RequestGrid = "exec DPC_BOR_Cutting_lst $Language_code$,$MAT_Id$," & eDPCBOROperation.eCutting
    End With
    
    With mt_MainConfig(9)
        .FrameIndex = 9
        .IsMultiDetailView = True
        .CurrentDetailIndex = 9
        .Initialized = False
        .NameFrame = "DPC_BOR_Rerolling"
        .ViewCode = ""
        .GridDelayMethod = eGridLoadMethod.egmDelayedExceptLastLevel
        .CurrentTvwSelMethod = etmNone
        .ToolbarFace = "0"
        .ToolbarIndex = 9
        .ToolbarID = 2940
        .RequestGrid = "exec DPC_BOR_Rerolling_lst $Language_code$"
    End With
    
    With mt_DetailConfig(0)
        .FrameIndex = 0
        .NameFrame = "DPC_BOR_OperCost"
        .MainConfigIndex = 0
        .DetailKey = 0
        .ClearControlsBeforeInit = True

        .RequestView = ""
        .RequestAdd = ""
        .RequestUpd = ""
        .RequestDel = ""
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_OperCost"
        .ToolbarIndex = 0
        .ToolbarID = 2863
        .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) = chk_Repositioning(0)
        
        .MainGridColumns = Array( _
            "OPR_Id®©400®©1®©OPR_Id®©#OPR_Id", _
            "RF_Desc®©3000®©0®©RF_Desc®©#RF_Desc")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(1)
        .FrameIndex = 1
        .NameFrame = "DPC_BOR_Perf"
        .MainConfigIndex = 1
        .DetailKey = 1
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Perf_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Perf_ins $BOP_Id$,$SYS_Name$,$PRF_Name$,$MAT_Name$,$BOP_ThsMin$,$BOP_ThsMax$,$BOP_CutAMin$,$BOP_CutAMax$,$BOP_CutBMin$,$BOP_CutBMax$,$BOP_QtyMin$,$BOP_QtyMax$,$BOP_Priority$,$BOP_KostSt1$,$BOP_AgId1$,$BOP_WghPnt1$,$BOP_KostSt2$,$BOP_AgId2$,$BOP_WghPnt2$,$BOP_KostSt3$,$BOP_AgId3$,$BOP_WghPnt3$,$Z_creator$", _
                            "exec DPC_BOR_Param_Prod_ins $BOP_Id$," & eDPCBOROperation.ePerforation & "," & eDPCCategory.cgPerforation & ",$PRF_Id$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Perf_upd $BOP_Id$,$SYS_Name$,$PRF_Name$,$MAT_Name$,$BOP_ThsMin$,$BOP_ThsMax$,$BOP_CutAMin$,$BOP_CutAMax$,$BOP_CutBMin$,$BOP_CutBMax$,$BOP_QtyMin$,$BOP_QtyMax$,$BOP_Priority$,$BOP_KostSt1$,$BOP_AgId1$,$BOP_WghPnt1$,$BOP_KostSt2$,$BOP_AgId2$,$BOP_WghPnt2$,$BOP_KostSt3$,$BOP_AgId3$,$BOP_WghPnt3$,$Z_last_upd_user$,$iConcurrency$", _
                            "exec DPC_BOR_Param_Prod_del $BOP_Id$," & eDPCBOROperation.ePerforation & "," & eDPCCategory.cgPerforation, _
                            "exec DPC_BOR_Param_Prod_ins $BOP_Id$," & eDPCBOROperation.ePerforation & "," & eDPCCategory.cgPerforation & ",$PRF_Id$,$Z_creator$")
        .RequestDel = Array("exec DPC_BOR_Param_Prod_del $BOP_Id$," & eDPCBOROperation.ePerforation & "," & eDPCCategory.cgPerforation, _
                            "exec DPC_BOR_Param_Mat_del $BOP_Id$," & eDPCBOROperation.ePerforation, _
                            "exec DPC_BOR_Param_Sys_del $BOP_Id$," & eDPCBOROperation.ePerforation, _
                            "exec DPC_BOR_Perf_del $BOP_Id$,$Z_last_upd_user$,$iConcurrency$")
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Perf"
        .ToolbarIndex = 1
        .ToolbarID = 2866
        .ToolbarFaces = Array("0", "1", "2", "3")
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BOP_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BOP_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BOP_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(9)
        .ListFieldsMandatory(0) = Array(txt_BOP_QtyMin, 24)
        .ListFieldsMandatory(1) = Array(txt_BOP_QtyMax, 25)
        .ListFieldsMandatory(2) = Array(txt_BOP_BMin, 106)
        .ListFieldsMandatory(3) = Array(txt_BOP_BMax, 107)
        .ListFieldsMandatory(4) = Array(cbo_BOB_Priority(0), 28)
        .ListFieldsMandatory(5) = Array(cbo_BOR_Perf_AgId(0), 29)
        .ListFieldsMandatory(6) = Array(txt_BOP_ThsMin, 108)
        .ListFieldsMandatory(7) = Array(txt_BOP_ThsMax, 109)
        .ListFieldsMandatory(8) = Array(txt_BOP_AMin, 26)
        .ListFieldsMandatory(9) = Array(txt_BOP_AMax, 27)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(1)
        
        .MainGridColumns = Array( _
            "BOP_Id®©0®©1®©BOP_Id®©#BOP_Id", _
            "SYS_Name®©2600®©0®©SYS_Name®©#SYS_Name", _
            "PRF_Name®©2400®©0®©PRF_Name®©#PRF_Name", _
            "MAT_Name®©1600®©0®©MAT_Name®©#MAT_Name", _
            "BOP_ThsMin®©900®©0®©BOP_ThsMin®©#BOP_ThsMin", _
            "BOP_ThsMax®©900®©0®©BOP_ThsMax®©#BOP_ThsMax", _
            "BOP_QtyMin®©900®©0®©BOP_QtyMin®©#BOP_QtyMin", _
            "BOP_QtyMax®©900®©0®©BOP_QtyMax®©#BOP_QtyMax", _
            "BOP_KostSt1®©600®©0®©BOP_KostSt1®©#CostCentre1", _
            "BOP_KostSt2®©600®©0®©BOP_KostSt2®©#CostCentre2", _
            "BOP_KostSt3®©600®©0®©BOP_KostSt3®©#CostCentre3", _
            "BOP_Priority®©1400®©0®©BOP_Priority®©#BOP_Priority", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(2)
        .FrameIndex = 2
        .NameFrame = "DPC_BOR_Bend"
        .MainConfigIndex = 2
        .DetailKey = 2
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Bend_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Bend_ins $BOB_Id$,$BND_KostSt$,$BOB_Name$,$SYS_Name$,$BOB_Priority$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Bend_upd $BOB_Id$,$BND_KostSt$,$BOB_Name$,$SYS_Name$,$BOB_Priority$,$Z_last_upd_user$,$iConcurrency$")
        .RequestDel = Array("exec DPC_BOR_Param_Sys_del $BOB_Id$," & eDPCBOROperation.eBending, _
                            "exec DPC_BOR_Bend_del $BOB_Id$,$Z_last_upd_user$,$iConcurrency$")
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        '.RequestCheckAdd = "SELECT BOB_Id FROM DPC_BOR_Bend WHERE SYS_Id=$SYS_Id$ AND BND_KostSt=$BND_KostSt$"
        '.RequestCheckUpdate = "SELECT BOB_Id FROM DPC_BOR_Bend WHERE SYS_Id=$SYS_Id$ AND BND_KostSt=$BND_KostSt$ AND BOB_Id<>$BOB_Id$"
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Bend"
        .ToolbarIndex = 2
        .ToolbarID = 2868
        .ToolbarFaces = Array("0", "1", "2", "3")
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(3)
        .ListFieldsMandatory(0) = Array(txt_BOB_SYS_Name, 1)
        .ListFieldsMandatory(1) = Array(txt_BOB_Name, 151)
        .ListFieldsMandatory(2) = Array(cbo_Cutout_KostSt(1), 92)
        .ListFieldsMandatory(3) = Array(cbo_BOB_Priority(1), 19)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(2)
        
        .MainGridColumns = Array( _
            "BOB_Id®©0®©1®©BOB_Id®©#BOB_Id", _
            "BND_KostSt®©700®©0®©BND_KostSt®©#KostSt", _
            "BOB_Name®©2000®©0®©BOB_Name®©#BOB_Name", _
            "SYS_Name®©2400®©0®©SYS_Name®©#SYS_Name", _
            "BOB_Priority®©1000®©0®©BOB_Priority®©#BOB_Priority", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(3)
        .FrameIndex = 3
        .NameFrame = "DPC_BOR_PunchNotch"
        .MainConfigIndex = 3
        .DetailKey = 3
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_PunchNotch_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_PunchNotch_ins $BPN_Id$,$SYS_Name$,$PRF_Name$,$MAT_Name$,$CUT_Id$,$BPN_CutAMin$,$BPN_CutAMax$,$BPN_CutBMin$,$BPN_CutBMax$,$BPN_JMax$,$BPN_KMax$,$BPN_DMax$,$BPN_QtyMin$,$BPN_QtyMax$," & _
                            "$BPN_Priority$,$BPN_KostSt1$,$BPN_AgId1$,$BPN_WghPnt1$,$BPN_KostSt2$,$BPN_AgId2$,$BPN_WghPnt2$,$BPN_KostSt3$,$BPN_AgId3$,$BPN_WghPnt3$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_PunchNotch_upd $BPN_Id$,$SYS_Name$,$PRF_Name$,$MAT_Name$,$CUT_Id$,$BPN_CutAMin$,$BPN_CutAMax$,$BPN_CutBMin$,$BPN_CutBMax$,$BPN_JMax$,$BPN_KMax$,$BPN_DMax$,$BPN_QtyMin$,$BPN_QtyMax$," & _
                            "$BPN_Priority$,$BPN_KostSt1$,$BPN_AgId1$,$BPN_WghPnt1$,$BPN_KostSt2$,$BPN_AgId2$,$BPN_WghPnt2$,$BPN_KostSt3$,$BPN_AgId3$,$BPN_WghPnt3$,$Z_last_upd_user$,$iConcurrency$")
        .RequestDel = Array("exec DPC_BOR_Param_Prod_del $BPN_Id$," & eDPCBOROperation.ePunchNotching & "," & eDPCCategory.cgPerforation, _
                            "exec DPC_BOR_Param_Mat_del $BPN_Id$," & eDPCBOROperation.ePunchNotching, _
                            "exec DPC_BOR_Param_Sys_del $BPN_Id$," & eDPCBOROperation.ePunchNotching, _
                            "exec DPC_BOR_PunchNotch_del $BPN_Id$,$Z_last_upd_user$,$iConcurrency$")
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_PunchNotch"
        .ToolbarIndex = 3
        .ToolbarID = 2870
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BPN_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BPN_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BPN_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(11)
        .ListFieldsMandatory(0) = Array(txt_BPN_CutAMin, 36)
        .ListFieldsMandatory(1) = Array(txt_BPN_CutAMax, 145)
        .ListFieldsMandatory(2) = Array(txt_BPN_CutBMin, 146)
        .ListFieldsMandatory(3) = Array(txt_BPN_CutBMax, 147)
        .ListFieldsMandatory(4) = Array(txt_BPN_JMax, 148)
        .ListFieldsMandatory(5) = Array(txt_BPN_KMax, 149)
        .ListFieldsMandatory(6) = Array(txt_BPN_DMax, 150)
        .ListFieldsMandatory(7) = Array(txt_BPN_QtyMin, 35)
        .ListFieldsMandatory(8) = Array(txt_BPN_QtyMax, 34)
        .ListFieldsMandatory(9) = Array(cbo_BOB_Priority(2), 31)
        .ListFieldsMandatory(10) = Array(cbo_BOR_Perf_AgId(2), 30)
        .ListFieldsMandatory(11) = Array(cbo_KostSt_Filter(2), 100)
        '.ListFieldsMandatory(12) = Array(cbo_Cutout, 37)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(3)
        
        .MainGridColumns = Array( _
            "BPN_Id®©0®©1®©BPN_Id®©#BPN_Id", _
            "SYS_Name®©2400®©0®©SYS_Name®©#SYS_Name", _
            "PRF_Name®©2400®©0®©PRF_Name®©#PRF_Name", _
            "MAT_Name®©2400®©0®©MAT_Name®©#MAT_Name", _
            "CUT_Name®©1500®©0®©CUT_Name®©#Cut Name", _
            "BPN_QtyMin®©700®©0®©BPN_QtyMin®©#QtyMin", _
            "BPN_QtyMax®©700®©0®©BPN_QtyMax®©#QtyMax", _
            "BPN_Priority®©800®©0®©BPN_Priority®©#Priority", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(4)
        .FrameIndex = 4
        .NameFrame = "DPC_BOR_Coating"
        .MainConfigIndex = 4
        .DetailKey = 4
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Coating_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Coating_ins $BOA_Id$,$PRF_Class$,$BOA_PanAMax$,$BOA_PanBMax$," & _
                            "$BOA_CoSid$,$BOA_BndVis$,$COA_Type$,$BOA_Priority$,$BOA_KostSt1$,$BOA_AgId1$,$BOA_WghPnt1$,$BOA_KostSt2$,$BOA_AgId2$,$BOA_WghPnt2$,$BOA_KostSt3$,$BOA_AgId3$,$BOA_WghPnt3$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Coating_upd $BOA_Id$,$PRF_Class$,$BOA_PanAMax$,$BOA_PanBMax$," & _
                            "$BOA_CoSid$,$BOA_BndVis$,$COA_Type$,$BOA_Priority$,$BOA_KostSt1$,$BOA_AgId1$,$BOA_WghPnt1$,$BOA_KostSt2$,$BOA_AgId2$,$BOA_WghPnt2$,$BOA_KostSt3$,$BOA_AgId3$,$BOA_WghPnt3$,$Z_last_upd_user$,$iConcurrency$")
        .RequestDel = Array("exec DPC_BOR_Coating_del $BOA_Id$,$Z_last_upd_user$,$iConcurrency$")
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Coating"
        .ToolbarIndex = 4
        .ToolbarID = 2872
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BOA_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BOA_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BOA_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(8)
        .ListFieldsMandatory(0) = Array(txt_BOA_PanAMax, 41)
        .ListFieldsMandatory(1) = Array(txt_BOA_PanBMax, 39)
        .ListFieldsMandatory(2) = Array(cbo_BOA_CoSid, 38)
        .ListFieldsMandatory(3) = Array(cbo_BOA_BndVis, 45)
        .ListFieldsMandatory(4) = Array(cbo_COA_Type, 43)
        .ListFieldsMandatory(5) = Array(cbo_BOB_Priority(3), 74)
        .ListFieldsMandatory(6) = Array(cbo_BOR_Perf_AgId(3), 33)
        .ListFieldsMandatory(7) = Array(cbo_PRF_Class, 44)
        .ListFieldsMandatory(8) = Array(cbo_KostSt_Filter, 101)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(4)
        
        .MainGridColumns = Array( _
            "BOA_Id®©0®©1®©BOA_Id®©#BOA_Id", _
            "PRF_Class®©1000®©0®©PRF_Class®©#PRF_Class", _
            "BOA_PanAMax®©900®©0®©BOA_PanAMax®©#PanAMax", _
            "BOA_PanBMax®©900®©0®©BOA_PanBMax®©#PanBMax", _
            "BOA_Side_Desc®©1500®©0®©BOA_Side_Desc®©#CoSid", _
            "BOA_BndVis_Desc®©1700®©0®©BOA_BndVis_Desc®©#BndVis", _
            "COA_Type_Desc®©1700®©0®©COA_Type_Desc®©#COA Type", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(5)
        .FrameIndex = 5
        .NameFrame = "DPC_BOR_Gasket"
        .MainConfigIndex = 5
        .DetailKey = 5
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Gasket_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Gasket_ins $BOG_Id$,$BOG_PanAMax$,$BOG_PanBMax$,$BOG_Type$,$PRF_Class$," & _
                            "$BOG_Priority$,$BOG_KostSt1$, $BOG_AgId1$,$BOG_WghPnt1$,$BOG_KostSt2$, $BOG_AgId2$,$BOG_WghPnt2$,$BOG_KostSt3$, $BOG_AgId3$,$BOG_WghPnt3$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Gasket_upd $BOG_Id$,$BOG_PanAMax$,$BOG_PanBMax$,$BOG_Type$,$PRF_Class$," & _
                            "$BOG_Priority$,$BOG_KostSt1$, $BOG_AgId1$,$BOG_WghPnt1$,$BOG_KostSt2$, $BOG_AgId2$,$BOG_WghPnt2$,$BOG_KostSt3$, $BOG_AgId3$,$BOG_WghPnt3$,$Z_last_upd_user$,$iConcurrency$")
        .RequestDel = Array("exec DPC_BOR_Gasket_del $BOG_Id$,$Z_last_upd_user$,$iConcurrency$")
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Gasket"
        .ToolbarIndex = 5
        .ToolbarID = 2874
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BOG_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BOG_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BOG_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(5)
        .ListFieldsMandatory(0) = Array(txt_BOG_PanAMax, 50)
        .ListFieldsMandatory(1) = Array(txt_BOG_PanBMax, 51)
        .ListFieldsMandatory(2) = Array(cbo_PRF_Class(1), 47)
        .ListFieldsMandatory(3) = Array(cbo_BOB_Priority(4), 75)
        .ListFieldsMandatory(4) = Array(cbo_BOR_Perf_AgId(4), 54)
        .ListFieldsMandatory(5) = Array(cbo_KostSt_Filter(4), 102)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(5)
        
        .MainGridColumns = Array( _
            "BOG_Id®©0®©1®©BOG_Id®©#BOG_Id", _
            "BOG_PanAMax®©900®©0®©BOG_PanAMax®©#PanAMax", _
            "BOG_PanBMax®©900®©0®©BOG_PanBMax®©#PanBMax", _
            "BOG_Type®©0®©0®©BOG_Type®©#Type", _
            "BOG_Type_Desc®©1500®©0®©BOG_Type_Desc®©#Type", _
            "PRF_Class®©900®©0®©PRF_Class®©#PRF Class", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(6)
        .FrameIndex = 6
        .NameFrame = "DPC_BOR_Inlay"
        .MainConfigIndex = 6
        .DetailKey = 6
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Inlay_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Inlay_ins $BOI_Id$,$RPL_PBordDesc$,$INL_Name$,$CUT_Name$,$PRF_Class$,$BOI_PanAMax$,$BOI_PanBMax$,$BOI_CHMax$,$BOI_DHMax$,$BOI_EHBMax$,$BOI_FHMax$," & _
                            "$PIN_Purch$,$PIN_Deliv$,$BOI_KostSt1$,$BOI_AgId1$,$BOI_WghPnt1$,$BOI_KostSt2$,$BOI_AgId2$,$BOI_WghPnt2$,$BOI_KostSt3$,$BOI_AgId3$,$BOI_WghPnt3$,$BOI_Priority$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Inlay_upd $BOI_Id$,$RPL_PBordDesc$,$INL_Name$,$CUT_Name$,$PRF_Class$,$BOI_PanAMax$,$BOI_PanBMax$,$BOI_CHMax$,$BOI_DHMax$,$BOI_EHBMax$,$BOI_FHMax$," & _
                            "$PIN_Purch$,$PIN_Deliv$,$BOI_KostSt1$,$BOI_AgId1$,$BOI_WghPnt1$,$BOI_KostSt2$,$BOI_AgId2$,$BOI_WghPnt2$,$BOI_KostSt3$,$BOI_AgId3$,$BOI_WghPnt3$,$BOI_Priority$,$Z_last_upd_user$,$iConcurrency$")
        .RequestDel = Array("exec DPC_BOR_Inlay_del $BOI_Id$,$Z_last_upd_user$,$iConcurrency$")
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Inlay"
        .ToolbarIndex = 6
        .ToolbarID = 2876
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BOI_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BOI_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BOI_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(9)
        .ListFieldsMandatory(0) = Array(txt_BOI_PanAMax, 57)
        .ListFieldsMandatory(1) = Array(txt_BOI_PanBMax, 56)
        .ListFieldsMandatory(2) = Array(txt_BOI_CHMax, 55)
        .ListFieldsMandatory(3) = Array(txt_BOI_DHMax, 49)
        .ListFieldsMandatory(4) = Array(cbo_PRF_Class(2), 59)
        .ListFieldsMandatory(5) = Array(cbo_BOB_Priority(5), 76)
        .ListFieldsMandatory(6) = Array(cbo_BOR_Perf_AgId(5), 46)
        .ListFieldsMandatory(7) = Array(txt_BOI_EHBMax, 52)
        .ListFieldsMandatory(8) = Array(txt_BOI_FHMax, 53)
        .ListFieldsMandatory(9) = Array(cbo_KostSt_Filter(5), 103)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(6)
        
        .MainGridColumns = Array( _
            "BOI_Id®©0®©1®©BOI_Id®©#BOI_Id", _
            "PRF_Class®©500®©0®©PRF_Class®©#PRF_Class", _
            "RPL_PBordDesc®©8000®©0®©RPL_PBordDesc®©#RPL_PBordDesc", _
            "INL_Name®©3000®©0®©INL_Name®©#INL Name", _
            "CUT_Name®©3000®©0®©CUT_Name®©#CUT Name", _
            "PIN_PurchDesc®©1500®©0®©PIN_PurchDesc®©#PIN_Purch", _
            "PIN_DelivDesc®©1500®©0®©PIN_DelivDesc®©#PIN Deliv", _
            "BOI_PanAMax®©900®©0®©BOI_PanAMax®©#PanAMax", _
            "BOI_PanBMax®©900®©0®©BOI_PanBMax®©#PanBMax", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(7)
        .FrameIndex = 7
        .NameFrame = "DPC_BOR_Packing"
        .MainConfigIndex = 7
        .DetailKey = 7
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Packing_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Packing_ins $BOK_Id$,$PKG_Id$,$PRF_Class$,$BOK_PkgAMax$,$BOK_PkgBMax$,$BOK_PkgHMax$,$BOK_WghMax$,$BOK_PkgQty$," & _
                            "$BOK_QtyMin$,$BOK_QtyMax$,$BOK_Priority$,$BOK_KostSt1$,$BOK_AgId1$,$BOK_WghPnt1$,$BOK_KostSt2$,$BOK_AgId2$,$BOK_WghPnt2$,$BOK_KostSt3$,$BOK_AgId3$,$BOK_WghPnt3$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Packing_upd $BOK_Id$,$PKG_Id$,$PRF_Class$,$BOK_PkgAMax$,$BOK_PkgBMax$,$BOK_PkgHMax$,$BOK_WghMax$,$BOK_PkgQty$," & _
                            "$BOK_QtyMin$,$BOK_QtyMax$,$BOK_Priority$,$BOK_KostSt1$,$BOK_AgId1$,$BOK_WghPnt1$,$BOK_KostSt2$,$BOK_AgId2$,$BOK_WghPnt2$,$BOK_KostSt3$,$BOK_AgId3$,$BOK_WghPnt3$,$Z_last_upd_user$,$iConcurrency$")
        .RequestDel = Array("exec DPC_BOR_Packing_del $BOK_Id$,$Z_last_upd_user$,$iConcurrency$")
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Packing"
        .ToolbarIndex = 7
        .ToolbarID = 2878
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BOK_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BOK_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BOK_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(11)
        .ListFieldsMandatory(0) = Array(txt_BOK_PkgAMax, 60)
        .ListFieldsMandatory(1) = Array(txt_BOK_PkgBMax, 61)
        .ListFieldsMandatory(2) = Array(txt_BOK_PkgHMax, 62)
        .ListFieldsMandatory(3) = Array(txt_BOK_PkgQty, 140)
        .ListFieldsMandatory(4) = Array(cbo_PRF_Class(3), 58)
        .ListFieldsMandatory(5) = Array(cbo_BOB_Priority(6), 77)
        .ListFieldsMandatory(6) = Array(cbo_BOR_Perf_AgId(6), 64)
        .ListFieldsMandatory(7) = Array(txt_BOK_QtyMin, 141)
        .ListFieldsMandatory(8) = Array(txt_BOK_QtyMax, 142)
        .ListFieldsMandatory(9) = Array(txt_BOK_WghMax, 63)
        .ListFieldsMandatory(10) = Array(cbo_KostSt_Filter(6), 104)
        .ListFieldsMandatory(11) = Array(cbo_Packing(1), 139)
        
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(7)
        
        .MainGridColumns = Array( _
            "BOK_Id®©0®©1®©BOK_Id®©#BOK_Id", _
            "PRF_Class®©900®©0®©PRF_Class®©#PRF Class", _
            "PKG_Name®©2000®©0®©PKG_Name®©#PKG Name", _
            "BOK_PkgAMax®©0®©0®©BOK_PkgAMax®©#PkgAMax", _
            "BOK_PkgBMax®©0®©0®©BOK_PkgBMax®©#PkgBMax", _
            "BOK_PkgHMax®©0®©0®©BOK_PkgHMax®©#PkgHMax", _
            "BOK_WghMax®©0®©0®©BOK_WghMax®©#WghHMax", _
            "BOK_PkgQty®©0®©0®©BOK_PkgQty®©#PkgQty", _
            "BOK_QtyMin®©0®©0®©BOK_QtyMin®©#QtyMin", _
            "BOK_QtyMax®©0®©0®©BOK_QtyMax®©#QtyMax", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(8)
        .FrameIndex = 8
        .NameFrame = "DPC_BOR_Cutting"
        .MainConfigIndex = 8
        .DetailKey = 8
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Cutting_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Cutting_ins $BOC_Id$,$MAT_Name$,$BOC_ThsMin$,$BOC_ThsMax$,$BOC_CutAMin$,$BOC_CutAMax$,$BOC_CutBMin$,$BOC_CutBMax$,$BOC_QtyMin$,$BOC_QtyMax$,$BOC_Priority$,$BOC_KostSt1$,$BOC_AgId1$,$BOC_WghPnt1$,$BOC_KostSt2$,$BOC_AgId2$,$BOC_WghPnt2$,$BOC_KostSt3$,$BOC_AgId3$,$BOC_WghPnt3$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Cutting_upd $BOC_Id$,$MAT_Name$,$BOC_ThsMin$,$BOC_ThsMax$,$BOC_CutAMin$,$BOC_CutAMax$,$BOC_CutBMin$,$BOC_CutBMax$,$BOC_QtyMin$,$BOC_QtyMax$,$BOC_Priority$,$BOC_KostSt1$,$BOC_AgId1$,$BOC_WghPnt1$,$BOC_KostSt2$,$BOC_AgId2$,$BOC_WghPnt2$,$BOC_KostSt3$,$BOC_AgId3$,$BOC_WghPnt3$,$Z_last_upd_user$,$iConcurrency$")
        .RequestDel = Array("exec DPC_BOR_Param_Mat_del $BOC_Id$," & eDPCBOROperation.eCutting & "", _
                            "exec DPC_BOR_Cutting_del $BOC_Id$,$Z_last_upd_user$,$iConcurrency$")
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Cutting"
        .ToolbarIndex = 8
        .ToolbarID = 2939
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BOC_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BOC_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BOC_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(10)
        .ListFieldsMandatory(0) = Array(txt_BOC_QtyMin, 121)
        .ListFieldsMandatory(1) = Array(txt_BOC_QtyMax, 120)
        .ListFieldsMandatory(2) = Array(txt_BOC_CutBMin, 114)
        .ListFieldsMandatory(3) = Array(txt_BOC_CutBMax, 113)
        .ListFieldsMandatory(4) = Array(cbo_BOB_Priority(7), 117)
        .ListFieldsMandatory(5) = Array(cbo_BOR_Perf_AgId(9), 116)
        .ListFieldsMandatory(6) = Array(cbo_KostSt_Filter(9), 115)
        .ListFieldsMandatory(7) = Array(txt_BOC_CutAMin, 119)
        .ListFieldsMandatory(8) = Array(txt_BOC_CutAMax, 118)
        .ListFieldsMandatory(9) = Array(txt_BOC_ThsMin, 112)
        .ListFieldsMandatory(10) = Array(txt_BOC_ThsMax, 111)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(8)
        
        .MainGridColumns = Array( _
            "BOC_Id®©0®©1®©BOC_Id®©#BOC_Id", _
            "MAT_Name®©4600®©0®©MAT_Name®©#MAT_Name", _
            "BOC_ThsMin®©1000®©0®©BOC_ThsMin®©#BOC_ThsMin", _
            "BOC_ThsMax®©1000®©0®©BOC_ThsMax®©#BOC_ThsMax", _
            "BOC_QtyMin®©1200®©0®©BOC_QtyMin®©#BOC_QtyMin", _
            "BOC_QtyMax®©1200®©0®©BOC_QtyMax®©#BOC_QtyMax", _
            "BOC_Priority®©1400®©0®©BOC_Priority®©#BOC_Priority", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(9)
        .FrameIndex = 9
        .NameFrame = "DPC_BOR_Rerolling"
        .MainConfigIndex = 9
        .DetailKey = 9
        .ClearControlsBeforeInit = True

        .RequestView = "exec DPC_BOR_Rerolling_sel $Key1$, $Language_Code$"
        .RequestAdd = Array("exec DPC_BOR_Rerolling_ins $BRR_Id$,$PRF_Name$,$MAT_Name$,$BRR_ThsMin$,$BRR_ThsMax$,$BRR_CutAMin$,$BRR_CutAMax$,$BRR_CutBMin$,$BRR_CutBMax$,$BRR_QtyMin$,$BRR_QtyMax$,$BRR_Priority$,$BRR_KostSt1$,$BRR_AgId1$,$BRR_WghPnt1$,$BRR_KostSt2$,$BRR_AgId2$,$BRR_WghPnt2$,$BRR_KostSt3$,$BRR_AgId3$,$BRR_WghPnt3$,$Z_creator$", _
                            "exec DPC_BOR_Param_Prod_ins $BRR_Id$," & eDPCBOROperation.eRerolling & "," & eDPCCategory.cgPerforation & ",$PRF_Id$,$Z_creator$")
        .RequestUpd = Array("exec DPC_BOR_Rerolling_upd $BRR_Id$,$PRF_Name$,$MAT_Name$,$BRR_ThsMin$,$BRR_ThsMax$,$BRR_CutAMin$,$BRR_CutAMax$,$BRR_CutBMin$,$BRR_CutBMax$,$BRR_QtyMin$,$BRR_QtyMax$,$BRR_Priority$,$BRR_KostSt1$,$BRR_AgId1$,$BRR_WghPnt1$,$BRR_KostSt2$,$BRR_AgId2$,$BRR_WghPnt2$,$BRR_KostSt3$,$BRR_AgId3$,$BRR_WghPnt3$,$Z_last_upd_user$,$iConcurrency$", _
                            "exec DPC_BOR_Param_Prod_del $BRR_Id$," & eDPCBOROperation.eRerolling & "," & eDPCCategory.cgPerforation, _
                            "exec DPC_BOR_Param_Prod_ins $BRR_Id$," & eDPCBOROperation.eRerolling & "," & eDPCCategory.cgPerforation & ",$PRF_Id$,$Z_creator$")
        .RequestDel = Array("exec DPC_BOR_Param_Prod_del $BRR_Id$," & eDPCBOROperation.eRerolling & "," & eDPCCategory.cgPerforation, _
                            "exec DPC_BOR_Param_Mat_del $BRR_Id$," & eDPCBOROperation.eRerolling, _
                            "exec DPC_BOR_Rerolling_del $BRR_Id$,$Z_last_upd_user$,$iConcurrency$")
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .RequestCheckAdd = ""
        .RequestCheckUpdate = ""
        
        .UseTransaction = True
        .TableName = "DPC_BOR_Rerolling"
        .ToolbarIndex = 9
        .ToolbarID = 2941
        .ToolbarFaces = Array("0", "1", "2", "3")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BRR_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BRR_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BRR_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(9)
        .ListFieldsMandatory(0) = Array(txt_BRR_QtyMin, 131)
        .ListFieldsMandatory(1) = Array(txt_BRR_QtyMax, 130)
        .ListFieldsMandatory(2) = Array(txt_BRR_CutBMin, 124)
        .ListFieldsMandatory(3) = Array(txt_BRR_CutBMax, 123)
        .ListFieldsMandatory(4) = Array(cbo_BOB_Priority(8), 127)
        .ListFieldsMandatory(5) = Array(cbo_BOR_Perf_AgId(14), 126)
        .ListFieldsMandatory(6) = Array(txt_BRR_ThsMin, 42)
        .ListFieldsMandatory(7) = Array(txt_BRR_ThsMax, 40)
        .ListFieldsMandatory(8) = Array(txt_BRR_CutAMin, 129)
        .ListFieldsMandatory(9) = Array(txt_BRR_CutAMax, 128)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(9)
        
        .MainGridColumns = Array( _
            "BRR_Id®©0®©1®©BRR_Id®©#BRR_Id", _
            "PRF_Name®©1400®©0®©PRF_Name®©#PRF_Name", _
            "MAT_Name®©2600®©0®©MAT_Name®©#MAT_Name", _
            "BRR_ThsMin®©1000®©0®©BRR_ThsMin®©#BRR_ThsMin", _
            "BRR_ThsMax®©1000®©0®©BRR_ThsMax®©#BRR_ThsMax", _
            "BRR_QtyMin®©1200®©0®©BRR_QtyMin®©#BRR_QtyMin", _
            "BRR_QtyMax®©1200®©0®©BRR_QtyMax®©#BRR_QtyMax", _
            "BRR_Priority®©1200®©0®©BOP_Priority®©#BOP_Priority", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        ReDim .InitControls(-1 To -1)
        'control, tag, visible, request, maxlength
    End With
    
    With mt_DetailConfig(10)
        .FrameIndex = 10
        .NameFrame = "DPC_DataImport"
        .MainConfigIndex = -1
        .DetailKey = 10
        .ClearControlsBeforeInit = False

        .RequestView = ""
        .RequestAdd = ""
        .RequestUpd = ""
        .RequestDel = ""
        
        .AffectedCount = Array(-1, -1, -1, -1)
        
        .UseTransaction = True
        .TableName = "DPC_DataImport"
        .ToolbarIndex = 10
        .ToolbarID = 2856
        .ToolbarFaces = Array("0", "1", "2", "3")
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(-1 To -1)
        
        ReDim .ListFieldsToDisable(0)
        Set .ListFieldsToDisable(0) = txt_DetailKey(10)
        
        .MainGridColumns = Array( _
            "MSG_Id®©0®©1®©MSG_Id®©#MSG_Id", _
            "MSG_Text®©3500®©0®©MSG_Text®©#MSG_Text", _
            "Z_Creator®©0®©0®©Z_Creator®©#Z_Creator", _
            "Z_Creation®©1000®©0®©Z_Creation®©#Creation date")
        
        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_BOR_OperCost"
        .DetailConfigIndex = 0
        .Initialized = False
        
        .RequestView = "exec DPC_BOR_OperCost_lst $Key1$"
        .RequestAdd = "exec DPC_BOR_OperCost_ins $RF_Code$,$BOC_KostSt$,$U_Code$"
        .RequestUpd = "exec DPC_BOR_OperCost_upd $RF_Code$,$BOC_KostSt$,$U_Code$,$iConcurrency$"
        .RequestDel = "exec DPC_BOR_OperCost_del $RF_Code$,$BOC_KostSt$,$U_Code$,$iConcurrency$"
        
        .RequestCheckAdd = "SELECT OPR_Id FROM DPC_BOR_OperCost WHERE BOC_KostSt = $BOC_KostSt$ AND OPR_Id = $RF_Code$ AND Drop_Flag <> 'X'"
        .RequestCheckUpdate = "SELECT OPR_Id FROM DPC_BOR_OperCost WHERE BOC_KostSt = $BOC_KostSt$ AND OPR_Id = $RF_Code$ AND Drop_Flag <> 'X'"
        
        .TableName = ""
        .TableOrder = ""
        
        .ToolbarID = 2864
        .ToolbarIndex = 0
        .ToolbarFaces = Array("0", "1", "2", "3", "4")
        
        .GridColumns = Array( _
            "BOC_KostSt®©1600®©1®©BOC_KostSt®©#BOC_KostSt", _
            "BOC_KostSt_Desc®©2600®©0®©BOC_KostSt_Desc®©#BOC_KostSt_Desc", _
            "RowStatus®©0®©0®©RowStatus®©#RowStatus", _
            "iConcurrency®©0®©0®©iConcurrency®©iConcurrency")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(0)
        .ListFieldsMandatory(0) = Array(cbo_KostSt, 67)
        
        ReDim .ListFieldsToDisable(-1 To -1)
    End With

    With mt_SubdetailConfig(1)
        .FrameIndex = 1
        .NameFrame = "DPC_BOR_Bend_Spec"
        .DetailConfigIndex = 2
        .Initialized = False
        
        .TabStribIndex = 0
        .TabIndex = 1
        .ShowInTabs = True
        
        .RequestView = "exec DPC_BOR_Bend_Spec_lst $Key1$, $Language_Code$"
        .RequestAdd = "exec DPC_BOR_Bend_Spec_ins $BOS_Id$,$BOB_Id$,$MAT_Id$,$BOS_PanAMin$,$BOS_PanAMax$,$BOS_PanBMin$,$BOS_PanBMax$,$BOS_ThsMin$,$BOS_ThsMax$,$BOS_CutAMin$,$BOS_CutAMax$,$BOS_CutBMin$,$BOS_CutBMax$,$BOS_ABMin$,$BOS_ExtBnd$,$BOS_CDIsEqual$,$U_Code$"
        .RequestUpd = "exec DPC_BOR_Bend_Spec_upd $BOS_Id$,$BOB_Id$,$MAT_Id$,$BOS_PanAMin$,$BOS_PanAMax$,$BOS_PanBMin$,$BOS_PanBMax$,$BOS_ThsMin$,$BOS_ThsMax$,$BOS_CutAMin$,$BOS_CutAMax$,$BOS_CutBMin$,$BOS_CutBMax$,$BOS_ABMin$,$BOS_ExtBnd$,$BOS_CDIsEqual$,$U_Code$,$iConcurrency$"
        .RequestDel = "exec DPC_BOR_Bend_Spec_del $BOS_Id$,$U_Code$,$iConcurrency$"
        
        '.RequestCheckAdd = "exec DPC_BOR_Bend_Spec_chk NULL,$SYS_Id$,$BND_KostSt$,$BOS_AMin$,$BOS_AMax$,$BOS_BMin$,$BOS_BMax$,$BOS_ThickMin$,$BOS_ThickMax$,$BOS_CutLengthA$,$BOS_CutLengthB$,$BOS_ABMin$"
        '.RequestCheckUpdate = "exec DPC_BOR_Bend_Spec_chk $BOS_Id$,$SYS_Id$,$BND_KostSt$,$BOS_AMin$,$BOS_AMax$,$BOS_BMin$,$BOS_BMax$,$BOS_ThickMin$,$BOS_ThickMax$,$BOS_CutLengthA$,$BOS_CutLengthB$,$BOS_ABMin$"
        
        .TableName = "DPC_BOR_Bend_Spec"
        .TableOrder = ""
        
        .ToolbarID = 2901
        .ToolbarIndex = 1
        .ToolbarFaces = Array("0", "1", "2", "3", "4")
        
        .GridColumns = Array( _
            "BOS_Id®©0®©1®©BOS_Id®©#BOS_Id", _
            "BOB_Id®©0®©0®©BOB_Id®©#BOB_Id", _
            "MAT_Id®©0®©0®©MAT_Id®©#MAT_Id", _
            "MAT_Name®©1000®©0®©MAT_Name®©#MAT_Name", _
            "BOS_PanAMin®©700®©0®©BOS_PanAMin®©#PanAMin", _
            "BOS_PanAMax®©700®©0®©BOS_PanAMax®©#PanAMax", _
            "BOS_PanBMin®©700®©0®©BOS_PanBMin®©#PanBMin", _
            "BOS_PanBMax®©700®©0®©BOS_PanBMax®©#PanBMax", _
            "BOS_ThsMin®©1200®©0®©BOS_ThsMin®©#ThsMin", _
            "BOS_ThsMax®©1200®©0®©BOS_ThsMax®©#ThsMax", _
            "BOS_CutAMin®©700®©0®©BOS_CutAMin®©#CutAMin", _
            "BOS_CutAMax®©700®©0®©BOS_CutAMax®©#CutAMax", _
            "BOS_CutBMin®©700®©0®©BOS_CutBMin®©#CutBMin", _
            "BOS_CutBMax®©700®©0®©BOS_CutBMax®©#CutBMax", _
            "BOS_ABMin®©800®©0®©BOS_ABMin®©#ABMin", _
            "BOS_ExtBnd®©800®©0®©BOS_ExtBnd®©#ExtBnd", _
            "BOS_CDIsEqual®©800®©0®©BOS_CDIsEqual®©#CDIsEqual", _
            "RowStatus®©0®©0®©RowStatus®©#RowStatus", _
            "iConcurrency®©0®©0®©iConcurrency®©iConcurrency")
        
        ReDim .ListFieldsDefaultValue(-1 To -1)
        
        ReDim .ListFieldsMandatory(12)
        .ListFieldsMandatory(0) = Array(txt_BOS_PanAMin, 11)
        .ListFieldsMandatory(1) = Array(txt_BOS_PanAMax, 11)
        .ListFieldsMandatory(2) = Array(txt_BOS_PanBMin, 15)
        .ListFieldsMandatory(3) = Array(txt_BOS_PanBMax, 15)
        .ListFieldsMandatory(4) = Array(txt_BOS_ThsMin, 93)
        .ListFieldsMandatory(5) = Array(txt_BOS_ThsMax, 93)
        .ListFieldsMandatory(6) = Array(txt_BOS_CutAMin, 95)
        .ListFieldsMandatory(7) = Array(txt_BOS_CutAMax, 95)
        .ListFieldsMandatory(8) = Array(txt_BOS_CutBMin, 167)
        .ListFieldsMandatory(9) = Array(txt_BOS_CutBMax, 167)
        .ListFieldsMandatory(10) = Array(txt_BOS_ABMin, 97)
        .ListFieldsMandatory(11) = Array(cbo_Material(1), 94)
        .ListFieldsMandatory(12) = Array(txt_BOS_ExtBnd, 0)
        
        
        ReDim .ListFieldsToDisable(-1 To -1)
    End With

    With mt_SubdetailConfig(2)
        .FrameIndex = 2
        .NameFrame = "DPC_BOR_Bend_Param"
        .DetailConfigIndex = 2
        .Initialized = False
        
        .TabStribIndex = 0
        .TabIndex = 2
        .ShowInTabs = True
        
        .RequestView = "exec DPC_BOR_Bend_Param_lst $Key1$,$Language_code$"
        .RequestAdd = "exec DPC_BOR_Bend_Param_ins $BOE_Id$,$BOB_Id$," & _
                            "$BND_IdC$,$BOE_CHMin$,$BOE_CHMax$,$BOE_CFMin$,$BOE_CFMax$,$BOE_CUZMin$,$BOE_CUZMax$,$BOE_CSMin$,$BOE_CSMax$," & _
                            "$BND_IdD$,$BOE_DHMin$,$BOE_DHMax$,$BOE_DFMin$,$BOE_DFMax$,$BOE_DUZMin$,$BOE_DUZMax$,$BOE_DSMin$,$BOE_DSMax$," & _
                            "$BND_IdE$,$BOE_EHMin$,$BOE_EHMax$,$BOE_EUZMin$,$BOE_EUZMax$,$BOE_ESMin$,$BOE_ESMax$," & _
                            "$BND_IdF$,$BOE_FHMin$,$BOE_FHMax$,$BOE_FUZMin$,$BOE_FUZMax$,$BOE_FSMin$,$BOE_FSMax$," & _
                            "$BOE_QtyMin$,$BOE_QtyMax$,$BOE_KostSt1$,$BOE_AgId1$,$BOE_WghPnt1$,$BOE_KostSt2$,$BOE_AgId2$,$BOE_WghPnt2$,$BOE_KostSt3$,$BOE_AgId3$,$BOE_WghPnt3$,$Z_creator$"
        .RequestUpd = "exec DPC_BOR_Bend_Param_upd $BOE_Id$,$BOB_Id$," & _
                            "$BND_IdC$,$BOE_CHMin$,$BOE_CHMax$,$BOE_CFMin$,$BOE_CFMax$,$BOE_CUZMin$,$BOE_CUZMax$,$BOE_CSMin$,$BOE_CSMax$," & _
                            "$BND_IdD$,$BOE_DHMin$,$BOE_DHMax$,$BOE_DFMin$,$BOE_DFMax$,$BOE_DUZMin$,$BOE_DUZMax$,$BOE_DSMin$,$BOE_DSMax$," & _
                            "$BND_IdE$,$BOE_EHMin$,$BOE_EHMax$,$BOE_EUZMin$,$BOE_EUZMax$,$BOE_ESMin$,$BOE_ESMax$," & _
                            "$BND_IdF$,$BOE_FHMin$,$BOE_FHMax$,$BOE_FUZMin$,$BOE_FUZMax$,$BOE_FSMin$,$BOE_FSMax$," & _
                            "$BOE_QtyMin$,$BOE_QtyMax$,$BOE_KostSt1$,$BOE_AgId1$,$BOE_WghPnt1$,$BOE_KostSt2$,$BOE_AgId2$,$BOE_WghPnt2$,$BOE_KostSt3$,$BOE_AgId3$,$BOE_WghPnt3$,$Z_last_upd_user$,$iConcurrency$"
        .RequestDel = "exec DPC_BOR_Bend_Param_del $BOE_Id$,$U_Code$,$iConcurrency$"
        
        '.RequestCheckAdd = "exec DPC_BOR_Bend_Param_chk NULL,$SYS_Id$,$BND_KostSt$,$BND_Id$,$BOB_CDHMin$,$BOB_CDHMax$,$BOB_CDUMin$,$BOB_CDUMax$,$BOB_CDSMin$,$BOB_CDSMax$,$BOB_CDIsEqual$," & _
        '                   "$BOB_EFHMin$,$BOB_EFHMax$,$BOB_EFUMin$,$BOB_EFUMax$,$BOB_EFSMin$,$BOB_EFSMax$,$BOB_EFIsEqual$,$BOB_Priority$,$BOB_AgId$"
        '.RequestCheckUpdate = "exec DPC_BOR_Bend_Param_chk $BOE_Id$,$SYS_Id$,$BND_KostSt$,$BND_Id$,$BOB_CDHMin$,$BOB_CDHMax$,$BOB_CDUMin$,$BOB_CDUMax$,$BOB_CDSMin$,$BOB_CDSMax$,$BOB_CDIsEqual$," & _
        '                   "$BOB_EFHMin$,$BOB_EFHMax$,$BOB_EFUMin$,$BOB_EFUMax$,$BOB_EFSMin$,$BOB_EFSMax$,$BOB_EFIsEqual$,$BOB_Priority$,$BOB_AgId$"
        
        .TableName = "DPC_BOR_Bend_Param"
        .TableOrder = ""
        
        .ToolbarID = 2902
        .ToolbarIndex = 2
        .ToolbarFaces = Array("0", "1", "2", "3", "4")
        
        .GridColumns = Array( _
            "BOE_Id®©0®©1®©BOE_Id®©#BOE_Id", _
            "BND_IdC®©0®©0®©BND_IdC®©#BND_IdC", "BND_NameC®©1500®©0®©BND_NameC®©#BND_NameC", _
            "BOE_CHMin®©0®©0®©BOE_CHMin®©#CHMin", "BOE_CHMax®©0®©0®©BOE_CHMax®©#CHMax", "BOE_CFMin®©0®©0®©BOE_CFMin®©#CFMin", "BOE_CFMax®©0®©0®©BOE_CFMax®©#CFMax", "BOE_CUZMin®©0®©0®©BOE_CUZMin®©#CUZMin", "BOE_CUZMax®©0®©0®©BOE_CUZMax®©#CUZMax", "BOE_CSMin®©0®©0®©BOE_CSMin®©#CSMin", "BOE_CSMax®©0®©0®©BOE_CSMax®©#CSMax", _
            "BND_IdD®©0®©0®©BND_IdD®©#BND_IdD", "BND_NameD®©1500®©0®©BND_NameD®©#BND_NameD", _
            "BOE_DHMin®©0®©0®©BOE_DHMin®©#DHMin", "BOE_DHMax®©0®©0®©BOE_DHMax®©#DHMax", "BOE_DFMin®©0®©0®©BOE_DFMin®©#DFMin", "BOE_DFMax®©0®©0®©BOE_DFMax®©#DFMax", "BOE_DUZMin®©0®©0®©BOE_DUZMin®©#DUZMin", "BOE_DUZMax®©0®©0®©BOE_DUZMax®©#DUZMax", "BOE_DSMin®©0®©0®©BOE_DSMin®©#DSMin", "BOE_DSMax®©0®©0®©BOE_DSMax®©#DSMax", _
            "BND_IdE®©0®©0®©BND_IdE®©#BND_IdE", "BND_NameE®©1500®©0®©BND_NameE®©#BND_NameE", _
            "BOE_EHMin®©0®©0®©BOE_EHMin®©#EHMin", "BOE_EHMax®©0®©0®©BOE_EHMax®©#EHMax", "BOE_EUZMin®©0®©0®©BOE_EUZMin®©#EUZMin", "BOE_EUZMax®©0®©0®©BOE_EUZMax®©#EUZMax", "BOE_ESMin®©0®©0®©BOE_ESMin®©#ESMin", "BOE_ESMax®©0®©0®©BOE_ESMax®©#ESMax", _
            "BND_IdF®©0®©0®©BND_IdF®©#BND_IdF", "BND_NameF®©1500®©0®©BND_NameF®©#BND_NameF", _
            "BOE_FHMin®©0®©0®©BOE_FHMin®©#FHMin", "BOE_FHMax®©0®©0®©BOE_FHMax®©#FHMax", "BOE_FUZMin®©0®©0®©BOE_FUZMin®©#FUZMin", "BOE_FUZMax®©0®©0®©BOE_FUZMax®©#FUZMax", "BOE_FSMin®©0®©0®©BOE_FSMin®©#FSMin", "BOE_FSMax®©0®©0®©BOE_FSMax®©#FSMax", _
            "BOE_QtyMin®©700®©0®©BOE_QtyMin®©#QtyMin", _
            "BOE_QtyMax®©700®©0®©BOE_QtyMax®©#QtyMax", _
            "BOE_KostSt1®©700®©0®©BOE_KostSt1®©#KostSt1", "BOE_AgId1®©900®©0®©BOE_AgId1®©#AgId1", "BOE_WghPnt1®©500®©0®©BOE_WghPnt1®©#WghPnt1", _
            "BOE_KostSt2®©700®©0®©BOE_KostSt2®©#KostSt2", "BOE_AgId2®©900®©0®©BOE_AgId2®©#AgId2", "BOE_WghPnt2®©500®©0®©BOE_WghPnt2®©#WghPnt2", _
            "BOE_KostSt3®©700®©0®©BOE_KostSt3®©#KostSt3", "BOE_AgId3®©900®©0®©BOE_AgId3®©#AgId3", "BOE_WghPnt3®©500®©0®©BOE_WghPnt3®©#WghPnt3", _
            "RowStatus®©0®©0®©RowStatus®©#RowStatus", _
            "iConcurrency®©0®©0®©iConcurrency®©iConcurrency")
        
        ReDim .ListFieldsDefaultValue(2)
        .ListFieldsDefaultValue(0) = Array(txt_BOE_WghPnt1, 0)
        .ListFieldsDefaultValue(1) = Array(txt_BOE_WghPnt2, 0)
        .ListFieldsDefaultValue(2) = Array(txt_BOE_WghPnt3, 0)
        
        ReDim .ListFieldsMandatory(35)
        .ListFieldsMandatory(0) = Array(cbo_Bending(0), 6)
        .ListFieldsMandatory(1) = Array(txt_BOE_CHMin, 7)
        .ListFieldsMandatory(2) = Array(txt_BOE_CHMax, 7)
        .ListFieldsMandatory(3) = Array(txt_BOE_CFMin, 2)
        .ListFieldsMandatory(4) = Array(txt_BOE_CFMax, 2)
        .ListFieldsMandatory(5) = Array(txt_BOE_CUZMin, 3)
        .ListFieldsMandatory(6) = Array(txt_BOE_CUZMax, 3)
        .ListFieldsMandatory(7) = Array(txt_BOE_CSMin, 17)
        .ListFieldsMandatory(8) = Array(txt_BOE_CSMax, 17)
        .ListFieldsMandatory(9) = Array(cbo_Bending(1), 155)
        .ListFieldsMandatory(10) = Array(txt_BOE_DHMin, 156)
        .ListFieldsMandatory(11) = Array(txt_BOE_DHMax, 156)
        .ListFieldsMandatory(12) = Array(txt_BOE_DFMin, 153)
        .ListFieldsMandatory(13) = Array(txt_BOE_DFMax, 153)
        .ListFieldsMandatory(14) = Array(txt_BOE_DUZMin, 154)
        .ListFieldsMandatory(15) = Array(txt_BOE_DUZMax, 154)
        .ListFieldsMandatory(16) = Array(txt_BOE_DSMin, 152)
        .ListFieldsMandatory(17) = Array(txt_BOE_DSMax, 152)
        .ListFieldsMandatory(18) = Array(cbo_Bending(2), 14)
        .ListFieldsMandatory(19) = Array(txt_BOE_EHMin, 10)
        .ListFieldsMandatory(20) = Array(txt_BOE_EHMax, 10)
        .ListFieldsMandatory(21) = Array(txt_BOE_EUZMin, 13)
        .ListFieldsMandatory(22) = Array(txt_BOE_EUZMax, 13)
        .ListFieldsMandatory(23) = Array(txt_BOE_ESMin, 16)
        .ListFieldsMandatory(24) = Array(txt_BOE_ESMax, 16)
        .ListFieldsMandatory(25) = Array(cbo_Bending(3), 164)
        .ListFieldsMandatory(26) = Array(txt_BOE_EHMin, 161)
        .ListFieldsMandatory(27) = Array(txt_BOE_EHMax, 161)
        .ListFieldsMandatory(28) = Array(txt_BOE_EUZMin, 160)
        .ListFieldsMandatory(29) = Array(txt_BOE_EUZMax, 160)
        .ListFieldsMandatory(30) = Array(txt_BOE_ESMin, 159)
        .ListFieldsMandatory(31) = Array(txt_BOE_ESMax, 159)
        .ListFieldsMandatory(32) = Array(txt_BOE_QtyMin, 98)
        .ListFieldsMandatory(33) = Array(txt_BOE_QtyMax, 18)
        .ListFieldsMandatory(34) = Array(cbo_KostSt_Filter(1), 105)
        .ListFieldsMandatory(35) = Array(cbo_BOR_Perf_AgId(1), 20)
        
        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
    
    ll_MainIndex = FindMainConfigByFrameIndex(Index)
    
    tlb_Main_CustomAction = False
    Select Case as_Role
    Case "A"
    Case "B", "C"
    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 FindDetailConfigByTableType(ByVal ae_TableType As eTableType) As Long
On Error GoTo ErrHandler

    Select Case ae_TableType
    Case eTableType.ttDPC_BOR_OperCost
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_OperCost")
    Case eTableType.ttDPC_BOR_Perf
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Perf")
    Case eTableType.ttDPC_BOR_Bend
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Bend")
    Case eTableType.ttDPC_BOR_PunchNotch
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_PunchNotch")
    Case eTableType.ttDPC_BOR_Coating
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Coating")
    Case eTableType.ttDPC_BOR_Gasket
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Gasket")
    Case eTableType.ttDPC_BOR_Gasket
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Inlay")
    Case eTableType.ttDPC_BOR_Gasket
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Packing")
    Case eTableType.ttDPC_BOR_Cutting
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Cutting")
    Case eTableType.ttDPC_BOR_Rerolling
        FindDetailConfigByTableType = FindDetailConfigByName("DPC_BOR_Rerolling")
    Case Else
        Err.Raise ArmErr.CompFncFailed, "ae_TableType", "Unknown table type : " & ae_TableType
    End Select
    Exit Function
ErrHandler:
    Call ErrorHandler("FindDetailConfigByTableType")
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
        If grd_Main(Index).SelectedCount = 1 Then
            mt_MainConfig(ll_MainIndex).CurrentDetailIndex = FindDetailConfigByTableType(Val(grd_Main(Index).SelectedLine(0, "DocType")))
        End If
    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 CopyParamSys(ByVal al_Id As Long, ByVal al_Id_Old As Long, ByVal al_Opr_Id As Integer)

On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_Cursor As Long
Dim ll_Sys_Id As Long

    ls_Request = "SELECT SYS_Id FROM DPC_BOR_Param_Sys WHERE BPS_Id=" & al_Id_Old & " AND OPR_Id =" & al_Opr_Id & " AND Drop_Flag <>'X'"
    ll_Cursor = mo_Db.OpenSQL(ls_Request)
    While Not mo_Db.EOF(ll_Cursor)
        ll_Sys_Id = mo_Db.GetFields(ll_Cursor, "SYS_Id")
        ls_Request = "exec DPC_BOR_Param_Sys_ins " & al_Id & "," & al_Opr_Id & "," & ll_Sys_Id & ",$U_Code$"
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
        Call mo_Db.Next(ll_Cursor)
    Wend
    Call mo_Db.Close(ll_Cursor)
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("CopyParamSys")
End Sub

Private Sub CopyParamProd(ByVal al_Id As Long, ByVal al_Id_Old As Long, ByVal al_Opr_Id As Integer, ByVal al_CAT_Id As Integer)

On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_Cursor As Long
Dim ls_PRD_Id As String

    ls_Request = "SELECT PRD_Id FROM DPC_BOR_Param_Prod WHERE BPP_Id=" & al_Id_Old & " AND OPR_Id =" & al_Opr_Id & " AND CAT_Id =" & al_CAT_Id & " AND Drop_Flag <>'X'"
    ll_Cursor = mo_Db.OpenSQL(ls_Request)
    While Not mo_Db.EOF(ll_Cursor)
        ls_PRD_Id = mo_Db.GetFields(ll_Cursor, "PRD_Id")
        ls_Request = "exec DPC_BOR_Param_Prod_ins " & al_Id & "," & al_Opr_Id & "," & al_CAT_Id & "," & ls_PRD_Id & ",$U_Code$"
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
        Call mo_Db.Next(ll_Cursor)
    Wend
    Call mo_Db.Close(ll_Cursor)
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("CopyParamProd")
End Sub

Private Sub CopyParamMat(ByVal al_Id As Long, ByVal al_Id_Old As Long, ByVal al_Opr_Id As Integer)

On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_Cursor As Long
Dim ll_MAT_Id As Long

    ls_Request = "SELECT MAT_Id FROM DPC_BOR_Param_Mat WHERE BPM_Id=" & al_Id_Old & " AND OPR_Id =" & al_Opr_Id & " AND Drop_Flag <>'X'"
    ll_Cursor = mo_Db.OpenSQL(ls_Request)
    While Not mo_Db.EOF(ll_Cursor)
        ll_MAT_Id = mo_Db.GetFields(ll_Cursor, "MAT_Id")
        ls_Request = "exec DPC_BOR_Param_Mat_ins " & al_Id & "," & al_Opr_Id & "," & ll_MAT_Id & ",$U_Code$"
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
        Call mo_Db.Next(ll_Cursor)
    Wend
    Call mo_Db.Close(ll_Cursor)
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("CopyParamMat")
End Sub

Private Sub CopyParamRef(ByVal al_Id As Long, ByVal al_Id_Old As Long, ByVal al_Opr_Id As Integer, ByVal al_GR_Code As Long)

On Error GoTo ErrHandler

Dim ls_Request As String
Dim ll_Cursor As Long
Dim ll_RF_Code As Long

    ls_Request = "SELECT RF_Code FROM DPC_BOR_Param_Ref WHERE BPR_Id=" & al_Id_Old & " AND OPR_Id =" & al_Opr_Id & " AND GR_Code =" & al_GR_Code & " AND Drop_Flag <>'X'"
    ll_Cursor = mo_Db.OpenSQL(ls_Request)
    While Not mo_Db.EOF(ll_Cursor)
        ll_RF_Code = mo_Db.GetFields(ll_Cursor, "RF_Code")
        ls_Request = "exec DPC_BOR_Param_Ref_ins " & al_Id & "," & al_Opr_Id & "," & al_GR_Code & "," & ll_RF_Code & ",$U_Code$"
        ls_Request = ReplaceCommonPlaceholders(ls_Request)
        Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
        Call mo_Db.Next(ll_Cursor)
    Wend
    Call mo_Db.Close(ll_Cursor)
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("CopyParamMat")
End Sub

Private Sub CopyRecordsIntoSystem(ByVal al_MainIndex As Long)
Const FRM_COPY_DETAILS = 11

On Error GoTo ErrHandler
    
Dim ll_ID_old As Long
Dim ll_ID As Long
Dim ll_Cursor As Long
Dim ls_Request As String
Dim ll_Index As Long
Dim lb_inTransaction As Boolean
Dim ll_BOB_Id As Long
Dim lv_Info(1) As String

    If grd_Main(al_MainIndex).SelectedCount = 0 Then
        Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, C_MSG_ID_BASE + 4, "#Select rows in grid to copy first!")
        Exit Sub
    End If
        
    lv_Info(0) = "%1"
    lv_Info(1) = grd_Main(al_MainIndex).SelectedCount

    If mo_Tools.ShowMsg(mo_Db, ms_Language_Code, C_MSG_ID_BASE + 41, "#You are going to copy %1 records?", lv_Info, vbOKCancel) = vbCancel Then
        Exit Sub
    End If
    
    Call mo_Tools.BeginTran(mo_Db, ml_U_Code, SCREEN_NAME, "CopyData")
    lb_inTransaction = True
    
    If mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Perf" Then

        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BOP_Id")
                                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Perf")
            ls_Request = "exec DPC_BOR_Perf_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
            
            Call CopyParamSys(ll_ID, ll_ID_old, eDPCBOROperation.ePerforation)
            Call CopyParamProd(ll_ID, ll_ID_old, eDPCBOROperation.ePerforation, eDPCCategory.cgPerforation)
            Call CopyParamMat(ll_ID, ll_ID_old, eDPCBOROperation.ePerforation)
            
        Next
        
    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Bend" Then

        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BOB_Id")
                                                
            ll_BOB_Id = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Bend")
            ls_Request = "exec DPC_BOR_Bend_cp " & ll_BOB_Id & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
            
            Call CopyParamSys(ll_BOB_Id, ll_ID_old, eDPCBOROperation.eBending)
            
            ls_Request = "SELECT BOS_Id FROM DPC_BOR_Bend_Spec WHERE BOB_Id=" & ll_ID_old & " AND Drop_Flag=' '"
            ll_Cursor = mo_Db.OpenSQL(ls_Request)
            While Not mo_Db.EOF(ll_Cursor)
                ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Bend_Spec")
                ll_ID_old = mo_Db.GetFields(ll_Cursor, "BOS_Id")
                ls_Request = "exec DPC_BOR_Bend_Spec_cp " & ll_ID & "," & ll_ID_old & "," & ll_BOB_Id & ",$U_Code$"
                ls_Request = ReplaceCommonPlaceholders(ls_Request)
                Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
                Call mo_Db.Next(ll_Cursor)
            Wend
            Call mo_Db.Close(ll_Cursor)
            
            ls_Request = "SELECT BOE_Id FROM DPC_BOR_Bend_Param WHERE BOB_Id=" & ll_ID_old & " AND Drop_Flag=' '"
            ll_Cursor = mo_Db.OpenSQL(ls_Request)
            While Not mo_Db.EOF(ll_Cursor)
                ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Bend_Param")
                ll_ID_old = mo_Db.GetFields(ll_Cursor, "BOE_Id")
                ls_Request = "exec DPC_BOR_Bend_Param_cp " & ll_ID & "," & ll_ID_old & "," & ll_BOB_Id & ",$U_Code$"
                ls_Request = ReplaceCommonPlaceholders(ls_Request)
                Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
                Call mo_Db.Next(ll_Cursor)
            Wend
            Call mo_Db.Close(ll_Cursor)
        Next

    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_PunchNotch" Then

        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BPN_Id")
                                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_PunchNotch")
            ls_Request = "exec DPC_BOR_PunchNotch_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
            
            Call CopyParamSys(ll_ID, ll_ID_old, eDPCBOROperation.ePunchNotching)
            Call CopyParamProd(ll_ID, ll_ID_old, eDPCBOROperation.ePunchNotching, eDPCCategory.cgPerforation)
            Call CopyParamMat(ll_ID, ll_ID_old, eDPCBOROperation.ePunchNotching)
            
        Next
        
    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Coating" Then
        
        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BOA_Id")
                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Coating")
            ls_Request = "exec DPC_BOR_Coating_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
        Next
    
    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Gasket" Then
        
        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BOG_Id")
                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Gasket")
            ls_Request = "exec DPC_BOR_Gasket_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
        Next
    
    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Inlay" Then
        
        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BOI_Id")
                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Inlay")
            ls_Request = "exec DPC_BOR_Inlay_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
            
            Call CopyParamProd(ll_ID, ll_ID_old, eDPCBOROperation.eInlay, eDPCCategory.cgInlay)
            Call CopyParamProd(ll_ID, ll_ID_old, eDPCBOROperation.eInlay, eDPCCategory.cgCutout)
            Call CopyParamRef(ll_ID, ll_ID_old, eDPCBOROperation.eInlay, eDPCReferenceML.rfPerforationBorderType)
            
        Next
    
    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Packing" Then
        
        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BOK_Id")
                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Packing")
            ls_Request = "exec DPC_BOR_Packing_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
                        
        Next
    
    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Cutting" Then
        
        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BOC_Id")
                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Cutting")
            ls_Request = "exec DPC_BOR_Cutting_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
                        
            Call CopyParamMat(ll_ID, ll_ID_old, eDPCBOROperation.eCutting)
                        
        Next
    
    ElseIf mt_MainConfig(al_MainIndex).NameFrame = "DPC_BOR_Rerolling" Then
        
        For ll_Index = 0 To grd_Main(al_MainIndex).SelectedCount - 1
            ll_ID_old = grd_Main(al_MainIndex).SelectedLine(ll_Index, "BRR_Id")
                        
            ll_ID = mo_Tools.GetNextID(mo_Db, "DPC_BOR_Rerolling")
            ls_Request = "exec DPC_BOR_Rerolling_cp " & ll_ID & "," & ll_ID_old & ",$U_Code$"
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request, 1)
                        
            Call CopyParamProd(ll_ID, ll_ID_old, eDPCBOROperation.eRerolling, eDPCCategory.cgPerforation)
            Call CopyParamMat(ll_ID, ll_ID_old, eDPCBOROperation.eRerolling)
                        
        Next
    
    End If
    
    Call mo_Tools.CommitTran(mo_Db, ml_U_Code, SCREEN_NAME, "CopyData")
    
    Call grd_Main(al_MainIndex).Refresh
    
    Exit Sub
ErrHandler:
    If lb_inTransaction Then
        Call mo_Tools.RollbackTran(mo_Db, ml_U_Code, SCREEN_NAME, "CopyData")
    End If
    Call ErrorHandler("CopyRecordsIntoSystem")
End Sub

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_MAT = "exec DPC_Material_lst2 $Language_Code$"
Const LIST2_REQUEST_MAT = "exec DPC_BOR_Param_Mat_lst $BPM_Id$,$OPR_Id$"
Const LIST_REQUEST_RF = "exec A_References_ML_Lst $GR_Code$,$Language_Code$"
Const LIST2_REQUEST_RF = "exec DPC_BOR_Param_Ref_lst $BPR_Id$,$OPR_Id$,$GR_Code$"
Const LIST_REQUEST_INL = "exec DPC_Inlay_lst3 $Language_Code$"
Const LIST2_REQUEST_INL = "exec DPC_BOR_Param_Prod_lst $BPP_Id$,$OPR_Id$,$CAT_Id$"
Const LIST_REQUEST_CUT = "exec DPC_CutType_lst2 $Language_Code$"
Const LIST2_REQUEST_CUT = "exec DPC_BOR_Param_Prod_lst $BPP_Id$,$OPR_Id$,$CAT_Id$"

Const TREEVIEW_REQ_SYS = "exec DPC_BOR_Param_Sys_tvw $Language_Code$"
Const TREELIST_REQ_SYS = "exec DPC_BOR_Param_Sys_lst $BPS_Id$,$OPR_Id$"

Const TREEVIEW_REQ_PRF = "exec DPC_BOR_Param_Prod_tvw $Language_Code$"
Const TREELIST_REQ_PRF = "exec DPC_BOR_Param_Prod_lst $BPP_Id$,$OPR_Id$,$CAT_Id$"

    Dim ll_DetailFrameIndex As Long
    Dim ls_Request As String
    Dim ls_Request2 As String
    Dim ll_Cursor As Long
    Dim ls_Items As String
    Dim ll_RoutCateg As Long
    Dim ls_AgID_cbo_Idx As String
    Dim ll_Index As Long
    Dim ll_Key As Long
    Dim ll_ComboIdx As Long
    
    ll_DetailFrameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
        
    If IsEmpty(av_Key) Then
        ll_Key = -1
    Else
        ll_Key = av_Key(0)
    End If
    
    If StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Perf", vbTextCompare) = 0 Then
        tvw_Detail(0).Enabled = True
        ls_Request = ReplacePlaceHolder(TREELIST_REQ_SYS, "$BPS_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.ePerforation))
        Call LoadDetailTreeView(0, TREEVIEW_REQ_SYS, ls_Request, "SYS_Id")
            
        ls_Request = ReplacePlaceHolder(LIST2_REQUEST_MAT, "$BPM_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.ePerforation))
        Call LoadDetailListView(lv_Materials(0), LIST_REQUEST_MAT, ls_Request, "MAT_Id", "MAT_Name")
    
    ElseIf StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Bend", vbTextCompare) = 0 Then
        tvw_Detail(3).Enabled = True
        ls_Request = ReplacePlaceHolder(TREELIST_REQ_SYS, "$BPS_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.eBending))
        Call LoadDetailTreeView(3, TREEVIEW_REQ_SYS, ls_Request, "SYS_Id")
                    
    ElseIf StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Cutting", vbTextCompare) = 0 Then
        
        ls_Request = ReplacePlaceHolder(LIST2_REQUEST_MAT, "$BPM_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.eCutting))
        Call LoadDetailListView(lv_Materials(1), LIST_REQUEST_MAT, ls_Request, "MAT_Id", "MAT_Name")

    ElseIf StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Rerolling", vbTextCompare) = 0 Then
        ls_Request = ReplacePlaceHolder(LIST2_REQUEST_MAT, "$BPM_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.eRerolling))
        Call LoadDetailListView(lv_Materials(2), LIST_REQUEST_MAT, ls_Request, "MAT_Id", "MAT_Name")
    
    ElseIf StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_PunchNotch", vbTextCompare) = 0 Then
        tvw_Detail(1).Enabled = True
        ls_Request = ReplacePlaceHolder(TREELIST_REQ_SYS, "$BPS_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.ePunchNotching))
        Call LoadDetailTreeView(1, TREEVIEW_REQ_SYS, ls_Request, "SYS_Id")
            
        tvw_Detail(2).Enabled = True
        ls_Request = ReplacePlaceHolder(TREELIST_REQ_PRF, "$BPP_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.ePunchNotching))
        ls_Request = ReplacePlaceHolder(ls_Request, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgPerforation))
        Call LoadDetailTreeView(2, TREEVIEW_REQ_PRF, ls_Request, "PRD_Id")
            
        ls_Request = ReplacePlaceHolder(LIST2_REQUEST_MAT, "$BPM_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.ePunchNotching))
        Call LoadDetailListView(lv_Materials(3), LIST_REQUEST_MAT, ls_Request, "MAT_Id", "MAT_Name")
    
    ElseIf StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Inlay", vbTextCompare) = 0 Then
    
        ls_Request = ReplacePlaceHolder(LIST_REQUEST_RF, "$GR_Code$", mo_Tools.SqlInt(eDPCReferenceML.rfPerforationBorderType))
        
        ls_Request2 = ReplacePlaceHolder(LIST2_REQUEST_RF, "$BPR_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request2 = ReplacePlaceHolder(ls_Request2, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.eInlay))
        ls_Request2 = ReplacePlaceHolder(ls_Request2, "$GR_Code$", mo_Tools.SqlInt(eDPCReferenceML.rfPerforationBorderType))

        Call LoadDetailListView(lv_PBordDesc, ls_Request, ls_Request2, "RF_Code", "RF_Desc")
            
        ls_Request2 = ReplacePlaceHolder(LIST2_REQUEST_INL, "$BPP_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request2 = ReplacePlaceHolder(ls_Request2, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.eInlay))
        ls_Request2 = ReplacePlaceHolder(ls_Request2, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgInlay))

        Call LoadDetailListView(lv_INL_Name, LIST_REQUEST_INL, ls_Request2, "PRD_Id", "PRD_Name")
            
        ls_Request2 = ReplacePlaceHolder(LIST2_REQUEST_CUT, "$BPP_Id$", mo_Tools.SqlInt(ll_Key))
        ls_Request2 = ReplacePlaceHolder(ls_Request2, "$OPR_Id$", mo_Tools.SqlInt(eDPCBOROperation.eInlay))
        ls_Request2 = ReplacePlaceHolder(ls_Request2, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgCutout))

        Call LoadDetailListView(lv_CUT_Name, LIST_REQUEST_CUT, ls_Request2, "PRD_Id", "PRD_Name")
    
    End If
            
    If ae_Mode <> emAdd Then
        If mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_System" Then
'            Call ShowImage(0, txt_ImgId(0), "")
        End If
    End If
    
    If ae_Mode = emAdd Then
        If mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_System" Then
'            pic_ImgBox(0).Picture = Nothing
        End If
    End If
                
    ll_RoutCateg = GetRoutCateg(mt_DetailConfig(al_DetailIndex).NameFrame)
    ls_AgID_cbo_Idx = GetAgID_cbo_Idx(mt_DetailConfig(al_DetailIndex).NameFrame)
    Dim ls_AgIdList() As String
    
    If ll_RoutCateg <> -1 Then
        
        ls_AgIdList = Split(ls_AgID_cbo_Idx, ",")
        
        ls_Request = "SELECT DISTINCT BOC_KostSt,BOC_KostSt FROM DPC_BOR_OperCost WHERE OPR_Id = " & ll_RoutCateg
        
        ll_Cursor = mo_Db.OpenSQL(ls_Request)

        ls_Items = ""
        While Not mo_Db.EOF(ll_Cursor)
            If ls_Items <> "" Then
                ls_Items = ls_Items & ","
            End If
            ls_Items = ls_Items & mo_Db.GetFields(ll_Cursor, 0)
            Call mo_Db.Next(ll_Cursor)
        Wend
        Call mo_Db.Close(ll_Cursor)
        
        For ll_Index = 0 To UBound(ls_AgIdList)
        
            ll_ComboIdx = CInt(ls_AgIdList(ll_Index))
            
            cbo_KostSt_Filter(ll_ComboIdx).Request = ls_Request
            cbo_KostSt_Filter(ll_ComboIdx).Load
                        
            Set cbo_BOR_Perf_AgId(ll_ComboIdx).ArmDb = mo_Db_2
            cbo_BOR_Perf_AgId(ll_ComboIdx).Request = "SELECT agid, CAST(stagnr as varchar) + ' - ' + agben FROM f250 WHERE kostst in (" & ls_Items & ")"
            cbo_BOR_Perf_AgId(ll_ComboIdx).Load
        Next
    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 ll_MainConfigIndex As Long

    ll_MainConfigIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    
    If StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_OperCost", vbTextCompare) = 0 Then
        txt_DetailKey(mt_DetailConfig(al_DetailIndex).DetailKey).Text = av_Key(0)
 '   ElseIf StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Perf", vbTextCompare) = 0 Then
 '       Call LoadDetailTreeView(0, av_Key(0), 1)
 '       Call LoadDetailListView(0, av_Key(0), 1)
 '   ElseIf StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Cutting", vbTextCompare) = 0 Then
 '       Call LoadDetailListView(1, av_Key(0), 2)
    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
Const CBO_PRIORITY_COATING = 3

On Error GoTo ErrHandler
    Dim ll_MainConfigIndex As Long
    Dim ll_MainFrameIndex As Long
    
    Item_CustomCheck = False
    ll_MainConfigIndex = mt_DetailConfig(al_DetailIndex).MainConfigIndex
    If ll_MainConfigIndex <> -1 Then
        ll_MainFrameIndex = mt_MainConfig(ll_MainConfigIndex).FrameIndex
        
    End If
    
    If mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_BOR_Perf" Then
        txt_BOR_PRF_MAT_Name.Text = GenerateNameListView(lv_Materials(0))
        txt_BOR_PRF_SYS_Name.Text = GenerateNameTreeView(0, 3)
    ElseIf mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_BOR_Bend" Then
        txt_BOB_SYS_Name.Text = GenerateNameTreeView(3, 3)
    ElseIf mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_BOR_Cutting" Then
        txt_BOC_MAT_Name.Text = GenerateNameListView(lv_Materials(1))
    ElseIf mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_BOR_Rerolling" Then
        txt_BRR_MAT_Name.Text = GenerateNameListView(lv_Materials(2))
    ElseIf mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_BOR_Inlay" Then
        txt_BOI_RPL_PBordDesc.Text = GenerateNameListView(lv_PBordDesc)
        txt_BOI_INL_Name.Text = GenerateNameListView(lv_INL_Name)
        txt_BOI_CUT_Name.Text = GenerateNameListView(lv_CUT_Name)
    ElseIf mt_DetailConfig(al_DetailIndex).NameFrame = "DPC_BOR_PunchNotch" Then
        txt_BPN_MAT_Name.Text = GenerateNameListView(lv_Materials(3))
        txt_BPN_SYS_Name.Text = GenerateNameTreeView(1, 3)
        txt_BPN_PRF_Name.Text = GenerateNameTreeView(2, 10)
    
    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

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
    
    If ab_InTransaction = True Then
        Call SaveDetailListAndTreeCommon(al_DetailIndex)
    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

    ll_frameIndex = mt_DetailConfig(al_DetailIndex).FrameIndex
        
    If ab_InTransaction = True Then
        Call SaveDetailListAndTreeCommon(al_DetailIndex)
    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
      '  If (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "EAS_SalesOrder", vbTextCompare) = 0) Then
      '      txt_SLO_DroppedNumber.Text = -Val(mo_Tools.GetNextID(mo_Db,"EAS_DroppedNumber"))
      '  ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "EAS_CreditMemo", vbTextCompare) = 0) Then
      '      txt_CRM_DroppedNumber.Text = -Val(mo_Tools.GetNextID(mo_Db,"EAS_DroppedNumber"))
      '  ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "EAS_DebitMemo", vbTextCompare) = 0) Then
      '      txt_DBM_DroppedNumber.Text = -Val(mo_Tools.GetNextID(mo_Db,"EAS_DroppedNumber"))
      '  ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "EAS_Return", vbTextCompare) = 0) Then
      '      txt_RET_DroppedNumber.Text = -Val(mo_Tools.GetNextID(mo_Db,"EAS_DroppedNumber"))
      '  End If
    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
       End If
    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
    Dim ll_Index As Integer
    
    ll_DetailIndex = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    If (ae_Mode = eMode.emAdd) Or (ae_Mode = eMode.emUpdate) Then
         
         If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BOR_OperCost" Then
            
            Set cbo_KostSt.ArmDb = mo_Db_2
            cbo_KostSt.Request = "SELECT kostst, Ben_1 + ' (' + CAST(kostst as varchar) + ')' FROM f300 WHERE fi_nr = 1"
            Call cbo_KostSt.Load
         
            'Call DisableFrameParts(GetListFieldsToDisable(txt_PCR_CAT_Id.Text))
         ElseIf mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BOR_Bend_Param" Then
            
         End If
    
    End If
    Exit Sub
ErrHandler:
    Call ErrorHandler("SubItem_CustomInit")
End Sub

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

    If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BendingConfig" Then
    End If
                
    Exit Sub
ErrHandler:
    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_PageNr 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 mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BOR_Bend_Spec" Then
    '    txt_BOS_SYS_Id_Item.Text = txt_BOS_SYS_Id.Text
    '    txt_BOS_BND_KostSt_Item.Text = txt_BOS_BND_KostSt.Text
    'End If
    'If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_BOR_Bend_Param" Then
    '    txt_BOB_SYS_Id_Item.Text = txt_BOB_SYS_Id.Text
    '    txt_BOB_BND_KostSt_Item.Text = txt_BOB_BND_KostSt.Text
    '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
'Dim le_DocumentType As eDocumentType

    ab_CustomSaved = False
    lb_OldInternalInit = mb_InternalInit
    mb_InternalInit = True
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailIndex = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    
    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_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailConfig = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    ll_DetailFrame = mt_DetailConfig(ll_DetailConfig).FrameIndex
    
    If ae_Mode = eMode.emDelete Then
        'll_ColIdx = grd_Subdetail(ll_frameIndex).Columns("DroppedPageNr").ColumnIndex
        'mt_SubdetailConfig(al_SubDetailIndex).DeletedRows(al_Index)(ll_ColIdx) = -Val(mo_Tools.GetNextID(mo_Db,"EAS_DroppedPageNr"))
    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
    
    If mt_SubdetailConfig(al_SubDetailIndex).NameFrame = "DPC_PriceCrit" Then
'        If ae_Mode = eMode.emAdd Then
'            mt_SubdetailConfig(al_SubDetailIndex).RequestAdd = "exec DPC_PriceCrit_ins $PCR_Id$,$PRD_Id$,$PRD_IdPar$,$CUA_Id$,$PCR_AMin$,$PCR_AMax$,$PCR_BMin$,$PCR_BMax$,$MAT_Id$,$PCR_Thick$,$PCR_TMin$,$PCR_TMax$,$PCR_IsPrf$,$PCR_GaCnt$,$PCR_CoSid$,$U_Code$"
'        ElseIf ae_Mode = eMode.emUpdate Then
'            mt_SubdetailConfig(al_SubDetailIndex).RequestUpd = "exec DPC_PriceCrit_upd $PCR_Id$,$PRD_Id$,$PRD_IdPar$,$CUA_Id$,$PCR_AMin$,$PCR_AMax$,$PCR_BMin$,$PCR_BMax$,$MAT_Id$,$PCR_Thick$,$PCR_TMin$,$PCR_TMax$,$PCR_IsPrf$,$PCR_GaCnt$,$PCR_CoSid$,$U_Code$,$iConcurrency$"
'        End If
    End If
    
    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, "", vbTextCompare) = 0 Then
    '    If tlb_Main(mt_MainConfig(al_MainIndex).ToolbarIndex).Language = "E" Then
            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
    
    '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, "", vbTextCompare) = 0 Then
        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 ArmDb_2(ByRef local_connection As Object)
    If Not (local_connection Is Nothing) Then
        Set mo_Db_2 = 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 Sub cmd_CustomerSeek_Click(Index As Integer)
On Error GoTo ErrHandler
    
Dim ls_CCUCapKey As String
Dim lo_SeekForm As SeekForm
Dim lv_Code As Variant
Dim lv_Desc As String
    
    Call mo_Tools.LockScreen(Me, True)
    gs_CaptureCountry = "GB"
    Set lo_SeekForm = New SeekForm
    Load lo_SeekForm
    lo_SeekForm.Language = ms_Language_Code
    Set lo_SeekForm.ArmDb = mo_Db
    lo_SeekForm.ComponentType = "CUSTOMER"
    lo_SeekForm.TreeViewFiltersDesc = ""
    lo_SeekForm.TreeViewFilters = "" & SEP & "" & SEP & "" & SEP & "NULL"
    lo_SeekForm.TreeView_DateType = "0"
    lo_SeekForm.Load_A_COM
    lo_SeekForm.SYS_code = 1
    
    Call mo_Tools.LockScreen(Me, False)
    Call mo_Tools.ShowModalForm(lo_SeekForm)
    Call mo_Tools.LockScreen(Me, True)
    
    If lo_SeekForm.SelectedData = True Then
    '    txt_CCU_Desc(Index).Text = lo_SeekForm.SelectedItemDesc
    '    txt_Cust_Code(Index).Text = GetSeparatedStringElement(lo_SeekForm.SelectedItemFull, "CUST_Code")
    '    txt_CCU_Capkey(Index).Text = GetSeparatedStringElement(lo_SeekForm.SelectedItemFull, "CCU_Capkey")
    '    If Not lo_SeekForm.cbo_country.SelectedItem Is Nothing Then
    '        txt_CT_Code(Index).Text = lo_SeekForm.cbo_country.SelectedItem.Key
    '        txt_CT_Desc(Index).Text = lo_SeekForm.cbo_country.Text
    '    End If
    End If
    
    Call lo_SeekForm.Unload_A_COM
    Unload lo_SeekForm
    Set lo_SeekForm = Nothing
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
ErrHandler:
    Call ErrorMessage("cmd_CustomerSeek_Click Index=" & Index)
End Sub

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 UploadImage(ByVal as_FileName As String, ByVal as_IMG_Id As String)
On Error GoTo ErrHandler

Dim ll_Index As Long
Dim ls_RequestIns As String
Dim ls_Filename As String

    ls_RequestIns = "INSERT INTO DPC_Image (IMG_Id,IMG_File) VALUES ($IMG_Id$,?)"
    ls_RequestIns = ReplacePlaceHolder(ls_RequestIns, "$IMG_Id$", as_IMG_Id)
        
    'Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_RequestDel)
    If Not mo_Db.FileToBlobSQL(ls_RequestIns, as_FileName, 9) Then
        Err.Raise ArmErr.SQLFailure, "FileToBlobSQL", mo_Db.LastErrorMessage & " Error writing blob: " & ls_RequestIns & " File: " & ls_Filename
    End If
    'Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_RequestIns)
    Exit Sub
ErrHandler:
    Call ErrorHandler("UploadImage as_FileName=" & as_FileName & _
                               "")
End Sub

Private Function ShowImage(ByVal al_Index As Long, ByVal al_ImgId As Long, ByVal as_FileName As String) As Boolean
On Error GoTo ErrHandler
    
    ShowImage = True
    
    Exit Function
ErrHandler:
    ShowImage = False
    Call ErrorHandler("ShowImage")
End Function

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

Dim ll_RoutCateg As Long
Dim ll_AgID_cbo_Idx As Long
Dim ll_MainConfigIndex As Long, ll_DetailConfigIndex As Long
Dim ls_Request As String, ls_Items As String
Dim ll_Cursor As Long
    
    If mb_InternalInit = True Then Exit Sub
    
    ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_DetailConfigIndex = FindDetailConfigByMainConfig(ll_MainConfigIndex)
        
    ll_RoutCateg = GetRoutCateg(mt_DetailConfig(ll_DetailConfigIndex).NameFrame)
    'll_AgID_cbo_Idx = GetAgID_cbo_Idx(mt_DetailConfig(ll_DetailConfigIndex).NameFrame)
    ll_AgID_cbo_Idx = Index
    
    If ll_RoutCateg <> -1 Then
                        
        If cbo_KostSt_Filter(Index).SelectedItem Is Nothing Then
        
            ls_Request = "SELECT DISTINCT BOC_KostSt FROM DPC_BOR_OperCost WHERE OPR_Id = " & ll_RoutCateg

            ll_Cursor = mo_Db.OpenSQL(ls_Request)
    
            ls_Items = ""
            While Not mo_Db.EOF(ll_Cursor)
                If ls_Items <> "" Then
                    ls_Items = ls_Items & ","
                End If
                ls_Items = ls_Items & mo_Db.GetFields(ll_Cursor, 0)
                Call mo_Db.Next(ll_Cursor)
            Wend
            Call mo_Db.Close(ll_Cursor)
    
            cbo_BOR_Perf_AgId(ll_AgID_cbo_Idx).Request = "SELECT agid, CAST(stagnr as varchar) + ' - ' + agben FROM f250 WHERE kostst in (" & ls_Items & ")"
        Else
            cbo_BOR_Perf_AgId(ll_AgID_cbo_Idx).Request = "SELECT agid, CAST(stagnr as varchar) + ' - ' + agben FROM f250 WHERE kostst = " & cbo_KostSt_Filter(Index).SelectedItem.Key
        End If
        
        cbo_BOR_Perf_AgId(ll_AgID_cbo_Idx).Load
    End If

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

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

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

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

  Dim lo_frmDPC_BOR As frmDPC_BOR
  
  Call mo_Tools.LockScreen(Me, True)
  If mo_Db_2 Is Nothing Then
    Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9857, "Error connecting to Baurer server: " & mo_Db_2.LastErrorMessage)
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
  End If
  
  Set lo_frmDPC_BOR = New frmDPC_BOR
  
  Load lo_frmDPC_BOR
  Set lo_frmDPC_BOR.ArmDb = mo_Db
  Set lo_frmDPC_BOR.Tools = mo_Tools
  Set lo_frmDPC_BOR.ArmDbBaeurer = mo_Db_2
  lo_frmDPC_BOR.Language_Code = ms_Language_Code
  Call lo_frmDPC_BOR.Load_A_COM
  
  Call mo_Tools.LockScreen(Me, False)
  Call mo_Tools.ShowModalForm(lo_frmDPC_BOR)
  Call mo_Tools.LockScreen(Me, True)
  If lo_frmDPC_BOR.Result Then
    Set cbo_KostSt_Filter(Index).SelectedItem = Nothing
    If cbo_KostSt_Filter(Index).SearchItem(lo_frmDPC_BOR.KostSt) = False Then
        Call cbo_KostSt_Filter(Index).AddItem(Array(lo_frmDPC_BOR.KostSt, lo_frmDPC_BOR.KostSt), True)
    End If
    If cbo_BOR_Perf_AgId(Index).SearchItem(lo_frmDPC_BOR.AgId) = False Then
        Call cbo_BOR_Perf_AgId(Index).AddItem(Array(lo_frmDPC_BOR.AgId, lo_frmDPC_BOR.AgIdDesc), True)
    End If
  End If
  lo_frmDPC_BOR.Unload_A_COM
  Unload lo_frmDPC_BOR
  Set lo_frmDPC_BOR = Nothing
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("cmd_AgIdSearch_Click")
End Sub

Private Sub lv_CUT_Name_ItemCheck(ByVal Item As MSComctlLib.ListItem)
On Error GoTo ErrHandler
        
    If mb_InternalInit Then Exit Sub

    If me_DetailMode = emView Then
        Item.Checked = Not Item.Checked
    End If
    
    Exit Sub

ErrHandler:
    Call LogMessage("lv_CUT_Name_ItemCheck")
End Sub

Private Sub lv_INL_Name_ItemCheck(ByVal Item As MSComctlLib.ListItem)
On Error GoTo ErrHandler
        
    If mb_InternalInit Then Exit Sub

    If me_DetailMode = emView Then
        Item.Checked = Not Item.Checked
    End If
    
    Exit Sub

ErrHandler:
    Call LogMessage("lv_INL_Name_ItemCheck")
End Sub

Private Sub lv_Materials_ItemCheck(Index As Integer, ByVal Item As MSComctlLib.ListItem)
On Error GoTo ErrHandler
        
    If mb_InternalInit Then Exit Sub

    If me_DetailMode = emView Then
        Item.Checked = Not Item.Checked
    End If
    
    Exit Sub

ErrHandler:
    Call LogMessage("lv_Materials_ItemCheck")
End Sub

Private Sub lv_PBordDesc_ItemCheck(ByVal Item As MSComctlLib.ListItem)
On Error GoTo ErrHandler
        
    If mb_InternalInit Then Exit Sub

    If me_DetailMode = emView Then
        Item.Checked = Not Item.Checked
    End If
    
    Exit Sub

ErrHandler:
    Call LogMessage("lv_PBordDesc_ItemCheck")
End Sub

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 "M"
            ' Want to copy
                Call CopyRecordsIntoSystem(ll_MainConfigIndex)
            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
                    ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
                    mt_MainConfig(ll_MainConfigIndex).CurrentDetailIndex = mt_DetailConfig(ll_DetailConfigIndex).PreviousDetailIndex
                End If
                If mt_DetailConfig(ll_DetailConfigIndex).MainConfigIndex <> -1 Or _
                   mt_DetailConfig(ll_DetailConfigIndex).NameFrame = "DPC_DataImport" Then
                    Call SetMode(emList)
                Else
                    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 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_Detail_NodeCheck(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

    If me_DetailMode = emView Then
        If Node.Tag.ml_State = TVI_STATE_CHECKED Then
            Call tvw_Detail(Index).SetNodeState(Node, TVI_STATE_UNCHECKED)
        Else
            Call tvw_Detail(Index).SetNodeState(Node, TVI_STATE_CHECKED)
        End If
            
        Call tvw_Detail(Index).SetParentState(Node)
        
    End If
    
    Exit Sub

ErrHandler:
    Call LogMessage("tvw_Detail_NodeClick")
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")
            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

    If StrComp(mt_MainConfig(la_MainConfigIndex).NameFrame, "DPC_BOR_Perf", vbTextCompare) = 0 Then
        Call ImportData(as_filePath, mt_MainConfig(la_MainConfigIndex).NameFrame)
    End If
    
    Exit Sub
ErrHandler:
    Call ErrorMessage("Process_File")
End Sub

' Omit plngLeft & plngRight; they are used internally during recursion
Public Sub QuickSort(ByRef pvarArray As Variant, ByRef keys() As Long, Optional ByVal plngLeft As Long, Optional ByVal plngRight As Long)
On Error GoTo ErrHandler

    Dim ll_First As Long
    Dim ll_Last As Long
    Dim ll_Mid As Long
    Dim ll_Store, ll_Idx As Integer
    
    If plngRight = 0 Then
        plngLeft = LBound(pvarArray, 1) + 1
        plngRight = UBound(pvarArray, 1)
    End If
    
    If plngLeft >= plngRight Then
        Exit Sub
    End If
    
    ll_First = plngLeft
    ll_Last = plngRight
    
    ll_Mid = (plngLeft + plngRight) \ 2
    Call QS_SwapRows(pvarArray, ll_Mid, ll_Last, keys)
    ll_Store = ll_First
    
    For ll_Idx = ll_First To ll_Last - 1
        If CompareRows(pvarArray, ll_Idx, ll_Last, keys) = True Then
            Call QS_SwapRows(pvarArray, ll_Idx, ll_Store, keys)
            ll_Store = ll_Store + 1
        End If
    Next
    Call QS_SwapRows(pvarArray, ll_Last, ll_Store, keys)
    
    QuickSort pvarArray, keys, plngLeft, ll_Store - 1
    QuickSort pvarArray, keys, ll_Store + 1, plngRight
    
    Exit Sub
ErrHandler:
    Call ErrorHandler("QuickSort")
End Sub

Private Sub QS_SwapRows(ByRef aa_array As Variant, ByVal al_first As Long, ByVal al_second As Long, ByRef keys() As Long)
    Dim varSwap As Variant
    Dim ll_Idx As Integer
    
    For ll_Idx = 1 To UBound(aa_array, 2)
        varSwap = aa_array(al_first, ll_Idx)
        aa_array(al_first, ll_Idx) = aa_array(al_second, ll_Idx)
        aa_array(al_second, ll_Idx) = varSwap
    Next
End Sub

Private Function CompareRows(ByRef aa_array As Variant, ByVal al_first As Long, ByVal al_last As Long, ByRef keys() As Long)
On Error GoTo ErrHandler

    Dim ll_Idx As Integer
    
    For ll_Idx = 0 To UBound(keys)
        If aa_array(al_first, keys(ll_Idx)) < aa_array(al_last, keys(ll_Idx)) Then
            CompareRows = True
            Exit Function
        ElseIf aa_array(al_first, keys(ll_Idx)) > aa_array(al_last, keys(ll_Idx)) Then
            CompareRows = False
            Exit Function
        End If
    Next

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

Private Function CompareRows2(ByRef aa_array As Variant, ByVal al_first As Long, ByVal al_last As Long, ByRef keys() As Long)
On Error GoTo ErrHandler
    
    Dim ll_Idx As Integer
    
    For ll_Idx = 0 To UBound(keys)
        If aa_array(al_first, keys(ll_Idx)) <> aa_array(al_last, keys(ll_Idx)) Then
            CompareRows2 = False
            Exit Function
        End If
    Next

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

Private Function ImportBORPerf_CheckExcelData(ByRef lv_DataArray As Variant, ByRef av_Headers As Dictionary, ByRef av_AgIds As Dictionary, ByRef at_Info() As tBOR_Perf, ByVal lngRow As Long, ByRef keys() As Long, ByRef as_Err As String)
On Error GoTo ErrHandler

Const SQL_SYSTEM_SEL = "select SYS_Id from DPC_SystemDesc WHERE SYS_Name = '$SYS_Name$'"
                         
Const SQL_PERF_SEL = "select PRD_Id from DPC_PrdDesc WHERE PRD_Name = '$PRD_Name$'"
                         
Const SQL_MATERIAL_SEL = "select MAT_Id from DPC_MaterialDesc WHERE MAT_Name = '$MAT_Name$'"
                             
Dim ll_Index
Dim ll_Sys_Id, ll_MAT_Id As Long
Dim ls_PRD_Id, ls_AgId As String
Dim ls_Request As String
Dim ll_Cursor As Long
            
    ImportBORPerf_CheckExcelData = False

    If Trim(lv_DataArray(lngRow, av_Headers(EX_SYS_NAME))) = "NULL" Or Trim(lv_DataArray(lngRow, av_Headers(EX_SYS_NAME))) = "" Then
        as_Err = "System name missing on line:" & lngRow
        Exit Function
    End If

    ls_Request = SQL_SYSTEM_SEL
    ls_Request = ReplacePlaceHolder(ls_Request, "$SYS_Name$", lv_DataArray(lngRow, av_Headers(EX_SYS_NAME)))
    ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
    
    If mo_Db.RowCount(ll_Cursor) = 1 Then
    
        ll_Sys_Id = mo_Db.GetFields(ll_Cursor, "SYS_Id")
                
    ElseIf mo_Db.RowCount(ll_Cursor) > 1 Then
        as_Err = "Inconsistent Data for System name = '" & lv_DataArray(lngRow, av_Headers(EX_SYS_NAME)) & "' on line:" & lngRow
        Call mo_Db.Close(ll_Cursor)
        Exit Function
    Else
        as_Err = "System is not available: SYS_Name = '" & lv_DataArray(lngRow, av_Headers(EX_SYS_NAME)) & "' on line:" & lngRow
        Call mo_Db.Close(ll_Cursor)
        Exit Function
    End If
    Call mo_Db.Close(ll_Cursor)

    If Trim(lv_DataArray(lngRow, av_Headers(EX_PRF_NAME))) = "NULL" Or Trim(lv_DataArray(lngRow, av_Headers(EX_PRF_NAME))) = "" Then
        as_Err = "Perforation name missing on line:" & lngRow
        Exit Function
    End If

    ls_Request = SQL_PERF_SEL
    ls_Request = ReplacePlaceHolder(ls_Request, "$PRD_Name$", lv_DataArray(lngRow, av_Headers(EX_PRF_NAME)))
    ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
    
    If mo_Db.RowCount(ll_Cursor) = 1 Then
    
        ls_PRD_Id = mo_Db.GetFields(ll_Cursor, "PRD_Id")
                
    ElseIf mo_Db.RowCount(ll_Cursor) > 1 Then
        as_Err = "Inconsistent Data for Perforation name = '" & lv_DataArray(lngRow, av_Headers(EX_PRF_NAME)) & "' on line:" & lngRow
        Call mo_Db.Close(ll_Cursor)
        Exit Function
    Else
        as_Err = "Perforation is not available: PRD_Name = '" & lv_DataArray(lngRow, av_Headers(EX_PRF_NAME)) & "' on line:" & lngRow
        Call mo_Db.Close(ll_Cursor)
        Exit Function
    End If
    Call mo_Db.Close(ll_Cursor)

    If Trim(lv_DataArray(lngRow, av_Headers(EX_MAT_NAME))) = "NULL" Or Trim(lv_DataArray(lngRow, av_Headers(EX_MAT_NAME))) = "" Then
        as_Err = "Material name missing on line:" & lngRow
        Exit Function
    End If

    ls_Request = SQL_MATERIAL_SEL
    ls_Request = ReplacePlaceHolder(ls_Request, "$MAT_Name$", lv_DataArray(lngRow, av_Headers(EX_MAT_NAME)))
    ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
    
    If mo_Db.RowCount(ll_Cursor) = 1 Then
    
        ll_MAT_Id = mo_Db.GetFields(ll_Cursor, "MAT_Id")
                
    ElseIf mo_Db.RowCount(ll_Cursor) > 1 Then
        as_Err = "Inconsistent Data for Material name = '" & lv_DataArray(lngRow, av_Headers(EX_MAT_NAME)) & "' on line:" & lngRow
        Call mo_Db.Close(ll_Cursor)
        Exit Function
    Else
        as_Err = "Material is not available: MAT_Name = '" & lv_DataArray(lngRow, av_Headers(EX_MAT_NAME)) & "' on line:" & lngRow
        Call mo_Db.Close(ll_Cursor)
        Exit Function
    End If
    Call mo_Db.Close(ll_Cursor)

    If lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MIN)) = "NULL" Or lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MIN)) = "" Then
        as_Err = "BOP_QTY_MIN missing for line:" & lngRow
        Exit Function
    Else
        If Not IsNumeric(lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MIN))) Then
            as_Err = "BOP_QTY_MIN must be a number for line:" & lngRow
            Exit Function
        End If
    End If
    
    If lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MAX)) = "NULL" Or lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MAX)) = "" Then
        as_Err = "BOP_QTY_MAX missing for line:" & lngRow
        Exit Function
    Else
        If Not IsNumeric(lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MAX))) Then
            as_Err = "BOP_QTY_MAX must be a number for line:" & lngRow
            Exit Function
        End If
    End If
            
    If lv_DataArray(lngRow, av_Headers(EX_BOP_BMIN)) = "NULL" Or lv_DataArray(lngRow, av_Headers(EX_BOP_BMIN)) = "" Then
        as_Err = "BOP_BMin missing for line:" & lngRow
        Exit Function
    Else
        If Not IsNumeric(lv_DataArray(lngRow, av_Headers(EX_BOP_BMIN))) Then
            as_Err = "BOP_BMin must be a number for line:" & lngRow
            Exit Function
        End If
    End If
    
    If lv_DataArray(lngRow, av_Headers(EX_BOP_BMAX)) = "NULL" Or lv_DataArray(lngRow, av_Headers(EX_BOP_BMAX)) = "" Then
        as_Err = "BOP_BMax missing for line:" & lngRow
        Exit Function
    Else
        If Not IsNumeric(lv_DataArray(lngRow, av_Headers(EX_BOP_BMAX))) Then
            as_Err = "BOP_BMax must be a number for line:" & lngRow
            Exit Function
        End If
    End If
    
    If lv_DataArray(lngRow, av_Headers(EX_BOP_PRIORITY)) = "NULL" Or lv_DataArray(lngRow, av_Headers(EX_BOP_PRIORITY)) = "" Then
        as_Err = "BOP_Priority missing for line:" & lngRow
        Exit Function
    Else
        If Not IsNumeric(lv_DataArray(lngRow, av_Headers(EX_BOP_PRIORITY))) Then
            as_Err = "BOP_Priority must be a number for line:" & lngRow
            Exit Function
        End If
    End If
    
    If lv_DataArray(lngRow, av_Headers(EX_BOP_AGID)) = "NULL" Or lv_DataArray(lngRow, av_Headers(EX_BOP_AGID)) = "" Then
        as_Err = "BOP_AgId missing for line:" & lngRow
        Exit Function
    Else
        If Not IsNumeric(lv_DataArray(lngRow, av_Headers(EX_BOP_AGID))) Then
            as_Err = "BOP_AgId must be a number for line:" & lngRow
            Exit Function
        Else
            ls_AgId = lv_DataArray(lngRow, av_Headers(EX_BOP_AGID))
            If Not av_AgIds.Exists(ls_AgId) Then
                as_Err = "AgId not in database for line:" & lngRow
                Exit Function
            End If
            
        End If
    End If
    
    at_Info(lngRow - 2).SYS_Id = ll_Sys_Id
    at_Info(lngRow - 2).PRF_Id = ls_PRD_Id
    at_Info(lngRow - 2).MAT_Id = ll_MAT_Id
    
    at_Info(lngRow - 2).QtyMin = lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MIN))
    at_Info(lngRow - 2).QtyMax = lv_DataArray(lngRow, av_Headers(EX_BOP_QTY_MAX))
    at_Info(lngRow - 2).BMin = lv_DataArray(lngRow, av_Headers(EX_BOP_BMIN))
    at_Info(lngRow - 2).BMax = lv_DataArray(lngRow, av_Headers(EX_BOP_BMAX))
    at_Info(lngRow - 2).Priority = lv_DataArray(lngRow, av_Headers(EX_BOP_PRIORITY))
    at_Info(lngRow - 2).AgId = av_AgIds.Item(lv_DataArray(lngRow, av_Headers(EX_BOP_AGID)))
                
    ImportBORPerf_CheckExcelData = True
    Exit Function
ErrHandler:
    as_Err = Err.Description
    ImportBORPerf_CheckExcelData = False
End Function

Private Sub ProgressBarShow(ByVal al_max As Long)
On Error GoTo ErrHandler
    
    Dim ll_MainConfigIndex, ll_Idx As Long
    
    ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
    ll_Idx = mt_MainConfig(ll_MainConfigIndex).FrameIndex
        
    Call fra_ProgressBar.Move(fra_MainItem(ll_Idx).Width / 2 - fra_ProgressBar.Width / 2, fra_MainItem(ll_Idx).Height / 2)
        
    LockWindowUpdate 0
    
    prb_Progress.Max = al_max
    prb_Progress.Value = 0
    fra_ProgressBar.Zorder
    fra_ProgressBar.Visible = True
    fra_MainItem(ll_Idx).Refresh
    fra_ProgressBar.Refresh
    Exit Sub
ErrHandler:
    Call ErrorHandler("ProgressBarShow")
End Sub

Private Sub ProgressBarStep()
On Error GoTo ErrHandler
    prb_Progress.Value = prb_Progress.Value + 1
    Exit Sub
ErrHandler:
    Call ErrorHandler("ProgressBarStep")
End Sub

Private Sub ProgressBarLabel(ByVal as_Msg As String)
On Error GoTo ErrHandler
    lbl_ProgressMsg.Caption = as_Msg
    lbl_ProgressMsg.Refresh
    Exit Sub
ErrHandler:
    Call ErrorHandler("ProgressBarLabel")
End Sub

Private Sub ProgressBarHide()
On Error GoTo ErrHandler
    fra_ProgressBar.Visible = False
    Exit Sub
ErrHandler:
    Call ErrorHandler("ProgressBarHide")
End Sub

Private Function ImportData(ByVal as_filePath As String, ByVal as_FrameName As String)

Const SQL_PERF_INS = "exec DPC_BOR_Perf_ins $BOP_Id$,$SYS_Id$,$PRF_Id$,$MAT_Id$,$BOP_QtyMin$,$BOP_QtyMax$,$BOP_BMin$,$BOP_BMax$,$BOP_Priority$,$BOP_AgId$,$U_Code$"

On Error GoTo ErrHandler

Dim lt_BOR_Perf As tBOR_Perf
Dim lt_ExcelImported As tExcelImported
Dim ls_Request As String
Dim ll_Cursor As Long
Dim ll_keys() As Long
Dim ll_MainConfigIndex As Long
Dim ll_DetailConfigIndex As Long
Dim lt_BOR_PerfInfo() As tBOR_Perf
Dim ll_Index As Integer
Dim ls_Msg As String

#If LIVE = 1 Then
    Dim lo_XLApp As Object   ' Excel.Application
    Dim lo_XLBook As Object  ' Excel.Workbook
    Dim lo_XLSheet As Object ' Excel.Worksheet
#Else
    Dim lo_XLApp As Excel.Application
    Dim lo_XLBook As Excel.Workbook
    Dim lo_XLSheet As Excel.Worksheet
#End If

Dim lngCol As Long, lngRow As Long
Dim ld_LastUpdated As Date

Dim lv_Headers As Dictionary
Dim lv_AgIds As Dictionary
Dim lv_DataArray() As Variant
Dim ll_Err As String

Set lo_XLApp = CreateObject("Excel.Application")
Set lo_XLBook = lo_XLApp.Workbooks.Open(as_filePath)

If lo_XLBook Is Nothing Then
    Call LogMessage("ImportExcelFile, Export Workbook not available in source xls file:" & as_filePath)
    Exit Function
End If

Set lo_XLSheet = lo_XLBook.Worksheets(1)

If lo_XLSheet Is Nothing Then
    Call LogMessage("ImportExcelFile, Export Worksheet not available in source xls file:" & as_filePath)
    Exit Function
End If

lv_DataArray = lo_XLSheet.UsedRange.Value

    lo_XLApp.Workbooks(1).Close (False)
    
    Set lo_XLSheet = Nothing
    Set lo_XLBook = Nothing
    Set lo_XLApp = Nothing

    lt_ExcelImported.Count = 0
    lt_ExcelImported.InsertedCount = 0
    lt_ExcelImported.UpdatedCount = 0
                            
    Set lv_Headers = New Dictionary
    
    For lngCol = 1 To UBound(lv_DataArray, 2)
        Call lv_Headers.Add(lv_DataArray(1, lngCol), lngCol)
    Next
          
    If as_FrameName = "DPC_BOR_Perf" Then
        ReDim ll_keys(8)
        ll_keys(0) = lv_Headers(EX_SYS_NAME)
        ll_keys(1) = lv_Headers(EX_PRF_NAME)
        ll_keys(2) = lv_Headers(EX_MAT_NAME)
        ll_keys(3) = lv_Headers(EX_BOP_QTY_MIN)
        ll_keys(4) = lv_Headers(EX_BOP_QTY_MAX)
        ll_keys(5) = lv_Headers(EX_BOP_BMIN)
        ll_keys(6) = lv_Headers(EX_BOP_BMAX)
        ll_keys(7) = lv_Headers(EX_BOP_PRIORITY)
        ll_keys(8) = lv_Headers(EX_BOP_AGID)
        
        For ll_Index = 0 To UBound(ll_keys)
            If ll_keys(ll_Index) = 0 Then
                ls_Msg = mo_Tools.MsgText(mo_Db, ms_Language_Code, C_MSG_ID_BASE + 47, "#Excel file column missing at index:")
                Call LogMessage(ls_Msg & ll_Index + 1)
                Call MsgBox(ls_Msg & ll_Index + 1, vbOKOnly, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
                Exit Function
            End If
        Next
        Set lv_AgIds = New Dictionary
        Call InitAgIds("DPC_BOR_Perf", lv_AgIds)

    End If
            
    Call ProgressBarShow(UBound(lv_DataArray, 1))
    Call ProgressBarLabel(mo_Tools.MsgText(mo_Db, ms_Language_Code, C_MSG_ID_BASE + 3, "#Sorting excel file ..."))
            
    Call QuickSort(lv_DataArray, ll_keys, 0, 0)
            
    grd_DataImport.ClearGrid
    ReDim lv_Data(grd_DataImport.Cols - 1)
    lv_Data(0) = ""         ' this is new
    
    ld_LastUpdated = Now()
    
    ReDim lt_BOR_PerfInfo(UBound(lv_DataArray, 1) - 1)
    
    Call ProgressBarLabel(mo_Tools.MsgText(mo_Db, ms_Language_Code, C_MSG_ID_BASE + 1, "#Checking excel file ..."))
    
    For lngRow = 2 To UBound(lv_DataArray, 1)
    
        Call ProgressBarStep
        If DateDiff("s", ld_LastUpdated, Now) > 5 Then
            ld_LastUpdated = Now()
            Refresh
            DoEvents
        End If
                
        'total row counter
        lt_ExcelImported.Count = lt_ExcelImported.Count + 1
                
        If ImportBORPerf_CheckExcelData(lv_DataArray, lv_Headers, lv_AgIds, lt_BOR_PerfInfo, lngRow, ll_keys, ll_Err) = False Then
            'add error message into grid
            
            If grd_DataImport.AddLine(lv_Data) Then
                                      
                grd_DataImport.SelectedLine(0, 0) = "0"
                grd_DataImport.SelectedLine(0, 1) = ll_Err
            
            End If
                                
        End If
    Next
    
    Call ProgressBarHide
    
    If grd_DataImport.Rows > 0 Then
        ll_MainConfigIndex = FindMainConfigByName(tbs_Main.SelectedItem.Key)
        ll_DetailConfigIndex = FindDetailConfigByMainConfig(ll_MainConfigIndex)
        
        mt_MainConfig(ll_MainConfigIndex).CurrentDetailIndex = DATA_IMPORT_CONFIG_INDEX
        mt_DetailConfig(DATA_IMPORT_CONFIG_INDEX).PreviousDetailIndex = ll_DetailConfigIndex
            
        Call Item_ViewInit(DATA_IMPORT_CONFIG_INDEX, 0)
        Set lv_Headers = Nothing
        Exit Function
    End If
                            
    On Error GoTo ErrorImportRow
    
    For lngRow = 0 To UBound(lt_BOR_PerfInfo)
                                                                                                                                            
        If as_FrameName = "DPC_BOR_Perf" Then
                                                                                                                                                
            ls_Request = SQL_PERF_INS
            ls_Request = Replace(ls_Request, "$BOP_Id$", mo_Tools.SqlInt(mo_Tools.GetNextID(mo_Db, "DPC_BOR_Perf")))
            ls_Request = Replace(ls_Request, "$SYS_Id$", mo_Tools.SqlInt(lt_BOR_PerfInfo(lngRow).SYS_Id), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$PRF_Id$", mo_Tools.SQLStr(lt_BOR_PerfInfo(lngRow).PRF_Id), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$MAT_Id$", mo_Tools.SqlInt(lt_BOR_PerfInfo(lngRow).MAT_Id), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$BOP_QtyMin$", mo_Tools.SqlInt(lt_BOR_PerfInfo(lngRow).QtyMin), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$BOP_QtyMax$", mo_Tools.SqlInt(lt_BOR_PerfInfo(lngRow).QtyMax), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$BOP_BMin$", mo_Tools.SqlDbl(lt_BOR_PerfInfo(lngRow).BMin), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$BOP_BMax$", mo_Tools.SqlDbl(lt_BOR_PerfInfo(lngRow).BMax), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$BOP_Priority$", mo_Tools.SqlInt(lt_BOR_PerfInfo(lngRow).Priority), , , vbTextCompare)
            ls_Request = Replace(ls_Request, "$BOP_AgId$", mo_Tools.SqlInt(lt_BOR_PerfInfo(lngRow).AgId), , , vbTextCompare)
            ls_Request = ReplaceCommonPlaceholders(ls_Request)
            
            Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request)
        End If
                                            
        GoTo NextImportRow
        'error managment - if import failed, continue to import next row
ErrorImportRow:
        Call LogMessage("ImportData Count=" & lt_ExcelImported.Count)
        If grd_DataImport.AddLine(lv_Data) Then
                                  
            grd_DataImport.SelectedLine(0, 0) = "0"
            grd_DataImport.SelectedLine(0, 1) = "ImportData error:" & Err.Description
        
        End If
        Resume NextImportRow
NextImportRow:
    Next
    
    Set lv_Headers = Nothing
        
    Exit Function
ErrHandler:
    Set lv_Headers = Nothing
    Call ProgressBarHide
    
    Call ErrorHandler("ImportData")
End Function

Private Function GetRoutCateg(ByVal as_NameFrame As String) As Integer
On Error GoTo ErrHandler
    
    GetRoutCateg = -1
    If StrComp(as_NameFrame, "DPC_BOR_Perf", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.ePerforation
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Bend", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.eBending
    ElseIf StrComp(as_NameFrame, "DPC_BOR_PunchNotch", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.ePunchNotching
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Coating", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.eCoating
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Gasket", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.eGasketSpacer
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Inlay", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.eInlay
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Packing", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.ePacking
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Cutting", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.eCutting
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Rerolling", vbTextCompare) = 0 Then
        GetRoutCateg = eDPCBOROperation.eRerolling
    End If
    Exit Function
ErrHandler:
    Call ErrorHandler("GetRoutCateg")
End Function

Private Function GetAgID_cbo_Idx(ByVal as_NameFrame As String) As String
On Error GoTo ErrHandler
    
    GetAgID_cbo_Idx = -1
    If StrComp(as_NameFrame, "DPC_BOR_Perf", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "0,7,8"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Bend", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "1,25,26"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_PunchNotch", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "2,23,24"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Coating", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "3,12,13"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Gasket", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "4,17,18"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Inlay", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "5,19,20"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Packing", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "6,21,22"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Cutting", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "9,10,11"
    ElseIf StrComp(as_NameFrame, "DPC_BOR_Rerolling", vbTextCompare) = 0 Then
        GetAgID_cbo_Idx = "14,15,16"
    End If
    Exit Function
ErrHandler:
    Call ErrorHandler("GetAgID_cbo_Idx")
End Function

Private Function InitAgIds(ByVal as_NameFrame As String, ByRef ad_AgIds As Dictionary) As Boolean
On Error GoTo ErrHandler

    Dim ls_Request As String
    Dim ll_Cursor As Long
    Dim ls_Items As String
    Dim ll_RoutCateg As Long
    
    InitAgIds = False
    ll_RoutCateg = GetRoutCateg(as_NameFrame)
        
    If ll_RoutCateg <> -1 Then
        
        ls_Request = "SELECT DISTINCT BOC_KostSt FROM DPC_BOR_OperCost WHERE OPR_Id = " & ll_RoutCateg
        
        ll_Cursor = mo_Db.OpenSQL(ls_Request)

        ls_Items = ""
        While Not mo_Db.EOF(ll_Cursor)
            If ls_Items <> "" Then
                ls_Items = ls_Items & ","
            End If
            ls_Items = ls_Items & mo_Db.GetFields(ll_Cursor, 0)
            Call mo_Db.Next(ll_Cursor)
        Wend
        Call mo_Db.Close(ll_Cursor)

        ls_Request = "SELECT agid, agben, stagnr FROM f250 WHERE kostst in (" & ls_Items & ")"
        
        ll_Cursor = mo_Db_2.OpenSQL(ls_Request)
        While Not mo_Db_2.EOF(ll_Cursor)
            Call ad_AgIds.Add(mo_Db_2.GetFields(ll_Cursor, "stagnr"), mo_Db_2.GetFields(ll_Cursor, "agid"))

            Call mo_Db_2.Next(ll_Cursor)
        Wend
        Call mo_Db_2.Close(ll_Cursor)
    
    End If
    
    InitAgIds = True
    
    Exit Function
ErrHandler:
    Call ErrorHandler("InitAgIds")
End Function

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 eTableType.ttDPC_BOR_Bend
            ls_Date = Split(as_Date, "/")
            If UBound(ls_Date) = 2 Then
                ConvertDate = DateSerial(Val(ls_Date(2)), Val(ls_Date(1)), Val(ls_Date(0)))
            End If
        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_BOR") 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 mo_Db.Close (mc_ScreenLabels)
    mc_ScreenLabels = 0
    If mc_Toolbars <> 0 Then mo_Db.Close (mc_Toolbars)
    mc_Toolbars = 0
        
    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

    If Width < 0 Or Height < 0 Then Exit Sub
    
    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    
    If StrComp(mt_SubdetailConfig(al_SubDetailIndex).NameFrame, "DPC_BOR_Bend", vbTextCompare) = 0 Then
    End If
    
    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)
    Call grd_SubDetail(ll_frameIndex).Move(FRM_SPACE_HOR, 2 * FRM_SPACE_VER, tlb_SubDetail(ll_frameIndex).Left - 2 * FRM_SPACE_HOR, fra_SubDetail(ll_frameIndex).Height - 3 * FRM_SPACE_VER)
    
    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

    Const LVSCW_AUTOSIZE = -1
    Const LVSCW_AUTOSIZE_USEHEADER = -2

    Const LVM_FIRST = &H1000
    Const LVM_GETCOLUMNWIDTH = LVM_FIRST + 29
    Const LVM_SETCOLUMNWIDTH = LVM_FIRST + 30
   
    Dim ls_Request As String
    Dim ll_Cursor As Long
    Dim ll_MaxWidth As Long
    Dim ls_Text As String
    Dim ll_Index 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)
    
    ll_MaxWidth = 0
        
    While Not mo_Db.EOF(ll_Cursor)
        ls_Text = mo_Db.GetFields(ll_Cursor, as_Name_Column) ' & "    " & Chr(10)
        If TextWidth(ls_Text) > ll_MaxWidth Then
            ll_MaxWidth = TextWidth(ls_Text)
        End If
        Call mo_Db.Next(ll_Cursor)
    Wend
    
    Call mo_Db.First(ll_Cursor)
    
    al_List.ListItems.Clear
    al_List.Font = "Arial Narrow"
        
    DoEvents 'this is enough to autoresize, but it does not work for "VLW" string for example
        
    ll_Index = 1
    While Not mo_Db.EOF(ll_Cursor)
        ls_Text = mo_Db.GetFields(ll_Cursor, as_Name_Column) ' & "    " & Chr(10)
        Call al_List.ListItems.Add(ll_Index, "ID" & mo_Db.GetFields(ll_Cursor, as_ID_Column), ls_Text)

        ll_Index = ll_Index + 1
        Call mo_Db.Next(ll_Cursor)
    Wend
        
    mo_Db.Close (ll_Cursor)
            
    'Call SendMessage(al_List.hwnd, LVM_SETCOLUMNWIDTH, CLng(0), ByVal LVSCW_AUTOSIZE) 'does not work
    'Call SendMessage(al_List.hwnd, LVM_SETCOLUMNWIDTH, CLng(0), 150 + ll_MaxWidth / Screen.TwipsPerPixelX)
    
    'Call al_List.Refresh
    
    DoEvents
      
    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 SaveDetailListAndTreeCommon(ByVal al_DetailIndex As Long)
On Error GoTo ErrHandler

Const DELETE_REQUEST_MAT = "exec DPC_BOR_Param_Mat_del $BP_Id$,$OPR_Id$"
Const INSERT_REQUEST_MAT = "exec DPC_BOR_Param_Mat_ins $BP_Id$,$OPR_Id$,$MAT_Id$,$Z_Creator$"
Const DELETE_REQUEST_RF = "exec DPC_BOR_Param_Ref_del $BP_Id$,$OPR_Id$,$GR_Code$"
Const INSERT_REQUEST_RF = "exec DPC_BOR_Param_Ref_ins $BP_Id$,$OPR_Id$,$GR_Code$,$RF_Code$,$Z_Creator$"
Const DELETE_REQUEST_PROD = "exec DPC_BOR_Param_Prod_del $BP_Id$,$OPR_Id$,$CAT_ID$"
Const INSERT_REQUEST_PROD = "exec DPC_BOR_Param_Prod_ins $BP_Id$,$OPR_Id$,$CAT_Id$,$PRD_Id$,$Z_Creator$"
Const DELETE_REQUEST_SYS = "exec DPC_BOR_Param_Sys_del $BP_Id$,$OPR_Id$"
Const INSERT_REQUEST_SYS = "exec DPC_BOR_Param_Sys_ins $BP_Id$,$OPR_Id$,$SYS_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_BOR_Perf", vbTextCompare) = 0) Then
        
        Call SaveDetailTreeView(0, DELETE_REQUEST_SYS, INSERT_REQUEST_SYS, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.ePerforation, "SYS_Id")
        Call SaveDetailListView(lv_Materials(0), DELETE_REQUEST_MAT, INSERT_REQUEST_MAT, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.ePerforation, "MAT_Id")
    
    ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Bend", vbTextCompare) = 0) Then
        
        Call SaveDetailTreeView(3, DELETE_REQUEST_SYS, INSERT_REQUEST_SYS, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.eBending, "SYS_Id")
    
    ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Cutting", vbTextCompare) = 0) Then
        Call SaveDetailListView(lv_Materials(1), DELETE_REQUEST_MAT, INSERT_REQUEST_MAT, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.eCutting, "MAT_Id")
    
    ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Rerolling", vbTextCompare) = 0) Then
        Call SaveDetailListView(lv_Materials(2), DELETE_REQUEST_MAT, INSERT_REQUEST_MAT, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.eRerolling, "MAT_Id")
    
    ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_Inlay", vbTextCompare) = 0) Then
        ls_Request = ReplacePlaceHolder(DELETE_REQUEST_RF, "$GR_Code$", mo_Tools.SqlInt(eDPCReferenceML.rfPerforationBorderType))
        ls_Request2 = ReplacePlaceHolder(INSERT_REQUEST_RF, "$GR_Code$", mo_Tools.SqlInt(eDPCReferenceML.rfPerforationBorderType))
        Call SaveDetailListView(lv_PBordDesc, ls_Request, ls_Request2, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.eInlay, "RF_Code")
    
        ls_Request = ReplacePlaceHolder(DELETE_REQUEST_PROD, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgInlay))
        ls_Request2 = ReplacePlaceHolder(INSERT_REQUEST_PROD, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgInlay))
        Call SaveDetailListView(lv_INL_Name, ls_Request, ls_Request2, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.eInlay, "PRD_Id")
    
        ls_Request = ReplacePlaceHolder(DELETE_REQUEST_PROD, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgCutout))
        ls_Request2 = ReplacePlaceHolder(INSERT_REQUEST_PROD, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgCutout))
        Call SaveDetailListView(lv_CUT_Name, ls_Request, ls_Request2, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.eInlay, "PRD_Id")
        
    ElseIf (StrComp(mt_DetailConfig(al_DetailIndex).NameFrame, "DPC_BOR_PunchNotch", vbTextCompare) = 0) Then
        
        Call SaveDetailTreeView(1, DELETE_REQUEST_SYS, INSERT_REQUEST_SYS, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.ePunchNotching, "SYS_Id")
        
        ls_Request = ReplacePlaceHolder(DELETE_REQUEST_PROD, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgPerforation))
        ls_Request2 = ReplacePlaceHolder(INSERT_REQUEST_PROD, "$CAT_Id$", mo_Tools.SqlInt(eDPCCategory.cgPerforation))
        Call SaveDetailTreeView(2, ls_Request, ls_Request2, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.ePunchNotching, "PRD_Id")
        
        Call SaveDetailListView(lv_Materials(3), DELETE_REQUEST_MAT, INSERT_REQUEST_MAT, txt_DetailKey(ll_frameIndex).Text, eDPCBOROperation.ePunchNotching, "MAT_Id")
    End If

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


Private Sub SaveDetailListView(al_List As ListView, ByVal as_Req_Del As String, ByVal as_Req_Ins As String, ByVal ai_BP_Id As Integer, ByVal ai_OPR_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, "$BP_Id$", mo_Tools.SqlInt(ai_BP_Id))
    ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(ai_OPR_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, "$BP_Id$", mo_Tools.SqlInt(ai_BP_Id))
            ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(ai_OPR_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 Sub LoadDetailTreeView(ByVal al_Index As Long, ByVal as_View_Req As String, ByVal as_List_Req As String, ByVal as_ID_Column As String)
On Error GoTo ErrHandler
    
    Dim ls_Request As String
    Dim ll_Cursor As Long
    Dim lo_Node As MSComctlLib.Node
        
    ls_Request = ReplacePlaceHolder(as_View_Req, "$Language_Code$", mo_Tools.SQLStr(ms_Language_Code))
    ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
    Debug.Assert (ll_Cursor <> 0)
    
    tvw_Detail(al_Index).Levels = 2
    tvw_Detail(al_Index).NodeRequests = ll_Cursor
    tvw_Detail(al_Index).Checkboxes = True
    
    If Not tvw_Detail(al_Index).LoadTree(LoadTypeTree) Then
        Call Err.Raise(CompFncFailed, "tvw_Detail(al_Index).LoadTree")
    End If
    
    Call mo_Db.Close(ll_Cursor)
    
    Dim ll_Index As Long
    'For ll_Index = 1 To tvw_Detail(al_Index).Count
    '    If tvw_Detail(al_Index).Nodes(ll_Index).Parent Is Nothing Then Call tvw_Detail(al_Index).ExpandNode(tvw_Detail(al_Index).Nodes(ll_Index))
    'Next
    
    If as_List_Req <> "" Then
        ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, as_List_Req)
        
        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 tvw_Detail(al_Index).Count
              Set lo_Node = tvw_Detail(al_Index).Nodes(ll_Index)
              If (lo_Node.Tag.ml_Level = 1) And (StrComp(lo_Node.Tag.IDValue, ll_Key, vbTextCompare) = 0) Then
                  Call tvw_Detail(al_Index).SetNodeState(lo_Node, TVI_STATE_CHECKED)
                  Call tvw_Detail(al_Index).SetParentState(lo_Node)
              End If
            Next
            Call mo_Db.Next(ll_Cursor)
        Wend
        Call mo_Db.Close(ll_Cursor)
    End If
    
    If tvw_Detail(al_Index).Count <> 0 Then Call tvw_Detail(al_Index).Nodes(1).EnsureVisible
        
    Exit Sub
ErrHandler:
    If ll_Cursor > 0 Then
            mo_Db.Close (ll_Cursor)
    End If
    Call ErrorMessage("LoadDetailTreeView")
End Sub

Private Sub SaveDetailTreeView(ByVal al_Index As Long, ByVal as_Del_Req As String, ByVal as_Ins_Req As String, ByVal al_BOR_Id As Long, ByVal ai_OPR_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_Del_Req, "$BP_Id$", mo_Tools.SqlInt(al_BOR_Id))
    ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(ai_OPR_Id))
    Call mo_Tools.ExecuteSQLSafe(mo_Db, ls_Request)

    Dim ll_Index As Long
    For ll_Index = 1 To tvw_Detail(al_Index).Count
        If Not tvw_Detail(al_Index).Nodes(ll_Index).Parent Is Nothing And tvw_Detail(al_Index).Nodes(ll_Index).Tag.ml_State = TVI_STATE_CHECKED Then
            ls_Request = ReplacePlaceHolder(as_Ins_Req, "$BP_Id$", mo_Tools.SqlInt(al_BOR_Id))
            ls_Request = ReplacePlaceHolder(ls_Request, "$OPR_Id$", mo_Tools.SqlInt(ai_OPR_Id))
            ls_Request = ReplacePlaceHolder(ls_Request, "$" & as_ID_Column & "$", tvw_Detail(al_Index).Nodes(ll_Index).Tag.IDValue)
            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("SaveDetailTreeView")
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 GenerateNameTreeView(ByVal al_Index As Long, ByVal al_MaxEntries As Long, Optional as_Separator = ",", Optional ab_UseCode = False) As String
On Error GoTo ErrHandler

Dim ll_Idx As Long
Dim ls_Name As String
Dim ls_ParentName As String
Dim ls_TmpName As String
Dim lb_All As Boolean
Dim ll_Counter As Long
Dim ll_TmpCounter As Long

    ls_Name = ""
    ls_TmpName = ""
    ls_ParentName = ""
    GenerateNameTreeView = ""
    
    ll_TmpCounter = 0
    ll_Counter = 0
    
    For ll_Idx = 1 To tvw_Detail(al_Index).Count
    
        If tvw_Detail(al_Index).Nodes(ll_Idx).Parent Is Nothing Then
            If ls_ParentName <> "" Then
                If lb_All = True Then
                    ls_Name = ls_Name & ls_ParentName
                    ll_Counter = ll_Counter + 1
                Else
                    ls_Name = ls_Name & ls_TmpName
                    ll_Counter = ll_Counter + ll_TmpCounter
                End If
                
                If ll_Counter >= al_MaxEntries Then
                    GenerateNameTreeView = ls_Name
                    Exit Function
                End If
                ll_TmpCounter = 0
                ls_TmpName = ""
            End If
            If ab_UseCode = True Then
                ls_ParentName = tvw_Detail(al_Index).Nodes(ll_Idx).Key & as_Separator
            Else
                ls_ParentName = tvw_Detail(al_Index).Nodes(ll_Idx).Text & as_Separator
            End If
            lb_All = True
        Else
            If tvw_Detail(al_Index).Nodes(ll_Idx).Tag.ml_State = TVI_STATE_CHECKED Then
                If ll_Counter + ll_TmpCounter < al_MaxEntries Then
                    If ab_UseCode = True Then
                        ls_TmpName = ls_TmpName & tvw_Detail(al_Index).Nodes(ll_Idx).Key & as_Separator
                    Else
                        ls_TmpName = ls_TmpName & tvw_Detail(al_Index).Nodes(ll_Idx).Text & as_Separator
                    End If
                    ll_TmpCounter = ll_TmpCounter + 1
                End If
            Else
                lb_All = False
            End If
        
        End If
    
    Next
    
    GenerateNameTreeView = ls_Name
    
    Exit Function
ErrHandler:
    Call ErrorHandler("GenerateNameTreeView")
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

    ll_frameIndex = mt_SubdetailConfig(al_SubDetailIndex).FrameIndex
    ll_DetailIndex = mt_SubdetailConfig(al_SubDetailIndex).DetailConfigIndex
    
    If (ae_Mode = emList) Or (ae_Mode = emView) Then
        fra_SubDetailItem(ll_frameIndex).Visible = False
        grd_SubDetail(ll_frameIndex).Top = 2 * FRM_SPACE_VER
        grd_SubDetail(ll_frameIndex).Height = fra_SubDetail(ll_frameIndex).Height - 3 * FRM_SPACE_VER
    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 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 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 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 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 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))
            ls_Request = ReplaceRequestByGridData(grd_SubDetail(ll_frameIndex), 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)
            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 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))
            ls_Request = ReplaceRequestByGridData(grd_SubDetail(ll_frameIndex), 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)
            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 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 ReinitMainGrid()
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)
    End If
    
    If Not grd_Main(ll_frameIndex).Load(grd_Main(ll_frameIndex).Requests, False, , , True) Then
        Err.Raise ArmErr.CompFncFailed, "grd_Main", "Method Load failed: " & grd_Main(ll_frameIndex).Requests(0)
    End If

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

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 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 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 "OPTIONBUTTON"
                    If Trim(lo_Control.Tag) <> "" Then
                        lsa_Columns = Split(lo_Control.Tag, SEP)
                        If mo_Db.GetFieldIndex(al_Cursor, lsa_Columns(0)) >= 0 And UBound(lsa_Columns) = 1 Then
                            If UCase(mo_Db.GetFields(al_Cursor, lsa_Columns(0))) = lsa_Columns(1) Then
                                lo_Control.Value = True
                            Else
                                lo_Control.Value = False
                            End If
                        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) >= 0 Then
                            lo_Control.Text = ao_grid.CurrentLine(lsa_Columns(0))
                        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



