VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.UserControl DSW 
   ClientHeight    =   13080
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   15495
   ScaleHeight     =   13080
   ScaleWidth      =   15495
   Begin VB.Frame fr_main 
      ForeColor       =   &H80000008&
      Height          =   10475
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Visible         =   0   'False
      Width           =   15375
      Begin Project1.ArmGrid grd_detail 
         Height          =   5400
         Left            =   2520
         TabIndex        =   57
         Top             =   860
         Width           =   12750
         _ExtentX        =   22490
         _ExtentY        =   9525
      End
      Begin VB.Frame fr_detail 
         Height          =   4215
         Left            =   2520
         TabIndex        =   10
         Top             =   6225
         Width           =   12735
         Begin VB.PictureBox export_Excel 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BorderStyle     =   0  'None
            ForeColor       =   &H80000008&
            Height          =   240
            Left            =   7080
            Picture         =   "DSW.ctx":0000
            ScaleHeight     =   240
            ScaleWidth      =   240
            TabIndex        =   55
            Top             =   120
            Width           =   240
         End
         Begin VB.CheckBox Sa_Flag 
            Caption         =   "SA"
            Enabled         =   0   'False
            Height          =   255
            Left            =   6600
            TabIndex        =   54
            Top             =   480
            Width           =   735
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   13
            Left            =   5880
            Locked          =   -1  'True
            TabIndex        =   52
            Top             =   2520
            Width           =   1410
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   12
            Left            =   5880
            Locked          =   -1  'True
            TabIndex        =   50
            Top             =   2160
            Width           =   1410
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   11
            Left            =   3480
            Locked          =   -1  'True
            TabIndex        =   48
            Top             =   2640
            Width           =   1530
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   10
            Left            =   720
            Locked          =   -1  'True
            TabIndex        =   46
            Top             =   2640
            Width           =   1530
         End
         Begin VB.TextBox dt_bck 
            Height          =   375
            Left            =   120
            TabIndex        =   45
            Top             =   3240
            Visible         =   0   'False
            Width           =   495
         End
         Begin MSComctlLib.ImageCombo cb_status 
            Height          =   330
            Left            =   8160
            TabIndex        =   44
            Top             =   3480
            Visible         =   0   'False
            Width           =   2895
            _ExtentX        =   5106
            _ExtentY        =   582
            _Version        =   393216
            ForeColor       =   -2147483640
            BackColor       =   16777152
            Locked          =   -1  'True
         End
         Begin VB.PictureBox tb_upd 
            Appearance      =   0  'Flat
            AutoRedraw      =   -1  'True
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   615
            Left            =   11160
            ScaleHeight     =   585
            ScaleWidth      =   1380
            TabIndex        =   40
            Top             =   3480
            Visible         =   0   'False
            Width           =   1410
            Begin VB.PictureBox quit_upd 
               Appearance      =   0  'Flat
               BackColor       =   &H00FFFFFF&
               BorderStyle     =   0  'None
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H80000008&
               Height          =   495
               Left            =   720
               Picture         =   "DSW.ctx":0102
               ScaleHeight     =   495
               ScaleWidth      =   615
               TabIndex        =   42
               Top             =   60
               Width           =   615
            End
            Begin VB.PictureBox valid_upd 
               Appearance      =   0  'Flat
               BackColor       =   &H00FFFFFF&
               BorderStyle     =   0  'None
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H80000008&
               Height          =   495
               Left            =   120
               Picture         =   "DSW.ctx":040C
               ScaleHeight     =   495
               ScaleWidth      =   615
               TabIndex        =   41
               Top             =   60
               Width           =   615
            End
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   18
            Left            =   1800
            Locked          =   -1  'True
            TabIndex        =   39
            Top             =   120
            Width           =   1800
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   17
            Left            =   5280
            Locked          =   -1  'True
            TabIndex        =   37
            Top             =   1680
            Width           =   1800
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   16
            Left            =   5280
            Locked          =   -1  'True
            TabIndex        =   35
            Top             =   1080
            Width           =   1800
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   4
            Left            =   1800
            Locked          =   -1  'True
            TabIndex        =   32
            Top             =   840
            Width           =   3215
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   3
            Left            =   4680
            Locked          =   -1  'True
            TabIndex        =   31
            Top             =   480
            Width           =   1800
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   2
            Left            =   1800
            Locked          =   -1  'True
            TabIndex        =   29
            Top             =   480
            Width           =   1800
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   1
            Left            =   4680
            Locked          =   -1  'True
            TabIndex        =   27
            Top             =   120
            Width           =   1800
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   0
            Left            =   9240
            Locked          =   -1  'True
            TabIndex        =   25
            Top             =   3840
            Width           =   1800
         End
         Begin VB.TextBox dt 
            Height          =   1095
            Index           =   19
            Left            =   960
            Locked          =   -1  'True
            MaxLength       =   2000
            MultiLine       =   -1  'True
            ScrollBars      =   2  'Vertical
            TabIndex        =   22
            Top             =   3000
            Width           =   6375
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   8
            Left            =   3480
            Locked          =   -1  'True
            TabIndex        =   21
            Top             =   2280
            Width           =   1530
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   9
            Left            =   1800
            Locked          =   -1  'True
            TabIndex        =   19
            Top             =   2280
            Width           =   975
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   7
            Left            =   1800
            Locked          =   -1  'True
            TabIndex        =   17
            Top             =   1920
            Width           =   3215
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   6
            Left            =   1800
            Locked          =   -1  'True
            TabIndex        =   15
            Top             =   1560
            Width           =   3215
         End
         Begin VB.TextBox dt 
            Alignment       =   1  'Right Justify
            Height          =   375
            Index           =   5
            Left            =   1800
            Locked          =   -1  'True
            TabIndex        =   13
            Top             =   1200
            Width           =   3215
         End
         Begin MSFlexGridLib.MSFlexGrid grd_DetailLine 
            Height          =   3255
            Left            =   7320
            TabIndex        =   11
            Top             =   120
            Width           =   5295
            _ExtentX        =   9340
            _ExtentY        =   5741
            _Version        =   393216
            Cols            =   1
            FixedCols       =   0
         End
         Begin VB.Label dl 
            Caption         =   "Fax"
            Height          =   255
            Index           =   13
            Left            =   5040
            TabIndex        =   53
            Top             =   2640
            Width           =   615
         End
         Begin VB.Label dl 
            Caption         =   "Phone"
            Height          =   255
            Index           =   12
            Left            =   5040
            TabIndex        =   51
            Top             =   2280
            Width           =   615
         End
         Begin VB.Label dl 
            Caption         =   "Country"
            Height          =   255
            Index           =   11
            Left            =   2400
            TabIndex        =   49
            Top             =   2760
            Width           =   975
         End
         Begin VB.Label dl 
            Caption         =   "County"
            Height          =   255
            Index           =   10
            Left            =   120
            TabIndex        =   47
            Top             =   2760
            Width           =   615
         End
         Begin VB.Label l_upd 
            Caption         =   "Status"
            Height          =   255
            Left            =   7560
            TabIndex        =   43
            Top             =   3480
            Visible         =   0   'False
            Width           =   615
         End
         Begin VB.Label dl 
            Caption         =   "Customer Rep"
            Height          =   375
            Index           =   18
            Left            =   120
            TabIndex        =   38
            Top             =   120
            Width           =   1335
         End
         Begin VB.Label dl 
            Caption         =   "Creator"
            Height          =   375
            Index           =   17
            Left            =   5280
            TabIndex        =   36
            Top             =   1440
            Width           =   1695
         End
         Begin VB.Label dl 
            Caption         =   "Creation Date"
            Height          =   375
            Index           =   16
            Left            =   5280
            TabIndex        =   34
            Top             =   840
            Width           =   1815
         End
         Begin VB.Label dl 
            Caption         =   "Contact"
            Height          =   255
            Index           =   4
            Left            =   120
            TabIndex        =   33
            Top             =   960
            Width           =   1575
         End
         Begin VB.Label dl 
            Caption         =   "Raised By"
            Height          =   375
            Index           =   3
            Left            =   3720
            TabIndex        =   30
            Top             =   480
            Width           =   855
         End
         Begin VB.Label dl 
            Caption         =   "Action Type"
            Height          =   375
            Index           =   2
            Left            =   120
            TabIndex        =   28
            Top             =   480
            Width           =   1695
         End
         Begin VB.Label dl 
            Caption         =   "Due Date"
            Height          =   375
            Index           =   1
            Left            =   3720
            TabIndex        =   26
            Top             =   120
            Width           =   975
         End
         Begin VB.Label dl 
            Caption         =   "Action Reference"
            Height          =   375
            Index           =   0
            Left            =   7560
            TabIndex        =   24
            Top             =   3840
            Width           =   1695
         End
         Begin VB.Label dl 
            Caption         =   "Comment"
            Height          =   255
            Index           =   19
            Left            =   120
            TabIndex        =   23
            Top             =   3000
            Width           =   1575
         End
         Begin VB.Label dl 
            Caption         =   "Town"
            Height          =   255
            Index           =   8
            Left            =   2880
            TabIndex        =   20
            Top             =   2400
            Width           =   975
         End
         Begin VB.Label dl 
            Caption         =   "Post Code"
            Height          =   255
            Index           =   9
            Left            =   120
            TabIndex        =   18
            Top             =   2400
            Width           =   1575
         End
         Begin VB.Label dl 
            Height          =   255
            Index           =   7
            Left            =   120
            TabIndex        =   16
            Top             =   2040
            Width           =   1575
         End
         Begin VB.Label dl 
            Caption         =   "Address"
            Height          =   255
            Index           =   6
            Left            =   120
            TabIndex        =   14
            Top             =   1680
            Width           =   1575
         End
         Begin VB.Label dl 
            Caption         =   "Company"
            Height          =   255
            Index           =   5
            Left            =   120
            TabIndex        =   12
            Top             =   1320
            Width           =   1575
         End
      End
      Begin VB.PictureBox tbl 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   615
         Left            =   2520
         ScaleHeight     =   585
         ScaleWidth      =   12690
         TabIndex        =   6
         Top             =   240
         Width           =   12720
         Begin VB.PictureBox quit 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   0  'None
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   495
            Left            =   12000
            Picture         =   "DSW.ctx":0716
            ScaleHeight     =   495
            ScaleWidth      =   615
            TabIndex        =   9
            Top             =   60
            Width           =   615
         End
         Begin VB.PictureBox upd 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   0  'None
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   495
            Left            =   840
            Picture         =   "DSW.ctx":0A20
            ScaleHeight     =   495
            ScaleWidth      =   615
            TabIndex        =   8
            Top             =   60
            Width           =   615
         End
         Begin VB.PictureBox grd_detail_refresh 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BorderStyle     =   0  'None
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   495
            Left            =   120
            Picture         =   "DSW.ctx":0D2A
            ScaleHeight     =   495
            ScaleWidth      =   615
            TabIndex        =   7
            Top             =   60
            Width           =   615
         End
      End
      Begin VB.Frame fr_tw 
         Height          =   10295
         Left            =   120
         TabIndex        =   2
         Top             =   120
         Width           =   2415
         Begin Project1.ArmTreeView tw 
            Height          =   9135
            Left            =   40
            TabIndex        =   56
            Top             =   720
            Width           =   2340
            _ExtentX        =   4128
            _ExtentY        =   16113
         End
         Begin VB.PictureBox tb 
            Appearance      =   0  'Flat
            AutoRedraw      =   -1  'True
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   615
            Left            =   40
            ScaleHeight     =   585
            ScaleWidth      =   2310
            TabIndex        =   4
            Top             =   120
            Width           =   2340
            Begin VB.PictureBox tw_refresh 
               Appearance      =   0  'Flat
               BackColor       =   &H00FFFFFF&
               BorderStyle     =   0  'None
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H80000008&
               Height          =   495
               Left            =   120
               Picture         =   "DSW.ctx":1034
               ScaleHeight     =   495
               ScaleWidth      =   615
               TabIndex        =   5
               Top             =   60
               Width           =   615
            End
         End
         Begin MSComctlLib.TabStrip tw_tab 
            Height          =   375
            Left            =   120
            TabIndex        =   3
            Top             =   9860
            Width           =   2655
            _ExtentX        =   4683
            _ExtentY        =   661
            MultiRow        =   -1  'True
            Placement       =   1
            TabMinWidth     =   706
            _Version        =   393216
            BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
               NumTabs         =   3
               BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
                  Caption         =   "All"
                  ImageVarType    =   2
               EndProperty
               BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
                  Caption         =   "Oustanding"
                  ImageVarType    =   2
               EndProperty
               BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
                  Caption         =   "Complete"
                  ImageVarType    =   2
               EndProperty
            EndProperty
         End
      End
   End
   Begin MSComctlLib.TabStrip Main_tab 
      Height          =   375
      Left            =   0
      TabIndex        =   0
      Top             =   10440
      Width           =   15165
      _ExtentX        =   26749
      _ExtentY        =   661
      MultiRow        =   -1  'True
      Placement       =   1
      TabMinWidth     =   12347
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   2
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Direct to Customers"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Bulk Shipment to Munster"
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "DSW"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private mo_Db As Object
Private curs As Long  'Armdb cursor
Private Const SEP = "®©"
Dim dsw_name As String
Public Event quit()
Dim ic As Long
Dim ls_Req As String
Dim first_line, last_line As Long  'index for first and last line of an action in the main grid
Dim charset_list As String
Dim Mode As String
Dim label_language As String
Dim Label(55) As String
Dim count_completion As Long
Dim Logged_user As String
Dim Use_DSW As Boolean
Private Const GRID_COMMENT_SIZE As Long = 1000  ' must be synchronized with memo length constant in sp selecting into grid

