VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form Quot_General_View 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   7455
   ClientLeft      =   240
   ClientTop       =   495
   ClientWidth     =   8160
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   7455
   ScaleWidth      =   8160
   ShowInTaskbar   =   0   'False
   Begin MSFlexGridLib.MSFlexGrid Grid 
      Height          =   675
      Left            =   60
      TabIndex        =   62
      Top             =   6720
      Visible         =   0   'False
      Width           =   3555
      _ExtentX        =   6271
      _ExtentY        =   1191
      _Version        =   393216
      SelectionMode   =   1
      AllowUserResizing=   1
   End
   Begin MSFlexGridLib.MSFlexGrid GridComment 
      Height          =   675
      Left            =   3720
      TabIndex        =   61
      Top             =   6720
      Visible         =   0   'False
      Width           =   3615
      _ExtentX        =   6376
      _ExtentY        =   1191
      _Version        =   393216
      AllowBigSelection=   0   'False
      SelectionMode   =   1
      AllowUserResizing=   2
   End
   Begin VB.ListBox lst_UpdateQuotation 
      Height          =   1035
      ItemData        =   "Q_General_View.frx":0000
      Left            =   5580
      List            =   "Q_General_View.frx":0002
      TabIndex        =   24
      Top             =   1560
      Visible         =   0   'False
      Width           =   2220
   End
   Begin VB.TextBox txt_QuotationLanguage 
      Height          =   315
      Left            =   3300
      Locked          =   -1  'True
      TabIndex        =   4
      TabStop         =   0   'False
      Top             =   720
      Width           =   2415
   End
   Begin VB.ListBox lst_AddQuotation 
      Height          =   1035
      ItemData        =   "Q_General_View.frx":0004
      Left            =   5580
      List            =   "Q_General_View.frx":0006
      TabIndex        =   22
      Top             =   1080
      Width           =   2220
   End
   Begin VB.Frame frm_Users 
      Height          =   1755
      Left            =   15
      TabIndex        =   54
      Top             =   1320
      Width           =   3675
      Begin VB.TextBox txt_Creator 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   5
         TabStop         =   0   'False
         Top             =   180
         Width           =   2415
      End
      Begin VB.TextBox txt_Approval 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   6
         TabStop         =   0   'False
         Top             =   720
         Width           =   2415
      End
      Begin VB.TextBox txt_ApprovalDate 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   7
         TabStop         =   0   'False
         Top             =   1260
         Width           =   2415
      End
      Begin VB.Label lbl_Creator 
         Caption         =   "Creator"
         Height          =   435
         Left            =   60
         TabIndex        =   57
         Top             =   180
         Width           =   1095
      End
      Begin VB.Label lbl_Approval 
         Caption         =   "Approval"
         Height          =   435
         Left            =   60
         TabIndex        =   56
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label lbl_ApprovalDate 
         Caption         =   "Approval Date"
         Height          =   435
         Left            =   60
         TabIndex        =   55
         Top             =   1260
         Width           =   1095
      End
   End
   Begin VB.Frame frm_Armstrong 
      Height          =   4035
      Left            =   3720
      TabIndex        =   49
      Top             =   1320
      Width           =   3675
      Begin VB.TextBox txt_SalesOffice 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   16
         TabStop         =   0   'False
         Top             =   1800
         Width           =   2415
      End
      Begin VB.TextBox txt_Plant 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   13
         TabStop         =   0   'False
         Top             =   180
         Width           =   2415
      End
      Begin VB.CommandButton btn_SalesRep 
         Caption         =   "Sales Rep"
         Height          =   315
         Left            =   900
         TabIndex        =   17
         Top             =   2340
         Width           =   1695
      End
      Begin VB.TextBox txt_DeliveryDate 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   14
         TabStop         =   0   'False
         Top             =   720
         Width           =   2415
      End
      Begin VB.TextBox txt_ValidityDate 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   15
         TabStop         =   0   'False
         Top             =   1260
         Width           =   2415
      End
      Begin VB.ListBox lst_SalesReps 
         Height          =   1230
         Left            =   300
         TabIndex        =   18
         Top             =   2700
         Visible         =   0   'False
         Width           =   3075
      End
      Begin VB.Label lbl_DeliveryDate 
         Caption         =   "Expected Delivery Date"
         Height          =   435
         Left            =   60
         TabIndex        =   51
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label lbl_Plant 
         Caption         =   "Default Plant"
         Height          =   435
         Left            =   60
         TabIndex        =   53
         Top             =   180
         Width           =   1095
      End
      Begin VB.Label lbl_SalesOffice 
         Caption         =   "Sales Office"
         Height          =   435
         Left            =   60
         TabIndex        =   52
         Top             =   1800
         Width           =   1095
      End
      Begin VB.Label lbl_ValidityDate 
         Caption         =   "Validity Date"
         Height          =   435
         Left            =   60
         TabIndex        =   50
         Top             =   1260
         Width           =   1095
      End
   End
   Begin VB.Frame frm_Customer 
      Height          =   1575
      Left            =   0
      TabIndex        =   46
      Top             =   3120
      Width           =   3675
      Begin VB.TextBox Txt_Contractor 
         Height          =   315
         Left            =   1140
         TabIndex        =   59
         TabStop         =   0   'False
         Top             =   680
         Width           =   2415
      End
      Begin VB.TextBox txt_Currency 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   9
         TabStop         =   0   'False
         Top             =   1080
         Width           =   2415
      End
      Begin VB.TextBox txt_Customer 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   8
         TabStop         =   0   'False
         Top             =   300
         Width           =   2415
      End
      Begin VB.Label Lbl_Contractor 
         Caption         =   "Contractor1"
         Height          =   255
         Left            =   60
         TabIndex        =   60
         Top             =   750
         Width           =   1575
      End
      Begin VB.Label lbl_Currency 
         Caption         =   "Currency"
         Height          =   435
         Left            =   60
         TabIndex        =   48
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label lbl_Customer 
         Caption         =   "Customer"
         Height          =   435
         Left            =   60
         TabIndex        =   47
         Top             =   300
         Width           =   1095
      End
   End
   Begin VB.Frame frm_Quotation 
      Height          =   1095
      Left            =   3720
      TabIndex        =   43
      Top             =   5520
      Width           =   3675
      Begin VB.TextBox txt_LoseReason 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   19
         TabStop         =   0   'False
         Top             =   180
         Width           =   2415
      End
      Begin VB.TextBox txt_SapOrder 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   20
         TabStop         =   0   'False
         Top             =   645
         Width           =   2415
      End
      Begin VB.Label lbl_LoseReason 
         Caption         =   "Lose Reason"
         Height          =   435
         Left            =   60
         TabIndex        =   45
         Top             =   180
         Width           =   1095
      End
      Begin VB.Label lbl_SapOrder 
         Caption         =   "SAP Order"
         Height          =   375
         Left            =   60
         TabIndex        =   44
         Top             =   660
         Width           =   1095
      End
   End
   Begin VB.Frame frm_Information 
      Height          =   1755
      Left            =   0
      TabIndex        =   39
      Top             =   4860
      Width           =   3675
      Begin VB.TextBox txt_LeadTime 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   12
         TabStop         =   0   'False
         Top             =   1260
         Width           =   2415
      End
      Begin VB.TextBox txt_TotalAmount 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   11
         TabStop         =   0   'False
         Top             =   720
         Width           =   2415
      End
      Begin VB.TextBox txt_TotalSurface 
         Height          =   315
         Left            =   1140
         Locked          =   -1  'True
         TabIndex        =   10
         TabStop         =   0   'False
         Top             =   180
         Width           =   2415
      End
      Begin VB.Label lbl_LeadTime 
         Caption         =   "Lead Time"
         Height          =   435
         Left            =   60
         TabIndex        =   42
         Top             =   1260
         Width           =   1095
      End
      Begin VB.Label lbl_TotalAmount 
         Caption         =   "Total Amount"
         Height          =   435
         Left            =   60
         TabIndex        =   41
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label lbl_TotalSurface 
         Caption         =   "Total Surface"
         Height          =   435
         Left            =   60
         TabIndex        =   40
         Top             =   180
         Width           =   1095
      End
   End
   Begin VB.TextBox txt_QuotationStatus 
      Height          =   315
      Left            =   5220
      Locked          =   -1  'True
      TabIndex        =   3
      TabStop         =   0   'False
      Top             =   0
      Width           =   2775
   End
   Begin VB.Frame SeparateLine 
      Height          =   75
      Left            =   0
      TabIndex        =   35
      Top             =   420
      Width           =   8115
   End
   Begin VB.ComboBox cbo_QuotationVersion 
      Height          =   315
      Left            =   3660
      Style           =   2  'Dropdown List
      TabIndex        =   2
      Top             =   0
      Width           =   615
   End
   Begin VB.TextBox txt_QuotationCode 
      Height          =   315
      Left            =   720
      Locked          =   -1  'True
      TabIndex        =   1
      TabStop         =   0   'False
      Top             =   0
      Width           =   1935
   End
   Begin VB.PictureBox ButtonBox 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ClipControls    =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   6675
      Left            =   7450
      ScaleHeight     =   6645
      ScaleWidth      =   630
      TabIndex        =   0
      Top             =   720
      Width           =   665
      Begin VB.PictureBox pic_Order 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   26
         Top             =   1800
         Width           =   480
      End
      Begin VB.PictureBox pic_Language 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   31
         Top             =   4800
         Width           =   480
      End
      Begin VB.PictureBox pic_help 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   8640
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   33
         Top             =   120
         Width           =   384
      End
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   30
         Top             =   4200
         Width           =   480
      End
      Begin VB.PictureBox pic_add 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   21
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_upd 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   23
         Top             =   600
         Width           =   480
      End
      Begin VB.PictureBox pic_delete 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   25
         Top             =   1200
         Width           =   480
      End
      Begin VB.PictureBox pic_search 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   1920
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   32
         Top             =   120
         Width           =   384
      End
      Begin VB.PictureBox pic_print 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   28
         Top             =   3000
         Width           =   480
      End
      Begin VB.PictureBox pic_log 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   27
         Top             =   2400
         Width           =   480
      End
      Begin VB.PictureBox pic_refresh 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DrawStyle       =   5  'Transparent
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   29
         Top             =   3600
         Width           =   480
      End
   End
   Begin VB.Label lbl_QuotationLanguage 
      Caption         =   "Quotation Language"
      Height          =   435
      Left            =   1740
      TabIndex        =   58
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label lbl_QuotationCode 
      Caption         =   "Code"
      Height          =   315
      Left            =   120
      TabIndex        =   38
      Top             =   60
      Width           =   615
   End
   Begin VB.Label lbl_QuotationStatus 
      Caption         =   "Status"
      Height          =   315
      Left            =   4500
      TabIndex        =   37
      Top             =   60
      Width           =   735
   End
   Begin VB.Label lbl_QuotationVersion 
      Caption         =   "Version"
      Height          =   315
      Left            =   2940
      TabIndex        =   36
      Top             =   60
      Width           =   735
   End
   Begin VB.Label lbl_MessageCount 
      Height          =   312
      Left            =   8640
      TabIndex        =   34
      Top             =   5820
      Visible         =   0   'False
      Width           =   552
   End
