home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / mts4.cab / Account.VB_Step8_receipt.cls < prev    next >
Text File  |  1997-11-14  |  3KB  |  80 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "GetReceipt"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. ' Filename: Account.vbp
  11. '
  12. ' Description:  GetReceipt Class
  13. '
  14. ' This file is provided as part of the Microsoft Transaction Server Samples
  15. '
  16. ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
  17. ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  18. ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
  19. ' OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
  20. ' PURPOSE.
  21. '
  22. ' Copyright (C) 1997 Microsoft Corporation, All rights reserved
  23.  
  24. Option Explicit
  25.  
  26. Private Const ERROR_NUMBER = vbObjectError + 0
  27. Private Const APP_ERROR = -2147467008
  28.  
  29. Public Function GetNextReceipt() As Long
  30.     
  31.     On Error GoTo ErrorHandler
  32.     
  33.     ' If Shared property does not already exist it will be initialized
  34.     Dim spmMgr As SharedPropertyGroupManager
  35.     Set spmMgr = CreateObject("MTxSpm.SharedPropertyGroupManager.1")
  36.  
  37.     Dim spmGroup As SharedPropertyGroup
  38.     Dim bResult As Boolean
  39.     Set spmGroup = spmMgr.CreatePropertyGroup("Receipt", LockMethod, Process, bResult)
  40.  
  41.     Dim spmPropNextReceipt As SharedProperty
  42.     Set spmPropNextReceipt = spmGroup.CreateProperty("Next", bResult)
  43.     
  44.     ' Set the initial value of the Shared Property to
  45.     ' 0 if the Shared Property didnÆt already exist.
  46.     ' This is not entirely necessary but demonstrates how to initialize a value.
  47.     If bResult = False Then
  48.         spmPropNextReceipt.Value = 0
  49.     End If
  50.  
  51.     Dim spmPropMaxNum As SharedProperty
  52.     Set spmPropMaxNum = spmGroup.CreateProperty("MaxNum", bResult)
  53.   
  54.     Dim objReceiptUpdate As Bank.UpdateReceipt
  55.     If spmPropNextReceipt.Value >= spmPropMaxNum.Value Then
  56.         Set objReceiptUpdate = GetObjectContext.CreateInstance("Bank.UpdateReceipt")
  57.         spmPropNextReceipt.Value = objReceiptUpdate.Update
  58.         spmPropMaxNum.Value = spmPropNextReceipt.Value + 100
  59.     End If
  60.  
  61.     ' Get the next receipt number and update property
  62.     spmPropNextReceipt.Value = spmPropNextReceipt.Value + 1
  63.  
  64.     GetObjectContext.SetComplete          ' we are finished and happy
  65.     
  66.     GetNextReceipt = spmPropNextReceipt.Value
  67.     
  68.     Exit Function
  69.     
  70. ErrorHandler:
  71.     GetObjectContext.SetAbort             ' we are unhappy
  72.     
  73.     GetNextReceipt = -1            ' indicate that an error occured
  74.     
  75.     Err.Raise Err.Number, "Bank.GetReceipt.GetNextReceipt", Err.Description
  76.     
  77. End Function
  78.  
  79.  
  80.