VERSION 5.00
Begin VB.Form Sample_Upd 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Sample"
   ClientHeight    =   4740
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4935
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4740
   ScaleWidth      =   4935
   StartUpPosition =   2  'CenterScreen
   Tag             =   "title"
   Begin VB.Frame frmMain 
      BorderStyle     =   0  'None
      Height          =   3855
      Left            =   45
      TabIndex        =   1
      Top             =   870
      Width           =   4875
      Begin VB.TextBox txt_Qty_sent 
         Height          =   315
         Left            =   3885
         TabIndex        =   14
         Top             =   570
         Width           =   855
      End
      Begin Project1.ArmCombobox cbo_edge 
         Height          =   345
         Left            =   1320
         TabIndex        =   12
         Top             =   1560
         Width           =   3435
         _ExtentX        =   6059
         _ExtentY        =   609
      End
      Begin VB.TextBox txt_SampleDoc 
         Enabled         =   0   'False
         Height          =   315
         Left            =   1740
         Locked          =   -1  'True
         TabIndex        =   7
         Top             =   195
         Width           =   3000
      End
      Begin VB.TextBox txt_Qty 
         Height          =   315
         Left            =   1740
         TabIndex        =   6
         Top             =   555
         Width           =   855
      End
      Begin VB.TextBox txt_comment 
         Height          =   1395
         Left            =   105
         MaxLength       =   254
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   5
         Top             =   2340
         Width           =   4665
      End
      Begin VB.Frame Frame1 
         Height          =   555
         Left            =   105
         TabIndex        =   2
         Top             =   870
         Width           =   4650
         Begin VB.OptionButton Option1 
            Caption         =   "#Hand sample"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   240
            TabIndex        =   4
            Tag             =   "opt_Hand"
            Top             =   210
            Width           =   1815
         End
         Begin VB.OptionButton Option2 
            Caption         =   "#Full size sample"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   2445
            TabIndex        =   3
            Tag             =   "opt_Full"
            Top             =   195
            Width           =   2085
         End
      End
      Begin VB.Label lbl_Qty_sent 
         Alignment       =   1  'Right Justify
         Caption         =   "#sent"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2700
         TabIndex        =   13
         Tag             =   "lbl_Qty_sent"
         Top             =   615
         Width           =   1095
      End
      Begin VB.Label lbl_SampleDoc 
         Caption         =   "#Sample doc"
         Height          =   255
         Left            =   105
         TabIndex        =   11
         Tag             =   "lbl_SampleDoc"
         Top             =   240
         Width           =   1500
      End
      Begin VB.Label lbl_Qty 
         Caption         =   "#Quantity"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   105
         TabIndex        =   10
         Tag             =   "lbl_Qty"
         Top             =   600
         Width           =   1500
      End
      Begin VB.Label lbl_Edge 
         Caption         =   "#Edge detail"
         Height          =   255
         Left            =   105
         TabIndex        =   9
         Tag             =   "lbl_Edge"
         Top             =   1665
         Width           =   1500
      End
      Begin VB.Label lbl_comment 
         Caption         =   "#Comment"
         Height          =   255
         Left            =   105
         TabIndex        =   8
         Tag             =   "lbl_Comment"
         Top             =   2100
         Width           =   1500
      End
   End
   Begin Project1.ToolBr toolbar 
      Align           =   1  'Align Top
      Height          =   435
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   4935
      _ExtentX        =   8705
      _ExtentY        =   767
   End
End
Attribute VB_Name = "Sample_Upd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'Curseur & données
Private mo_ArmDb As Object
Private mb_Created As Boolean
Private mb_use_framework_connection As Boolean
Private ms_ConnectString As String
Private ms_UID As String

Private m_Language As String

Private ms_ActionType As String
Private ms_SampleDoc As String
Private ms_Quantity As String
Private ms_QuantitySent As String
Private mb_QtySentEdit As Boolean           ' if quantity sent is editable
Private ms_HF As String
Private ms_EdgeDetailCode As String
Private ms_EdgeDetailDesc As String
Private ms_Comment As String
Private mb_Valid As Boolean
Private ms_ActionSample As String

Public Property Set ArmDb(ByRef ao_local_connection As Object)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd: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 toolbar.ArmDb = mo_ArmDb
        Set cbo_edge.ArmDb = mo_ArmDb
    End If
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd: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, "Sample_Upd:ConnectString_Let", "as_ConnectString=" & as_ConnectString
    #End If
    CapMouseOff
    
    ms_UID = ConnectionStringValidation(as_ConnectString)
    If ms_UID = "" Then GoTo Trace_End
    
    ms_ConnectString = as_ConnectString
    
    toolbar.ConnectString = ms_ConnectString
    cbo_edge.ConnectString = ms_ConnectString
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:ConnectString_Let"
    #End If
    CapMouseOn