End
Attribute VB_Name = "Quot_General_View"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Const LST_AQ_NEW = 1
Const LST_AQ_NEW_VERSION = 2
Const LST_AQ_COPY = 3

Public mi_TopForm As Integer
Public mi_LeftForm As Integer

Private ms_QuotationLanguageDesc As String

Private ms_UpdateLabel As String

Private mi_iConcurrency As Integer
Private ml_CustomerCode As Long
Private ms_CurrencyCode As String
Private mi_DeliveryAddressCode As Integer
Private ms_DeliveryAddressDesc As String
Private ml_SalesProjectCode As Long
Private ms_SalesProjectDesc As String
Private mi_SalesOfficeCode As String
Private ms_PlantCode As String
Private mi_LoseReasonCode As Integer
Private mo_SalesRepCode As New Collection
Private ms_DropFlag As String

Private Sub Btn_SalesRep_Click()

    If Lst_SalesReps.Visible = KO Then
        Lst_SalesReps.Visible = OK
        
        If Lst_SalesReps.Tag = UNLOADED Then
        
            MouseOff
            
            Quotation_ReadSalesRep gi_QuotationCode, gi_QuotationVersion, mo_SalesRepCode, Lst_SalesReps
            
            MouseOn
        End If
    Else
        Lst_SalesReps.Visible = KO
    End If
    
End Sub

Private Sub Cbo_QuotationVersion_Click()

    MouseOff

    If Quotation_UpdateCommonInformation(txt_QuotationStatus, cbo_QuotationVersion) = OK Then
        ReadQuotation gi_QuotationCode, gi_QuotationVersion
    End If

    MouseOn

End Sub

Private Sub Form_Click()
    lst_AddQuotation.Visible = KO
    lst_UpdateQuotation.Visible = KO
End Sub

Private Sub Form_Load()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim li_MaxVersion As Integer
Dim i As Integer

    MouseOff
    
    If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me
    
    Me.top = mi_TopForm
    Me.left = mi_LeftForm
    
    'Initialize the pictures
    pic_add.Picture = LoadResPicture(RES_ADD, 1)
    pic_upd.Picture = LoadResPicture(RES_MODIFY, 1)
    pic_help.Picture = LoadResPicture(RES_HELP, 1)
    pic_Log.Picture = LoadResPicture(RES_LOG, 1)
    pic_print.Picture = LoadResPicture(RES_PRINT, 1)
    pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
    pic_Refresh.Picture = LoadResPicture(RES_REFRESH, 1)

    lst_AddQuotation.Visible = KO
    pic_delete.Visible = KO
    pic_search.Visible = KO

    If gut_Actor.MSC = KO Then
        pic_add.Visible = KO
    End If

    'Initialize the listbox to unloaded status
    Lst_SalesReps.Tag = UNLOADED

    'Fill the captions
    GetCaptions

    'Fill the common element
    'and all the click event of the combobox
    Quotation_View_Load txt_QuotationCode, txt_QuotationStatus, cbo_QuotationVersion

End Sub