Public Property Set DB(ByRef ao_DB As ARMSYSCOMLib.ArmDb)

    On Error GoTo Db_er
    
    Set mo_Db = ao_DB
    
    Exit Property
  
Db_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in property DB", True, True

End Property

Public Function Load_A_Com()
On Error GoTo Load_A_COM_er
Load_A_Com = False
Dim j As Integer
count_completion = 0

UserControl.Height = 11000
UserControl.Width = 15500


If Not Load_Language Then
Exit Function
End If


charset_list = Get_A_Config("CHARSET")
If Use_DSW Then
A_MsgBox "Samples Program Version DSW started by " & Logged_user & " Version: " & App.Major & "." & App.Minor & "." & App.Revision, False, False
dsw_name = Get_A_Config("DSWCODE")
Else
A_MsgBox "Samples Program started at Armstrong by " & Logged_user & " Version: " & App.Major & "." & App.Minor & "." & App.Revision, False, False
dsw_name = Logged_user
End If

cb_status.ComboItems.Clear
ls_Req = "select as_code, as_desc from cap_actionstatus where language_code='" & label_language & "'"
curs = mo_Db.OpenSQL(ls_Req)
If curs = 0 Then
A_MsgBox "Error executing " & ls_Req & mo_Db.LastErrorCode & "  " & mo_Db.LastErrorMessage, True, True

