VERSION 5.00
Begin VB.Form frmConnect 
   Caption         =   "Connection"
   ClientHeight    =   6825
   ClientLeft      =   9225
   ClientTop       =   4065
   ClientWidth     =   8895
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   12
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmConnect.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   6825
   ScaleWidth      =   8895
   Begin VB.Frame FraArranque 
      Caption         =   "Start-Up"
      Height          =   2265
      Left            =   210
      TabIndex        =   19
      Top             =   4350
      Width           =   8475
      Begin VB.CommandButton cmdStartUp 
         Caption         =   "Start-Up"
         Enabled         =   0   'False
         Height          =   540
         Left            =   3532
         TabIndex        =   11
         Top             =   1410
         Width           =   1830
      End
      Begin VB.TextBox txtCfg 
         Alignment       =   1  'Right Justify
         Height          =   390
         Left            =   2640
         Locked          =   -1  'True
         TabIndex        =   8
         Text            =   "0"
         Top             =   480
         Width           =   495
      End
      Begin VB.CommandButton cmdIdentificarDispositius 
         Caption         =   "Show Devices"
         Enabled         =   0   'False
         Height          =   540
         Left            =   6060
         TabIndex        =   10
         Top             =   330
         Width           =   1830
      End
      Begin VB.TextBox txtDsp 
         Alignment       =   1  'Right Justify
         Height          =   390
         Left            =   4890
         Locked          =   -1  'True
         TabIndex        =   9
         Top             =   480
         Width           =   495
      End
      Begin VB.Label lblIDConfiguración 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "ID Configuration"
         Enabled         =   0   'False
         Height          =   270
         Left            =   420
         TabIndex        =   21
         Top             =   540
         Width           =   1680
      End
      Begin VB.Label lblLblDsp 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Device"
         Enabled         =   0   'False
         Height          =   270
         Left            =   3570
         TabIndex        =   20
         Top             =   540
         Width           =   735
      End
   End
   Begin VB.Frame FraConexión 
      Caption         =   "Connection"
      Height          =   4065
      Left            =   210
      TabIndex        =   12
      Top             =   180
      Width           =   8505
      Begin VB.CommandButton cmdConectar 
         Caption         =   "Connect"
         Height          =   540
         Left            =   3532
         TabIndex        =   7
         Top             =   3090
         Width           =   1830
      End
      Begin VB.OptionButton OptLocal 
         Alignment       =   1  'Right Justify
         Caption         =   "Local"
         Height          =   345
         Left            =   2610
         TabIndex        =   0
         Top             =   420
         Width           =   1215
      End
      Begin VB.OptionButton OptRemoto 
         Alignment       =   1  'Right Justify
         Caption         =   "Remote"
         Height          =   285
         Left            =   2610
         TabIndex        =   1
         Top             =   900
         Width           =   1215
      End
      Begin VB.TextBox txtIP 
         Height          =   390
         Left            =   4770
         TabIndex        =   2
         Text            =   "CashKeeper"
         Top             =   840
         Width           =   3405
      End
      Begin VB.TextBox txtH 
         Alignment       =   1  'Right Justify
         Height          =   390
         Left            =   2520
         TabIndex        =   3
         Text            =   "8001"
         Top             =   1380
         Width           =   915
      End
      Begin VB.TextBox txtPO 
         Alignment       =   1  'Right Justify
         Height          =   390
         Left            =   2520
         TabIndex        =   4
         Text            =   "8002"
         Top             =   1860
         Width           =   915
      End
      Begin VB.ComboBox cboTC 
         Height          =   390
         Left            =   2520
         Style           =   2  'Dropdown List
         TabIndex        =   6
         Top             =   2340
         Width           =   2505
      End
      Begin VB.TextBox txtSeed 
         Alignment       =   1  'Right Justify
         Height          =   390
         Left            =   4770
         TabIndex        =   5
         Text            =   "100001"
         Top             =   1380
         Width           =   1125
      End
      Begin VB.Label lblHostCashKeeper 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Host CashKeeper"
         Height          =   270
         Left            =   300
         TabIndex        =   18
         Top             =   450
         Width           =   1875
      End
      Begin VB.Label lblPuertoHost 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Master Port"
         Height          =   270
         Left            =   300
         TabIndex        =   17
         Top             =   1440
         Width           =   1215
      End
      Begin VB.Label lblPuertoOffice 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Office Port"
         Height          =   270
         Left            =   300
         TabIndex        =   16
         Top             =   1920
         Width           =   1110
      End
      Begin VB.Label lblTipoConexión 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Connection Type"
         Height          =   270
         Left            =   300
         TabIndex        =   15
         Top             =   2400
         Width           =   1755
      End
      Begin VB.Label lblHost 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Host"
         Height          =   270
         Left            =   4050
         TabIndex        =   14
         Top             =   915
         Width           =   480
      End
      Begin VB.Label lblSeed 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Seed"
         Height          =   270
         Left            =   4050
         TabIndex        =   13
         Top             =   1440
         Width           =   570
      End
   End