Private Sub lst_AddQuotation_Click()
Dim i As Integer

    If lst_AddQuotation.ListIndex = -1 Then Exit Sub

    On Error GoTo lst_AddQuotation_Err
    
    lst_AddQuotation.Visible = KO
    Select Case lst_AddQuotation.ItemData(lst_AddQuotation.ListIndex)
    Case LST_AQ_NEW

        Quotation_AddNew Me.left, Me.top
        
    Case LST_AQ_NEW_VERSION
        
        MouseOff
        
        Quot_General_mtnc.mi_Action = QA_NewVersion
        
        'We select and read the last version
        cbo_QuotationVersion.ListIndex = cbo_QuotationVersion.ListCount - 1
        
        If gi_QuotationStatusCode = Quotation_Status.closed Then
            MsgBox "You can not create a new version of a closed quotation"
            MouseOn
            Exit Sub
        End If
        
        If gi_QuotationStatusCode = Quotation_Status.Archived Then
            MsgBox "You can not create a new version of an archived quotation"
            MouseOn
            Exit Sub
        End If
        
        For i = Quot_General_mtnc.mo_SalesRepCode.Count To 1 Step -1
            Quot_General_mtnc.mo_SalesRepCode.Remove i
        Next
        For i = Quot_General_mtnc.mo_SalesRepDesc.Count To 1 Step -1
            Quot_General_mtnc.mo_SalesRepDesc.Remove i
        Next
        
        If Lst_SalesReps.Tag = Loaded Then
            Quot_General_mtnc.mb_SalesRepLoaded = OK
            For i = 1 To mo_SalesRepCode.Count
                Quot_General_mtnc.mo_SalesRepCode.Add mo_SalesRepCode.Item(i)
                Quot_General_mtnc.mo_SalesRepDesc.Add Lst_SalesReps.List(i - 1)
            Next
        Else
            Quot_General_mtnc.mb_SalesRepLoaded = KO
        End If
        
        Quot_General_mtnc.mi_iConcurrency = mi_iConcurrency
        If Txt_TotalSurface.Text <> "" Then
            Quot_General_mtnc.ml_TotalSurface = CLng(Txt_TotalSurface.Text)
        Else
            Quot_General_mtnc.ml_TotalSurface = 0
        End If
        If Txt_TotalAmount.Text <> "" Then
            Quot_General_mtnc.mr_TotalAmount = Val(Txt_TotalAmount.Text)
        Else
            Quot_General_mtnc.mr_TotalAmount = 0
        End If
        If txt_LeadTime.Text <> "" Then
            Quot_General_mtnc.mr_LeadTime = Val(txt_LeadTime.Text)
        Else
            Quot_General_mtnc.mr_LeadTime = 0
        End If
        
        Quot_General_mtnc.ms_LanguageCode = gs_QuotationLanguageCode
        Quot_General_mtnc.ms_LanguageDesc = txt_QuotationLanguage.Text
        Quot_General_mtnc.ml_ClaimCustomerCode = ml_CustomerCode
        Quot_General_mtnc.ms_ClaimCustomerDesc = Txt_Customer.Text
        Quot_General_mtnc.mi_DeliveryAddressCode = mi_DeliveryAddressCode
        Quot_General_mtnc.ms_DeliveryAddressDesc = ms_DeliveryAddressDesc
        Quot_General_mtnc.ms_PlantCode = ms_PlantCode
        Quot_General_mtnc.ms_PlantDesc = txt_Plant.Text
        Quot_General_mtnc.ml_SalesProjectCode = ml_SalesProjectCode
        Quot_General_mtnc.ms_SalesProjectDesc = ms_SalesProjectDesc
        Quot_General_mtnc.ms_Contractor = Txt_Contractor.Text
        Quot_General_mtnc.ms_SalesOfficeCode = mi_SalesOfficeCode
        Quot_General_mtnc.ms_SalesOfficeDesc = txt_SalesOffice.Text
        Quot_General_mtnc.ms_CurrencyCode = ms_CurrencyCode
        Quot_General_mtnc.ms_currencyDesc = txt_Currency.Text
        Quot_General_mtnc.mi_QuotationCode = gi_QuotationCode
        Quot_General_mtnc.ms_QuotationDesc = txt_QuotationCode.Text
        Quot_General_mtnc.mi_QuotationVersion = CInt(cbo_QuotationVersion.Text) + 1
        Quot_General_mtnc.mi_QuotationStatusCode = Quotation_Status.opened
        Quot_General_mtnc.mi_QuotationStatusDesc = Quotation_Status_Desc(Quotation_Status.opened, gs_QuotationLanguageCode)
        Quot_General_mtnc.ms_Creator = Txt_Creator.Text
        Quot_General_mtnc.ms_Approval = "" 'This version is no more approval
        Quot_General_mtnc.ms_DeliveryDate = txt_DeliveryDate.Text
        Quot_General_mtnc.ms_ValidityDate = txt_ValidityDate.Text
        Quot_General_mtnc.ms_ApprovalDate = "" 'This version is no more approval
        Quot_General_mtnc.ms_InternetFlag = KO
        Quot_General_mtnc.ms_DropDate = ""
        Quot_General_mtnc.ms_SAPOrder = Txt_SapOrder.Text
        Quot_General_mtnc.mi_LoseReasonCode = mi_LoseReasonCode
        Quot_General_mtnc.ms_LoseReasonDesc = txt_LoseReason.Text
    
        MouseOn
    
        Quot_General_mtnc.show 1
    
        If Quot_General_mtnc.mb_Return = OK Then
            Quotation_Change Quot_General_mtnc.mi_QuotationCode, Quot_General_mtnc.ms_QuotationDesc, Me.left, Me.top, 2
            FrmMain.QuotationOutLine.LocalDelItem Quot_General_mtnc.mi_QuotationCode
            FrmMain.QuotationOutLine.LocalAddItem Quot_General_mtnc.mi_QuotationCode, Quot_General_mtnc.ms_QuotationDesc
            'FrmMain.QuotationOutLine.SearchOutline Quot_General_mtnc.mi_QuotationCode
        End If
        
    Case LST_AQ_COPY
        
        MouseOff
        
        Quot_General_mtnc.mi_Action = QA_Copy
        
        'We select and read the last version
        cbo_QuotationVersion.ListIndex = cbo_QuotationVersion.ListCount - 1
        
        For i = Quot_General_mtnc.mo_SalesRepCode.Count To 1 Step -1
            Quot_General_mtnc.mo_SalesRepCode.Remove i
        Next
        For i = Quot_General_mtnc.mo_SalesRepDesc.Count To 1 Step -1
            Quot_General_mtnc.mo_SalesRepDesc.Remove i
        Next
        
        If Lst_SalesReps.Tag = Loaded Then
            Quot_General_mtnc.mb_SalesRepLoaded = OK
            For i = 1 To mo_SalesRepCode.Count
                Quot_General_mtnc.mo_SalesRepCode.Add mo_SalesRepCode.Item(i)
                Quot_General_mtnc.mo_SalesRepDesc.Add Lst_SalesReps.List(i - 1)
            Next
        Else
            Quot_General_mtnc.mb_SalesRepLoaded = KO
        End If
        
        Quot_General_mtnc.mi_iConcurrency = mi_iConcurrency
        If Txt_TotalSurface.Text <> "" Then
            Quot_General_mtnc.ml_TotalSurface = CLng(Txt_TotalSurface.Text)
        Else
            Quot_General_mtnc.ml_TotalSurface = 0
        End If
        If Txt_TotalAmount.Text <> "" Then
            Quot_General_mtnc.mr_TotalAmount = Val(Txt_TotalAmount.Text)
        Else
            Quot_General_mtnc.mr_TotalAmount = 0
        End If
        If txt_LeadTime.Text <> "" Then
            Quot_General_mtnc.mr_LeadTime = Val(txt_LeadTime.Text)
        Else
            Quot_General_mtnc.mr_LeadTime = 0
        End If
        
        Quot_General_mtnc.ms_LanguageCode = gs_QuotationLanguageCode
        Quot_General_mtnc.ms_LanguageDesc = txt_QuotationLanguage.Text
        Quot_General_mtnc.ml_ClaimCustomerCode = ml_CustomerCode
        Quot_General_mtnc.ms_ClaimCustomerDesc = Txt_Customer.Text
        Quot_General_mtnc.mi_DeliveryAddressCode = mi_DeliveryAddressCode
        Quot_General_mtnc.ms_DeliveryAddressDesc = ms_DeliveryAddressDesc
        Quot_General_mtnc.ms_PlantCode = ms_PlantCode
        Quot_General_mtnc.ms_PlantDesc = txt_Plant.Text
        Quot_General_mtnc.ml_SalesProjectCode = ml_SalesProjectCode
        Quot_General_mtnc.ms_SalesProjectDesc = ms_SalesProjectDesc
        Quot_General_mtnc.ms_Contractor = Txt_Contractor.Text
        Quot_General_mtnc.ms_SalesOfficeCode = mi_SalesOfficeCode
        Quot_General_mtnc.ms_SalesOfficeDesc = txt_SalesOffice.Text
        Quot_General_mtnc.ms_CurrencyCode = ms_CurrencyCode
        Quot_General_mtnc.ms_currencyDesc = txt_Currency.Text
        Quot_General_mtnc.mi_QuotationCode = 0
        Quot_General_mtnc.ms_QuotationDesc = ""
        Quot_General_mtnc.mi_QuotationVersion = 1
        Quot_General_mtnc.mi_QuotationStatusCode = Quotation_Status.opened
        Quot_General_mtnc.mi_QuotationStatusDesc = Quotation_Status_Desc(Quotation_Status.opened, gs_QuotationLanguageCode)
        Quot_General_mtnc.ms_Creator = Txt_Creator.Text
        Quot_General_mtnc.ms_Approval = "" 'This version is no more approval
        Quot_General_mtnc.ms_DeliveryDate = txt_DeliveryDate.Text
        Quot_General_mtnc.ms_ValidityDate = txt_ValidityDate.Text
        Quot_General_mtnc.ms_ApprovalDate = "" 'This version is no more approval
        Quot_General_mtnc.ms_InternetFlag = KO
        Quot_General_mtnc.ms_DropDate = ""
        Quot_General_mtnc.ms_SAPOrder = Txt_SapOrder.Text
        Quot_General_mtnc.mi_LoseReasonCode = mi_LoseReasonCode
        Quot_General_mtnc.ms_LoseReasonDesc = txt_LoseReason.Text
    
        MouseOn
    
        Quot_General_mtnc.show 1
    
        If Quot_General_mtnc.mb_Return = OK Then
            Quotation_Change Quot_General_mtnc.mi_QuotationCode, Quot_General_mtnc.ms_QuotationDesc, Me.left, Me.top, 2
            FrmMain.QuotationOutLine.LocalAddItem Quot_General_mtnc.mi_QuotationCode, Quot_General_mtnc.ms_QuotationDesc
            'FrmMain.QuotationOutLine.SearchOutline Quot_General_mtnc.mi_QuotationCode
        End If
    End Select
    
    Exit Sub
    