End If
If mo_Db.RowCount(curs) > 0 Then
For j = 1 To mo_Db.RowCount(curs)
Call cb_status.ComboItems.Add(j, SEP & mo_Db.GetFields(curs, 0), mo_Db.GetFields(curs, 1))
mo_Db.Next (curs)
Next j
mo_Db.Close (curs)
End If


tw.Load_A_Com
Set tw.ArmDb = mo_Db
tw.Levels = 1

grd_detail.MultiSelect = False
grd_detail.AllowExcelExport = False
grd_detail.ExportTitles = True
grd_detail.Load_A_Com
Set grd_detail.ArmDb = mo_Db
grd_detail.FetchAll = False
' task 299.3 ACT_commentLen added
Call grd_detail.SetColumns(Array(Join(Array("Key", 1650, 1, "ac_code", ""), SEP) _
, Join(Array("Due Date", 1300, 0, "ACT_dueDate", "", "Date", "dd/mm/yyyy", "Center"), SEP), Join(Array("Description", 1000, 0, "sdg_desc", "", "String", "", "Left"), SEP) _
, Join(Array("Raised By", 1000, 0, "ACT_raisedBy", "", "String", "", "Left"), SEP) _
, Join(Array("Contact", 1500, 0, "cnt_name", "", "String", "", "Left"), SEP) _
, Join(Array("Customer", 1500, 0, "ccu_desc", "", "String", "", "Left"), SEP) _
, Join(Array("adr 1", 1500, 0, "ccu_addr1", "", "String", "", "Left"), SEP) _
, Join(Array("Adr 2", 1500, 0, "ccu_addr2", "", "String", "", "Left"), SEP) _
, Join(Array("Town", 1000, 0, "ccu_town", "", "String", "", "Left"), SEP) _
, Join(Array("Zip", 800, 0, "ccu_zip", "", "String", "", "Left"), SEP) _
, Join(Array("County", 800, 0, "cty_desc", "", "String", "", "Left"), SEP) _
, Join(Array("Country", 800, 0, "ct_desc", "", "String", "", "Left"), SEP) _
, Join(Array("Phone", 800, 0, "ccu_tel", "", "String", "", "Left"), SEP), Join(Array("Fax", 800, 0, "ccu_fax", "", "String", "", "Left"), SEP) _
, Join(Array("SA", 1500, 0, "ccu_saflag", "", "String", "", "Left"), SEP) _
, Join(Array("Sample Desc", 1500, 0, "sd_desc", "", "String", "", "Left"), SEP) _
, Join(Array("Qty", 800, 0, "asd_qty", "", "String", "", "right"), SEP) _
, Join(Array("H/F", 300, 0, "handorfullflag", "", "String", "", "Left"), SEP) _
, Join(Array("Edge", 1000, 0, "pe_desc", "", "String", "", "Left"), SEP) _
, Join(Array("Creator", 1000, 0, "z_creator", "", "String", "", "Left"), SEP) _
, Join(Array("Creation date", 1500, 0, "z_creation", "", "Date", "dd/mm/yyyy", "Center"), SEP) _
, Join(Array("Cust Reps", 1000, 0, "sr_name", "", "String", "", "Left"), SEP) _
, Join(Array("Action Comment", 1000, 0, "Act_comment", "", "String", "", "Left"), SEP) _
, Join(Array("Line Comment", 1000, 0, "Asd_comment", "", "String", "", "Left"), SEP) _
, Join(Array("Asd_code", 0, 0, "Asd_code", "", "String", "", "Left"), SEP) _
, Join(Array("iConcurrency", 0, 0, "iConcurrency", "", "String", "", "Left"), SEP) _
, Join(Array("ACT_commentLen", 0, 0, "ACT_commentLen", "", "Number", "", "Left"), SEP)))

