home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmClient
- Caption = "Customer"
- ClientHeight = 3000
- ClientLeft = 840
- ClientTop = 1785
- ClientWidth = 4470
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 3000
- ScaleWidth = 4470
- Begin VB.Timer Timer1
- Interval = 500
- Left = 3360
- Top = 240
- End
- Begin VB.ListBox lstPurchase
- Height = 1395
- Left = 180
- TabIndex = 3
- Top = 1140
- Width = 4095
- End
- Begin VB.CheckBox chkShop
- Caption = "Shop"
- Height = 255
- Left = 1260
- TabIndex = 2
- Top = 660
- Width = 1335
- End
- Begin VB.TextBox txtClient
- Height = 285
- Left = 1260
- MaxLength = 1
- TabIndex = 0
- Text = "1"
- Top = 240
- Width = 1335
- End
- Begin VB.Label lblStatus
- Height = 195
- Left = 180
- TabIndex = 4
- Top = 2700
- Width = 4095
- End
- Begin VB.Label Label1
- Alignment = 1 'Right Justify
- Caption = "Customer #:"
- Height = 195
- Left = 120
- TabIndex = 1
- Top = 300
- Width = 1095
- End
- Attribute VB_Name = "frmClient"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- ' Copyright
- 1997 by Desaware Inc. All Rights Reserved
- ' Simple state machine
- ' 0 - Idle
- ' 1 - Looking for checkstand
- ' 2 - Waiting for checkstand to be free
- ' 3 - Checkstand is free, data loaded
- ' 4 - Waiting for checkout complete
- Dim CurrentState%
- Dim CurrentTotal As Single
- Dim MappingHandle As Long
- Dim MappingAddress As Long
- Private Sub Form_Unload(Cancel As Integer)
- CleanUp
- End Sub
- Private Sub Timer1_Timer()
- Dim usename$
- Dim newtotal&
- Dim cs As CheckStand
- Dim x%
- Select Case CurrentState
- Case 0
- If chkShop.value = 1 Then
- CurrentState = 1
- End If
- Case 1
- usename$ = GetMappingName$()
- ' Right now we only use checkstand 1
- MappingHandle = OpenFileMapping(FILE_MAP_WRITE, False, usename$)
- If MappingHandle = 0 Then Exit Sub
- MappingAddress = MapViewOfFile(MappingHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0)
- CurrentState = 2
- Case 2
- agCopyData ByVal MappingAddress, cs, Len(cs)
- If cs.Total = 0 Then CurrentState = 3
- Case 3
- CurrentTotal = 0
- For x = 0 To CInt(Rnd(99))
- cs.Prices(x) = 100 * Rnd()
- CurrentTotal = CurrentTotal + cs.Prices(x)
- Next x
- cs.Done = True
- cs.Client = "Client" & txtClient.Text
- agCopyData cs, ByVal MappingAddress, Len(cs)
- CurrentState = 4
- Case 4
- agCopyData ByVal MappingAddress, cs, Len(cs)
- If cs.Total <> 0 Then
- For x = 0 To 99
- newtotal = newtotal + cs.Prices(x)
- Next x
- cs.Total = 0
- lstPurchase.AddItem Format$(CurrentTotal, "0.00")
- agCopyData cs, ByVal MappingAddress, Len(cs)
- If chkShop.value = 0 Then
- CurrentState = 0
- Else
- CurrentState = 1
- End If
- ' Clear file mapping handles, etc.
- CleanUp
- End If
- End Select
- Select Case CurrentState
- Case 0
- lblStatus.Caption = "Idle"
- Case 1
- lblStatus.Caption = "Looking for checkstand"
- Case 2
- lblStatus.Caption = "Waiting in line at checkstand"
- Case 3
- lblStatus.Caption = "Loading items onto checkstand"
- Case 4
- lblStatus.Caption = "Waiting for checkout to be complete"
- End Select
- End Sub
- Public Function GetMappingName() As String
- GetMappingName = "ChkStd1map"
- End Function
- Private Sub CleanUp()
- ' Remember, this won't get called if you Stop without
- ' closing the main window.
- If MappingAddress <> 0 Then
- Call UnmapViewOfFile(MappingAddress)
- MappingAddress = 0
- End If
- If MappingHandle <> 0 Then
- Call CloseHandle(MappingHandle)
- MappingHandle = 0
- End If
- End Sub
-