lst_AddQuotation_Err:
    StdError
    
End Sub

Private Sub lst_AddQuotation_LostFocus()
    If ActiveControl.Name <> "pic_add" Then lst_AddQuotation.Visible = KO
End Sub

Private Sub lst_UpdateQuotation_Click()
Dim i As Integer

    If lst_UpdateQuotation.ListIndex = -1 Then Exit Sub

    On Error GoTo lst_UpdateQuotation_Err
    
    MouseOff
    
    lst_UpdateQuotation.Visible = KO
        
    If lst_UpdateQuotation.ItemData(lst_UpdateQuotation.ListIndex) = 0 Then
        Quot_General_mtnc.mi_Action = QA_Update
        Quot_General_mtnc.mi_QuotationStatusCode = gi_QuotationStatusCode
        Quot_General_mtnc.mi_QuotationStatusDesc = Quotation_Status_Desc(gi_QuotationStatusCode, gs_QuotationLanguageCode)
    Else
        Quot_General_mtnc.mi_Action = QA_StatusChange
        Quot_General_mtnc.mi_OldStatus = gi_QuotationStatusCode
        Quot_General_mtnc.mi_QuotationStatusCode = lst_UpdateQuotation.ItemData(lst_UpdateQuotation.ListIndex)
        Quot_General_mtnc.mi_QuotationStatusDesc = lst_UpdateQuotation.List(lst_UpdateQuotation.ListIndex)
    End If
        
    'We select and read the last version of the quotation
    cbo_QuotationVersion.ListIndex = cbo_QuotationVersion.ListCount - 1
    
    'We delete all the sales reps of the quotation_General module
    For i = Quot_General_mtnc.mo_SalesRepCode.Count To 1 Step -1
        Quot_General_mtnc.mo_SalesRepCode.Remove i
    Next
    For i = Quot_General_mtnc.mo_SalesRepDesc.Count To 1 Step -1
        Quot_General_mtnc.mo_SalesRepDesc.Remove i
    Next
    
    'If the sales reps was loaded, we add the information to the Quotation_General Module
    If Lst_SalesReps.Tag = Loaded Then
        Quot_General_mtnc.mb_SalesRepLoaded = OK
        For i = 1 To mo_SalesRepCode.Count
            Quot_General_mtnc.mo_SalesRepCode.Add mo_SalesRepCode.Item(i)
            Quot_General_mtnc.mo_SalesRepDesc.Add Lst_SalesReps.List(i - 1)
        Next
    Else
        Quot_General_mtnc.mb_SalesRepLoaded = KO
    End If
    
    'We renseign the loaded iConcurrency
    Quot_General_mtnc.mi_iConcurrency = mi_iConcurrency
    
    If Txt_TotalSurface.Text <> "" Then
        Quot_General_mtnc.ml_TotalSurface = CLng(Txt_TotalSurface.Text)
    Else
        Quot_General_mtnc.ml_TotalSurface = 0
    End If
    If Txt_TotalAmount.Text <> "" Then
        Quot_General_mtnc.mr_TotalAmount = Val(Txt_TotalAmount.Text)
    Else
        Quot_General_mtnc.mr_TotalAmount = 0
    End If
    If txt_LeadTime.Text <> "" Then
        Quot_General_mtnc.mr_LeadTime = Val(txt_LeadTime.Text)
    Else
        Quot_General_mtnc.mr_LeadTime = 0
    End If
    Quot_General_mtnc.ms_LanguageCode = gs_QuotationLanguageCode
    Quot_General_mtnc.ms_LanguageDesc = txt_QuotationLanguage.Text
    Quot_General_mtnc.ml_ClaimCustomerCode = ml_CustomerCode
    Quot_General_mtnc.ms_ClaimCustomerDesc = Txt_Customer.Text
    Quot_General_mtnc.mi_DeliveryAddressCode = mi_DeliveryAddressCode
    Quot_General_mtnc.ms_DeliveryAddressDesc = ms_DeliveryAddressDesc
    Quot_General_mtnc.ms_PlantCode = ms_PlantCode
    Quot_General_mtnc.ms_PlantDesc = txt_Plant.Text
    Quot_General_mtnc.ml_SalesProjectCode = ml_SalesProjectCode
    Quot_General_mtnc.ms_SalesProjectDesc = ms_SalesProjectDesc
    Quot_General_mtnc.ms_Contractor = Txt_Contractor.Text
    Quot_General_mtnc.ms_SalesOfficeCode = mi_SalesOfficeCode
    Quot_General_mtnc.ms_SalesOfficeDesc = txt_SalesOffice.Text
    Quot_General_mtnc.ms_CurrencyCode = ms_CurrencyCode
    Quot_General_mtnc.ms_currencyDesc = txt_Currency.Text
    Quot_General_mtnc.mi_QuotationCode = gi_QuotationCode
    Quot_General_mtnc.ms_QuotationDesc = txt_QuotationCode.Text
    Quot_General_mtnc.mi_QuotationVersion = CInt(cbo_QuotationVersion.Text)
    Quot_General_mtnc.ms_Creator = Txt_Creator.Text
    Quot_General_mtnc.ms_Approval = "" 'This version is no more approval
    Quot_General_mtnc.ms_DeliveryDate = txt_DeliveryDate.Text
    Quot_General_mtnc.ms_ValidityDate = txt_ValidityDate.Text
    Quot_General_mtnc.ms_ApprovalDate = "" 'This version is no more approval
    Quot_General_mtnc.ms_InternetFlag = KO
    Quot_General_mtnc.ms_DropDate = ""
    Quot_General_mtnc.ms_SAPOrder = Txt_SapOrder.Text
    Quot_General_mtnc.mi_LoseReasonCode = mi_LoseReasonCode
    Quot_General_mtnc.ms_LoseReasonDesc = txt_LoseReason.Text
    
    MouseOn
    
    Quot_General_mtnc.show 1
    
    If Quot_General_mtnc.mb_Return = OK Then
        Quotation_Change Quot_General_mtnc.mi_QuotationCode, Quot_General_mtnc.ms_QuotationDesc, Me.left, Me.top, 1
        FrmMain.QuotationOutLine.LocalDelItem Quot_General_mtnc.mi_QuotationCode
        FrmMain.QuotationOutLine.LocalAddItem Quot_General_mtnc.mi_QuotationCode, Quot_General_mtnc.ms_QuotationDesc
        'FrmMain.QuotationOutLine.SearchOutline Quot_General_mtnc.mi_QuotationCode
    End If
    
    Exit Sub

