VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.UserControl Capmem 
   ClientHeight    =   10380
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   11955
   ScaleHeight     =   10380
   ScaleWidth      =   11955
   ToolboxBitmap   =   "Capmem.ctx":0000
   Begin VB.Frame fraItem 
      Height          =   10245
      Left            =   840
      TabIndex        =   9
      Top             =   60
      Width           =   10875
      Begin VB.Frame fraItemTop 
         Height          =   6360
         Left            =   120
         TabIndex        =   10
         Top             =   1050
         Width           =   10335
         Begin Project1.A_SrchTxt srch_project 
            Height          =   345
            Left            =   2100
            TabIndex        =   1
            Top             =   3945
            Width           =   3390
            _ExtentX        =   5980
            _ExtentY        =   609
         End
         Begin VB.TextBox txt_Spare4 
            Height          =   345
            Left            =   6810
            TabIndex        =   7
            Text            =   "Text1"
            Top             =   5205
            Visible         =   0   'False
            Width           =   3090
         End
         Begin VB.TextBox txt_Spare3 
            Height          =   345
            Left            =   6810
            TabIndex        =   6
            Text            =   "Text1"
            Top             =   4800
            Visible         =   0   'False
            Width           =   3090
         End
         Begin VB.TextBox txt_Spare2 
            Height          =   345
            Left            =   6810
            TabIndex        =   5
            Text            =   "Text1"
            Top             =   4410
            Visible         =   0   'False
            Width           =   3090
         End
         Begin VB.TextBox txt_Spare1 
            Height          =   345
            Left            =   6840
            TabIndex        =   4
            Text            =   "Text1"
            Top             =   4005
            Visible         =   0   'False
            Width           =   3090
         End
         Begin VB.TextBox txt_comment 
            Height          =   3510
            Left            =   2100
            MaxLength       =   5000
            MultiLine       =   -1  'True
            ScrollBars      =   2  'Vertical
            TabIndex        =   0
            Top             =   285
            Width           =   8100
         End
         Begin Project1.A_SrchTxt srch_customer 
            Height          =   345
            Left            =   2100
            TabIndex        =   2
            Top             =   4320
            Width           =   3390
            _ExtentX        =   5980
            _ExtentY        =   609
         End
         Begin Project1.A_SrchTxt srch_contact 
            Height          =   345
            Left            =   2100
            TabIndex        =   3
            Top             =   4680
            Width           =   3390
            _ExtentX        =   5980
            _ExtentY        =   609
         End
         Begin VB.Label Label4 
            Caption         =   "#Spare4"
            Height          =   255
            Left            =   5580
            TabIndex        =   22
            Top             =   5265
            Visible         =   0   'False
            Width           =   990
         End
         Begin VB.Label Label2 
            Caption         =   "#Spare3"
            Height          =   255
            Left            =   5580
            TabIndex        =   21
            Top             =   4860
            Visible         =   0   'False
            Width           =   990
         End
         Begin VB.Label Label3 
            Caption         =   "#Spare2"
            Height          =   255
            Left            =   5580
            TabIndex        =   20
            Top             =   4470
            Visible         =   0   'False
            Width           =   990
         End
         Begin VB.Label Spare1 
            Caption         =   "#Spare1"
            Height          =   255
            Left            =   5580
            TabIndex        =   19
            Top             =   4065
            Visible         =   0   'False
            Width           =   990
         End
         Begin VB.Label lbl_contact 
            Caption         =   "#Contact"
            Height          =   255
            Left            =   120
            TabIndex        =   15
            Tag             =   "lbl_contact"
            Top             =   4755
            Width           =   915
         End
         Begin VB.Label lbl_project 
            Caption         =   "#Project"
            Height          =   255
            Left            =   120
            TabIndex        =   14
            Tag             =   "lbl_project"
            Top             =   4020
            Width           =   1035
         End
         Begin VB.Label lbl_customer 
            Caption         =   "#Customer"
            Height          =   255
            Left            =   120
            TabIndex        =   13
            Tag             =   "lbl_customer"
            Top             =   4395
            Width           =   1095
         End
         Begin VB.Label lbl_comment 
            Caption         =   "#Comment"
            Height          =   255
            Left            =   120
            TabIndex        =   11
            Tag             =   "lbl_comment"
            Top             =   300
            Width           =   1215
         End
      End
      Begin Project1.ToolBr pbitem 
         Height          =   855
         Left            =   120
         TabIndex        =   17
         Top             =   180
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   1508
      End
      Begin VB.Frame fraItemBottom 
         Height          =   3375
         Left            =   1080
         TabIndex        =   16
         Top             =   4800
         Width           =   6420
      End
      Begin MSComctlLib.TabStrip tbsEmbedded 
         Height          =   375
         Left            =   120
         TabIndex        =   8
         Top             =   9360
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   661
         Placement       =   1
         _Version        =   393216
         BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
            NumTabs         =   1
            BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
   End
   Begin VB.Frame fraList 
      Height          =   4935
      Left            =   0
      TabIndex        =   12
      Top             =   0
      Width           =   9015
      Begin Project1.ArmGrid grdlst 
         Height          =   2775
         Left            =   240
         TabIndex        =   23
         Top             =   1200
         Width           =   5175
         _ExtentX        =   9128
         _ExtentY        =   4895
      End
      Begin Project1.ToolBr pblst 
         Height          =   495
         Left            =   240
         TabIndex        =   18
         Top             =   240
         Width           =   2955
         _ExtentX        =   5212
         _ExtentY        =   1296
      End
   End
End
Attribute VB_Name = "Capmem"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

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

'******** Curseur de connexion
Private mo_ArmDb As Object
Private mb_Created As Boolean
Dim mb_use_framework_connection As Boolean
Private ms_ConnectString As String
Private ms_UID As String

'******** Propriétés de Cap_Project

Private mt_CstValues As Type_CstValues         ' Structure which contains constants value
Private mi_DisplayMode As Variant       ' Current display mode
Private mi_OldDisplayMode As Variant    ' Old display mode, need for know parameters
Private mi_EmbeddedIn As Integer        ' Indicates the tag  of the component which embed this component
Private mi_EmbedTag As Integer          ' Indicates the tag of the last component embedded
Private mi_CptTag As Integer            ' Tag of the component type
Private mb_Root As Boolean              ' Indicates if the component is the focus of the user

'******** Clé en cours (enreg. en cours de visu ou modif ou delete
Private m_CurrentKey1 As String
Private m_CurrentKey2 As String
Private m_CurrentKey3 As String

Private m_Language As String

'******** iConccurency of current Record
Private p_iCon As Integer

'******** Type de l'objet (1=Normal, liste longue; 2=Liste courte)
Private mi_TypeList As Integer
Private mi_TypeParam As Integer

Private m_Project As String 'For the property .Project, display in ShortList
Private m_Contact As String 'For the property .Contact, display in ShortList
Private m_Customer As String 'For the property .Customer, display in ShortList
Private m_Action As String 'For the property .Action, display in ShortList
Private m_Product As String 'For the property .Product, display in ShortList
Private mb_EmbeddedIsDropped As Boolean '298.2

'Ask the application to change the size of component
Public Event SwitchToView(ByVal li_View As Integer)
' Ask the application to simulate encapsulation of a component by resizing it and push it to front
Public Event Catch(ByVal li_TagEmbedded As Integer, ByVal ls_Param As String)
' Ask the application to release the encapsulation : hide the component embedded
Public Event Release()
Public Event quit()
Public Event HideGrid(AParentID As Integer)
Public Event Updated() ' Indicates if user update date when it's embedded

Private p_DefaultValues(MAX_VALUE) As DefaultValue
Private p_DefaultValuesCount As Integer
Private p_DefaultValuesLoaded As Boolean

Public Property Set ArmDb(ByRef ao_local_connection As Object)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ArmDb_Set"
    #End If
    CapMouseOff
    
    If Not (ao_local_connection Is Nothing) Then
        Set mo_ArmDb = ao_local_connection
        mb_use_framework_connection = True
        
       
            Set grdlst.ArmDb = mo_ArmDb
        
        Set pblst.ArmDb = mo_ArmDb
        Set pbItem.ArmDb = mo_ArmDb
        Set srch_customer.ArmDb = mo_ArmDb
        Set srch_contact.ArmDb = mo_ArmDb
        Set srch_project.ArmDb = mo_ArmDb
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ArmDb_Set"
    #End If
    CapMouseOn
End Property

Property Let ConnectString(as_ConnectString As String)

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ConnectString_Let"
    #End If
    CapMouseOff
    
    ms_UID = ConnectionStringValidation(as_ConnectString)
    If ms_UID = "" Then GoTo Trace_End
    
    ms_ConnectString = as_ConnectString
    
    'Affectation aux objets
    grdlst.ConnectString = ms_ConnectString
    pblst.ConnectString = ms_ConnectString
    pbItem.ConnectString = ms_ConnectString
    srch_customer.ConnectString = ms_ConnectString
    srch_contact.ConnectString = ms_ConnectString
    srch_project.ConnectString = ms_ConnectString
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ConnectString_Let"
    #End If
    CapMouseOn
End Property