End Property

Property Let Language(ALng As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:Language_Let", "ALng=" & ALng
    #End If
    CapMouseOff
    
    m_Language = ALng
    
    toolbar.Language = m_Language
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:Language_Let"
    #End If
    CapMouseOn
End Property

Public Property Let ActionType(ByVal as_ActionType As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:ActionType_Let", "as_ActionType=" & as_ActionType
    #End If
    CapMouseOff
    
    ms_ActionType = as_ActionType
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:ActionType_Let"
    #End If
    CapMouseOn
End Property

Public Property Let ActionSample(ByVal as_ActionSample As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:ActionSample_Let", "as_ActionSample=" & as_ActionSample
    #End If
    CapMouseOff
    
    ms_ActionSample = as_ActionSample
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:ActionSample_Let"
    #End If
    CapMouseOn
End Property

Public Property Get Quantity() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:Quantity_Get"
    #End If
    CapMouseOff
    
    Quantity = txt_Qty.Text
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:Quantity_Get", "Result=" & Quantity
    #End If
    CapMouseOn
End Property

Public Property Let Quantity(ByVal as_Quantity As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:Quantity_Let", "as_Quantity=" & as_Quantity
    #End If
    CapMouseOff
    
    ms_Quantity = as_Quantity
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:Quantity_Let"
    #End If
    CapMouseOn
End Property

Public Property Let QuantitySent(ByVal as_QuantitySent As String)
    ms_QuantitySent = as_QuantitySent
End Property

Public Property Get QuantitySent() As String
    QuantitySent = txt_Qty_sent.Text
End Property

Public Property Let QuantitySentEdit(ByVal ab_allowEdit As Boolean)
    mb_QtySentEdit = ab_allowEdit
End Property

Public Property Get HF() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:HF_Get"
    #End If
    CapMouseOff
    
    If Option1.Value = True Then
        HF = "H"
    Else
        HF = "F"
    End If
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:HF_Get", "Result=" & HF
    #End If
    CapMouseOn
End Property

Public Property Let HF(ByVal as_HF As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:HF_Let", "as_HF=" & as_HF
    #End If
    CapMouseOff
    
    ms_HF = as_HF
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:HF_Let"
    #End If
    CapMouseOn
End Property

Public Property Get EdgeDetailCode() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:EdgeDetailCode_Get"
    #End If
    CapMouseOff
    
    EdgeDetailCode = GetCodeFromCombo(cbo_edge)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:EdgeDetailCode_Get", "Result=" & EdgeDetailCode
    #End If
    CapMouseOn
End Property

Public Property Let EdgeDetailCode(ByVal as_EdgeDetailCode As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:EdgeDetailCode_Let", "as_EdgeDetailCode=" & as_EdgeDetailCode
    #End If
    CapMouseOff
    
    ms_EdgeDetailCode = as_EdgeDetailCode
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:EdgeDetailCode_Let"
    #End If
    CapMouseOn
End Property

Public Property Get EdgeDetailDesc() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:EdgeDetailDesc_Get"
    #End If
    CapMouseOff
    
    EdgeDetailDesc = GetTextFromCombo(cbo_edge)
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:EdgeDetailDesc_Get", "Result=" & EdgeDetailDesc
    #End If
    CapMouseOn
End Property

Public Property Let EdgeDetailDesc(ByVal as_EdgeDetailDesc As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:EdgeDetailDesc_Let", "as_EdgeDetailDesc=" & as_EdgeDetailDesc
    #End If
    CapMouseOff
    
    ms_EdgeDetailDesc = as_EdgeDetailDesc
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:EdgeDetailDesc_Let"
    #End If
    CapMouseOn
End Property

Public Property Get Comment() As String
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:Comment_Get"
    #End If
    CapMouseOff
    
    Comment = txt_Comment.Text
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:Comment_Get", "Result=" & Comment
    #End If
    CapMouseOn
End Property

Public Property Let Comment(ByVal as_Comment As String)
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:Comment_Let", "as_Comment=" & as_Comment
    #End If
    CapMouseOff
    
    ms_Comment = as_Comment
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:Comment_Let"
    #End If
    CapMouseOn
End Property

Public Property Get Valid() As Boolean
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:Valid_Get"
    #End If
    CapMouseOff
    
    Valid = mb_Valid
    
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:Valid_Get", "Result=" & Valid
    #End If
    CapMouseOn
End Property

Private Sub UpdateLock()

    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:UpdateLock"
    #End If
        
    frmMain.Enabled = True
    txt_SampleDoc.Enabled = False
    txt_Qty_sent.Visible = mb_QtySentEdit
    lbl_Qty_sent.Visible = mb_QtySentEdit
    txt_Qty.Locked = mb_QtySentEdit
    Frame1.Enabled = Not mb_QtySentEdit
    cbo_edge.Enabled = Not mb_QtySentEdit

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


Private Sub UpdateInitFields()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:UpdateInitFields"
    #End If
        
    txt_SampleDoc.Text = ms_ActionSample
    txt_Qty.Text = IIf(ms_Quantity = "0", "1", ms_Quantity)
    txt_Qty_sent.Text = IIf(ms_QuantitySent = "", txt_Qty.Text, ms_QuantitySent)
    Select Case ms_HF
        Case "H"
            Option1.Value = True
        Case "F"
            Option2.Value = True
        Case Else
            Option1.Value = True
    End Select
    txt_Comment.Text = ms_Comment
    
    cbo_edge.Clear
    cbo_edge.FirstBlankItem = True
    cbo_edge.Request = "Exec products_edges_cbo 'C001', " & "'" & m_Language & "'"
    If ms_EdgeDetailCode <> "" Then
        cbo_edge.AddItem Array(ms_EdgeDetailCode, ms_EdgeDetailDesc), True
    End If
    
    Select Case UCase$(ms_ActionType)
    Case "7" 'Sample
        Frame1.Visible = True
        lbl_Edge.Visible = True
        cbo_edge.Visible = True
        lbl_comment.Top = cbo_edge.Top + cbo_edge.Height + 45
    Case Else
        Frame1.Visible = False
        lbl_Edge.Visible = False
        cbo_edge.Visible = False
        lbl_comment.Top = Frame1.Top + 45
    End Select
    txt_Comment.Top = lbl_comment.Top + lbl_comment.Height + 45
    txt_Comment.Height = frmMain.Height - txt_Comment.Top - 90
    
Trace_End:
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "Sample_Upd:UpdateInitFields"
    #End If
    CapMouseOn
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "Sample_Upd:UpdateInitFields"
    CapMouseOn
End Sub

Public Sub Load_A_COM()
    On Error GoTo Trace_Err
    CapMouseOff
    #If CapDebug Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "Sample_Upd:Load_A_Com"
    #End If
    
    VerifyInitialization mo_ArmDb, ms_ConnectString, m_Language, Me
    
    mb_Valid = False
    
    toolbar.Load_A_COM
    toolbar.ClearAllIcons
    toolbar.PictureDisplayed = "P_Valid=1 P_Undo=2 P_Quit=-1"
    cbo_edge.Load_A_COM
    
    UpdateInitFields
    
    UpdateLock
    
    LoadLabels mo_ArmDb, Me.Controls, "Cap_ActionSample", m_Language

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

Private Sub toolbar_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, "Sample_Upd:toolbar_action", "as_ActionType=" & as_ActionType
    #End If
        
    Select Case as_ActionType
        Case "Quit"
            Me.Hide
                
        Case "Undo"
           UpdateInitFields
         
        Case "Valid"
            ErrorOFF
            txt_Qty.Text = CorrectDec(mo_ArmDb, m_Language, txt_Qty, True, True, True)
            If txt_Qty.Text = "" Then
                GoTo Trace_End
            End If
            
            If InStr(1, txt_Qty.Text, ".") <> 0 Then
                Call ASC_SendMessage(mo_ArmDb, m_Language, 990, "#Incorrect value.")
                txt_Qty.SetFocus
                GoTo Trace_End
            End If
            
            txt_Qty.Text = CLng(txt_Qty.Text)
            
            txt_Qty_sent.Text = CorrectDec(mo_ArmDb, m_Language, txt_Qty_sent, True, True, False)
            If txt_Qty_sent.Text = "" Then
                GoTo Trace_End
            End If
            
            If InStr(1, txt_Qty_sent.Text, ".") <> 0 Then
                Call ASC_SendMessage(mo_ArmDb, m_Language, 990, "#Incorrect value.")
                txt_Qty_sent.SetFocus
                GoTo Trace_End
            End If

            txt_Qty_sent.Text = CLng(txt_Qty_sent.Text)
            
            If CLng(txt_Qty_sent.Text) > CLng(txt_Qty.Text) Then
                Call ASC_SendMessage(mo_ArmDb, m_Language, 991, "#Quantity sent cannot be more than quantity required.")
                GoTo Trace_End
            End If
            
            mb_Valid = True
            Me.Hide
            
        Case Else
            Me.Hide
            
    End Select

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