lst_UpdateQuotation_Err:
    StdError
    
End Sub

Private Sub Lst_UpdateQuotation_LostFocus()
    lst_UpdateQuotation.Visible = False
End Sub

Private Sub pic_add_Click()
    
    If lst_AddQuotation.Visible = OK Then
        lst_AddQuotation.Visible = KO
    Else
        lst_AddQuotation.Visible = OK
        lst_AddQuotation.ListIndex = -1
        lst_AddQuotation.SetFocus
    End If
    
End Sub
    
Private Sub pic_log_Click()
    Quotation_Historic
End Sub

'Private Function AddInTotal(ByVal ls_Quantity As String, ls_Unit As String, ls_AmountEuro As String, ls_Amount As String) As Boolean
''------------------------------------------------------------------
'' Name : AddInTotal
''
'' Purpose : Calcul the total by type of unit for the quotation line for the printing process
''
'' A special unit TOTALAMOUNT is used to make the total of the quotation for the amount in euro and in the quotation currency
''
'' Parameters :
''       ls_Quantity     : Quantity
''       ls_Unit         : Unit of the quantity
''       ls_AmountEuro   : Amount in Euro
''       ls_Amount       : Amount in the quotation's currency
''
'' review : Nov/17/1999 by JJB
''------------------------------------------------------------------
'Dim li_Count As Integer
'Dim li_FindLine As Integer
'
'On Error GoTo Err_AddInTotal
'AddInTotal = KO
'If ls_Unit <> "" Then
'    li_FindLine = -1
'    For li_Count = 0 To GridTotal.Rows - 1
'        GridTotal.Row = li_Count
'        GridTotal.col = 0
'        If GridTotal.Text = ls_Unit Then
'            li_FindLine = li_Count
'            Exit For
'        End If
'    Next li_Count
'    If li_FindLine >= 0 Then
'        GridTotal.Row = li_FindLine
'        'Quantity
'        GridTotal.col = 1
'        If GridTotal.Text <> "" Then
'            GridTotal.Text = Plus(Formatage(GridTotal.Text, 5), Formatage(ls_Quantity, 5))
'        Else
'            GridTotal.Text = ls_Quantity
'        End If
'        'Amout in Euro
'        GridTotal.col = 2
'        If GridTotal.Text <> "" Then
'            GridTotal.Text = Plus(Formatage(GridTotal.Text, 5), Formatage(ls_AmountEuro, 5))
'        Else
'            GridTotal.Text = ls_AmountEuro
'        End If
'        'Amout in currency
'        GridTotal.col = 3
'        If GridTotal.Text <> "" Then
'            GridTotal.Text = Plus(Formatage(GridTotal.Text, 5), Formatage(ls_Amount, 5))
'        Else
'            GridTotal.Text = ls_Amount
'        End If
'    Else
'        GridTotal.Row = 0
'        GridTotal.col = 0
'        If GridTotal.Text <> "" Then
'            GridTotal.Rows = GridTotal.Rows + 1
'        End If
'        GridTotal.Row = GridTotal.Rows - 1
'        'unit
'        GridTotal.col = 0
'        GridTotal.Text = ls_Unit
'        'Quantity
'        GridTotal.col = 1
'        GridTotal.Text = ls_Quantity
'        'Amout in Euro
'        GridTotal.col = 2
'        GridTotal.Text = ls_AmountEuro
'        'Amout in currency
'        GridTotal.col = 3
'        GridTotal.Text = ls_Amount
'    End If
'    AddInTotal = OK
'End If
'Exit Function
'Err_AddInTotal:
'MsgBox "Abnormal Data. Canceling Printing process."
'End Function
Private Sub pic_print_Click()
On Error GoTo Err_Print
Dim lo_appWD As New CWord

'
'
'
Dim ls_Req As String
Dim li_Status As Integer
Dim ll_Statement As Long
Dim li_nbRows As Integer
Dim li_nbcols As Integer
Dim li_CursCol As Integer

Dim ls_QLType As String
Dim ls_Quantity As String
Dim ls_Unit As String
Dim ls_AmountEuro As String
Dim ls_Amount As String
Dim li_Count As Integer
Dim ls_Field As String
Dim ls_Text  As String
Dim ls_Description As String
Dim ls_ItemCode As String

Dim ls_Param1Code As String
Dim ls_Param1Text As String
Dim ls_Param1iConcurrency As String

Dim ls_Param2Code As String
Dim ls_Param2Text As String
Dim ls_Param2iConcurrency As String

Dim ls_PrintingTitle As String
Dim li_PrintingChoice As Integer

Dim ll_lngrows As Long

Dim li_ArrayLineCount As Integer

MouseOff

'Clear grids
    li_nbRows = 1
    Grid.Rows = 1
    Grid.Cols = 24
    Grid.Row = 0
    For li_Count = 0 To 8
        Grid.Col = li_Count
        Grid.Text = ""
    Next li_Count
    GridComment.Rows = 1
    GridComment.Cols = 1
    GridComment.Row = 0


'choose header and footer
C_2TextChoice.ms_ParamReqCsts = "EXEC Screen_Csts 'ChHeaderFooter', '" & gut_LangLogin.Code & "'"
'C_2TextChoice.ms_FillDefaultReq = ""
C_2TextChoice.ms_ReqParam1 = "Exec TopBottomPage_cbo " & TOPBOTTOMPAGE_CODEHEADER & "," & QUOTATION_SYSTEM_CODE & ",'"
C_2TextChoice.ms_ReqParam2 = "Exec TopBottomPage_cbo " & TOPBOTTOMPAGE_CODEFOOTER & "," & QUOTATION_SYSTEM_CODE & ",'"
C_2TextChoice.ms_LanguageCode = gs_QuotationLanguageCode
C_2TextChoice.ms_FillDefaultReqParam1 = "EXEC Quot_TopBottomPage_sel " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & "," & TOPBOTTOMPAGE_CODEHEADER & ",'" & gs_QuotationLanguageCode & "'"
C_2TextChoice.ms_FillDefaultReqParam2 = "EXEC Quot_TopBottomPage_sel " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & "," & TOPBOTTOMPAGE_CODEFOOTER & ",'" & gs_QuotationLanguageCode & "'"