Property Let Language(as_Language As String)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Language_Let"
    #End If
    CapMouseOff
    
    m_Language = as_Language
    
    'grdlst.Language = m_Language
    pbItem.Language = m_Language
    pblst.Language = m_Language
    srch_contact.Language = m_Language
    srch_customer.Language = m_Language
    srch_project.Language = m_Language
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Language_Let"
    #End If
    CapMouseOn
End Property

Private Sub CboView_Resize(ALabel As Label, ACboView As Object, AFrame As Frame)
Dim LMargin As Integer

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:CboView_Resize"
    #End If
    
    LMargin = 100
    
    ALabel.AutoSize = True
    ALabel.Left = LMargin
    ACboView.Left = ALabel.Left + ALabel.Width + LMargin
    ACboView.Width = AFrame.Width - ACboView.Left - LMargin
    
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:CboView_Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:CboView_Resize"
    CapMouseOn
End Sub


Private Sub DrawMainGrid()
Dim la_Columns(8) As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:DrawMainGrid"
    #End If
    
    mi_TypeList = 1

    pblst.ClearAllIcons
    pblst.TableName = ""
    pblst.TableName = mt_CstValues.SecurityMemo
    pblst.PictureDisplayed = "P_Refresh=7 P_Quit=-1"
    
    grdlst.ResetGrid
    grdlst.Title = "Memo"
    grdlst.MultiSelect = True
    
    la_Columns(0) = "ac_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "ac_code" & CH_LDELIMIT & "ac_code"
    la_Columns(1) = "ccu_capkey" & CH_LDELIMIT & "0" & CH_LDELIMIT & "2" & CH_LDELIMIT & "ccu_capkey" & CH_LDELIMIT & "ccu_capkey"
    la_Columns(2) = "language_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "3" & CH_LDELIMIT & "language_code" & CH_LDELIMIT & "language_code"
    la_Columns(3) = "due" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "due" & CH_LDELIMIT & "due"
    la_Columns(4) = "at_desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "at_desc" & CH_LDELIMIT & "at_desc"
    la_Columns(5) = "as_desc" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "as_desc" & CH_LDELIMIT & "as_desc"
    la_Columns(6) = "raise for" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "raise for" & CH_LDELIMIT & "raise for"
    la_Columns(7) = "contact name" & CH_LDELIMIT & "1000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "contact name" & CH_LDELIMIT & "contact name"
    la_Columns(8) = "ccu desc" & CH_LDELIMIT & "2000" & CH_LDELIMIT & "0" & CH_LDELIMIT & "ccu desc" & CH_LDELIMIT & "ccu desc"
    
    grdlst.SetColumns la_Columns
    grdlst.LoadConstants ptSQL, "EXEC screen_csts_lst2 'cap_memo_longlist', 'grid', '" & m_Language & "'", ctColumns
 
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:DrawMainGrid"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:DrawMainGrid"
    CapMouseOn
End Sub

Public Sub GoToTab1()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:GoToTab1"
    #End If
    
    If UserControl.tbsEmbedded.Tabs.Count > 0 Then
        UserControl.tbsEmbedded.Tabs(1).Selected = True
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:GoToTab1"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:GoToTab1"
    CapMouseOn
End Sub

Private Sub InitParentKey()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:InitParentKey"
    #End If
    
    m_Project = ""
    m_Customer = ""
    m_Contact = ""
    m_Product = ""
    m_Action = ""

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:InitParentKey"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:InitParentKey"
    CapMouseOn
End Sub

Private Sub Add_Resize()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Add_Resize"
    #End If
    
    With UserControl
        
        .fraItem.Left = mt_CstValues.Frm_Spacing
        .fraItem.Top = mt_CstValues.Frm_Spacing
        .fraItem.Width = .Width - .fraItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .fraItem.Height = .Height - .fraItem.Top - (2 * mt_CstValues.Frm_Spacing)
        
        .pbItem.Height = mt_CstValues.View_ToolBar_Height
        .pbItem.Top = mt_CstValues.Frm_Spacing * 4
        .pbItem.Left = mt_CstValues.Frm_Spacing
        .pbItem.Width = .fraItem.Width - .pbItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .pbItem.Refresh
        
        .tbsEmbedded.Visible = False
        
        .fraItemTop.Width = .fraItem.Width - .fraItemTop.Left - mt_CstValues.Frm_Spacing
        .fraItemTop.Left = mt_CstValues.Frm_Spacing
        .fraItemTop.Top = mt_CstValues.Frm_Spacing + .pbItem.Top + .pbItem.Height
        
        .tbsEmbedded.Top = .fraItem.Height - .tbsEmbedded.Height - mt_CstValues.Frm_Spacing
        .tbsEmbedded.Left = mt_CstValues.Frm_Spacing
        .tbsEmbedded.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        
        .fraItemBottom.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        .fraItemBottom.Height = mt_CstValues.Cpt_View_Emb_Height
        .fraItemBottom.Top = .tbsEmbedded.Top - .fraItemBottom.Height
        .fraItemBottom.Left = mt_CstValues.Frm_Spacing
        
        .fraItem.Visible = True
        .fraItemTop.BorderStyle = 0
        .fraItemBottom.Visible = True
        .fraItemBottom.BorderStyle = 0
        
    End With

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Add_Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Add_Resize"
    CapMouseOn
End Sub

Private Sub AddDisplay()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:AddDisplay"
    #End If
    
    RaiseEvent SwitchToView(mt_CstValues.View_Full)
    
    'If the component was on short list, it does appear now in long list
    InitControl 4
    
    BlankFields
    Add_Enablecontrols
    Add_Resize
    AddInitFields
    
    txt_comment.SetFocus
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:AddDisplay"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:AddDisplay"
    CapMouseOn
End Sub
Private Sub Delete_Resize()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Delete_Resize"
    #End If
    
    With UserControl
        
        .fraItem.Left = mt_CstValues.Frm_Spacing
        .fraItem.Top = mt_CstValues.Frm_Spacing
        .fraItem.Width = .Width - .fraItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .fraItem.Height = .Height - .fraItem.Top - (2 * mt_CstValues.Frm_Spacing)
        
        .pbItem.Height = mt_CstValues.View_ToolBar_Height
        .pbItem.Top = mt_CstValues.Frm_Spacing * 4
        .pbItem.Left = mt_CstValues.Frm_Spacing
        .pbItem.Width = .fraItem.Width - .pbItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .pbItem.Refresh
        
        .tbsEmbedded.Visible = False
        
        .fraItemTop.Width = .fraItem.Width - .fraItemTop.Left - mt_CstValues.Frm_Spacing
        .fraItemTop.Left = mt_CstValues.Frm_Spacing
        .fraItemTop.Top = mt_CstValues.Frm_Spacing + .pbItem.Top + .pbItem.Height
        
        .tbsEmbedded.Top = .fraItem.Height - .tbsEmbedded.Height - mt_CstValues.Frm_Spacing
        .tbsEmbedded.Left = mt_CstValues.Frm_Spacing
        .tbsEmbedded.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        
        .fraItemBottom.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        .fraItemBottom.Height = mt_CstValues.Cpt_View_Emb_Height
        .fraItemBottom.Top = .tbsEmbedded.Top - .fraItemBottom.Height
        .fraItemBottom.Left = mt_CstValues.Frm_Spacing
        
        .fraItem.Visible = True
        .fraItemTop.Visible = True
        .fraItemBottom.Visible = True
        .fraItemTop.BorderStyle = 0
        .fraItemBottom.BorderStyle = 0
    End With
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Delete_Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Delete_Resize"
    CapMouseOn
End Sub

Private Sub DeleteDisplay()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:DeleteDisplay"
    #End If
    
    RaiseEvent SwitchToView(mt_CstValues.View_Full)
    
    'If the component was on short list, it does appear now in long list
    InitControl 4
    
    BlankFields
    Delete_EnableControls
    Delete_Resize
    ViewInitFields

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:DeleteDisplay"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:DeleteDisplay"
    CapMouseOn
End Sub

Private Sub Delete_EnableControls()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Delete_EnableControls"
    #End If
    
    ControlsEnable UserControl.Controls, fraItemTop, False
    ControlsEnable UserControl.Controls, fraItemBottom, False
    
    txt_comment.Enabled = True
    txt_comment.Locked = True
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Delete_EnableControls"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Delete_EnableControls"
    CapMouseOn
End Sub