Call grd_detail.LoadConstants(ptStatic, Label(25) & SEP & Label(26) & SEP & Label(27) & SEP & Label(28) & SEP & Label(29) & SEP & Label(30) & SEP & Label(31) & SEP & Label(32) & SEP & Label(33) & SEP & Label(34) _
& SEP & Label(35) & SEP & Label(36) & SEP & Label(37) & SEP & Label(38) & SEP & Label(39) _
& SEP & Label(40) & SEP & Label(41) & SEP & Label(42) & SEP & Label(43) & SEP & Label(44) & SEP & Label(45) & SEP & Label(46) & SEP & Label(47) & SEP & Label(48) & SEP & "" & SEP & "" & SEP & "", ctColumns)  ' task299.3

grd_detail.Height = 9650
grd_DetailLine_init

fr_detail.Visible = False
upd.Visible = False
fr_main.Top = 0
fr_main.Left = 0
fr_main.Height = 10495
fr_main.Width = 15300
fr_main.Visible = True
Mode = "D" ' By default, we display direct action to customers
tw_tab.Tabs.Item(2).Selected = True
Load_A_Com = True
Exit Function
Load_A_COM_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function load_A_com", True, True
End Function




Private Function ChangeCharset(ByVal new_country As String) As Boolean
On Error GoTo ChangeCharset_er:
Dim new_charset, Pos As Integer
Dim wrk1 As String
ChangeCharset = False
Pos = InStr(1, charset_list, "®" & new_country & "®")
If Pos > 0 Then
wrk1 = Left(charset_list, Pos - 1)
new_charset = Mid(wrk1, InStrRev(wrk1, "{") - 3, 3)
Else
new_charset = 0
End If
Dim lc_Control As Control
    For Each lc_Control In UserControl
        Select Case UCase(TypeName(lc_Control))
        Case "TABSTRIP", "TEXTBOX", "LABEL", "FRAME", "COMMANDBUTTON", _
              "LISTVIEW", "CHECKBOX", "OPTIONBUTTON", _
               "TREEVIEW", "MSHFLEXGRID", "ARMTREEVIEW", "ARMGRID", "IMAGECOMBO", "MSHFLEXGRID"
          lc_Control.Font.Name = "MS Sans Serif"
          lc_Control.Font.Size = 8
          lc_Control.Font.Charset = new_charset
          Case Else
          End Select
    Next
ChangeCharset = True
Exit Function
ChangeCharset_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function ChangeCharSet", True, True
End Function










