home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / mts4.cab / Bank.VB_VBBank.frm < prev    next >
Text File  |  1997-11-14  |  18KB  |  618 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Sample Bank - Visual Basic"
  6.    ClientHeight    =   4320
  7.    ClientLeft      =   5040
  8.    ClientTop       =   5325
  9.    ClientWidth     =   8205
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   4320
  15.    ScaleWidth      =   8205
  16.    Begin VB.Frame Frame7 
  17.       Caption         =   "Language"
  18.       Height          =   735
  19.       Left            =   5760
  20.       TabIndex        =   32
  21.       Top             =   2280
  22.       Width           =   2415
  23.       Begin VB.OptionButton VB 
  24.          Caption         =   "VB"
  25.          Height          =   255
  26.          Left            =   600
  27.          TabIndex        =   35
  28.          Top             =   360
  29.          Width           =   255
  30.       End
  31.       Begin VB.OptionButton VC 
  32.          Caption         =   "Option2"
  33.          Height          =   255
  34.          Left            =   1320
  35.          TabIndex        =   34
  36.          Top             =   360
  37.          Width           =   255
  38.       End
  39.       Begin VB.OptionButton VJ 
  40.          Caption         =   "Option3"
  41.          Height          =   375
  42.          Left            =   2040
  43.          TabIndex        =   33
  44.          Top             =   240
  45.          Width           =   255
  46.       End
  47.       Begin VB.Label Label12 
  48.          Alignment       =   2  'Center
  49.          Caption         =   "Visual Basic"
  50.          Height          =   375
  51.          Left            =   120
  52.          TabIndex        =   38
  53.          Top             =   240
  54.          Width           =   495
  55.       End
  56.       Begin VB.Label Label11 
  57.          Alignment       =   2  'Center
  58.          Caption         =   "Visual C++"
  59.          Height          =   375
  60.          Left            =   840
  61.          TabIndex        =   37
  62.          Top             =   240
  63.          Width           =   495
  64.       End
  65.       Begin VB.Label Label10 
  66.          Alignment       =   2  'Center
  67.          Caption         =   "Visual J++"
  68.          Height          =   375
  69.          Left            =   1560
  70.          TabIndex        =   36
  71.          Top             =   240
  72.          Width           =   495
  73.       End
  74.    End
  75.    Begin VB.Frame Frame6 
  76.       Caption         =   "Component"
  77.       Height          =   975
  78.       Left            =   5760
  79.       TabIndex        =   27
  80.       Top             =   1320
  81.       Width           =   2415
  82.       Begin VB.OptionButton StatefulMoveMoney 
  83.          Caption         =   "Option2"
  84.          Height          =   255
  85.          Left            =   2040
  86.          TabIndex        =   40
  87.          Top             =   600
  88.          Width           =   255
  89.       End
  90.       Begin VB.OptionButton MoveMoney 
  91.          Caption         =   "Option2"
  92.          Height          =   255
  93.          Left            =   2040
  94.          TabIndex        =   31
  95.          Top             =   240
  96.          Width           =   255
  97.       End
  98.       Begin VB.OptionButton Account 
  99.          Caption         =   "VB"
  100.          Height          =   255
  101.          Left            =   840
  102.          TabIndex        =   29
  103.          Top             =   240
  104.          Width           =   255
  105.       End
  106.       Begin VB.Label Label6 
  107.          Alignment       =   2  'Center
  108.          Caption         =   "Stateful MoveMoney"
  109.          Height          =   255
  110.          Index           =   1
  111.          Left            =   480
  112.          TabIndex        =   39
  113.          Top             =   600
  114.          Width           =   1575
  115.       End
  116.       Begin VB.Label Label6 
  117.          Alignment       =   2  'Center
  118.          Caption         =   "MoveMoney"
  119.          Height          =   255
  120.          Index           =   0
  121.          Left            =   1080
  122.          TabIndex        =   30
  123.          Top             =   240
  124.          Width           =   975
  125.       End
  126.       Begin VB.Label Label5 
  127.          Alignment       =   2  'Center
  128.          Caption         =   "Account"
  129.          Height          =   255
  130.          Left            =   120
  131.          TabIndex        =   28
  132.          Top             =   240
  133.          Width           =   735
  134.       End
  135.    End
  136.    Begin VB.Frame Frame5 
  137.       Caption         =   "Response (sec)"
  138.       Height          =   975
  139.       Left            =   0
  140.       TabIndex        =   17
  141.       Top             =   2040
  142.       Width           =   5655
  143.       Begin VB.TextBox AvgResp 
  144.          Enabled         =   0   'False
  145.          Height          =   285
  146.          Left            =   4680
  147.          TabIndex        =   22
  148.          Top             =   360
  149.          Width           =   615
  150.       End
  151.       Begin VB.TextBox MaxResp 
  152.          Enabled         =   0   'False
  153.          Height          =   285
  154.          Left            =   2880
  155.          TabIndex        =   20
  156.          Top             =   360
  157.          Width           =   615
  158.       End
  159.       Begin VB.TextBox MinResp 
  160.          Enabled         =   0   'False
  161.          Height          =   285
  162.          Left            =   960
  163.          TabIndex        =   18
  164.          Top             =   360
  165.          Width           =   615
  166.       End
  167.       Begin VB.Label AvgRespCap 
  168.          Caption         =   "Average"
  169.          Height          =   255
  170.          Left            =   3840
  171.          TabIndex        =   23
  172.          Top             =   360
  173.          Width           =   735
  174.       End
  175.       Begin VB.Label Label4 
  176.          Caption         =   "Maximum"
  177.          Height          =   255
  178.          Left            =   2160
  179.          TabIndex        =   21
  180.          Top             =   360
  181.          Width           =   735
  182.       End
  183.       Begin VB.Label Label7 
  184.          Caption         =   "Minimum"
  185.          Height          =   255
  186.          Left            =   240
  187.          TabIndex        =   19
  188.          Top             =   360
  189.          Width           =   735
  190.       End
  191.    End
  192.    Begin VB.Frame Frame3 
  193.       Caption         =   "Result"
  194.       Height          =   1095
  195.       Left            =   0
  196.       TabIndex        =   15
  197.       Top             =   3120
  198.       Width           =   8175
  199.       Begin VB.TextBox Result 
  200.          Height          =   735
  201.          Left            =   120
  202.          MultiLine       =   -1  'True
  203.          TabIndex        =   16
  204.          Top             =   240
  205.          Width           =   7935
  206.       End
  207.    End
  208.    Begin VB.Frame Frame2 
  209.       Caption         =   "Iterations"
  210.       Height          =   615
  211.       Left            =   2760
  212.       TabIndex        =   12
  213.       Top             =   1320
  214.       Width           =   2895
  215.       Begin VB.CheckBox Step 
  216.          Caption         =   "Check1"
  217.          Height          =   255
  218.          Left            =   2520
  219.          TabIndex        =   41
  220.          Top             =   240
  221.          Width           =   255
  222.       End
  223.       Begin VB.TextBox nCurTrans 
  224.          Enabled         =   0   'False
  225.          Height          =   285
  226.          Left            =   240
  227.          TabIndex        =   26
  228.          Text            =   "11111"
  229.          Top             =   240
  230.          Width           =   615
  231.       End
  232.       Begin VB.TextBox nTrans 
  233.          Height          =   285
  234.          Left            =   1200
  235.          TabIndex        =   7
  236.          Top             =   240
  237.          Width           =   615
  238.       End
  239.       Begin VB.Label Label13 
  240.          Caption         =   "&Step"
  241.          Height          =   255
  242.          Left            =   2040
  243.          TabIndex        =   43
  244.          Top             =   240
  245.          Width           =   375
  246.       End
  247.       Begin VB.Label Label9 
  248.          Caption         =   "Label9"
  249.          Height          =   15
  250.          Left            =   2040
  251.          TabIndex        =   42
  252.          Top             =   360
  253.          Width           =   15
  254.       End
  255.       Begin VB.Label Label8 
  256.          Caption         =   "&of"
  257.          Height          =   255
  258.          Left            =   960
  259.          TabIndex        =   13
  260.          Top             =   240
  261.          Width           =   135
  262.       End
  263.    End
  264.    Begin VB.CommandButton Close 
  265.       Cancel          =   -1  'True
  266.       Caption         =   "&Close"
  267.       Height          =   375
  268.       Left            =   5760
  269.       TabIndex        =   9
  270.       Top             =   720
  271.       Width           =   2415
  272.    End
  273.    Begin VB.CommandButton Command1 
  274.       Caption         =   "&Submit"
  275.       Default         =   -1  'True
  276.       Height          =   375
  277.       Index           =   0
  278.       Left            =   5760
  279.       TabIndex        =   8
  280.       Top             =   240
  281.       Width           =   2415
  282.    End
  283.    Begin VB.Frame Frame4 
  284.       Caption         =   "Transaction Type"
  285.       Height          =   615
  286.       Left            =   0
  287.       TabIndex        =   3
  288.       Top             =   1320
  289.       Width           =   2655
  290.       Begin VB.OptionButton Transfer 
  291.          Caption         =   "Trans&fer"
  292.          Height          =   315
  293.          Left            =   1680
  294.          TabIndex        =   6
  295.          Top             =   240
  296.          Width           =   915
  297.       End
  298.       Begin VB.OptionButton Credit 
  299.          Caption         =   "&Credit"
  300.          Height          =   315
  301.          Left            =   240
  302.          TabIndex        =   4
  303.          Top             =   240
  304.          Value           =   -1  'True
  305.          Width           =   735
  306.       End
  307.       Begin VB.OptionButton Debit 
  308.          Caption         =   "&Debit"
  309.          Height          =   315
  310.          Left            =   960
  311.          TabIndex        =   5
  312.          Top             =   240
  313.          Width           =   735
  314.       End
  315.    End
  316.    Begin VB.Frame Frame1 
  317.       Caption         =   "Your Account Information"
  318.       Height          =   1095
  319.       Left            =   0
  320.       TabIndex        =   0
  321.       Top             =   120
  322.       Width           =   5655
  323.       Begin VB.TextBox PrimeAcct 
  324.          Height          =   285
  325.          Left            =   1860
  326.          TabIndex        =   1
  327.          Top             =   360
  328.          Width           =   1215
  329.       End
  330.       Begin VB.TextBox SecondAcct 
  331.          Enabled         =   0   'False
  332.          Height          =   285
  333.          Left            =   1860
  334.          TabIndex        =   14
  335.          Top             =   720
  336.          Width           =   1215
  337.       End
  338.       Begin VB.TextBox Amount 
  339.          Height          =   285
  340.          Left            =   4200
  341.          TabIndex        =   2
  342.          Top             =   360
  343.          Width           =   1215
  344.       End
  345.       Begin VB.Label promptSecondAcct 
  346.          Alignment       =   1  'Right Justify
  347.          Caption         =   "&Transfer to Account "
  348.          Enabled         =   0   'False
  349.          Height          =   315
  350.          Left            =   240
  351.          TabIndex        =   25
  352.          Top             =   720
  353.          Width           =   1515
  354.       End
  355.       Begin VB.Label Label1 
  356.          Alignment       =   1  'Right Justify
  357.          Caption         =   "&Account Number"
  358.          Height          =   315
  359.          Left            =   240
  360.          TabIndex        =   24
  361.          Top             =   360
  362.          Width           =   1515
  363.       End
  364.       Begin VB.Label Label3 
  365.          Caption         =   "Label3"
  366.          Height          =   15
  367.          Left            =   300
  368.          TabIndex        =   11
  369.          Top             =   2100
  370.          Width           =   615
  371.       End
  372.       Begin VB.Label Label2 
  373.          Alignment       =   1  'Right Justify
  374.          Caption         =   "A&mount"
  375.          Height          =   315
  376.          Left            =   3240
  377.          TabIndex        =   10
  378.          Top             =   360
  379.          Width           =   915
  380.       End
  381.    End
  382. End
  383. Attribute VB_Name = "Form1"
  384. Attribute VB_GlobalNameSpace = False
  385. Attribute VB_Creatable = False
  386. Attribute VB_PredeclaredId = True
  387. Attribute VB_Exposed = False
  388. ' Filename: Bank.vbp
  389. '
  390. ' Description: Sample bank client
  391. '
  392. ' This file is provided as part of the Microsoft Transaction Server Samples
  393. '
  394. ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
  395. ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  396. ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
  397. ' OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
  398. ' PURPOSE.
  399. '
  400. ' Copyright (C) 1997 Microsoft Corporation, All rights reserved
  401.  
  402. Option Explicit
  403. Private Const APP_ERROR = -2147467008
  404.  
  405. ' Timer Variables
  406. Private Declare Function GetTickCount Lib "kernel32" () As Long
  407. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  408. Private StartTime As Long
  409. Private Elapsed As Long
  410. Private AvgResponseTime As Long
  411. Private minRespTime As Long
  412. Private maxRespTime As Long
  413. Private lRet As Long
  414. Private Res As Variant
  415.  
  416. Private Sub Account_Click()
  417.     VC.Enabled = True
  418.     VJ.Enabled = True
  419.     Transfer.Enabled = False
  420. End Sub
  421.  
  422. Private Sub Close_Click()
  423.     End
  424. End Sub
  425.  
  426. Private Sub Command1_Click(Index As Integer)
  427.     Dim lSecondAcct As Long
  428.     Dim TranType As String
  429.     
  430.     Screen.MousePointer = 11
  431.     On Error GoTo ErrorHandler
  432.     
  433.     ' Decide which component to use
  434.     Dim ProgID As String
  435.     If Account = True Then
  436.         ProgID = "Bank.Account"
  437.     Else
  438.         ProgID = "Bank.MoveMoney"
  439.     End If
  440.     
  441.     ' Decide which language to use
  442.     If VC = True Then
  443.         ProgID = ProgID + ".VC"
  444.     ElseIf VJ = True Then
  445.         ProgID = ProgID + ".VJ"
  446.     End If
  447.     
  448.     ' Decide transaction type
  449.     Result = ""
  450.     lSecondAcct = 0
  451.     Dim Mult As Long
  452.     If Debit = True Then
  453.         TranType = 1
  454.         Mult = -1
  455.     ElseIf Credit = True Then
  456.         TranType = 2
  457.         Mult = 1
  458.     Else
  459.         If ProgID = "Bank.Account" Then
  460.             MsgBox "Error. Use MoveMoney component to transfer."
  461.             MoveMoney.SetFocus
  462.             Screen.MousePointer = 0
  463.             Exit Sub
  464.         End If
  465.         If SecondAcct = "" Then
  466.             MsgBox "Error. Transfer to Account must be filled in."
  467.             SecondAcct.SetFocus
  468.             Screen.MousePointer = 0
  469.             Exit Sub
  470.         Else
  471.             TranType = 3
  472.             lSecondAcct = CLng(SecondAcct)
  473.         End If
  474.     End If
  475.    
  476.     ' Create the appropriate MoveMoney object
  477.     On Error GoTo objError
  478.     Dim obj As Object
  479.     Set obj = CreateObject(ProgID)
  480.     On Error GoTo ErrorHandler
  481.     
  482.     If obj Is Nothing Then
  483.         Screen.MousePointer = 0
  484.         MsgBox "Create object " + ProgID + "failed."
  485.         Exit Sub
  486.     End If
  487.     
  488.     InitTimer
  489.     
  490.     ' Call the object
  491.     Dim i As Long
  492.     For i = 1 To nTrans
  493.         StartTimer
  494.         Res = ""
  495.         If Account = True Then
  496.             Res = obj.Post(CLng(PrimeAcct), CLng(Amount * Mult))
  497.         ElseIf MoveMoney = True Then
  498.             Res = obj.Perform(CLng(PrimeAcct), lSecondAcct, CLng(Amount), TranType)
  499.         Else
  500.             obj.PrimeAccount = PrimeAcct
  501.             obj.SecondAccount = lSecondAcct
  502.             Res = obj.StatefulPerform(CLng(Amount), TranType)
  503.         End If
  504.         EndTimer
  505.         nCurTrans = i
  506.         Result = Res
  507.         If lRet <> 0 Then
  508.             Exit For
  509.         End If
  510.         If Step = 1 And i <> nTrans Then
  511.             MsgBox "Step mode, OK to continue"
  512.         End If
  513.     Next i
  514.     
  515.     FinishTimer
  516.     
  517.     Set obj = Nothing
  518.   
  519.     Result = Res
  520.     Screen.MousePointer = 0
  521.     Exit Sub
  522.     
  523. objError:
  524.     MsgBox "Error " & Err.Number & ": Make sure the Sample Bank package has been correctly installed in MTS."
  525.     Screen.MousePointer = 0
  526.     Err.Clear
  527.     Exit Sub
  528.     
  529. ErrorHandler:
  530.     Screen.MousePointer = 0
  531.     MsgBox Err.Number & "(" & Err.Source & ") :" & Err.Description
  532.     Err.Clear
  533.  
  534. End Sub
  535.  
  536. Private Sub Credit_Click()
  537.     SecondAcct.Enabled = False
  538.     promptSecondAcct.Enabled = False
  539.     SecondAcct = ""
  540.     Account.Enabled = True
  541. End Sub
  542. Private Sub Debit_Click()
  543.     SecondAcct.Enabled = False
  544.     promptSecondAcct.Enabled = False
  545.     SecondAcct = ""
  546.     Account.Enabled = True
  547. End Sub
  548. Private Sub Form_Load()
  549.     PrimeAcct = 1
  550.     SecondAcct = ""
  551.     Amount = 1
  552.     Result = ""
  553.     Debit = 0
  554.     Credit = 1
  555.     Transfer = 0
  556.     MoveMoney = 1
  557.     VB = 1
  558.     nCurTrans = 0
  559.     nTrans = 1
  560.     Step = 0
  561.     MinResp = 0
  562.     MaxResp = 0
  563.     AvgResp = 0
  564. End Sub
  565.  
  566. Private Sub MoveMoney_Click()
  567.     VC.Enabled = True
  568.     VJ.Enabled = True
  569.     Transfer.Enabled = True
  570. End Sub
  571.  
  572. Private Sub transfer_Click()
  573.     SecondAcct.Enabled = True
  574.     promptSecondAcct.Enabled = True
  575.     Account.Enabled = False
  576. End Sub
  577.  
  578. Public Sub StartTimer()
  579.     StartTime = GetTickCount()
  580. End Sub
  581.  
  582. Public Sub EndTimer()
  583.     Elapsed = GetTickCount - StartTime
  584.     If Elapsed < minRespTime Then minRespTime = Elapsed
  585.     If Elapsed > maxRespTime Then maxRespTime = Elapsed
  586.     AvgResponseTime = AvgResponseTime + Elapsed
  587. End Sub
  588.  
  589. Public Sub FinishTimer()
  590.     AvgResponseTime = AvgResponseTime / nTrans
  591.     AvgResp = Format(AvgResponseTime / 1000, "#0.###")
  592.     MinResp = Format(minRespTime / 1000, "#0.###")
  593.     MaxResp = Format(maxRespTime / 1000, "#0.###")
  594.     Form1.Refresh
  595. End Sub
  596. Public Sub InitTimer()
  597.     minRespTime = 99999999
  598.     maxRespTime = 0
  599.     AvgResponseTime = 0
  600. End Sub
  601.  
  602. Private Sub VC_Click()
  603.     StatefulMoveMoney.Enabled = False
  604. End Sub
  605.  
  606. Private Sub VJ_Click()
  607.     StatefulMoveMoney.Enabled = False
  608. End Sub
  609.  
  610. Private Sub VB_Click()
  611.     StatefulMoveMoney.Enabled = True
  612. End Sub
  613. Private Sub StatefulMoveMoney_Click()
  614.     VC.Enabled = False
  615.     VJ.Enabled = False
  616.     Transfer.Enabled = True
  617. End Sub
  618.