Private Sub Update_Resize()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Update_Resize"
    #End If
    
    With UserControl
    
        .fraItem.Left = mt_CstValues.Frm_Spacing
        .fraItem.Top = mt_CstValues.Frm_Spacing
        .fraItem.Width = .Width - .fraItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .fraItem.Height = .Height - .fraItem.Top - (2 * mt_CstValues.Frm_Spacing)
        
        .pbItem.Height = mt_CstValues.View_ToolBar_Height
        .pbItem.Top = mt_CstValues.Frm_Spacing * 4
        .pbItem.Left = mt_CstValues.Frm_Spacing
        .pbItem.Width = .fraItem.Width - .pbItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .pbItem.Refresh
        
        .fraItemTop.Width = .fraItem.Width - .fraItemTop.Left - mt_CstValues.Frm_Spacing
        .fraItemTop.Left = mt_CstValues.Frm_Spacing
        .fraItemTop.Top = mt_CstValues.Frm_Spacing + .pbItem.Top + .pbItem.Height
        
        .tbsEmbedded.Top = .fraItem.Height - .tbsEmbedded.Height - mt_CstValues.Frm_Spacing
        .tbsEmbedded.Left = mt_CstValues.Frm_Spacing
        .tbsEmbedded.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        
        .fraItemBottom.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        .fraItemBottom.Height = mt_CstValues.Cpt_View_Emb_Height
        .fraItemBottom.Top = .tbsEmbedded.Top - .fraItemBottom.Height
        .fraItemBottom.Left = mt_CstValues.Frm_Spacing
        
        .tbsEmbedded.Visible = False
        
        .fraItem.Visible = True
        .fraItemTop.BorderStyle = 0
        .fraItemBottom.Visible = True
        .fraItemBottom.BorderStyle = 0
    
    End With

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Update_Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Update_Resize"
    CapMouseOn
End Sub

Private Sub UpdateDisplay()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:UpdateDisplay"
    #End If
    
    RaiseEvent SwitchToView(mt_CstValues.View_Full)
    
    'If the component was on short list, it does appear now in long list
    InitControl 4
    
    If mi_OldDisplayMode <> mt_CstValues.DisplayMode_View Then BlankFields
    Update_EnableControls
    Update_Resize
    If mi_OldDisplayMode <> mt_CstValues.DisplayMode_View Then
        UpdateInitFields
    End If
    
    txt_comment.SetFocus
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:UpdateDisplay"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:UpdateDisplay"
    CapMouseOn
End Sub

Function RecordAdd() As Boolean
Dim ls_Request As String
Dim ls_Result As String
Dim lb_Result As Boolean

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:RecordAdd"
    #End If
    
    RecordAdd = False
    
    ErrorOFF
    
    Dim ls_MEM_Code As String
    ls_MEM_Code = mo_ArmDb.SQLNextID("Cap_Memo")
    If ls_MEM_Code = "" Then Call Err.Raise(SQLFailure, "", "SQL Error: mo_ArmDb.SQLNextID(""Cap_Memo"") return nothing.")

    'Construct the request
    ls_Request = "Exec Cap_Memo_ins2 "
    ls_Request = ls_Request & "  " & CorrectKeyStr(mo_ArmDb, m_Language, srch_project) ',
    ls_Request = ls_Request & ", " & CorrectKeyStr(mo_ArmDb, m_Language, srch_customer) ',
    ls_Request = ls_Request & ", " & CorrectKeyStr(mo_ArmDb, m_Language, srch_contact) ',
    ls_Request = ls_Request & ", " & CorrectString(mo_ArmDb, m_Language, txt_comment) '@MEM_text text,
    ls_Request = ls_Request & ", " & "''" '@Internet CHAR(1),
    ls_Request = ls_Request & ", " & "''" '@Drop CHAR(1),
    ls_Request = ls_Request & ", " & "NULL" '@Drop_date DATETIME,
    ls_Request = ls_Request & ", " & CorrectString(mo_ArmDb, m_Language, txt_spare1) '@spare1_varchar VARCHAR(1),
    ls_Request = ls_Request & ", " & CorrectString(mo_ArmDb, m_Language, txt_spare2) '@spare2_varchar VARCHAR(1),
    ls_Request = ls_Request & ", " & CorrectDec(mo_ArmDb, m_Language, txt_spare3) '@spare3_real REAL,
    ls_Request = ls_Request & ", " & CorrectDec(mo_ArmDb, m_Language, txt_spare4) '@spare4_real REAL
    ls_Request = ls_Request & ",'" & ls_MEM_Code & "'"
    
    If ErrorFound Then GoTo Trace_End
    
    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    Dim lb_Transaction As Boolean
    ASC_BeginTransaction mo_ArmDb
    lb_Transaction = True
    
    lb_Result = ASC_RecordExec(mo_ArmDb, ls_Request, ls_MEM_Code)
    If lb_Result = False Then
        ASC_RollBackTransaction mo_ArmDb
        lb_Transaction = False
        Select Case ls_MEM_Code
            Case "-1"
                Call ASC_SendMessage(mo_ArmDb, m_Language, 891, "#An error occured during this manipulation, please contact your IT support")
            Case Else
                Call ASC_SendMessage(mo_ArmDb, m_Language, 891, "#An error occured during this manipulation, please contact your IT support")
        End Select
        GoTo Trace_End
    End If
    
    ASC_CommitTransaction mo_ArmDb
    lb_Transaction = False
    
    'The data has been inserted
    RaiseEvent Updated
    RecordAdd = True
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:RecordAdd", "Result=" & RecordAdd
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If lb_Transaction Then
        ASC_RollBackTransaction mo_ArmDb
    End If
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:RecordAdd"
    CapMouseOn
End Function

Function RecordUpdate(ACode As String) As Boolean
Dim ls_Request As String
Dim lb_Result As Boolean
Dim ls_Result As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:RecordUpdate", "ACode=" & ACode
    #End If
    
    RecordUpdate = False
    
    If Trim$(ACode) = "" Then
        Call ASC_SendMessage(mo_ArmDb, m_Language, 891, "#An error occured during this manipulation, please contact your IT support")
        GoTo Trace_End
    End If
    
    ErrorOFF

    ls_Request = "Exec Cap_Memo_upd2 "

    ls_Request = ls_Request & "  " & "'" & ACode & "'" ',,
    ls_Request = ls_Request & ",  " & p_iCon '@iConc      SMALLINT,
    ls_Request = ls_Request & ", " & CorrectKeyStr(mo_ArmDb, m_Language, srch_project) ',
    ls_Request = ls_Request & ", " & CorrectKeyStr(mo_ArmDb, m_Language, srch_customer) ',
    ls_Request = ls_Request & ", " & CorrectKeyStr(mo_ArmDb, m_Language, srch_contact) ',
    ls_Request = ls_Request & ", " & CorrectString(mo_ArmDb, m_Language, txt_comment) '@MEM_text text,
    ls_Request = ls_Request & ", " & "''" '@Internet CHAR(1),
    ls_Request = ls_Request & ", " & "''" '@Drop CHAR(1),
    ls_Request = ls_Request & ", " & "NULL" '@Drop_date DATETIME,
    ls_Request = ls_Request & ", " & CorrectString(mo_ArmDb, m_Language, txt_spare1) '@spare1_varchar VARCHAR(1),
    ls_Request = ls_Request & ", " & CorrectString(mo_ArmDb, m_Language, txt_spare2) '@spare2_varchar VARCHAR(1),
    ls_Request = ls_Request & ", " & CorrectDec(mo_ArmDb, m_Language, txt_spare3) '@spare3_real REAL,
    ls_Request = ls_Request & ", " & CorrectDec(mo_ArmDb, m_Language, txt_spare4) '@spare4_real REAL

    'Execution
    If ErrorFound Then GoTo Trace_End

    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    ASC_BeginTransaction mo_ArmDb

    lb_Result = ASC_RecordExec(mo_ArmDb, ls_Request, ls_Result)

    If lb_Result = False Then
        ASC_RollBackTransaction mo_ArmDb
        Select Case ls_Result
            Case "-18"
                Call ASC_SendMessage(mo_ArmDb, m_Language, 916, "#This data has been updated by another user. Data will be reloaded. Please check the data and try again.")
                ViewInitFields
            Case Else
                Call ASC_SendMessage(mo_ArmDb, m_Language, 891, "#An error occured during this manipulation, please contact your IT support")
        End Select
        GoTo Trace_End
    End If

    ASC_CommitTransaction mo_ArmDb
    
    'The data has been updated
    RaiseEvent Updated
    RecordUpdate = True
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:RecordUpdate", "Result=" & RecordUpdate
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    ASC_RollBackTransaction mo_ArmDb
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:RecordUpdate"
    CapMouseOn
End Function

Function RecordDelete(ACode As String) As Boolean
Dim ls_Request As String
Dim lb_Result As Boolean
Dim ls_Result As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:RecordDelete", "ACode=" & ACode
    #End If
    
    RecordDelete = False
    
    If Trim$(ACode) = "" Then
        Call ASC_SendMessage(mo_ArmDb, m_Language, 891, "#An error occured during this manipulation, please contact your IT support")
        GoTo Trace_End
    End If
    
    ErrorOFF

    ls_Request = "Exec cap_memo_del2 "
    
    ls_Request = ls_Request & "  " & "'" & ACode & "'" '
    ls_Request = ls_Request & ", " & p_iCon '@iConcurrency   SMALLINT

    'Execution
    If ErrorFound Then GoTo Trace_End
    
    If DeleteConfirmation(mo_ArmDb, m_Language) = False Then GoTo Trace_End
    
    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    ASC_BeginTransaction mo_ArmDb
    
    lb_Result = ASC_RecordExec(mo_ArmDb, ls_Request, ls_Result)
    If lb_Result = False Then
        ASC_RollBackTransaction mo_ArmDb
        Select Case ls_Result
            Case "-6"
                Call ASC_SendMessage(mo_ArmDb, m_Language, 916, "#This data has been updated by another user. Data will be reloaded. Please check the data and try again.")
                ViewInitFields
            Case Else
                Call ASC_SendMessage(mo_ArmDb, m_Language, 891, "#An error occured during this manipulation, please contact your IT support")
        End Select
        GoTo Trace_End
    End If
    
    ASC_CommitTransaction mo_ArmDb
    
    'The data has been deleted
    RaiseEvent Updated
    RecordDelete = True
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:RecordDelete", "Result=" & RecordDelete
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    ASC_RollBackTransaction mo_ArmDb
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:RecordDelete"
    CapMouseOn