Private Sub export_Excel_Click()
On Error GoTo export_Excel_Click_er
Dim a_ExcelApp As Object 'Excel.Application
Dim a_ExcelWorkBook As Object
Dim a_ExcelSheet1 As Object
Dim li_Row As Integer, li_Col As Integer
   Dim li_ColExcel As Long, li_rowExcel As Long
    Set a_ExcelApp = GetObject(, "Excel.Application")
    Set a_ExcelWorkBook = a_ExcelApp.Workbooks.Add
    Set a_ExcelSheet1 = a_ExcelWorkBook.Worksheets(1)
    a_ExcelApp.Application.Visible = -1
    a_ExcelSheet1.Application.Visible = -1
 With a_ExcelSheet1
        .Columns("A").ColumnWidth = 50
        .Columns("B").ColumnWidth = 12
        .Columns("C:C").HorizontalAlignment = -4108
     End With
                With a_ExcelSheet1
                li_rowExcel = 0
                li_ColExcel = 1
                
                    For li_Row = 0 To grd_DetailLine.Rows - 1
                        li_ColExcel = 0
                        For li_Col = 0 To grd_DetailLine.Cols - 1
                                .cells(li_rowExcel + 1, li_ColExcel + 1).value = grd_DetailLine.TextMatrix(li_Row, li_Col)
                                li_ColExcel = li_ColExcel + 1
                        Next
                       li_rowExcel = li_rowExcel + 1
                    Next
                End With
                Dim i As Integer
li_rowExcel = li_rowExcel + 1
     li_rowExcel = li_rowExcel + 1

                Set a_ExcelSheet1 = Nothing
                Set a_ExcelWorkBook = Nothing
                Set a_ExcelApp = Nothing
      Screen.MousePointer = 0
    

  
Exit Sub
export_Excel_Click_er:
Screen.MousePointer = 0
Select Case Err:
Case 429:
        Set a_ExcelApp = CreateObject("Excel.Application")
        Resume Next
Case Else
  Set a_ExcelSheet1 = Nothing
  Set a_ExcelWorkBook = Nothing
  Set a_ExcelApp = Nothing
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function export_Excel_Click", True, True

End Select
End Sub

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 Visible(ByVal aVisible As Boolean)
    UserControl.Extender.Visible = aVisible
End Property

Private Sub grd_detail_Click()
On Error GoTo grd_detail_Click_er
Dim cks As String 'current key selected
Dim i As Integer
Dim j As Long
first_line = 0
last_line = 0
grd_DetailLine_init
' debug index=2
If tw_tab.SelectedItem.Index = 2 Then upd.Visible = True Else upd.Visible = False
grd_detail.Visible = False
If grd_detail.Rows <= 0 Then
upd.Visible = False
Else
cks = grd_detail.CurrentLine(0)
Do Until grd_detail.CurrentLine(0) <> cks Or grd_detail.Row <= 0
grd_detail.Row = grd_detail.Row - 1
Loop
If grd_detail.Row = 0 And grd_detail.CurrentLine(0) = cks Then Else grd_detail.Row = grd_detail.Row + 1
first_line = grd_detail.Row

For i = 0 To 13
dt(i).Text = grd_detail.CurrentLine(i)
Next i
If grd_detail.CurrentLine(14) = "" Then Sa_Flag.value = 0 Else Sa_Flag.value = 1
dt(16).Text = grd_detail.CurrentLine(20)
dt(17).Text = grd_detail.CurrentLine(19)
dt(18).Text = grd_detail.CurrentLine(21)
'task 299.3 begin
' load full memo into grid as it cannont be fully loaded with grid content sp ( fetchall=false )
If grd_detail.CurrentLine("ACT_commentLen") < GRID_COMMENT_SIZE Then
    dt(19).Text = grd_detail.CurrentLine("Action Comment")
Else
    dt(19).Text = GetCommentText(grd_detail.CurrentLine("Key"))
End If
'task 299.3 end

ic = grd_detail.CurrentLine(25)
Do Until grd_detail.CurrentLine(0) <> cks Or grd_detail.Row = grd_detail.Rows - 1
grd_detail.Row = grd_detail.Row + 1
Loop
If grd_detail.Row = grd_detail.Rows - 1 And grd_detail.CurrentLine(0) = cks Then Else grd_detail.Row = grd_detail.Row - 1
last_line = grd_detail.Row
grd_DetailLine.Row = grd_DetailLine.Rows - 1
For j = first_line To last_line
grd_detail.Row = j
' BEGIN T298.WP7
grd_DetailLine.TextMatrix(grd_DetailLine.Row, 0) = grd_detail.CurrentLine(2)
grd_DetailLine.TextMatrix(grd_DetailLine.Row, 1) = grd_detail.CurrentLine(15)
grd_DetailLine.TextMatrix(grd_DetailLine.Row, 2) = grd_detail.CurrentLine(16)
grd_DetailLine.TextMatrix(grd_DetailLine.Row, 3) = grd_detail.CurrentLine(17)
grd_DetailLine.TextMatrix(grd_DetailLine.Row, 4) = grd_detail.CurrentLine(18)
grd_DetailLine.TextMatrix(grd_DetailLine.Row, 5) = grd_detail.CurrentLine(23)
' END T298.WP7
grd_DetailLine.Rows = grd_DetailLine.Rows + 1
grd_DetailLine.Row = grd_DetailLine.Rows - 1
Next j
grd_DetailLine.Rows = grd_DetailLine.Rows - 1
grd_detail.Height = 5400
grd_detail.Visible = True
fr_detail.Visible = True
End If
Exit Sub
grd_detail_Click_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function grd_detail_Click", True, True

End Sub


Private Sub grd_detail_refresh_Click()
tw_Click
End Sub


Private Sub quit_Click()
RaiseEvent quit
End Sub