MouseOn
C_2TextChoice.show 1

If C_2TextChoice.mb_Return = KO Then
    Exit Sub
End If

MouseOff

ls_Param1Code = C_2TextChoice.ms_Param1Code
ls_Param1Text = C_2TextChoice.ms_Param1Text
ls_Param1iConcurrency = C_2TextChoice.ms_Param1iconcurrency

ls_Param2Code = C_2TextChoice.ms_Param2Code
ls_Param2Text = C_2TextChoice.ms_Param2Text
ls_Param2iConcurrency = C_2TextChoice.ms_Param2iconcurrency

ls_PrintingTitle = C_2TextChoice.ms_Option2Desc
li_PrintingChoice = C_2TextChoice.mi_Option2Chosen


'Update Quot_TopBottomPage
If BeginTran(gl_Environment, gl_Database) Then
    If ls_Param1Code <> "" And ls_Param1Code <> "0" Then
        'new
        ls_Req = "EXEC Quot_TopBottomPage_upd " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & "," & ls_Param1Code & "," & TOPBOTTOMPAGE_CODEHEADER & "," & ls_Param1iConcurrency & ",'E'"
        If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
            li_Status = SQL_SUCCESS
            li_Status = SQLRowCount(ll_Statement, ll_lngrows)
            If ll_lngrows = 0 Then
                SendMessage 2, "Another user change the record", gut_LangLogin.Code
                GoTo ConcurrencyAbort_Print
            End If
        Else
            li_Status = SQL_ERROR
            RollbackTran gl_Environment, gl_Database
            GoTo Err_Print
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End If
    
    If ls_Param1Code = "0" Then
        ls_Req = "EXEC Quot_TopBottomPage_del " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & "," & TOPBOTTOMPAGE_CODEHEADER & "," & ls_Param1iConcurrency & ",'E'"
        If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
            li_Status = SQL_SUCCESS
            li_Status = SQLRowCount(ll_Statement, ll_lngrows)
            If ll_lngrows = 0 Then
                SendMessage 2, "Another user change the record", gut_LangLogin.Code
                GoTo ConcurrencyAbort_Print
            End If
        Else
            li_Status = SQL_ERROR
            RollbackTran gl_Environment, gl_Database
            GoTo Err_Print
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End If
    
    If ls_Param2Code <> "" And ls_Param2Code <> "0" Then
        ls_Req = "EXEC Quot_TopBottomPage_upd " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & "," & ls_Param2Code & "," & TOPBOTTOMPAGE_CODEFOOTER & "," & ls_Param2iConcurrency & ",'E'"
        If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
            li_Status = SQL_SUCCESS
            li_Status = SQLRowCount(ll_Statement, ll_lngrows)
            If ll_lngrows = 0 Then
                SendMessage 2, "Another user change the record", gut_LangLogin.Code
                GoTo ConcurrencyAbort_Print
            End If
        Else
            li_Status = SQL_ERROR
            RollbackTran gl_Environment, gl_Database
            GoTo Err_Print
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End If

    If ls_Param2Code = "0" Then
        ls_Req = "EXEC Quot_TopBottomPage_del " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & "," & TOPBOTTOMPAGE_CODEFOOTER & "," & ls_Param2iConcurrency & ",'E'"
        If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
            li_Status = SQL_SUCCESS
            li_Status = SQLRowCount(ll_Statement, ll_lngrows)
            If ll_lngrows = 0 Then
                SendMessage 2, "Another user change the record", gut_LangLogin.Code
                GoTo ConcurrencyAbort_Print
            End If
        Else
            li_Status = SQL_ERROR
            RollbackTran gl_Environment, gl_Database
            GoTo Err_Print
        End If
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    End If
    CommitTran gl_Environment, gl_Database
Else
    GoTo Abort_Print
End If


If li_PrintingChoice = 3 Then
'Read Translated constants for the table
    ls_Req = "EXEC Screen_Csts 'Quot_Print2', '" _
        & gs_QuotationLanguageCode & "'"
Else
ls_Req = "EXEC Screen_Csts 'Quot_Print1', '" _
        & gs_QuotationLanguageCode & "'"
End If
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
    GoTo Err_Print
End If
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ls_Field = ODBCData(ll_Statement, 1)
        ls_Text = ODBCData(ll_Statement, 2)
        Select Case ls_Field
        '-- Top of the page
        Case "c0":
            Grid.Col = 0
            Grid.Text = ls_Text
        Case "c1":
            Grid.Col = 1
            Grid.Text = ls_Text
        Case "c2":
            Grid.Col = 2
            Grid.Text = ls_Text
        Case "c3":
            Grid.Col = 3
            Grid.Text = ls_Text
        Case "c4":
            Grid.Col = 4
            Grid.Text = ls_Text
        Case "c5":
            Grid.Col = 5
            Grid.Text = ls_Text
        Case "c6":
            Grid.Col = 6
            Grid.Text = ls_Text
        Case "c7":
            Grid.Col = 7
            Grid.Text = ls_Text
        Case "c8":
            Grid.Col = 8
            Grid.Text = ls_Text
        Case "c9":
            Grid.Col = 9
            Grid.Text = ls_Text
        Case "c10":
            Grid.Col = 10
            Grid.Text = ls_Text
        Case "c11":
            Grid.Col = 11
            Grid.Text = ls_Text
        Case "c12":
            Grid.Col = 12
            Grid.Text = ls_Text
        Case "c13":
            Grid.Col = 13
            Grid.Text = ls_Text
        Case "c14":
            Grid.Col = 14
            Grid.Text = ls_Text
        Case "c15":
            Grid.Col = 15
            Grid.Text = ls_Text
        Case "c16":
            Grid.Col = 16
            Grid.Text = ls_Text
        Case "c17":
            Grid.Col = 17
            Grid.Text = ls_Text
        Case "c18":
            Grid.Col = 18
            Grid.Text = ls_Text
        Case "c19":
            Grid.Col = 19
            Grid.Text = ls_Text
        Case "c20":
            Grid.Col = 20
            Grid.Text = ls_Text
        Case "c21":
            Grid.Col = 21
            Grid.Text = ls_Text
        Case "c22":
            Grid.Col = 22
            Grid.Text = ls_Text
        Case "c23":
            Grid.Col = 23
            Grid.Text = ls_Text
        Case "c24":
            Grid.Col = 24
            Grid.Text = ls_Text
        
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
If li_PrintingChoice <> 3 Then
'Get Quotation Line data
    li_ArrayLineCount = 0
    ls_Req = "EXEC Quotation_PrintArray1_t_lst " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & ",'" & "E" & "'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
        GoTo Err_Print
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            li_ArrayLineCount = li_ArrayLineCount + 1
            'For i = 1 To 6
                Grid.Rows = li_nbRows + 1
                Grid.Row = li_nbRows
                li_nbRows = li_nbRows + 1
                'line number
                Grid.Col = 0
                Grid.Text = li_nbRows - 1
                ' type of Quotation line
                ls_QLType = ODBCData(ll_Statement, 1)
                ' Item code
                Grid.Col = 1
                ls_ItemCode = ODBCData(ll_Statement, 2)
                Grid.Text = ls_ItemCode
                ' Face Pattern
                Grid.Col = 2
                Grid.Text = ODBCData(ll_Statement, 3)
                ' EdgeDetail length
                Grid.Col = 3
                Grid.Text = ODBCData(ll_Statement, 4)
                ' Edge detail width
                Grid.Col = 4
                Grid.Text = ODBCData(ll_Statement, 5)
                ' Actual Dimension
                    Grid.Col = 5
                Grid.Text = ODBCData(ll_Statement, 6)
                ' Thickness
                Grid.Col = 6
                Grid.Text = ODBCData(ll_Statement, 7)
                ' Colour
                    Grid.Col = 7
                Grid.Text = ODBCData(ll_Statement, 8)
                ' Quantity / unit
                Grid.Col = 8
                Grid.Text = ODBCData(ll_Statement, 9)
                ' Net selling price Currency/unit(Amount in Euros)
                Grid.Col = 9
                Grid.Text = ODBCData(ll_Statement, 10)
                ' Leadtime
                Grid.Col = 10
                Grid.Text = ODBCData(ll_Statement, 11)
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)


    li_nbRows = 0
    ls_Req = "EXEC Quotation_PrintArray2_t_lst " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & ",'" & "E" & "'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
        GoTo Err_Print
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            li_ArrayLineCount = li_ArrayLineCount + 1
            'For i = 1 To 6
                GridComment.Rows = li_nbRows + 1
                GridComment.Row = li_nbRows
                li_nbRows = li_nbRows + 1
                'line number
                GridComment.Col = 0
                GridComment.ColWidth(0) = 2000
                GridComment.Text = ODBCData(ll_Statement, 1)
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