End Function

Private Sub ViewDisplay()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ViewDisplay"
    #End If
    
    If mi_EmbeddedIn = -1 Then
        RaiseEvent SwitchToView(mt_CstValues.View_Full)
    Else
        RaiseEvent SwitchToView(mt_CstValues.View_Medium)
    End If
    
    'If the component was on short list, it doues appear now in long list
    InitControl 3
    
    BlankFields
    View_EnableControls
    ViewLoad
    View_Resize
    ViewInitFields

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ViewDisplay"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ViewDisplay"
    CapMouseOn
End Sub

Private Sub View_Resize()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:View_Resize"
    #End If
    
    With UserControl
        
        If mi_EmbeddedIn = -1 And Not mb_Root Then
        
            .fraItem.Left = mt_CstValues.Frm_Spacing
            
            .tbsEmbedded.Visible = False 'true
            .tbsEmbedded.ZOrder 0
            
        Else
            .fraItem.Left = mt_CstValues.Frm_Spacing
            
            .tbsEmbedded.Visible = False 'true
            .tbsEmbedded.ZOrder 0
            
        End If
        
        .fraItem.Top = mt_CstValues.Frm_Spacing
        .fraItem.Width = .Width - .fraItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .fraItem.Height = .Height - .fraItem.Top - (2 * mt_CstValues.Frm_Spacing)
        
        .pbItem.Height = mt_CstValues.View_ToolBar_Height
        .pbItem.Top = mt_CstValues.Frm_Spacing * 4
        .pbItem.Left = mt_CstValues.Frm_Spacing
        .pbItem.Width = .fraItem.Width - .pbItem.Left - (2 * mt_CstValues.Frm_Spacing)
        .pbItem.Refresh
        
        .fraItemTop.Width = .fraItem.Width - .fraItemTop.Left - mt_CstValues.Frm_Spacing
        .fraItemTop.Left = mt_CstValues.Frm_Spacing
        .fraItemTop.Top = mt_CstValues.Frm_Spacing + .pbItem.Top + .pbItem.Height
        
        .tbsEmbedded.Top = .fraItem.Height - .tbsEmbedded.Height - mt_CstValues.Frm_Spacing
        .tbsEmbedded.Left = mt_CstValues.Frm_Spacing
        .tbsEmbedded.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        
        .fraItemBottom.Width = .fraItem.Width - .tbsEmbedded.Left - mt_CstValues.Frm_Spacing
        .fraItemBottom.Height = mt_CstValues.Cpt_View_Emb_Height
        .fraItemBottom.Top = .tbsEmbedded.Top - .fraItemBottom.Height
        .fraItemBottom.Left = mt_CstValues.Frm_Spacing
        
        .fraItemBottom.Visible = True
        
        .fraItem.Visible = True
        .fraItemTop.BorderStyle = 0
        .fraItemBottom.BorderStyle = 0
        
    End With

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:View_Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:View_Resize"
    CapMouseOn
End Sub

Property Get UserControlWidth() As Long
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:UserControlWidth_Get"
    #End If
    UserControlWidth = UserControl.Width
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:UserControlWidth_Get", "Result=" & UserControlWidth
    #End If
    
End Property

Property Get CurrentKey(Optional APart As Integer = 0) As String

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:CurrentKey_Get", "APart=" & APart
    #End If
    CapMouseOff
    
    If APart = 0 Then
        CurrentKey = m_CurrentKey1 & CH_LDELIMIT & m_CurrentKey2
    ElseIf APart = 1 Then
        CurrentKey = m_CurrentKey1
    ElseIf APart = 2 Then
        CurrentKey = m_CurrentKey2
    Else
        CurrentKey = ""
    End If
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:CurrentKey_Get", "Result=" & CurrentKey
    #End If
    CapMouseOn

End Property

Property Let CurrentKey(Optional APart As Integer = 0, AKeyValue As String)

    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:CurrentKey_Let", "APart=" & APart, "AKeyValue=" & AKeyValue
    #End If
    CapMouseOff
    
    If APart = 0 Then
        m_CurrentKey1 = AKeyValue
        m_CurrentKey2 = ""
        m_CurrentKey3 = ""
    ElseIf APart = 1 Then
        m_CurrentKey1 = AKeyValue
    ElseIf APart = 2 Then
        m_CurrentKey2 = AKeyValue
    Else
        CurrentKey = ""
    End If
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:CurrentKey_Let"
    #End If
    CapMouseOn

End Property

Property Let TypeList(AType As Integer)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:TypeList_Let", "AType=" & AType
    #End If
    mi_TypeList = AType
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:TypeList_Let"
    #End If
End Property

Property Get TypeList() As Integer
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:TypeList_Get"
    #End If
    TypeList = mi_TypeList
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:TypeList_Get", "Result=" & TypeList
    #End If
End Property

Private Sub ShortList_Resize()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ShortList_Resize"
    #End If
    
    With UserControl
    
        .fraList.Left = mt_CstValues.Frm_Spacing
        .fraList.Top = mt_CstValues.Frm_Spacing
        .fraList.Width = .Width - .fraList.Left - (2 * mt_CstValues.Frm_Spacing)
        .fraList.Height = .Height - .fraList.Top - (2 * mt_CstValues.Frm_Spacing)
   
        .pblst.Height = mt_CstValues.View_ToolBar_Height
        .pblst.Top = mt_CstValues.Frm_Spacing * 4
        .pblst.Left = mt_CstValues.Frm_Spacing
        .pblst.Width = .fraList.Width - .pblst.Left - (2 * mt_CstValues.Frm_Spacing)
        .pblst.Refresh
        
        .grdlst.Top = mt_CstValues.Frm_Spacing + .pblst.Top + .pblst.Height
        .grdlst.Left = mt_CstValues.Frm_Spacing
        .grdlst.Width = .fraList.Width - .grdlst.Left - mt_CstValues.Frm_Spacing
        .grdlst.Height = .fraList.Height - .pblst.Height - .pblst.Top - (2 * mt_CstValues.Frm_Spacing)
        
        .fraList.Visible = True
        
    End With
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ShortList_Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ShortList_Resize"
    CapMouseOn
End Sub

' Called when application must resize the current view
Public Sub Resize()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Resize"
    #End If
    
    Call DisplayMode_None
    
    Select Case DisplayMode
        Case mt_CstValues.DisplayMode_List
               Call ShortList_Resize
    End Select
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Resize"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Resize"
    CapMouseOn
End Sub

Property Let product(AProductKey As String)
Dim TheKeys As Variant

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Product_Let", "AProductKey=" & AProductKey
    #End If
    
    'AKey represents the concatenation of several keys separated by '@'
    If AProductKey = "" Then GoTo Trace_End

    ' First, we hide all elements
    DisplayMode_None
    
    If (Not mb_Root) And (mi_TypeList <> 1) Then
        mi_EmbedTag = -1
    End If
    
    InitControl 2
    
    mi_EmbeddedIn = mt_CstValues.Tag_Product
    mb_EmbeddedIsDropped = False
    TheKeys = Split(AProductKey, CH_LDELIMIT)
    m_Product = CStr(TheKeys(0))
    
    SwapToDisplayMode mt_CstValues.DisplayMode_List
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Product_Let"
    #End If
    CapMouseOn
    Exit Property
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Product_Let"
    CapMouseOn
End Property

Property Let action(AActionKey As String)
Dim TheKeys As Variant

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:action_let", "AActionKey=" & AActionKey
    #End If
    
    'AKey represents the concatenation of several keys separated by '@'
    If AActionKey = "" Then GoTo Trace_End

    ' First, we hide all elements
    DisplayMode_None
    
    If (Not mb_Root) And (mi_TypeList <> 1) Then
        mi_EmbedTag = -1
    End If
    
    InitControl 2
    
    mi_EmbeddedIn = mt_CstValues.Tag_Action
   
    m_Action = CStr(TheKeys(0))
    mb_EmbeddedIsDropped = False
    
    SwapToDisplayMode mt_CstValues.DisplayMode_List
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:action_let"
    #End If
    CapMouseOn
    Exit Property
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:action_let"
    CapMouseOn
End Property