Private Sub quit_upd_Click()
dt(19).BackColor = &H80000005
dt(19) = dt_bck
ic = grd_detail.CurrentLine(25)
chg_to_upd (False)
first_line = 0
last_line = 0
End Sub



Private Sub Main_tab_Click()
On Error GoTo Main_tab_Click_er
Dim current_mode As String
current_mode = Mode
Select Case Main_tab.SelectedItem.Index
Case 1:
Mode = "D"  ' Direct to customers
Case 2
Mode = "B"  ' Bulk delivery to DC
End Select
If current_mode <> Mode Then  ' Detect if mode has really changed
Raz_Detail
fr_detail.Visible = False
grd_detail.Height = 9650
tw_tab_Click
End If
Exit Sub
Main_tab_Click_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function Main_tab_Click", True, True

End Sub






Private Sub tw_tab_Click()
On Error GoTo tw_tab_Click_er
Dim Request As String
grd_detail.ClearGrid
grd_detail.Height = 9650
grd_DetailLine_init
fr_detail.Visible = False
If Mode = "D" Then
Request = "CapTv_Action_dsw_direct"
Else
Request = "CapTv_Action_dsw_Bulk"
End If

Select Case tw_tab.SelectedItem.Index
Case 1:
upd.Visible = False
grd_detail.AllowExcelExport = False
tw.Clear
tw.NodeRequests = Array(Request & " 'E',Null,'" & dsw_name & "'", 1)
tw.LoadTree (LoadTypeTree)
Case 2:
tw.Clear
grd_detail.AllowExcelExport = True
tw.NodeRequests = Array(Request & " 'E',2,'" & dsw_name & "'", 1)
tw.LoadTree (LoadTypeTree)
Case 3:
upd.Visible = False
grd_detail.AllowExcelExport = False
tw.Clear
tw.NodeRequests = Array(Request & " 'E',1,'" & dsw_name & "'", 1)
tw.LoadTree (LoadTypeTree)
End Select
Exit Sub
tw_tab_Click_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function tw_tab_Click", True, True


End Sub


Private Sub tw_refresh_Click()
tw_tab_Click
End Sub


Private Sub tw_Click()
On Error GoTo tw_Click_er
If Not tw.SelectedItem Is Nothing Then
ChangeCharset tw.NodeInfo(tw.SelectedItem).GetData(0)
Dim i As Long
Dim ac_status, Request As String
fr_detail.Visible = False
upd.Visible = False
If Mode = "D" Then
Request = "Cap_Action_dsw_direct"
Else
Request = "Cap_Action_dsw_Bulk"
End If
Select Case tw_tab.SelectedItem.Index
Case 1:
ac_status = "Null"
Case 2: ac_status = "2"
Case 3: ac_status = "1"
End Select
Dim cl As Long
cl = &HC0FFC0
Dim prv As String
grd_detail.Visible = False
grd_detail.ClearGrid
Select Case tw_tab.SelectedItem.Index
Case 2:
grd_detail.FetchAll = True
grd_detail.Requests = Array(Request & " 'E'," & ac_status & ",'" & dsw_name & "','" & tw.NodeInfo(tw.SelectedItem).GetData(0) & "'")
grd_detail.Refresh
Case Else
Call grd_detail.Load(Request & " 'E'," & ac_status & ",'" & dsw_name & "','" & tw.NodeInfo(tw.SelectedItem).GetData(0) & "'", False)
End Select
prv = ""
  grd_detail.Row = 1
If ac_status = "2" Then
For i = 0 To grd_detail.Rows '- 1
grd_detail.Row = i
If prv = grd_detail.CurrentLine(0) Then
grd_detail.LineColor(i) = cl
Else
prv = grd_detail.CurrentLine(0)
If cl = &HC0FFC0 Then cl = &HFFC0FF Else cl = &HC0FFC0
grd_detail.LineColor(i) = cl
End If
Next i
End If
grd_detail.Height = 9650
grd_detail.Visible = True
End If
Exit Sub
tw_Click_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function tw_Click", True, True

End Sub


Private Sub grd_DetailLine_init()
On Error GoTo grd_DetailLine_init_er
grd_DetailLine.Clear
' BEGIN T298.WP7
grd_DetailLine.Cols = 6
grd_DetailLine.Rows = 2
grd_DetailLine.FixedRows = 1
grd_DetailLine.TextMatrix(0, 0) = "Group" '"Group"
grd_DetailLine.TextMatrix(0, 1) = Label(50) '"Description"
grd_DetailLine.TextMatrix(0, 2) = Label(51) '"Qty"
grd_DetailLine.TextMatrix(0, 3) = Label(52) '"Hand/Full"
grd_DetailLine.TextMatrix(0, 4) = Label(53) '"Edge"
grd_DetailLine.TextMatrix(0, 5) = Label(54) '"Comment"
grd_DetailLine.ColAlignment(0) = 1
grd_DetailLine.ColAlignment(1) = 1
grd_DetailLine.ColAlignment(2) = 7
grd_DetailLine.ColAlignment(3) = 1
grd_DetailLine.ColAlignment(4) = 1
grd_DetailLine.ColAlignment(5) = 1
grd_DetailLine.ColWidth(0) = 1000
grd_DetailLine.ColWidth(1) = 2000
grd_DetailLine.ColWidth(2) = 500
grd_DetailLine.ColWidth(3) = 500
grd_DetailLine.ColWidth(4) = 500
grd_DetailLine.ColWidth(5) = 2500
' END T298.WP7
Exit Sub
grd_DetailLine_init_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function grd_DetailLine_init", True, True