If li_ArrayLineCount > 0 Then
       If C_2TextChoice.mi_Option1Chosen = 1 Then
     'export to word
          Call lo_appWD.ExportQuotationToWord(ls_PrintingTitle, App.Path & "\Quotation.dot", CStr(gi_QuotationCode), CStr(gi_QuotationVersion), gs_QuotationLanguageCode, Grid, Array(3, 10, 13, 7, 7, 10, 10, 10, 10, 10, 10), _
            GridComment, Array(TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft, TFormatColumn.AlignLeft), Array(TFormatColumn.AlignRight, TFormatColumn.AlignRight, TFormatColumn.AlignLeft, TFormatColumn.AlignRight, TFormatColumn.AlignRight, TFormatColumn.AlignRight, TFormatColumn.AlignRight, TFormatColumn.AlignRight, TFormatColumn.AlignRight, TFormatColumn.AlignRight, TFormatColumn.AlignRight), C_2TextChoice.ms_Param1Text, C_2TextChoice.ms_Param2Text)
       ' Call lo_appWD.ExportQuotationMetalToWord(App.Path & "\Quotation.dot", CStr(gi_QuotationCode), CStr(gi_QuotationVersion), "E", Grid, GridComment, C_2TextChoice.ms_Param1Text, C_2TextChoice.ms_Param2Text)
   Else
           'Print the document
           'PrintQuotation Portrait, CStr(gi_QuotationCode), CStr(gi_QuotationVersion), "E", Grid, Array(4, 14, 40, 0, 0, 16, 0, 13, 13), GridTotal, C_2TextChoice.ms_Param1Text, C_2TextChoice.ms_Param2Text
       End If
    Else
         SendMessage 128, "There is no Quotation line. Printing aborted.", gut_LangLogin.Code
    End If

Else
    'Get Quotation Line data For Metal Products
    li_ArrayLineCount = 0
    ls_Req = "EXEC QuotationMetal_PrintArray1_t_lst " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & ",'" & "E" & "'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
        GoTo Err_Print
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            li_ArrayLineCount = li_ArrayLineCount + 1
            
                Grid.Rows = li_nbRows + 1
                Grid.Row = li_nbRows
                li_nbRows = li_nbRows + 1
            For li_CursCol = 1 To 23
                'System
                Grid.Col = li_CursCol
                Grid.Text = ODBCData(ll_Statement, li_CursCol)
            Next
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)


    li_nbRows = 0
    ls_Req = "EXEC Quotation_PrintArray2_t_lst " & CStr(gi_QuotationCode) & "," & CStr(gi_QuotationVersion) & ",'" & "E" & "'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
        GoTo Err_Print
        End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            li_ArrayLineCount = li_ArrayLineCount + 1
            'For i = 1 To 6
                GridComment.Rows = li_nbRows + 1
                GridComment.Row = li_nbRows
                li_nbRows = li_nbRows + 1
                'line number
                GridComment.Col = 0
                GridComment.Text = ODBCData(ll_Statement, 1)
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
   
    If li_ArrayLineCount > 0 Then
       If C_2TextChoice.mi_Option1Chosen = 1 Then
         'export to word
            Call lo_appWD.ExportQuotationMetalToWord(ls_PrintingTitle, App.Path & "\Quotation.dot", CStr(gi_QuotationCode), CStr(gi_QuotationVersion), gs_QuotationLanguageCode, Grid, GridComment, C_2TextChoice.ms_Param1Text, C_2TextChoice.ms_Param2Text)
       Else
       'Print the document
       'PrintQuotation Portrait, CStr(gi_QuotationCode), CStr(gi_QuotationVersion), "E", Grid, Array(4, 14, 40, 0, 0, 16, 0, 13, 13), GridTotal, C_2TextChoice.ms_Param1Text, C_2TextChoice.ms_Param2Text
   End If
Else
     SendMessage 128, "There is no Quotation line. Printing aborted.", gut_LangLogin.Code
    End If
End If


MouseOn
Exit Sub

ConcurrencyAbort_Print:
On Error Resume Next
    RollbackTran gl_Environment, gl_Database
Err_Print:
On Error Resume Next
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Abort_Print:
On Error Resume Next
    Select Case C_2TextChoice.mi_Option1Chosen
    Case 1
        SendMessage 125, "Error on printing process, command aborted", gut_LangLogin.Code
    Case 2
        SendMessage 124, "Error on printing process, command aborted", gut_LangLogin.Code
        Printer.KillDoc
    Case Else
        SendMessage 125, "Error on printing process, command aborted", gut_LangLogin.Code
    End Select
    MouseOn
End Sub

Private Sub pic_quit_Click()
    FrmMain.QuotationOutLine.HideViewBar
    Unload Me
End Sub

Private Sub pic_refresh_Click()
    MouseOff
    Quotation_Refresh txt_QuotationStatus, cbo_QuotationVersion, Me.left, Me.top
    ReadQuotation gi_QuotationCode, gi_QuotationVersion
    MouseOn
End Sub

Private Sub pic_upd_Click()
    If lst_UpdateQuotation.Visible = OK Then
        lst_UpdateQuotation.Visible = KO
    Else
        lst_UpdateQuotation.Visible = OK
        lst_UpdateQuotation.ListIndex = -1
        lst_UpdateQuotation.SetFocus
    End If
End Sub