Property Let contact(AKey As String)
Dim TheKeys As Variant

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Contact_let", "AKey=" & AKey
    #End If
    
    'AKey represents the concatenation of several keys separated by '@'
    If AKey = "" Then GoTo Trace_End

    ' First, we hide all elements
    DisplayMode_None
    
    If (Not mb_Root) And (mi_TypeList <> 1) Then
        mi_EmbedTag = -1
    End If
    
    InitControl 2
    
    mi_EmbeddedIn = mt_CstValues.Tag_Contact
   
    TheKeys = Split(AKey, CH_LDELIMIT)
    m_Project = ""
    m_Customer = CStr(TheKeys(1))
    m_Contact = CStr(TheKeys(0))
    mb_EmbeddedIsDropped = (TheKeys(3) = "1") ' TAKS 298.2
    ListContactOf CStr(TheKeys(0)), CStr(TheKeys(1)), CStr(TheKeys(2))
    
    SwapToDisplayMode mt_CstValues.DisplayMode_List
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Contact_let"
    #End If
    CapMouseOn
    Exit Property
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Contact_let"
    CapMouseOn
End Property
Property Let Customer(AKey As String)
Dim TheKeys As Variant

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Customer_let", "AKey=" & AKey
    #End If
    
    'AKey represents the concatenation of several keys separated by '@'
    If AKey = "" Then GoTo Trace_End

    ' First, we hide all elements
    DisplayMode_None
    
    If (Not mb_Root) And (mi_TypeList <> 1) Then
        mi_EmbedTag = -1
    End If
    
    InitControl 2
    
    mi_EmbeddedIn = mt_CstValues.Tag_Customer
   
    TheKeys = Split(AKey, CH_LDELIMIT)
    m_Project = ""
    m_Contact = ""
    m_Customer = CStr(TheKeys(0))
    mb_EmbeddedIsDropped = (TheKeys(2) = "1") ' TASK 298.2
    ListCustomerOf CStr(TheKeys(0)), CStr(TheKeys(1))
    
    SwapToDisplayMode mt_CstValues.DisplayMode_List
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Customer_let"
    #End If
    CapMouseOn
    Exit Property
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Customer_let"
    CapMouseOn
End Property
Property Let project(AKey As String)
Dim TheKeys As Variant

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Project_let", "AKey=" & AKey
    #End If
    
    'AKey represents the concatenation of several keys separated by '@'
    If AKey = "" Then GoTo Trace_End

    ' First, we hide all elements
    DisplayMode_None
    
    If (Not mb_Root) And (mi_TypeList <> 1) Then
        mi_EmbedTag = -1
    End If
    
    InitControl 2
    
    mi_EmbeddedIn = mt_CstValues.Tag_Project
   
    TheKeys = Split(AKey, CH_LDELIMIT)
    m_Customer = ""
    m_Contact = ""
    m_Project = CStr(TheKeys(0))
    mb_EmbeddedIsDropped = False
    ListProjectOf CStr(TheKeys(0)), CStr(TheKeys(1))
    
    SwapToDisplayMode mt_CstValues.DisplayMode_List
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Project_let"
    #End If
    CapMouseOn
    Exit Property
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Project_let"
    CapMouseOn
End Property

Sub UnCatch()
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:UnCatch"
    #End If
    mi_EmbeddedIn = -1
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:UnCatch"
    #End If
End Sub

Private Sub grdLst_ItemSelected()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:grdlst_Click"
    #End If
    
    m_CurrentKey1 = grdlst.CurrentKey(0)
    m_CurrentKey2 = grdlst.CurrentKey(1)

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:grdlst_Click"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:grdlst_Click"
    CapMouseOn
End Sub

Private Sub srch_contact_OnClick()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:srch_contact_OnClick"
    #End If
    
    srch_contact.CodeProject = srch_project.Key1
    srch_contact.CodeCustomer = srch_customer.Key1

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:srch_contact_OnClick"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:srch_contact_OnClick"
    CapMouseOn
End Sub

Private Sub srch_customer_OnValid()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:srch_customer_OnValid"
    #End If
    
    srch_contact.Clear
    srch_contact.CodeCustomer = srch_customer.Key1
    srch_contact.CodeProject = srch_project.Key1
    srch_contact.TypeSearch = "Contact"

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:srch_customer_OnValid"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:srch_customer_OnValid"
    CapMouseOn
End Sub


Private Sub srch_project_OnClick()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:srch_project_OnClick"
    #End If
    
    srch_project.CodeCustomer = srch_customer.Key1
    srch_project.CodeContact = srch_contact.Key1

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:srch_project_OnClick"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:srch_project_OnClick"
    CapMouseOn
End Sub

' Initialization of the component
Public Sub Load_A_Com(ab_root As Boolean)

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Load_A_Com", "ab_root = " & ab_root
    #End If
    
    VerifyInitialization mo_ArmDb, ms_ConnectString, m_Language, Me
    
    mi_EmbeddedIn = -1  '   Component is not embedded by someone
    mi_EmbedTag = -1    '   Component embed none component

    mb_Root = False     ' Component is not the default focus

    grdlst.Load_A_Com
    srch_contact.Load_A_Com
    srch_customer.Load_A_Com
    srch_project.Load_A_Com
    pblst.Load_A_Com
    pbItem.Load_A_Com
    pblst.DrivenByCapture = True
    pbItem.DrivenByCapture = True

    'Screen csts
    LoadLabels mo_ArmDb, UserControl.Controls, "Cap_Memo_Detail", m_Language

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Load_A_Com"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Load_A_Com"
    CapMouseOn
End Sub

Public Function cas_all(ByVal parm As String)
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:cas_all", "parm=" & parm
    #End If
    
    Select Case UCase(parm)
        Case "'ALL'", "''", Len(parm) = 0, "'A'":            cas_all = "Null"
        Case "'N'":  cas_all = "''"
        Case Else: cas_all = parm
    End Select

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:cas_all", "Result=" & cas_all
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:cas_all"
    CapMouseOn
End Function

' Get the root state
Public Property Get Root() As Boolean
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Root_Get"
    #End If
    Root = mb_Root
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Root_Get", "Result=" & Root
    #End If
End Property

Public Property Let Root(ByVal ab_root As Boolean)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Root_Let", "ab_Root=" & ab_root
    #End If
    mb_Root = ab_root
    If mb_Root = True Then
        mi_EmbeddedIn = -1
    End If
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Root_Let"
    #End If
End Property

Private Sub pbItem_action(ByVal as_ActionType As String)
Dim lb_Result As Boolean

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:pbItem_action", "as_ActionType=" & as_ActionType
    #End If
    
    Select Case UCase$(as_ActionType)
        Case UCase$("Add")
            DisplayMode = mt_CstValues.DisplayMode_Add
            
        Case UCase$("Update")
            If grdlst.Row >= 0 Then DisplayMode = mt_CstValues.DisplayMode_Update
        
        Case UCase$("Delete")
            If grdlst.Row >= 0 Then DisplayMode = mt_CstValues.DisplayMode_Delete
        
        Case UCase$("Excel")

        Case UCase$("Quit")
            If mi_EmbedTag <> -1 Then
                RaiseEvent Release
                mi_EmbedTag = -1
            End If
            
'            'Cycle
'            If mi_TypeList = -1 Then
'                DrawMainGrid
'                DisplayMode = mt_CstValues.DisplayMode_List
'            Else
                DisplayMode = mt_CstValues.DisplayMode_List
'            End If
            
        Case UCase$("Valid")
        
'            'Cycle
'            If mi_TypeList = -1 Then DrawMainGrid
            
            lb_Result = False
            Select Case DisplayMode
                Case mt_CstValues.DisplayMode_Add
                    lb_Result = RecordAdd
                Case mt_CstValues.DisplayMode_Update
                    lb_Result = RecordUpdate(m_CurrentKey1)
                Case mt_CstValues.DisplayMode_Delete
                    lb_Result = RecordDelete(m_CurrentKey1)
            End Select
            If lb_Result Then
                grdlst.Refresh
                DisplayMode = mt_CstValues.DisplayMode_List
            End If
            
        Case UCase$("Undo")
            BlankFields
            'DisplayMode = mt_CstValues.DisplayMode_List
            If mi_DisplayMode = mt_CstValues.DisplayMode_Add Then
                AddInitFields
            Else
                ViewInitFields
            End If
            
        Case UCase$("Previous")
            If grdlst.Row = 0 Then
                Call ASC_SendMessage(mo_ArmDb, m_Language, 927, "#No more previous item.")
            Else
                grdlst.Row = grdlst.Row - 1
                m_CurrentKey1 = grdlst.CurrentKey(0)
                m_CurrentKey2 = grdlst.CurrentKey(1)
                BlankFields
                ViewInitFields
            End If
        
        Case UCase$("Next")
            If grdlst.Row = grdlst.Rows - 1 And grdlst.AllDataLoaded = True Then
                Call ASC_SendMessage(mo_ArmDb, m_Language, 928, "#No more next item.")
            Else
                grdlst.Row = grdlst.Row + 1
                m_CurrentKey1 = grdlst.CurrentKey(0)
                m_CurrentKey2 = grdlst.CurrentKey(1)
                BlankFields
                ViewInitFields
            End If
        
        Case Else
            Call ASC_SendMessage(mo_ArmDb, m_Language, 929, "#Invalid option :", as_ActionType)
    
    End Select

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:pbItem_action"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:pbItem_action"
    CapMouseOn
End Sub

