VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Account Bean"
   ClientHeight    =   4275
   ClientLeft      =   3855
   ClientTop       =   3390
   ClientWidth     =   6585
   BeginProperty Font 
      Name            =   "Times New Roman"
      Size            =   24
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   4275
   ScaleWidth      =   6585
   Begin VB.CommandButton Connect 
      Caption         =   "Connect to server"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4440
      TabIndex        =   14
      Top             =   240
      Width           =   1935
   End
   Begin VB.TextBox URL 
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2160
      TabIndex        =   12
      Text            =   "t3://localhost:7001"
      Top             =   240
      Width           =   2055
   End
   Begin VB.CommandButton Deposit 
      Caption         =   "Deposit"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3720
      TabIndex        =   5
      Top             =   2160
      Width           =   1215
   End
   Begin VB.CommandButton Withdraw 
      Caption         =   "Withdraw"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   4
      Top             =   2160
      Width           =   1335
   End
   Begin VB.TextBox Amount 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2160
      TabIndex        =   3
      Top             =   1560
      Width           =   2055
   End
   Begin VB.CommandButton LookupAccount 
      Caption         =   "Lookup Account"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4440
      TabIndex        =   1
      Top             =   840
      Width           =   1815
   End
   Begin VB.TextBox AccountNum 
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2160
      TabIndex        =   0
      Top             =   840
      Width           =   2055
   End
   Begin VB.Label Label2 
      Caption         =   "Server URL:Port:"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   13
      Top             =   240
      Width           =   1695
   End
   Begin VB.Label Summary 
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   2040
      TabIndex        =   11
      Top             =   3480
      Width           =   4095
   End
   Begin VB.Label Label6 
      Caption         =   "Summary:"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   960
      TabIndex        =   10
      Top             =   3480
      Width           =   975
   End
   Begin VB.Label Label5 
      Caption         =   "Transaction:"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   840
      TabIndex        =   9
      Top             =   2160
      Width           =   1215
   End
   Begin VB.Label Label4 
      Caption         =   "Transaction amount:"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   8
      Top             =   1560
      Width           =   1815
   End
   Begin VB.Label Label3 
      Caption         =   "Account number:"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   7
      Top             =   840
      Width           =   1695
   End
   Begin VB.Label Balance 
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2280
      TabIndex        =   6
      Top             =   2760
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Balance:  $"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1080
      TabIndex        =   2
      Top             =   2760
      Width           =   1095
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ctx As Object
Dim broker As Object
Dim account As Object


Rem Connect to WebLogic Server
Private Sub Connect_Click()
    Set WebLogic = GetObject("java:weblogic.com.Tengah")
    Set ctx = WebLogic.getInitialContext(URL.Text)
    Set broker = ctx.lookup("beanManaged.AccountHome")
    LookupAccount.Enabled = True
    AccountNum.Enabled = True
    URL.Enabled = False
    Connect.Enabled = False
End Sub

Rem Initialize dialog
Private Sub Form_Load()
    Amount.Enabled = False
    Withdraw.Enabled = False
    Deposit.Enabled = False
    LookupAccount.Enabled = False
    AccountNum.Enabled = False
End Sub

Rem Look up the account
Private Sub LookupAccount_Click()

    On Error GoTo lookupfailed
    Set pk = GetObject("java:examples.ejb.beanManaged.interfaces.AccountPK")
    pk.accountId = AccountNum.Text
    Set account = broker.findByPrimaryKey(pk)
    GoTo success
    
lookupfailed:
    On Error GoTo createfailed
    Set account = broker.Create(AccountNum.Text, 3000)
    GoTo success
    
createfailed:
    AccountNum.Text = "assertion, shouldn't happen"
    Exit Sub
    
success:
    Balance.Caption = account.Balance
    Amount.Enabled = True
    Withdraw.Enabled = True
    Deposit.Enabled = True
    Summary.Caption = ""
End Sub

Rem Withdraw from the account
Private Sub WithDraw_Click()
    On Error GoTo withdrawfailed
    account.Withdraw Amount.Text
    Balance.Caption = account.Balance
    Summary.Caption = ("Withdrew $" + Amount.Text)
    Amount.Text = ""
    Exit Sub
    
withdrawfailed:
    Summary.Caption = "Withdraw failed, rolling back transaction"
    Amount.Text = ""
    
End Sub

Rem Deposit into the account
Private Sub Deposit_Click()
    On Error GoTo depositfailed
    account.Deposit Amount.Text
    Balance.Caption = account.Balance
    Summary.Caption = ("Deposited $" + Amount.Text)
    Amount.Text = ""
    Exit Sub
    
depositfailed:
    Summary.Caption = "Deposit failed"
    Amount.Text = ""

End Sub

