VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "BuyIt1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' Simple purchase class
' Copyright © 1998 by Desaware Inc. All Rights Reserved

Option Explicit

Private m_LoggedIn As Boolean ' True when the user is logged in
Private m_ItemToBuy As String ' The item to buy
Private m_ItemQuantity As Long   ' The quantity to buy
Private m_CustomerName As String ' The name of the current user

Public Property Get LoggedIn() As Boolean
   LoggedIn = m_LoggedIn
End Property

Public Property Get ItemToBuy() As String
   ItemToBuy = m_ItemToBuy
End Property

Public Property Get ItemQuantity() As Long
   ItemQuantity = m_ItemQuantity
End Property

Public Property Get CustomerName() As String
   CustomerName = m_CustomerName
End Property


Public Function Login(ByVal name As String) As Long
   If m_LoggedIn Or name = "" Then
      Login = -1
      Exit Function
   End If
   m_LoggedIn = True
   m_CustomerName = name
End Function

Public Function Logout() As Long
   If Not m_LoggedIn Then
      Logout = -1
      Exit Function
   End If
   m_LoggedIn = False
   m_CustomerName = ""
   m_ItemToBuy = ""
   m_ItemQuantity = 0
End Function

Public Function SetProduct(ByVal ProductName As String) As Long
   If Not m_LoggedIn Or ProductName = "" Then
      SetProduct = -1
      Exit Function
   End If
   m_ItemToBuy = ProductName
End Function

Public Function SetQuantity(ByVal Quantity As Long) As Long
   If Not m_LoggedIn Or Quantity <= 0 Then
      SetQuantity = -1
      Exit Function
   End If
   m_ItemQuantity = Quantity
End Function

Public Function Buy() As Long
   If Not m_LoggedIn Or m_ItemQuantity <= 0 Or m_ItemToBuy = "" Then
      Buy = -1
      Exit Function
   End If
   ' Some sort of purchasing functionality goes here
   m_ItemQuantity = 0
   m_ItemToBuy = ""
End Function