Private Sub pbLst_Action(ByVal as_ActionType As String)

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:pbLst_Action", "as_ActionType=" & as_ActionType
    #End If
    
    ' TASK 298.2
    Select Case UCase$(as_ActionType)
    
        Case UCase$("Add")
            Select Case mi_EmbeddedIn
                Case mt_CstValues.Tag_Customer
                    If mb_EmbeddedIsDropped Then
                        Call ASC_SendMessage(mo_ArmDb, m_Language, 2507, "#You are unable to create an memo for a Deleted Customer")
                    Else
                        DisplayMode = mt_CstValues.DisplayMode_Add
                    End If
                
                Case mt_CstValues.Tag_Contact
                    If mb_EmbeddedIsDropped Then
                        Call ASC_SendMessage(mo_ArmDb, m_Language, 2508, "#You are unable to create an memo for a Deleted Contact")
                    Else
                        DisplayMode = mt_CstValues.DisplayMode_Add
                    End If
                
                Case Else
                    DisplayMode = mt_CstValues.DisplayMode_Add
            End Select
            
        Case UCase$("Update")
            If grdlst.Row >= 0 Then
                DisplayMode = mt_CstValues.DisplayMode_Update
            End If
            
        Case UCase$("Delete")
            If grdlst.Row >= 0 Then
            DisplayMode = mt_CstValues.DisplayMode_Delete
            End If
        
        Case UCase$("Refresh")
            grdlst.Refresh
            
        Case UCase$("Print")
        
        Case UCase$("Excel")
            
        Case UCase$("Quit")
            RaiseEvent quit
        
        Case Else
            Call ASC_SendMessage(mo_ArmDb, m_Language, 929, "#Invalid option :", as_ActionType)
    
    End Select

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:pbLst_Action"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:pbLst_Action"
    CapMouseOn
End Sub

Sub View_EnableControls()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:View_EnableControls"
    #End If
    
    ControlsEnable UserControl.Controls, fraItemTop, False
    ControlsEnable UserControl.Controls, fraItemBottom, False
    
    txt_comment.Enabled = True
    txt_comment.Locked = True
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:View_EnableControls"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:View_EnableControls"
    CapMouseOn
End Sub
Sub Add_Enablecontrols()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Add_EnableControls"
    #End If
    
    ControlsEnable UserControl.Controls, fraItemTop, True
    ControlsEnable UserControl.Controls, fraItemBottom, True
    
    If m_Customer <> "" Then
        srch_customer.Locked = True
    End If
    
    If m_Contact <> "" Then
        srch_contact.Locked = True
    End If
    
    If m_Project <> "" Then
        srch_project.Locked = True
    End If
    
    txt_comment.Locked = False
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Add_EnableControls"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Add_EnableControls"
    CapMouseOn
End Sub

Sub Update_EnableControls()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Update_EnableControls"
    #End If
    
    ControlsEnable UserControl.Controls, fraItemTop, True
    ControlsEnable UserControl.Controls, fraItemBottom, True
    
    If m_Customer <> "" Then
        srch_customer.Locked = True
    End If
    
    If m_Contact <> "" Then
        srch_contact.Locked = True
    End If
    
    If m_Project <> "" Then
        srch_project.Locked = True
    End If
    
    txt_comment.Locked = False
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Update_EnableControls"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Update_EnableControls"
    CapMouseOn
End Sub

Sub UpdateInitFields()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:UpdateInitFields"
    #End If
    
    'idem
    ViewInitFields

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:UpdateInitFields"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:UpdateInitFields"
    CapMouseOn
End Sub


Private Sub InitControl(Optional aMode As Integer = 0)
Dim ConnectData As Variant
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:InitControl", "AMode=" & aMode
    #End If
    
    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    Select Case aMode
        Case 0
    'If No mode then exit
            GoTo Trace_End
   
        Case 1
    'If already initialized then exit
        If mi_TypeList <> 1 Then
            mi_TypeList = 1
        Else
            pblst.PictureDisplayed = "P_Quit=-1"
            GoTo Trace_End
        End If
        Case 2
        If mi_TypeList <> 1 And mi_TypeList <> 2 Then
            mi_TypeList = 2
        End If
    End Select
   
    UserControl.ScaleMode = 1
    
    'Object unvisble
    ObjectVisible False
    
    Select Case aMode
        Case 2
    'Pour la liste courte
        
        'Grille
        grdlst.ResetGrid
        
        'Pour liste longue : Initialisation toolbar
        pblst.ClearAllIcons
        pblst.TableName = mt_CstValues.SecurityMemo_lst
        pblst.PictureDisplayed = "P_Refresh=7"
        
        Case 3
    'Pour détail
    
        pbItem.ClearAllIcons
'            If WithParent Then
'                pbItem.TableName = mt_CstValues.SecurityMemo_lst
'            Else
'                pbItem.TableName = mt_CstValues.SecurityMemo
'            End If
'            pbItem.PictureDisplayed = "P_Print=5 P_Quit=-1"
            pbItem.TableName = ""
            pbItem.PictureDisplayed = "P_Update=2 P_Previous=4 P_Next=5 P_Quit=-1"
    
        Case 4
    'Pour màj
    
        'Toolbar
        pbItem.ClearAllIcons
        pbItem.PictureDisplayed = "P_Valid=1 P_UnDo=2 P_Quit=-1"
    
    End Select
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:InitControl"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:InitControl"
    CapMouseOn
End Sub
Private Sub ObjectVisible(Optional aVisible As Boolean = True)

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ObjectVisible", "AVisible=" & aVisible
    #End If
    
    UserControl.fraItem.Visible = aVisible
    UserControl.fraList.Visible = aVisible

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ObjectVisible"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ObjectVisible"
    CapMouseOn
End Sub

Public Sub FrameWorkInit(ByRef lt_CstValues As Type_CstValues, ByVal ls_InstanceName As String, Optional ATypeList As Integer = 0)
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:FrameWorkInit", "ls_InstanceName=" & ls_InstanceName, "ATypeList=" & ATypeList
    #End If
    
    'Restriction of initialsation
    mi_TypeParam = ATypeList
        
    Set mt_CstValues = lt_CstValues
    
    
    mi_CptTag = mt_CstValues.Tag_Memo
    
    ' Add the tabulation for the embedded controls
    With UserControl
        .ScaleMode = 1
        .tbsEmbedded.Tabs.Clear
        .tbsEmbedded.TabFixedWidth = 150
        Dim lt_Tab As Object
        Set lt_Tab = .tbsEmbedded.Tabs.Add(.tbsEmbedded.Tabs.Count + 1, "Project", "#Project")
        lt_Tab.Tag = mt_CstValues.Tag_Project
        Set lt_Tab = Nothing
        Set lt_Tab = .tbsEmbedded.Tabs.Add(.tbsEmbedded.Tabs.Count + 1, "Action", "#Action")
        lt_Tab.Tag = mt_CstValues.Tag_Action
        Set lt_Tab = Nothing
        Set lt_Tab = .tbsEmbedded.Tabs.Add(.tbsEmbedded.Tabs.Count + 1, "Customer", "#Customer")
        lt_Tab.Tag = mt_CstValues.Tag_Customer
        Set lt_Tab = Nothing
        Set lt_Tab = .tbsEmbedded.Tabs.Add(.tbsEmbedded.Tabs.Count + 1, "Contact", "#Contact")
        lt_Tab.Tag = mt_CstValues.Tag_Contact
        Set lt_Tab = Nothing
        Set lt_Tab = .tbsEmbedded.Tabs.Add(.tbsEmbedded.Tabs.Count + 1, "Product", "#Product")
        lt_Tab.Tag = mt_CstValues.Tag_Product
        Set lt_Tab = Nothing
        Set lt_Tab = .tbsEmbedded.Tabs.Add(.tbsEmbedded.Tabs.Count + 1, "Memo", "#Memo")
        lt_Tab.Tag = mt_CstValues.Tag_Memo
        Set lt_Tab = Nothing
    End With
    
    mi_DisplayMode = mt_CstValues.DisplayMode_None
    mi_OldDisplayMode = mi_DisplayMode
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:FrameWorkInit"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:FrameWorkInit"
    CapMouseOn
End Sub


' Release the memory used
Public Sub Unload_A_Com()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:Unload_A_COM"
    #End If
    
    grdlst.Unload_A_Com
    pblst.Unload_A_Com
    pbItem.Unload_A_Com
    
    srch_customer.Unload_A_Com
    srch_contact.Unload_A_Com
    srch_project.Unload_A_Com
    
    ASC_DisconnectFromDB mo_ArmDb, ms_UID, mb_Created
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:Unload_A_COM"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:Unload_A_COM"
    CapMouseOn
End Sub


' Properties for let application access to critical data
Public Property Get CptTag()
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:CptTag_Get"
    #End If
    CptTag = mi_CptTag
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:CptTag_Get", "Result=" & CptTag
    #End If
End Property

' Give the tag of the component which embed this instance
Public Property Get EmbeddedIn() As Integer
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:EmbeddedIn_Get"
    #End If
    EmbeddedIn = mi_EmbeddedIn
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:EmbeddedIn_Get", "Result=" & EmbeddedIn
    #End If
End Property