End Sub

Private Sub upd_Click()
dt(19).BackColor = &HFFFFC0
dt_bck = dt(19)
chg_to_upd (True)
End Sub



Private Function chg_to_upd(ByVal v As Boolean)
On Error GoTo Chg_to_upd_er
Dim i As Integer
Main_tab.Enabled = Not (v)
grd_detail.Enabled = Not (v)
fr_tw.Enabled = Not (v)
tw_tab.Enabled = Not (v)
tw_refresh.Enabled = Not (v)
grd_detail_refresh.Enabled = Not (v)
upd.Enabled = Not (v)
quit.Enabled = Not (v)
upd.Visible = Not (v)
l_upd.Visible = v
cb_status.Visible = v
tb_upd.Visible = v
dt(19).Locked = Not (v)
If v = False Then
Set cb_status.SelectedItem = Nothing
cb_status.Text = ""
Else
Set cb_status.SelectedItem = Nothing
For i = 1 To cb_status.ComboItems.Count
Set cb_status.SelectedItem = cb_status.ComboItems.Item(i)
If cb_status.SelectedItem.Key = SEP & "2" Then Exit For
Next i
End If

Exit Function
Chg_to_upd_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function Chg_to_upd", True, True
End Function



Public Sub Unload_A_Com()
    grd_detail.Unload_A_Com
    tw.Unload_A_Com
End Sub

Private Sub valid_upd_Click()
On Error GoTo valid_upd_Click_er
Dim i As Long
    Call ASC_BeginTransaction(mo_Db)        ' task 299.3
    
    If Not mo_Db.ExecuteSQL("update cap_action set z_last_upd= getdate(), z_last_upd_user= '" & dsw_name & "',  as_code=" & Mid(cb_status.SelectedItem.Key, 3, 1) & ", iconcurrency= " & Val(ic) + 1 & "  where ac_code='" & dt(0) & "' and iconcurrency=" & ic) Then
        Call ASC_RollBackTransaction(mo_Db)     ' task 299.3
    A_MsgBox "Error while updating record with key: " & dt(0) & " " & mo_Db.LastErrorCode & "  " & mo_Db.LastErrorMessage, True, True
    Else
        If mo_Db.SQLRowsAffected <> 1 Then
            Call ASC_RollBackTransaction(mo_Db)     ' task 299.3
        Screen.MousePointer = 0
        MsgBox "Somebody else change the data during you editing it. Please refresh the record and retry"
        Else
        ' update memo
        ' task 299.3 begin
        Const REQupd = "EXEC Cap_Memo_Comment_upd '$AC_CODE$', $Comment$, 'N', Null, 2, $uid$"
        Dim ls_Result As String
        
        ' update cap_memo
        Dim ls_Request As String
        Dim lb_Result As Boolean
        
        ls_Request = Replace(REQupd, "$AC_CODE$", dt(0))
            ls_Request = Replace(ls_Request, "$Comment$", FormatSqlStringParameter(dt(19).Text))
        ls_Request = Replace(ls_Request, "$uid$", "'" & Logged_user & "'")
        lb_Result = ASC_RecordExec(mo_Db, ls_Request, ls_Result)
            If lb_Result = False Then
                Call ASC_RollBackTransaction(mo_Db)     ' task 299.3
                Call ASC_SendMessage(mo_Db, label_language, 891, "#An error occured during this manipulation, please contact your IT support")
                GoTo Trace_End
            End If
        ' task 299.3 end
        Call ASC_CommitTransaction(mo_Db)         ' task 299.3 end
        
        dt(19).BackColor = &H80000005
        dt_bck = ""
            If Mid(cb_status.SelectedItem.Key, 3, 1) = "1" Then
            count_completion = count_completion + 1
            grd_detail.Visible = False
            Do Until Not grd_detail.DeleteLine(dt(0))
            Loop
                If grd_detail.Rows = 0 Then
                tw.RemoveNode tw.Nodes(tw.SelectedItem.Index)
                Raz_Detail
                fr_detail.Visible = False
                grd_detail.Height = 9650
                tw_tab_Click
                End If
            grd_detail.Visible = True
            Else
            dt_bck = dt(19)
            For i = first_line To last_line
            grd_detail.Row = i
            grd_detail.CurrentLine("Action Comment") = Left(dt_bck, GRID_COMMENT_SIZE)        ' task 299.3
            grd_detail.CurrentLine(25) = Val(ic) + 1
            grd_detail.CurrentLine("ACT_commentLen") = Len(dt_bck)                         ' task 299.3
            Next i
            End If
        chg_to_upd (False)
        grd_detail_Click
        End If
    End If
Trace_End:
Exit Sub
valid_upd_Click_er:
    Call ASC_RollBackTransaction(mo_Db)     ' task 299.3
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function valid_upd_Click", True, True

End Sub
Private Function Raz_Detail()
On Error GoTo raz_detail_er
Dim ind As Integer
For ind = 0 To 13
dt(ind) = ""
Next ind
For ind = 16 To 19
dt(ind) = ""
Next ind
grd_DetailLine_init
Exit Function
raz_detail_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function Raz_Detail", True, True

End Function

