VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
Begin VB.Form MainForm 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "SampleLP"
   ClientHeight    =   3420
   ClientLeft      =   4920
   ClientTop       =   5235
   ClientWidth     =   8280
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3420
   ScaleWidth      =   8280
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton Exit 
      Caption         =   ""
      Height          =   375
      Left            =   6600
      TabIndex        =   6
      Top             =   3000
      Width           =   1575
   End
   Begin VB.CommandButton PageProperties 
      Caption         =   " "
      Height          =   375
      Left            =   4080
      TabIndex        =   5
      Top             =   3000
      Width           =   1575
   End
   Begin VB.CheckBox Cache 
      Caption         =   " "
      Height          =   255
      Left            =   1800
      TabIndex        =   4
      Top             =   2640
      Width           =   1695
   End
   Begin VB.CheckBox Enable 
      Caption         =   " "
      Height          =   255
      Left            =   1800
      TabIndex        =   3
      Top             =   2280
      Width           =   2175
   End
   Begin VB.CommandButton WriteData 
      Caption         =   " "
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   2760
      Width           =   1575
   End
   Begin VB.CommandButton ReadData 
      Caption         =   " "
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   2280
      Width           =   1575
   End
   Begin ComctlLib.ListView List 
      Height          =   2055
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   8055
      _ExtentX        =   14208
      _ExtentY        =   3625
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      _Version        =   327682
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   0
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BorderStyle     =   1  'Fixed Single
      Caption         =   "     .      ,   ."
      Height          =   735
      Left            =   4080
      TabIndex        =   7
      Top             =   2160
      Width           =   4095
   End
End
Attribute VB_Name = "MainForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public LP As Object

Private Sub UpdateForm()
   '  
   If (LP.DeviceEnabled) Then
      Enable.Value = 1
   Else
      Enable.Value = 0
   End If
      
   If (LP.CacheReport) Then
        Cache.Value = 1
   Else
        Cache.Value = 0
   End If
End Sub

Private Sub Cache_Click()
   On Error GoTo ErrorHandler
   
   ' /  
   If (Cache.Value) Then
      LP.CacheReport = True
   Else
      LP.CacheReport = False
   End If
   UpdateForm
   Exit Sub

ErrorHandler:
   '  
   If LP.ResultCode = 0 Then
       MsgBox (" Visual Basic: " + Err.Description)
       Exit Sub
   Else
       MsgBox LP.ResultDescription
       UpdateForm
   End If
End Sub

Private Sub Enable_Click()
   On Error GoTo ErrorHandler
   
   ' / 
   If (Enable.Value) Then
      LP.DeviceEnabled = True
   Else
      LP.DeviceEnabled = False
   End If
   UpdateForm
   Exit Sub
   
ErrorHandler:
   '  
   If LP.ResultCode = 0 Then
       MsgBox (" Visual Basic: " + Err.Description)
       Exit Sub
   Else
       MsgBox LP.ResultDescription
       UpdateForm
   End If
End Sub

Private Sub Exit_Click()
   '   
   End
End Sub

Private Sub Form_Load()
    Set LP = CreateObject("AddIn.LP45")

    '    ( )
    Call List.ColumnHeaders.Add(1, , "PLU", 500)
    Call List.ColumnHeaders.Add(2, , "", 800)
    Call List.ColumnHeaders.Add(3, , " ", 900)
    Call List.ColumnHeaders.Add(4, , "", 1200)
    Call List.ColumnHeaders.Add(5, , " 2", 1200)
    Call List.ColumnHeaders.Add(6, , " ", 600)
    Call List.ColumnHeaders.Add(7, , " ", 600)
    Call List.ColumnHeaders.Add(8, , " ", 600)
    Call List.ColumnHeaders.Add(9, , " ", 500)
    Call List.ColumnHeaders.Add(10, , " ", 700)
    
    UpdateForm
    
End Sub

Private Sub PageProperties_Click()
   '   
   LP.ShowProperties
   UpdateForm
End Sub

Private Sub ReadData_Click()
    Dim li As ListItem
    '   
    On Error GoTo ErrorHandler
    
    '  ,  
    List.ListItems.Clear
    
    '    PLU
    LP.FirstRecord = 1
    '  50,        
    LP.LastRecord = 50
    
    '   
    LP.BeginReport
    
    RowIndex = 1
    For i = 1 To 50
        LP.GetRecord
        
        Set li = List.ListItems.Add(RowIndex, , LP.PLU)
        li.SubItems(1) = LP.Price
        li.SubItems(2) = LP.ICode
        li.SubItems(3) = LP.Name
        li.SubItems(4) = LP.Name2
        li.SubItems(5) = LP.MsgNo
        li.SubItems(6) = LP.Life
        li.SubItems(7) = LP.Tare
        li.SubItems(8) = LP.GCode
        li.SubItems(9) = LP.WareType
                
        RowIndex = RowIndex + 1
    Next i
    
    LP.EndReport
    UpdateForm
   
    Exit Sub
    
ErrorHandler:
   '  
   If LP.ResultCode = 0 Then
       MsgBox (" Visual Basic: " + Err.Description)
       Exit Sub
   
   ElseIf LP.ResultCode <> -2001 Then
        ' -2001 =   PLU
        MsgBox LP.ResultDescription
        UpdateForm
   End If
End Sub

Private Sub WriteData_Click()
    '   
    On Error GoTo ErrorHandler
    
    '    PLU
    LP.FirstRecord = 1
    LP.LastRecord = 10
    
    LP.BeginAdd
    
    '    10  ( )
    For i = 1 To 10
        LP.PLU = i * 10
        LP.Price = i * 99
        LP.ICode = i * 10
        LP.Name = " "
        LP.Name2 = "  2"
        LP.MsgNo = i * 10
        LP.Life = i * 10
        LP.Tare = i * 0.5
        LP.GCode = i * 9
        LP.WareType = 1
        '   
        LP.SetRecord
    Next i
    
    LP.EndAdd
    
    UpdateForm
    Exit Sub
    
ErrorHandler:
    '  
    If LP.ResultCode = 0 Then
        MsgBox (" Visual Basic: " + Err.Description)
        Exit Sub
    Else
        MsgBox LP.ResultDescription
        UpdateForm
    End If
End Sub