' Give the tag of the component embed by this
Public Property Get EmbedTag() As Integer
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:EmbedTag_Get"
    #End If
    EmbedTag = mi_EmbedTag
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:EmbedTag_Get", "Result=" & EmbedTag
    #End If
End Property


' Give the actual display mode
Public Property Get DisplayMode() As Integer
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:DisplayMode_Get"
    #End If
    DisplayMode = mi_DisplayMode
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:DisplayMode_Get", "Result=" & DisplayMode
    #End If
End Property

' Change the actual display mode
Public Property Let DisplayMode(ByVal li_DisplayMode As Integer)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:DisplayMode_Let", "li_DisplayMode=" & li_DisplayMode
    #End If
    SwapToDisplayMode li_DisplayMode
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:DisplayMode_Let"
    #End If
End Property



' when a component embed this instance
Public Sub CatchBy(ByVal li_TagCaller, ByVal ls_Params As String)
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:CatchBy", "li_TagCaller=" & li_TagCaller, "ls_Params=" & ls_Params
    #End If
    
    mi_EmbeddedIn = li_TagCaller
    mb_Root = False
    mi_EmbedTag = -1
    
    If mi_EmbeddedIn <> -1 Then
        ' When a component is embedded, it always appears in short list
        SwapToDisplayMode mt_CstValues.DisplayMode_List, ls_Params
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:CatchBy"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:CatchBy"
    CapMouseOn
End Sub

Private Function WithParent() As Boolean
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:WithParent"
    #End If
    
    If m_Project = "" And m_Customer = "" And m_Contact = "" And m_Product = "" And m_Action = "" Then
        WithParent = False
    Else
        WithParent = True
    End If

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:WithParent", "Result=" & WithParent
    #End If
    CapMouseOn
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:WithParent"
    CapMouseOn
End Function

' Change the display mode
Private Sub SwapToDisplayMode(li_DisplayMode As Integer, Optional ls_Params As String = "")
 
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:SwapToDisplayMode", "li_DisplayMode=" & li_DisplayMode, "ls_Params=" & ls_Params
    #End If
    
    mi_OldDisplayMode = mi_DisplayMode
   
    'When a component is root, it can't select the list mode
    If mb_Root And (li_DisplayMode = mt_CstValues.DisplayMode_List) And (EmbeddedIn = -1) Then
        li_DisplayMode = mt_CstValues.DisplayMode_View
    End If
    mi_DisplayMode = li_DisplayMode
   
    'We should hide all graphics frames before resize and move it
    DisplayMode_None
    
    Select Case mi_DisplayMode
        Case mt_CstValues.DisplayMode_List
            'the component is embedded
            ShortListDisplay ls_Params
        
        Case mt_CstValues.DisplayMode_View
                ViewDisplay
            
        Case mt_CstValues.DisplayMode_Update
                UpdateDisplay
            
        Case mt_CstValues.DisplayMode_Add
                AddDisplay
            
        Case mt_CstValues.DisplayMode_Delete
                DeleteDisplay
            
    End Select
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:SwapToDisplayMode"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:SwapToDisplayMode"
    CapMouseOn
End Sub

' Hide all graphics elements
Private Sub DisplayMode_None()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:DisplayMode_None"
    #End If
    
   With UserControl
        .fraItem.Visible = False
        .fraList.Visible = False
    End With
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:DisplayMode_None"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:DisplayMode_None"
    CapMouseOn
End Sub

Private Sub ViewLoad()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ViewLoad"
    #End If
    
    If (mb_Root And mi_OldDisplayMode <> mt_CstValues.DisplayMode_List) Or mi_EmbedTag = -1 Then
        With UserControl
                .tbsEmbedded.Tabs.Item(1).Selected = True
        End With
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ViewLoad"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ViewLoad"
    CapMouseOn
End Sub

Private Sub ShortListDisplay(ByVal ls_Params As String)
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ShortListDisplay", "ls_Params=" & ls_Params
    #End If
    
    RaiseEvent SwitchToView(mt_CstValues.View_Embedded)
   
    ShortList_Resize
        
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ShortListDisplay"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ShortListDisplay"
    CapMouseOn
End Sub

Private Sub grdlst_DblClick()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:grdlst_DblClick"
    #End If
    
    If grdlst.Row >= 0 Then DisplayMode = mt_CstValues.DisplayMode_View
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:grdlst_DblClick"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:grdlst_DblClick"
    CapMouseOn
End Sub


' Embed a component
Private Sub tbsEmbedded_Click()
    
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:tbsEmbedded_Click"
    #End If
    
    If mi_EmbedTag = UserControl.tbsEmbedded.SelectedItem.Tag Then
        GoTo Trace_End
    End If
    
    With UserControl
        
        If mi_EmbedTag <> -1 Then
            RaiseEvent Release
            mi_EmbedTag = -1
        End If
        
        If .tbsEmbedded.SelectedItem.Index = 1 Then
            If mi_EmbeddedIn <> -1 Then
                 RaiseEvent SwitchToView(mt_CstValues.View_Medium)
            End If
            .fraItemBottom.Visible = True
        Else
            .fraItemBottom.Visible = False
            If mi_EmbeddedIn <> -1 Then
                If .tbsEmbedded.SelectedItem.Tag = mt_CstValues.Tag_Memo Then
                     RaiseEvent SwitchToView(mt_CstValues.View_Medium)
                Else
                    RaiseEvent SwitchToView(mt_CstValues.View_Full)
                End If
            End If
            mi_EmbedTag = .tbsEmbedded.SelectedItem.Tag
            RaiseEvent Catch(mi_EmbedTag, m_CurrentKey1 & CH_LDELIMIT & m_CurrentKey2)
        End If
    End With

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:tbsEmbedded_Click"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:tbsEmbedded_Click"
    CapMouseOn
End Sub


Private Sub AddInitFields()
Dim ls_Request As String
Dim ll_Cursor As Long

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:AddInitFields"
    #End If
    
    'Try connection, 'use_framework_connection' is inside 'ASC_ConnectToDB' !
    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    ls_Request = "exec Cap_memo_sel2 '" & m_Project & "','" & m_Customer & "','" & m_Contact & "'"
    ll_Cursor = mo_ArmDb.OpenSQL(ls_Request, -1, 0)
    If ll_Cursor = 0 Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError mo_ArmDb, "CapMem:AddInitFields", "Request=" & ls_Request
        GoTo Trace_End
    End If
      
    txt_comment.Text = ""

    txt_spare1.Text = ""
    txt_spare2.Text = ""
    txt_spare3.Text = ""
    txt_spare4.Text = ""

    srch_project.Clear
    srch_project.CodeCustomer = m_Customer
    srch_project.CodeContact = m_Contact
    srch_project.TypeSearch = "Project"
    srch_project.Key1 = m_Project
    srch_project.Text = mo_ArmDb.GetFields(ll_Cursor, "SP_Desc")

    srch_customer.Clear
    srch_customer.CodeProject = m_Project
    srch_customer.TypeSearch = "Customer"
    srch_customer.Key1 = m_Customer
    srch_customer.Text = mo_ArmDb.GetFields(ll_Cursor, "CCU_Desc")
    
    srch_contact.Clear
    srch_contact.CodeProject = m_Project
    srch_contact.CodeContact = m_Contact
    srch_contact.CodeCustomer = m_Customer
    srch_contact.TypeSearch = "Contact"
    srch_contact.Key1 = m_Contact
    srch_contact.Text = mo_ArmDb.GetFields(ll_Cursor, "CNT_LastName")
    srch_contact.CodeCustomerRequired = True

    DisplayDefaultValues
    
Trace_End:
    mo_ArmDb.Close ll_Cursor
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:AddInitFields"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    mo_ArmDb.Close ll_Cursor
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:AddInitFields"
    CapMouseOn
End Sub

Private Sub BlankFields()
Dim TheRequest As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:BlankFields"
    #End If
    
    'Ici on vire le contenu des champs
          
    txt_comment.Text = ""

    txt_spare1.Text = ""
    txt_spare2.Text = ""
    txt_spare3.Text = ""
    txt_spare4.Text = ""

    srch_project.Clear
    srch_customer.Clear
    srch_contact.Clear
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:BlankFields"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:BlankFields"
    CapMouseOn
End Sub

Public Sub DisplayDefaultValues()
Dim i As Integer
Dim TheControl As Control
Dim TheControlName As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:DisplayDefaultValues"
    #End If
    
    If p_DefaultValuesLoaded = False Then
        p_DefaultValuesCount = GetScreenDefaultValues(mo_ArmDb, ms_UID, m_Language, "Cap_Memo_Detail", p_DefaultValues)
        p_DefaultValuesLoaded = True
            End If
    DisplayScreenDefaultValues UserControl.Controls, p_DefaultValues, p_DefaultValuesCount

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:DisplayDefaultValues"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:DisplayDefaultValues"
    CapMouseOn
End Sub

