Skip to content

Commit

Permalink
fixes for running/installing on Win10
Browse files Browse the repository at this point in the history
  • Loading branch information
acnicholls committed Mar 14, 2020
1 parent 5c2a1c0 commit 326788c
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 47 deletions.
1 change: 1 addition & 0 deletions ATS.VBP
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Form=Forms\frmPIN.frm
Form=Forms\frmReportSelector.frm
Form=Forms\frmTransferTransaction.frm
Form=Forms\frmWithdrawalTransaction.frm
Module=LIB_Extern; LIB _Extern.bas
IconForm="frmMain"
Startup="frmMain"
HelpFile=""
Expand Down
2 changes: 1 addition & 1 deletion Data/Accounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"10003",3,200
"10004",352900.1,618785.1
"10001",43515.4901,48712.7296
"10007",1007,4280.5
"10007",1007,24280.5
2 changes: 1 addition & 1 deletion Data/TransactionIDGenerator.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"1234500134"
"1234500136"
3 changes: 2 additions & 1 deletion Data/Transactions.dat
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@
"07/12/2003",1234500124,"ADMINISTRATOR","00000","","F",5000,0,0,5000
"07/12/2003",1234500125,"ADMINISTRATOR","00000","","R",5000,0,0,10000
"07/18/2003",1234500126,"ADMINISTRATOR","00000","","F",5000,0,0,5000

"03-14-2020",1234500134,"Vaughan","10007","S","D",10000,1007,14280.5,4010
"03-14-2020",1234500135,"Vaughan","10007","S","D",10000,1007,24280.5,4010
1 change: 1 addition & 0 deletions Forms/frmAccountInfo.frm
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ Begin VB.Form frmAccountInfo
Left = 3720
TabIndex = 1
Top = 2280
Visible = 0 'False
Width = 1215
End
Begin VB.Label Label5
Expand Down
2 changes: 1 addition & 1 deletion Forms/frmAdministrator.frm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Private Sub mnuMoneyFillUp_Click()
dtmToday = Date
'open file and read teller's balance for today's date
intFileHandle = FreeFile
Open App.Path & "\Data\DailyBalances.dat" For Input As #intFileHandle
Open gstrDailyBalanceFile For Input As #intFileHandle
Do While Not EOF(intFileHandle)
Input #intFileHandle, strDate, intBalance
'test date on file for equality to today's date
Expand Down
29 changes: 27 additions & 2 deletions Forms/frmMain.frm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 5.00
Begin VB.Form frmMain
BackColor = &H00808080&
BorderStyle = 4 'Fixed ToolWindow
BorderStyle = 1 'Fixed Single
ClientHeight = 8985
ClientLeft = 6195
ClientTop = 645
Expand All @@ -14,7 +14,6 @@ Begin VB.Form frmMain
MinButton = 0 'False
ScaleHeight = 8985
ScaleWidth = 11985
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.Timer Timer1
Enabled = 0 'False
Expand Down Expand Up @@ -339,6 +338,25 @@ End Sub
Private Sub Form_Load()
'set timer value to false to prevent timer activation without login
Timer1.Enabled = False
' set filenames for all data files
gstrDataFileLocation = GetSystemDrive & "\ProgramData\ATS"
gstrAccountFile = gstrDataFileLocation & "\Accounts.dat"
gstrTempAccountFile = gstrDataFileLocation & "\TempAccounts.dat"
gstrTransactionFile = gstrDataFileLocation & "\Transactions.dat"
gstrTransactionIdFile = gstrDataFileLocation & "\TransactionIdGenerator.dat"
gstrDailyBalanceFile = gstrDataFileLocation & "\DailyBalances.dat"
gstrTempDailyBalanceFile = gstrDataFileLocation & "\TempDailyBalances.dat"
gstrDatabaseFile = gstrDataFileLocation & "\ATM.mdb"

If Not FolderExists("C:\ProgramData\ATS") Then
MkDir gstrDataFileLocation
FileCopy App.Path & "\Data\Accounts.dat", gstrAccountFile
FileCopy App.Path & "\Data\Transactions.dat", gstrTransactionFile
FileCopy App.Path & "\Data\TransactionIDGenerator.dat", gstrTransactionIdFile
FileCopy App.Path & "\Data\DailyBalances.dat", gstrDailyBalanceFile
FileCopy App.Path & "\Data\ATM.mdb", gstrDatabaseFile
End If


End Sub

Expand Down Expand Up @@ -367,3 +385,10 @@ Private Sub Timer1_Timer()
Timer1.Enabled = False
frmMain.Refresh
End Sub