End
Attribute VB_Name = "frmConnect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private WithEvents CKEv As CKeeperLibV2.CKeeper
Attribute CKEv.VB_VarHelpID = -1

Private Sub CKEv_ProcessInterrupted(ByVal State As Byte, ByVal Value As Long, ByVal target As Long, ByVal Operation As Byte)
    'MsgBox "Se ha detectado un pago interrumpido Target = " & Format(CCur(target) / 100, "standard") & ", Current = " & Format(CCur(Value) / 100, "standard"), vbCritical + vbOKOnly
    MsgBox "Interrupted Payout detected Target = " & Format(CCur(target) / 100, "standard") & ", Current = " & Format(CCur(Value) / 100, "standard"), vbCritical + vbOKOnly
End Sub

Private Sub cmdConectar_Click()
    lblIDConfiguración.Enabled = False
    lblLblDsp.Enabled = False
    cmdIdentificarDispositius.Enabled = False
    cmdStartUp.Enabled = False
    txtCfg.Locked = True
    txtDsp.Locked = True
    DoEvents
    If OptLocal.Value Then
        CIP = "127.0.0.1"
    Else
        CIP = txtIP.text
    End If
    CPM = CLng(txtH.text)
    CPO = CLng(txtPO.text)
    CS = CLng(txtSeed.text)
    CTC = cboTC.ListIndex = 0
    CMode = IIf(CTC, HostMachine, BackOffice)
    If CK.Connect(CIP, CPM, CPO, CMode, CS) Then
        lblIDConfiguración.Enabled = True
        lblLblDsp.Enabled = True
        cmdIdentificarDispositius.Enabled = True
        cmdStartUp.Enabled = True
        txtCfg.Locked = False
        txtDsp.Locked = False
        'cmdConectar.Enabled = False
        CK.SetLanguage Eng
    Else
        lblIDConfiguración.Enabled = False
        lblLblDsp.Enabled = False
        cmdIdentificarDispositius.Enabled = False
        cmdStartUp.Enabled = False
        txtCfg.Locked = True
        txtDsp.Locked = True
        MsgBox "Connect Error: " & CK.ErrorCode & "-" & CK.ErrorDescription
    End If
End Sub

Private Sub cmdIdentificarDispositius_Click()
    Dim ids As String
    
    If CK.GetDevices(ids) Then
        'MsgBox "Dispositivos detectados " & ids
        MsgBox "Devices detected " & ids
    Else
        MsgBox "GetDevices Error: " & CK.ErrorCode & "-" & CK.ErrorDescription
    End If
End Sub

Private Sub cmdStartUp_Click()
    Dim ok As Boolean
    
    CCF = CByte(txtCfg.text)
    If Len(txtDsp.text) > 0 Then
        CDSP = CLng(txtDsp.text)
        ok = CK.StartUp(CCF, CDSP)
    Else
        CDSP = 0
        ok = CK.StartUp(CCF)
    End If
    If Not ok Then
        MsgBox "StartUp Error: " & CK.ErrorCode & "-" & CK.ErrorDescription
    Else
        Unload Me
    End If
End Sub

Private Sub Form_Load()
    CentraForm Me
    OptLocal.Value = True
    txtH.text = 8001
    txtPO.text = 8002
    txtSeed.text = 100001
    cboTC.Clear
    cboTC.AddItem "Maestro"
    cboTC.AddItem "Office"
    cboTC.ListIndex = 0
    txtCfg.text = "0"
    Set CKEv = CK
    'txtIP.text = ""
    'txtIP.Enabled = False
    'lblHost.Enabled = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If CK.State = 0 Then
        CK.Terminate
    Else
        Principal.Show
    End If
    Set CKEv = Nothing
End Sub

Private Sub OptLocal_Click()
    'txtIP.text = ""
    txtIP.Enabled = False
    lblHost.Enabled = False
End Sub

Private Sub OptRemoto_Click()
    txtIP.Enabled = True
    lblHost.Enabled = True
End Sub