Private Sub ViewInitFields()
Dim ls_Request As String
Dim ll_Cursor As Long
Dim Thekey1 As String
Dim Thekey2 As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ViewInitFields"
    #End If
    
    'On construit la requête
    Thekey1 = grdlst.CurrentKey(0)
    Thekey2 = grdlst.CurrentKey(1)
    
    m_CurrentKey1 = Thekey1
    m_CurrentKey2 = Thekey2
    
    'Si pas de clé en cours, ie pas de ligne en grille sélectionnée alors bye
    If Thekey1 = "" Or Thekey2 = "" Then GoTo Trace_End
    
    'Try connection, 'use_framework_connection' is inside 'ASC_ConnectToDB' !
    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    ls_Request = "exec cap_memo_t_sel '" & Thekey1 & "','" & Thekey2 & "'"
    ll_Cursor = mo_ArmDb.OpenSQL(ls_Request, -1, 0)
    If ll_Cursor = 0 Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError mo_ArmDb, "CapMem:ViewInitFields", "Request=" & ls_Request
        GoTo Trace_End
    End If
  
    p_iCon = mo_ArmDb.GetFields(ll_Cursor, "iConcurrency")
  
    txt_comment.Text = mo_ArmDb.GetFields(ll_Cursor, "MEM_text")
    
    srch_customer.Key1 = mo_ArmDb.GetFields(ll_Cursor, "ccu_capkey")
    srch_customer.Text = mo_ArmDb.GetFields(ll_Cursor, "ccu_desc")
    srch_customer.CodeProject = mo_ArmDb.GetFields(ll_Cursor, "sp_capkey")
    srch_customer.TypeSearch = "Customer"
    
    srch_contact.Key1 = mo_ArmDb.GetFields(ll_Cursor, "cnt_code")
    srch_contact.Text = mo_ArmDb.GetFields(ll_Cursor, "cnt_lastname")
    srch_contact.CodeProject = mo_ArmDb.GetFields(ll_Cursor, "sp_capkey")
    srch_contact.CodeCustomer = mo_ArmDb.GetFields(ll_Cursor, "ccu_capkey")
    srch_contact.TypeSearch = "Contact"
    srch_contact.CodeCustomerRequired = True
    
    srch_project.Key1 = mo_ArmDb.GetFields(ll_Cursor, "sp_capkey")
    srch_project.Text = mo_ArmDb.GetFields(ll_Cursor, "sp_desc")
    srch_project.CodeContact = mo_ArmDb.GetFields(ll_Cursor, "cnt_code")
    srch_project.CodeCustomer = mo_ArmDb.GetFields(ll_Cursor, "ccu_capkey")
    srch_project.TypeSearch = "Project"
  
    txt_spare1.Text = mo_ArmDb.GetFields(ll_Cursor, "spare1_varchar")
    txt_spare2.Text = mo_ArmDb.GetFields(ll_Cursor, "spare2_varchar")
    txt_spare3.Text = mo_ArmDb.GetFields(ll_Cursor, "spare3_real")
    txt_spare4.Text = mo_ArmDb.GetFields(ll_Cursor, "spare4_real")
   

Trace_End:
    mo_ArmDb.Close ll_Cursor
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ViewInitFields"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    mo_ArmDb.Close ll_Cursor
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ViewInitFields"
    CapMouseOn
End Sub
Private Sub ListCustomerOf(ACustomerkey1 As String, ACustomerkey2 As String)
Dim la_Columns(6) As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ListCustomerOf", "ACustomerkey1=" & ACustomerkey1, "ACustomerkey2=" & ACustomerkey2
    #End If
    
    If Not (ACustomerkey1 <> "" And ACustomerkey2 <> "") Then GoTo Trace_End

    grdlst.ResetGrid
    grdlst.MultiSelect = False
    
    la_Columns(0) = "MEM_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "MEM_code" & CH_LDELIMIT & "MEM_code"
    la_Columns(1) = "Language_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "2" & CH_LDELIMIT & "Language_code" & CH_LDELIMIT & "Language_code"
    la_Columns(2) = "z_creation" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creation" & CH_LDELIMIT & "z_creation"
    la_Columns(3) = "z_creator" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creator" & CH_LDELIMIT & "z_creator"
    la_Columns(4) = "MEM_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "MEM_desc" & CH_LDELIMIT & "MEM_desc"
    la_Columns(5) = "CNT_lastname" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_lastname" & CH_LDELIMIT & "CNT_lastname"
    la_Columns(6) = "SP_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_desc" & CH_LDELIMIT & "SP_desc"
    
    grdlst.SetColumns la_Columns
    grdlst.LoadConstants ptSQL, "EXEC screen_csts_lst2 'cap_MemoOfCustomer_Short', 'grid', '" & m_Language & "'", ctColumns
    
    grdlst.Requests = "exec Cap_MemoCustomer_t_lst2 '" & ACustomerkey1 & "','" & m_Language & "'"
    If grdlst.Execute = False Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grdlst.ArmDb, "CapMem:ListCustomerOf", "Requests=", grdlst.Requests
    End If

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ListCustomerOf"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ListCustomerOf"
    CapMouseOn
End Sub
Private Sub ListProjectOf(AProjectKey1 As String, AProjectKey2 As String)
Dim la_Columns(6) As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ListProjectOf", "AProjectKey1=" & AProjectKey1, "AProjectKey2=" & AProjectKey2
    #End If
    
    If Not (AProjectKey1 <> "" And AProjectKey2 <> "") Then GoTo Trace_End

    grdlst.ResetGrid
    grdlst.MultiSelect = False
    
    la_Columns(0) = "MEM_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "MEM_code" & CH_LDELIMIT & "MEM_code"
    la_Columns(1) = "Language_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "2" & CH_LDELIMIT & "Language_code" & CH_LDELIMIT & "Language_code"
    la_Columns(2) = "z_creation" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creation" & CH_LDELIMIT & "z_creation"
    la_Columns(3) = "z_creator" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creator" & CH_LDELIMIT & "z_creator"
    la_Columns(4) = "MEM_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "MEM_desc" & CH_LDELIMIT & "MEM_desc"
    la_Columns(5) = "CNT_lastname" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CNT_lastname" & CH_LDELIMIT & "CNT_lastname"
    la_Columns(6) = "CCU_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_desc" & CH_LDELIMIT & "CCU_desc"
    
    grdlst.SetColumns la_Columns
    grdlst.LoadConstants ptSQL, "EXEC screen_csts_lst2 'cap_MemoOfProject_Short', 'grid', '" & m_Language & "'", ctColumns
    
    grdlst.Requests = "exec Cap_MemoProject_t_lst '" & AProjectKey1 & "', '" & m_Language & "'"
    If grdlst.Execute = False Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grdlst.ArmDb, "Capmem:ListProjectOf", "Requests=", grdlst.Requests
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ListProjectOf"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ListProjectOf"
    CapMouseOn
End Sub

Private Sub ListContactOf(AContactKey1 As String, AContactKey2 As String, AContactKey3 As String)
Dim la_Columns(6) As String

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:ListContactOf", "AContactKey1=" & AContactKey1, "AContactKey2=" & AContactKey2, "AContactKey3=" & AContactKey3
    #End If
    
    If Not (AContactKey1 <> "" And AContactKey2 <> "" And AContactKey3 <> "") Then GoTo Trace_End

    grdlst.ResetGrid
    grdlst.MultiSelect = False
    
    la_Columns(0) = "MEM_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "1" & CH_LDELIMIT & "MEM_code" & CH_LDELIMIT & "MEM_code"
    la_Columns(1) = "Language_code" & CH_LDELIMIT & "0" & CH_LDELIMIT & "2" & CH_LDELIMIT & "Language_code" & CH_LDELIMIT & "Language_code"
    la_Columns(2) = "z_creation" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creation" & CH_LDELIMIT & "z_creation"
    la_Columns(3) = "z_creator" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "z_creator" & CH_LDELIMIT & "z_creator"
    la_Columns(4) = "MEM_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "MEM_desc" & CH_LDELIMIT & "MEM_desc"
    la_Columns(5) = "CCU_Desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "CCU_Desc" & CH_LDELIMIT & "CCU_Desc"
    la_Columns(6) = "SP_desc" & CH_LDELIMIT & "1500" & CH_LDELIMIT & "0" & CH_LDELIMIT & "SP_desc" & CH_LDELIMIT & "SP_desc"
    
    grdlst.SetColumns la_Columns
    grdlst.LoadConstants ptSQL, "EXEC screen_csts_lst2 'cap_MemoOfContact_Short', 'grid', '" & m_Language & "'", ctColumns
    
    grdlst.Requests = "exec Cap_MemoContact_t_lst '" & AContactKey1 & "', '" & AContactKey2 & "','" & m_Language & "'"
    If grdlst.Execute = False Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError grdlst.ArmDb, "CapMem:ListContactOf", "Requests=", grdlst.Requests
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:ListContactOf"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:ListContactOf"
    CapMouseOn
End Sub

Private Sub srch_Customer_OnDelete()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "capmem:srch_Customer_OnDelete"
    #End If
    
    srch_contact.Clear
    srch_contact.CodeProject = srch_project.Key1
    srch_contact.TypeSearch = "Contact"

Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "capmem:srch_Customer_OnDelete"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "capmem:srch_Customer_OnDelete"
    CapMouseOn
End Sub

' This function is called by the application when the component embedded is updated
Public Sub Embedded_Updated()
' DO NOTHING
End Sub