Private Function FolderExists(sFullPath As String) As Boolean
Dim myFSO As Object
Set myFSO = CreateObject("Scripting.FileSystemObject")
FolderExists = myFSO.FolderExists(sFullPath)
End Function
25 changes: 6 additions & 19 deletions Forms/frmPIN.frm
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Begin VB.Form frmPIN
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data\ATM.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data\ATM.mdb;Persist Security Info=False"
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
Expand Down Expand Up @@ -186,30 +186,13 @@ End Sub
Private Sub cmdOK_Click()
'this sub varifies lgoin data and directs the user an appropriate screen based on security level
Dim blnLoginOkay As Boolean
' Dim strUserType As String
' Dim intFileHandle As Integer
Dim strName As String
Dim strPIN As String
Dim strAccountNumber As String
'****************************************REMOVED CODE

' 'test user name field for info
' If txtUserName.Text = "" Then
' MsgBox " You must enter your name to proceed", vbOKOnly, "Missing field ..."
' txtUserName.SetFocus
' Exit Sub
' End If
' 'test PIN field for info
' If txtPIN.Text = "" Then
' MsgBox "You must enter your PIN to proceed", vbOKOnly, "Missing field ..."
' txtPIN.SetFocus
' Exit Sub
' End If
'if both fields are filled with info, count this as a login attempt
'Add one to counter and ready variables for testing
mintCounter = mintCounter - 1
blnLoginOkay = True
' strUserType = ""
'''''REady the recordset
adoPINS.Refresh
'goto first record
Expand Down Expand Up @@ -307,6 +290,10 @@ End Sub

Private Sub Form_Load()
mintCounter = 3
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\ProgramData\ATS\ATM.mdb;Persist Security Info=False
Me.adoPINS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & gstrDatabaseFile & ";Persist Security Info=False"




End Sub
Expand Down
5 changes: 3 additions & 2 deletions Forms/frmReportSelector.frm
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ Private Sub Form_Load()
frmReportSelector.Caption = "Date Transaction Report ..."
lblMessage.Caption = "Please select the date for which the transactions should be printed: "
intFileHandle = FreeFile
Open App.Path & "\Data\Transactions.dat" For Input As #intFileHandle
Open gstrTransactionFile For Input As #intFileHandle
Do While Not EOF(intFileHandle)
'read a record
Input #intFileHandle, strDate, lngTransactionID, strUserName, strUserAccountNumber, strAccountType, _
strTransactionCode, curTransactionAmount, curUserChequingAccountBalance, curUserSavingsAccountBalance, _
intTellerDailyBalance
blnFound = False
'test for each date already in the combobox to see if the date value has been found
For intCounter = 0 To cboSelection.ListCount
If Format(strDate, "yyyy/dd/mm") = Format(cboSelection.List(intCounter), "yyyy/dd/mm") Then
Expand All @@ -156,7 +157,7 @@ Private Sub Form_Load()
frmReportSelector.Caption = "Account Transaction Report ..."
lblMessage.Caption = "Please select the Account # for which the transactions should be printed: "
intFileHandle = FreeFile
Open App.Path & "\Data\Transactions.dat" For Input As #intFileHandle
Open gstrTransactionFile For Input As #intFileHandle
Do While Not EOF(intFileHandle)
'read a record
Input #intFileHandle, strDate, lngTransactionID, strUserName, strUserAccountNumber, strAccountType, _
Expand Down
2 changes: 1 addition & 1 deletion Forms/frmTransferTransaction.frm
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Private Sub cmdOK_Click()
gcurUserSavingsAccountBalance = gcurUserSavingsAccountBalance - curTransactionAmount
gcurUserChequingAccountBalance = gcurUserChequingAccountBalance + curTransactionAmount
WriteTransaction "S", "T", curTransactionAmount
gstrMessage = gstrMessage & "Chequing account to Savings account." & vbNewLine & vbNewLine
gstrMessage = gstrMessage & "Savings account to Chequing account." & vbNewLine & vbNewLine
gstrMessage = gstrMessage & "New Chequing account balance:" & Format(gcurUserChequingAccountBalance, "currency")
gstrMessage = gstrMessage & vbNewLine
gstrMessage = gstrMessage & "New Savings account balance:" & Format(gcurUserSavingsAccountBalance, "currency") & vbNewLine
Expand Down
3 changes: 3 additions & 0 deletions LIB _Extern.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Attribute VB_Name = "LIB_Extern"
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

57 changes: 38 additions & 19 deletions Libraries/LIB_ATS.bas
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ Public Const DEMO_MODE As Boolean = True
Public Const ADMINISTRATOR_NAME As String = "Korben Dallas"
Public Const ADMINISTRATOR_PIN As String = "D001"

' global variables for the file names containing data
Public gstrDataFileLocation As String
Public gstrAccountFile As String
Public gstrTempAccountFile As String
Public gstrTransactionFile As String
Public gstrTransactionIdFile As String
Public gstrDailyBalanceFile As String
Public gstrTempDailyBalanceFile As String
Public gstrDatabaseFile As String

'global variables used to display message to user
Public gstrMessage As String
Public gstrTitle As String
Expand Down Expand Up @@ -37,7 +47,7 @@ Public Sub ReadAccountsBalance()
Dim curSavingsAccountBalance As Currency
'open the file and read a record, test record against current user account number
intFileHandleInput = FreeFile
Open App.Path & "\Data\Accounts.dat" For Input As #intFileHandleInput
Open gstrAccountFile For Input As #intFileHandleInput
'while there is information to be read input each record and test the User account number
'if it tests true then apply users account balances to global variables and exit
Do While Not EOF(intFileHandleInput)
Expand All @@ -61,7 +71,7 @@ Public Sub WriteTransaction(ByVal strAccountType, ByVal strTransactionCode, ByVa
lngCurrentTransactionID = CLng(GetNextTransactionID)
intFileHandle = FreeFile
'open the file and write current transaction record
Open App.Path & "\Data\Transactions.dat" For Append As #intFileHandle
Open gstrTransactionFile For Append As #intFileHandle
Write #intFileHandle, Format(Date, "mm/dd/yyyy"); lngCurrentTransactionID; gstrUserName; gstrUserAccountNumber; _
strAccountType; strTransactionCode; curTransactionAmount; gcurUserChequingAccountBalance; _
gcurUserSavingsAccountBalance; gintTellerDailyBalance
Expand All @@ -81,7 +91,7 @@ Public Sub WriteAdministratorTransaction(ByVal strTransactionCode)
'get newest transaction ID and write transaction to file depending on transaction code
lngCurrentTransactionID = CLng(GetNextTransactionID)
intFileHandle = FreeFile
Open App.Path & "\Data\Transactions.dat" For Append As #intFileHandle
Open gstrTransactionFile For Append As #intFileHandle
Write #intFileHandle, Format(Date, "mm/dd/yyyy"); lngCurrentTransactionID; "ADMINISTRATOR"; "00000"; _
""; strTransactionCode; 5000, 0; 0; gintTellerDailyBalance
Close #intFileHandle
Expand All @@ -99,17 +109,18 @@ Public Sub CheckTellerBalance()
Dim strDate As String
Dim intBalance As Integer
Dim intFileHandle As Integer
Dim strMatchDate As String

blnFound = False
dtmToday = Date

'read Teller's balance
intFileHandle = FreeFile
Open App.Path & "\Data\DailyBalances.dat" For Input As #intFileHandle
Open gstrDailyBalanceFile For Input As #intFileHandle
Do While Not EOF(intFileHandle)
Input #intFileHandle, strDate, intBalance
'if found use global variable to hold the amount found for today's balance
If Format(strDate, "mm/dd/yyyy") = dtmToday Then
If Format(strDate, "mm/dd/yyyy") = Format(dtmToday, "mm/dd/yyyy") Then
blnFound = True
gintTellerDailyBalance = intBalance
Exit Do
Expand All @@ -122,7 +133,7 @@ Public Sub CheckTellerBalance()
gintTellerDailyBalance = 5000
strDate = Format(dtmToday, "mm/dd/yyyy")
WriteAdministratorTransaction ("F")
Open App.Path & "\Data\DailyBalances.dat" For Append As #intFileHandle
Open gstrDailyBalanceFile For Append As #intFileHandle
Write #intFileHandle, strDate, gintTellerDailyBalance
Close #intFileHandle
End If
Expand All @@ -141,10 +152,10 @@ Public Sub SaveTellerBalance()
dtmDate = Now
'open a file for reading
intFileHandleInput = FreeFile
Open App.Path & "\Data\DailyBalances.dat" For Input As #intFileHandleInput
Open gstrDailyBalanceFile For Input As #intFileHandleInput
'open a file for writing to
intFileHandleOutput = FreeFile
Open App.Path & "\Data\TempDailyBalances.dat" For Output As #intFileHandleOutput
Open gstrTempDailyBalanceFile For Output As #intFileHandleOutput
'while there is still information to be read, test the date against today's date and write to file if not equal
Do While Not EOF(intFileHandleInput)
Input #intFileHandleInput, strDate, intBalance
Expand All @@ -157,8 +168,8 @@ Public Sub SaveTellerBalance()
Write #intFileHandleOutput, Format(dtmDate, "mm/dd/yyyy"); gintTellerDailyBalance
Close
'change the temp output file to the permanent DailyBalances.dat file
Kill App.Path & "\Data\DailyBalances.dat"
Name App.Path & "\Data\TempDailyBalances.dat" As App.Path & "\Data\DailyBalances.dat"
Kill gstrDailyBalanceFile
Name gstrTempDailyBalanceFile As gstrDailyBalanceFile

End Sub

Expand All @@ -168,7 +179,7 @@ Public Function GetNextTransactionID() As Long
Dim strNextTransactionID As String
'open the file get the ID and close
intFileHandle = FreeFile
Open App.Path & "\Data\TransactionIDGenerator.dat" For Input As #intFileHandle
Open gstrTransactionIdFile For Input As #intFileHandle
Input #intFileHandle, strNextTransactionID
Close #intFileHandle
'make sure it's a long value, no decimals allowed
Expand All @@ -183,7 +194,7 @@ Public Function GenerateNextTransactionID(ByVal strCurrentTransactionID As Strin
intFileHandle = FreeFile
'add one to the current transaction ID and save to file for retrieval
strCurrentTransactionID = strCurrentTransactionID + 1
Open App.Path & "\Data\TransactionIDGenerator.dat" For Output As #intFileHandle
Open gstrTransactionIdFile For Output As #intFileHandle
Write #intFileHandle, Format(Val(strCurrentTransactionID), "0000000000")
Close #intFileHandle
'set the boolean concerning the next transaction ID number generated
Expand All @@ -205,10 +216,10 @@ Public Sub SaveAccountsBalance()
dtmToday = Date
'open Accounts.dat file to read from
intFileHandleInput = FreeFile
Open App.Path & "\Data\Accounts.dat" For Input As #intFileHandleInput
Open gstrAccountFile For Input As #intFileHandleInput
'create temporary file to write to
intFileHandleOutput = FreeFile
Open App.Path & "\Data\TempAccounts.dat" For Output As #intFileHandleOutput
Open gstrTempAccountFile For Output As #intFileHandleOutput
Do While Not EOF(intFileHandleInput)
'read a record
Input #intFileHandleInput, strUserAccountNumber, curChequingAccountBalance, curSavingsAccountBalance
Expand All @@ -222,8 +233,8 @@ Public Sub SaveAccountsBalance()
Write #intFileHandleOutput, gstrUserAccountNumber, gcurUserChequingAccountBalance, gcurUserSavingsAccountBalance
Close
'delete old file and replace with temp one
Kill App.Path & "\Data\Accounts.dat"
Name App.Path & "\Data\TempAccounts.dat" As App.Path & "\Data\Accounts.dat"
Kill gstrAccountFile
Name gstrTempAccountFile As gstrAccountFile
'send call to save teller's balance
SaveTellerBalance

Expand Down Expand Up @@ -306,7 +317,7 @@ Public Sub PrintDateReport()
Dim strLongDataToPrint As String * 23
'open the transactions file
intFileHandleTransaction = FreeFile
Open App.Path & "\Data\Transactions.dat" For Input As #intFileHandleTransaction
Open gstrTransactionFile For Input As #intFileHandleTransaction
Do While Not EOF(intFileHandleTransaction)
Input #intFileHandleTransaction, strDate, lngTransactionID, strUserName, strUserAccountNumber, _
strAccountType, strTransactionCode, curTransactionAmount, curUserChequingAccountBalance, _
Expand Down Expand Up @@ -360,7 +371,7 @@ Public Sub PrintAllTransactions()
Dim strLongDataToPrint As String * 23
'open the transaction file
intFileHandleTransaction = FreeFile
Open App.Path & "\Data\Transactions.dat" For Input As #intFileHandleTransaction
Open gstrTransactionFile For Input As #intFileHandleTransaction
Do While Not EOF(intFileHandleTransaction)
'input and print all records on file...no testing here folks!!
Input #intFileHandleTransaction, strDate, lngTransactionID, strUserName, strUserAccountNumber, _
Expand Down Expand Up @@ -412,7 +423,7 @@ Public Sub PrintAccountReport()
Dim strLongDataToPrint As String * 23
'open transaction file
intFileHandleTransaction = FreeFile
Open App.Path & "\Data\Transactions.dat" For Input As #intFileHandleTransaction
Open gstrTransactionFile For Input As #intFileHandleTransaction
Do While Not EOF(intFileHandleTransaction)
Input #intFileHandleTransaction, strDate, lngTransactionID, strUserName, strUserAccountNumber, _
strAccountType, strTransactionCode, curTransactionAmount, curUserChequingAccountBalance, _
Expand Down Expand Up @@ -447,3 +458,11 @@ Public Sub PrintAccountReport()
Printer.FontSize = 16
Printer.Print Space(6); "End of Report"
End Sub

'Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Public Function GetSystemDrive() As String
GetSystemDrive = Space(1000)
Call GetWindowsDirectory(GetSystemDrive, Len(GetSystemDrive))
GetSystemDrive = Left$(GetSystemDrive, 2)
End Function

0 comments on commit 326788c

Please sign in to comment.