Private Function Load_Language() As Boolean
On Error GoTo load_language_er
Dim indx As Integer
Load_Language = False
Dim nb_rec As Integer
ls_Req = "screen_csts 'DSW','" & label_language & "'"
curs = mo_Db.OpenSQL(ls_Req)
    If curs = 0 Then
    A_MsgBox "Error executing " & ls_Req & mo_Db.LastErrorCode & "  " & mo_Db.LastErrorMessage, True, True
    Else
    nb_rec = mo_Db.RowCount(curs)
    If nb_rec < 55 Then
    mo_Db.Close (curs)
    Screen.MousePointer = 0
    MsgBox "Labels missing as to load teh samples components"
    Exit Function
    End If
    If nb_rec > 55 Then nb_rec = 55 ' there is only 54 labels needed!
    
    For indx = 0 To nb_rec
    Label(indx) = mo_Db.GetFields(curs, 1)
    mo_Db.Next (curs)
    Next indx
    mo_Db.Close (curs)


dl(0) = Label(0)
dl(1) = Label(1)
dl(2) = Label(2)
dl(3) = Label(3)
dl(4) = Label(4)
dl(5) = Label(5)
dl(6) = Label(6)
dl(7) = Label(7)
dl(8) = Label(8)
dl(9) = Label(9)
dl(10) = Label(10)
dl(11) = Label(11)
dl(12) = Label(12)
dl(13) = Label(13)

dl(16) = Label(16)
dl(17) = Label(17)
dl(18) = Label(18)
dl(19) = Label(19)

l_upd = Label(14)
Sa_Flag.Caption = Label(15)
tw_tab.Tabs(1).Caption = Label(20)
tw_tab.Tabs(2).Caption = Label(21)
tw_tab.Tabs(3).Caption = Label(22)
Main_tab.Tabs(1).Caption = Label(23)
Main_tab.Tabs(2).Caption = Label(24)
Load_Language = True
End If
Exit Function
load_language_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function load_language", True, True

End Function

Public Property Let Language(ByVal choosen_language As String)
label_language = choosen_language
End Property

Public Property Let Use_by_DSW(ByVal dsw As String)
Use_DSW = dsw
End Property

Public Property Let user_info(ByVal theuser As String)
Logged_user = theuser
End Property

Private Sub Quit_program()
On Error GoTo quit_program_er
A_MsgBox "Samples Program Log out, User was" & dsw_name & " " & count_completion & " action(s) completed", False, False
Dim try As Integer
try = 0
tw.Unload_A_Com
grd_detail.Unload_A_Com
RaiseEvent quit
Exit Sub
quit_program_er:
try = try + 1
If try < 2 Then RaiseEvent quit Else End
End Sub

Private Function Get_A_Config(ByVal TheKey As String) As String
On Error GoTo Get_A_Config_er
Get_A_Config = ""
ls_Req = "select cfg_value from A_config where cfg_Key ='" & UCase(TheKey) & "'"
curs = mo_Db.OpenSQL(ls_Req)
    If curs = 0 Then
    A_MsgBox "Error executing " & ls_Req & mo_Db.LastErrorCode & "  " & mo_Db.LastErrorMessage, True, True
    
    Else
        If mo_Db.RowCount(curs) <> 1 Then
        mo_Db.Close (curs)
        A_MsgBox "Executing " & ls_Req & " returned " & mo_Db.RowCount(curs) & " record(s) while one was expected", True, True
        
        Else
        Get_A_Config = mo_Db.GetFields(curs, 0)
        mo_Db.Close (curs)
        End If
    End If
Exit Function
Get_A_Config_er:
Screen.MousePointer = 0
A_MsgBox "Unexpected Error " & Err.Number & " " & Err.Description & " occured in function Get_A_Config", True, True
End Function

Private Function A_MsgBox(ByVal msg As String, ByVal will_quit As Boolean, ByVal will_display As Boolean)
Dim current_mp As Integer
current_mp = Screen.MousePointer
Screen.MousePointer = 0
    If Not mo_Db.ExecuteSQL("insert into zlog (log_date,log_txt,nb_record,application) values(getdate(),'" & msg & "',1,'DSW Samples')") Then
        If UCase(Left(msg, 2)) <> UCase("Samples Program Log out, User was") Then  'in case user disconnected, not worse displaying an error msg just becasue we cannot log this warning
        MsgBox "Error while inserting error into log. Please write down this message and contact IT. " & " Msg to log was: " & msg & " Current error is " & mo_Db.LastErrorCode & "  " & mo_Db.LastErrorMessage
        End If
    Quit_program
    End If
    If will_display Then
        If UCase(Left(msg, 2)) <> UCase("Samples Program Log out, User was") Then  'in case user disconnected, not worse displaying an error msg just becasue we cannot log this warning
            MsgBox "Following error occured: " & msg
        End If
    End If
If will_quit Then Quit_program
Screen.MousePointer = current_mp
End Function

' task 299.3 begin
Private Function GetCommentText(ByVal as_ac_code As String) As String
    Dim ll_Cursor As Long
    GetCommentText = ""
    ll_Cursor = mo_Db.OpenSQL("SELECT MEM_text FROM Cap_Memo WHERE spare1_varchar = '" & as_ac_code & "' AND spare3_real=2 AND Language_code='E'")
    If ll_Cursor > 0 Then
        If Not mo_Db.EOF(ll_Cursor) Then
            GetCommentText = mo_Db.GetFields(ll_Cursor, "MEM_text")
        End If
        Call mo_Db.Close(ll_Cursor)
    Else
        A_MsgBox "Error while retrieving memo for action with key: " & as_ac_code & " " & mo_Db.LastErrorCode & "  " & mo_Db.LastErrorMessage, True, True
    End If
End Function
' task 299.3 end