Private Function ReadQuotation(lS_Code As Integer, li_version As Integer) As Boolean
Dim ls_Req As String
Dim li_Status As Integer
Dim ll_Statement As Long
Dim ls_InternetFlag As String
Dim lo_NextStatusCode As Collection
Dim i As Integer

    ReadQuotation = KO
    
    On Error GoTo ReadQuotation_Err
    
    gi_QuotationCode = lS_Code
    gi_QuotationVersion = li_version
    
    ls_Req = "exec quotation_sel " & CStr(lS_Code) & "," & CStr(li_version) & ",'" & gut_LangLogin.Code & "'"
    
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) = KO Then
        Exit Function
    End If
    
    li_Status = SQL_SUCCESS
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    'Get the row of data
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            mi_iConcurrency = Formatage2(ODBCDataInt(ll_Statement, 1))
            ml_CustomerCode = Formatage2(ODBCDataInt(ll_Statement, 2))
            Txt_Customer.Text = ODBCData(ll_Statement, 3)
            mi_DeliveryAddressCode = Formatage2(ODBCDataInt(ll_Statement, 4))
            ms_DeliveryAddressDesc = ODBCData(ll_Statement, 5)
            ms_PlantCode = ODBCData(ll_Statement, 6)
            txt_Plant.Text = ODBCData(ll_Statement, 7)
            mi_LoseReasonCode = Formatage2(ODBCDataInt(ll_Statement, 8))
            txt_LoseReason.Text = ODBCData(ll_Statement, 9)
            ml_SalesProjectCode = Formatage2(ODBCDataInt(ll_Statement, 10))
            ms_SalesProjectDesc = ODBCData(ll_Statement, 11)
            mi_SalesOfficeCode = ODBCData(ll_Statement, 12)
            txt_SalesOffice = ODBCData(ll_Statement, 13)
            ms_CurrencyCode = ODBCData(ll_Statement, 14)
            txt_Currency.Text = ODBCData(ll_Statement, 15)
            'the 16th element is the quotation description. We don't read because we have it in global
            'the 17th element is the quotation language code. We don't read because we have it in global
            ms_QuotationLanguageDesc = ODBCData(ll_Statement, 18)
            txt_QuotationLanguage.Text = ms_QuotationLanguageDesc
            Txt_Creator.Text = ODBCData(ll_Statement, 19)
            Txt_Approval.Text = ODBCData(ll_Statement, 20)
            txt_DeliveryDate.Text = ODBCData(ll_Statement, 21)
            txt_ValidityDate.Text = ODBCData(ll_Statement, 22)
            Txt_ApprovalDate.Text = ODBCData(ll_Statement, 23)
            Txt_SapOrder = ODBCData(ll_Statement, 24)
            Txt_TotalSurface.Text = ODBCData(ll_Statement, 25)
            Txt_TotalAmount.Text = ODBCData(ll_Statement, 26)
            txt_LeadTime.Text = ODBCData(ll_Statement, 27)
            'the 28th is the quotation status code. We don't read because we have it in global
            'The 29th is the quotation status desc. We don't read because we have it in global
            'The 30th is the internet Flag that we don't use no more
            'The 31th and 32th are the drop flag and drop date that we don't use no more
            Txt_Contractor.Text = ODBCData(ll_Statement, 33)
        End If
    Loop

    ReadQuotation = OK

    Lst_SalesReps.Tag = UNLOADED

    If Lst_SalesReps.Visible = OK Then Quotation_ReadSalesRep lS_Code, li_version, mo_SalesRepCode, Lst_SalesReps

    'Delete the update list
    lst_UpdateQuotation.Clear

    'Read the new CodeList
    Set lo_NextStatusCode = Quotation_NextStatusList(gi_QuotationStatusCode)
    For i = 1 To lo_NextStatusCode.Count
        lst_UpdateQuotation.AddItem Quotation_Status_AltDesc(lo_NextStatusCode.Item(i), gs_QuotationLanguageCode)
        lst_UpdateQuotation.ItemData(i - 1) = lo_NextStatusCode.Item(i)
    Next
    Set lo_NextStatusCode = Nothing

    'If the user is MSC or (the user is COS and Quotation is Archived),
    'the user can update the quotation
    If gut_Actor.MSC = OK Or (gut_Actor.COS = OK And gi_QuotationStatusCode = Quotation_Status.Archived) Then
        'Insert the case of the Update for the sales reps
        lst_UpdateQuotation.AddItem ms_UpdateLabel
        lst_UpdateQuotation.ItemData(lst_UpdateQuotation.NewIndex) = 0
    End If

    'If the quotation is closed, is in old version or is in Customer changes quotation, we cannot update this quotation
    'If the user is Plant, he cannot update this quotation
    If (gut_Actor.COS = OK And gi_QuotationStatusCode <> Quotation_Status.Waiting_Customer_Confirmation And gi_QuotationStatusCode <> Quotation_Status.Enter_customer_order And gi_QuotationStatusCode <> Quotation_Status.Archived) _
       Or gut_Actor.Plant = OK _
       Or gi_QuotationStatusCode = Quotation_Status.closed _
       Or gi_QuotationStatusCode = Quotation_Status.Old_Version _
       Or gi_QuotationStatusCode = Quotation_Status.Customer_changes_Quotation _
       Then
        pic_upd.Visible = KO
    End If

    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

    Exit Function

ReadQuotation_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError

End Function

Private Sub GetCaptions()
Dim ls_Field As String
Dim ls_Text As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Req As String

    On Error GoTo suite
    ls_Req = "EXEC Screen_Csts 'Quot_general', '" & gut_LangLogin.Code & "'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Field = ODBCData(ll_Statement, 1)
            ls_Text = ODBCData(ll_Statement, 2)
            Select Case ls_Field
                Case "lbl_code": lbl_QuotationCode.Caption = ls_Text
                Case "lbl_version": lbl_QuotationVersion.Caption = ls_Text
                Case "lbl_status": lbl_QuotationStatus.Caption = ls_Text
                Case "lbl_qlanguage": Lbl_QuotationLanguage.Caption = ls_Text
                Case "lbl_creator": Lbl_Creator.Caption = ls_Text
                Case "lbl_approval": Lbl_Approval.Caption = ls_Text
                Case "lbl_appdate": Lbl_ApprovalDate.Caption = ls_Text
                Case "lbl_customer": lbl_customer.Caption = ls_Text
                Case "lbl_currency": lbl_Currency.Caption = ls_Text
                Case "lbl_totsurface": Lbl_TotalSurface.Caption = ls_Text
                Case "lbl_totamount": Lbl_TotalAmount.Caption = ls_Text
                Case "lbl_leadtime": lbl_leadTime.Caption = ls_Text
                Case "lbl_defplant": lbl_Plant.Caption = ls_Text
                Case "lbl_expdeldate": Lbl_DeliveryDate.Caption = ls_Text
                Case "lbl_valdate": Lbl_ValidityDate.Caption = ls_Text
                Case "lbl_salesoff": Lbl_SalesOffice.Caption = ls_Text
                Case "btn_salesreps": btn_SalesRep.Caption = ls_Text
                Case "lbl_losereason": Lbl_LoseReason.Caption = ls_Text
                Case "lbl_saporder": Lbl_SapOrder.Caption = ls_Text
                Case "lst_newquot":
                    lst_AddQuotation.AddItem ls_Text
                    lst_AddQuotation.ItemData(lst_AddQuotation.NewIndex) = LST_AQ_NEW
                Case "lst_newversion":
                    lst_AddQuotation.AddItem ls_Text
                    lst_AddQuotation.ItemData(lst_AddQuotation.NewIndex) = LST_AQ_NEW_VERSION
                Case "lst_copyquot":
                    lst_AddQuotation.AddItem ls_Text
                    lst_AddQuotation.ItemData(lst_AddQuotation.NewIndex) = LST_AQ_COPY
                Case "lst_update": ms_UpdateLabel = ls_Text
                Case "lbl_Contractor": Lbl_Contractor.Caption = ls_Text
            End Select
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
suite:
    StdError
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
End Sub


