Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="atm/src"/>
<classpathentry kind="output" path="atm/build/classes"/>
</classpath>
28 changes: 28 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ATM-Management-System-Maintenance-Project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1768836522542</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This repository contains an ATM Management System project implemented in Java.

## Instructions

To run the program, follow these steps:
To run the program, follow these steps: --

1. Run the `AtmMainDriver` file.
1. Run the `AtmMainDriver` file.
2. No additional packages need to be downloaded.
3. The username and password for both "Admin" and "User" are as follows:
- Username: zahid
Expand Down
Binary file added atm/bin/atm/AccountData.class
Binary file not shown.
Binary file added atm/bin/atm/Admin.class
Binary file not shown.
Binary file added atm/bin/atm/AfterLogin.class
Binary file not shown.
Binary file added atm/bin/atm/AtmMainDriver.class
Binary file not shown.
Binary file added atm/bin/atm/LoginForm.class
Binary file not shown.
Binary file added atm/bin/atm/TestTransactionHistory.class
Binary file not shown.
Binary file modified atm/build/classes/atm/AccountData.class
Binary file not shown.
Binary file modified atm/build/classes/atm/Admin.class
Binary file not shown.
Binary file modified atm/build/classes/atm/AfterLogin.class
Binary file not shown.
Binary file modified atm/build/classes/atm/AtmMainDriver.class
Binary file not shown.
Binary file removed atm/build/classes/atm/LoginForm$ATM_System.class
Binary file not shown.
Binary file modified atm/build/classes/atm/LoginForm.class
Binary file not shown.
Binary file not shown.
40 changes: 38 additions & 2 deletions atm/src/atm/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import java.awt.Color;
import java.awt.Container;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.io.*;

/*\ I have to add these options
Add Account
Expand All @@ -23,7 +23,7 @@ public class Admin extends JFrame implements ActionListener
JLabel atmLab;
Container con;
ArrayList customerlist;
String s1,s2,s3;
String s1;
Admin()
{
super("ADMIN");
Expand Down Expand Up @@ -67,7 +67,42 @@ public class Admin extends JFrame implements ActionListener
saveToFile.addActionListener(this);
logOut.addActionListener(this);

loadPersons();
}

/*******************************LOAD ACCOUNT FROM FILE*******************************************/
public void loadPersons()
{
String ss[]=null;
String pincode,customername,accounttype,accountnumber,startbalance;

try
{
FileReader fr=new FileReader("Customer Record.txt");
BufferedReader br=new BufferedReader(fr);

String line=br.readLine();

while(line != null)
{
ss=line.split(",");
pincode=ss[0];
customername=ss[1];
accounttype=ss[2];
accountnumber=ss[3];
startbalance=ss[4];

AccountData atm=new AccountData(pincode,customername,accounttype,accountnumber,startbalance);
customerlist.add(atm);
line=br.readLine();
}
br.close();
fr.close();
}
catch(IOException ioEX)
{
System.out.println("No existing customer records found. Starting fresh.");
}
}

/*******************************ADD ACCOUNT************************************************/
Expand Down Expand Up @@ -218,6 +253,7 @@ public void edit(String n)
/************************************************************************************************************/

/***************************************************************************************************/
@Override
public void actionPerformed(ActionEvent e)
{

Expand Down
160 changes: 133 additions & 27 deletions atm/src/atm/AfterLogin.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package atm;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.io.*;

public class AfterLogin extends JFrame implements ActionListener
{

JButton equiryBtn,withdrawBtn,logoutBtn,transferBtn;
JButton equiryBtn,withdrawBtn,logoutBtn,transferBtn,transactionHistoryButton;
JLabel atmLab;
Container con;
ArrayList customerlist;
Admin adm = new Admin();
String s1;
String pincode;

AfterLogin()
{
Expand All @@ -38,20 +38,25 @@ public class AfterLogin extends JFrame implements ActionListener
withdrawBtn = new JButton("WithDraw Money");
withdrawBtn.setBounds(260,230,150,40);


transactionHistoryButton = new JButton("Transaction History");
transactionHistoryButton.setBounds(200,300,180,30);
transactionHistoryButton.setFont(new Font("Arial", Font.BOLD, 14));

logoutBtn = new JButton("Logout");
logoutBtn.setBounds(10,230,150,40);

con.add(atmLab);
con.add(equiryBtn);
con.add(withdrawBtn);
con.add(transferBtn);
con.add(transactionHistoryButton);
con.add(logoutBtn);
/********************************************************************/

equiryBtn.addActionListener(this);
transferBtn.addActionListener(this);
withdrawBtn.addActionListener(this);
transactionHistoryButton.addActionListener(this);
logoutBtn.addActionListener(this);

loadPersons();
Expand Down Expand Up @@ -95,19 +100,79 @@ public void loadPersons()

/***************************************************************************************************************************/

/********************************************************* Transaction Logging Method *************************************/
private void logTransaction(String type, double amount, double newBalance) {
String filename = "transactions_" + this.pincode + ".txt";
try {
FileWriter fw = new FileWriter(filename, true);
BufferedWriter bw = new BufferedWriter(fw);

// Get current timestamp
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String timestamp = sdf.format(new java.util.Date());

// Write transaction details
bw.write(type + " | " + amount + " | " + newBalance + " | " + timestamp);
bw.newLine();
bw.close();
fw.close();
} catch(IOException ioEX) {
System.out.println(ioEX);
}
}

/***************************************************************************************************************************/

/********************************************************* View Transaction History *************************************/
public void viewTransactionHistory(String pincode) {
String filename = "transactions_" + pincode + ".txt";
try {
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);

ArrayList<String> transactions = new ArrayList<>();
String line = br.readLine();

while(line != null) {
transactions.add(line);
line = br.readLine();
}
br.close();
fr.close();

// Display last 10 transactions
StringBuilder history = new StringBuilder();
int start = Math.max(0, transactions.size() - 10);

if(transactions.isEmpty()) {
history.append("No transactions found.");
} else {
history.append("Last ").append(Math.min(10, transactions.size())).append(" Transactions:\n\n");
for(int i = start; i < transactions.size(); i++) {
history.append(transactions.get(i)).append("\n");
}
}

JOptionPane.showMessageDialog(null, history.toString(), "Transaction History", JOptionPane.INFORMATION_MESSAGE);
} catch(IOException ioEX) {
JOptionPane.showMessageDialog(null, "No transaction history found for this account.", "Transaction History", JOptionPane.INFORMATION_MESSAGE);
}
}

/***************************************************************************************************************************/


/********************************************************* Balance Enquiry of Customer ************************************/
private void inquiry(String k) {
for(int i=0;i<customerlist.size();i++) {
AccountData atm=(AccountData)customerlist.get(i);
if(k.equals(atm.pincode)) {
this.pincode = k;
JOptionPane.showMessageDialog(null,"Welcome to your atm data Mr ."+atm.customername+"\nYour Total Cash Is : "+atm.startbalance,"WELCOME WELCOME MR "+atm.customername,JOptionPane.INFORMATION_MESSAGE);
}
}
}

/********************************************************* Balance Enquiry of Customer ************************************/
public void inquiry(String n)
{
for(int i=0;i<customerlist.size();i++)
{
AccountData atm=(AccountData)customerlist.get(i);
if(n.equals(atm.pincode))
{
JOptionPane.showMessageDialog(null,"Welcome to your atm data Mr ."+atm.customername+"\nYour Total Cash Is : "+atm.startbalance,"WELCOME WELCOME MR "+atm.customername,JOptionPane.INFORMATION_MESSAGE);
}
}
}
/***************************************************************************************************************************/


Expand All @@ -127,10 +192,17 @@ public void transfer(String k)
d=Integer.parseInt(a);

c=JOptionPane.showInputDialog(null,"Enter The Account Number To whom you Transfer Amount","MONEY TRANSACTION MENU",JOptionPane.QUESTION_MESSAGE);
b=JOptionPane.showInputDialog(null,"Enter The Amount To Transfer","MONEYTRANSACTION MENU",JOptionPane.QUESTION_MESSAGE);
e=Integer.parseInt(b);

f=d-e;
//CR02- validation & error handling for balance transfer
try {
b = JOptionPane.showInputDialog(null,"Enter The Amount To Transfer", "MONEY TRANSACTION MENU",JOptionPane.QUESTION_MESSAGE);
e = Integer.parseInt(b);
if (e <= 0) {
throw new NumberFormatException();
}
} catch (NumberFormatException ex) {JOptionPane.showMessageDialog(null,"Invalid input. Please enter a valid numeric amount.","Input Error",JOptionPane.ERROR_MESSAGE);
return;
}
f = d - e;
while(f < 0)
{
a=atm.startbalance;
Expand All @@ -143,6 +215,8 @@ public void transfer(String k)
String u=String.valueOf(f);
atm.startbalance=u;

logTransaction("Transfer", (double)e, (double)f);

JOptionPane.showMessageDialog(null,"Transaction is done succesfully\n\nAmount of "+b+"is transferd To "+c+"\n\nYour Total Cash Is : "+atm.startbalance,"MONEY TRANSACTION PROCESSED",JOptionPane.INFORMATION_MESSAGE);

Admin as = new Admin();
Expand All @@ -168,10 +242,17 @@ public void withdraw(String o)
a=atm.startbalance;
d=Integer.parseInt(a);

b=JOptionPane.showInputDialog(null,"Enter The Amout To Withdarw","WITHDARW MENU",JOptionPane.QUESTION_MESSAGE);
e=Integer.parseInt(b);

f=d-e;
//CR02-validation & error handling for withdraw balance
try {
b = JOptionPane.showInputDialog(null,"Enter The Amount To Withdraw","WITHDRAW MENU",JOptionPane.QUESTION_MESSAGE);
e = Integer.parseInt(b);
if (e <= 0) {
throw new NumberFormatException();
}
} catch (NumberFormatException ex) {JOptionPane.showMessageDialog(null,"Invalid input. Please enter a valid numeric amount.","Input Error",JOptionPane.ERROR_MESSAGE);
return;
}
f = d - e;

while(f <0)
{
Expand All @@ -184,8 +265,9 @@ public void withdraw(String o)
f=d-e;
}
c=String.valueOf(f);
atm.startbalance=c;
JOptionPane.showMessageDialog(null,"Withdarw proccesed\nYou have Withdarwed Amount of"+b+"\nYour Total Cash Is now: "+atm.startbalance,"Information",JOptionPane.INFORMATION_MESSAGE);
atm.startbalance=c;
logTransaction("Withdraw", (double)e, (double)f);
JOptionPane.showMessageDialog(null,"Withdarw proccesed\nYou have Withdarwed Amount of"+b+"\nYour Total Cash Is now: "+atm.startbalance,"Information",JOptionPane.INFORMATION_MESSAGE);
Admin ad = new Admin();
ad.savePerson();
}
Expand All @@ -204,6 +286,7 @@ public void actionPerformed(ActionEvent e)
if(b == equiryBtn)
{
s1= JOptionPane.showInputDialog(null,"Enter PinCode To Check Account Balance ","Check Balance",JOptionPane.QUESTION_MESSAGE);
this.pincode = s1;


for(int i=0;i<customerlist.size();i++)
Expand All @@ -227,6 +310,7 @@ else if(s1.equals(atm.pincode))
if(b == withdrawBtn)
{
s1=JOptionPane.showInputDialog(null,"Enter PinCode To withDraw Balance ","Withdraw Balance",JOptionPane.QUESTION_MESSAGE);
this.pincode = s1;
for(int i=0;i<customerlist.size();i++)
{
AccountData atm=(AccountData)customerlist.get(i);
Expand All @@ -240,7 +324,7 @@ else if(s1.equals(atm.pincode))
else if(!s1.equals(atm.pincode))
{
JOptionPane.showMessageDialog(null,"You have entered Wrong Pincode \nPlease Enter Valid Pincode!!!!","Warning",JOptionPane.WARNING_MESSAGE);

}
}
}
Expand All @@ -249,6 +333,7 @@ else if(!s1.equals(atm.pincode))
if(b == transferBtn)
{
s1=JOptionPane.showInputDialog(null,"Enter PinCode To Transfer Balance ","Share balance",JOptionPane.QUESTION_MESSAGE);
this.pincode = s1;

for(int i=0;i<customerlist.size();i++)
{
Expand All @@ -267,6 +352,27 @@ else if(s1.equals(atm.pincode))
}
}

/******************************************************************************************************************************/

if(b == transactionHistoryButton)
{
s1= JOptionPane.showInputDialog(null,"Enter PinCode To View Transaction History ","Transaction History",JOptionPane.QUESTION_MESSAGE);

for(int i=0;i<customerlist.size();i++)
{
AccountData atm=(AccountData)customerlist.get(i);

if(s1.equals(atm.pincode))
{
viewTransactionHistory(s1);
}
else if(!s1.equals(atm.pincode))
{
JOptionPane.showMessageDialog(null,"You have entered Wrong Pincode \nPlease Enter Valid Pincode!!!!","Warning",JOptionPane.WARNING_MESSAGE);
}
}
}

/******************************************************************************************************************************/

if(b == logoutBtn)
Expand Down
4 changes: 1 addition & 3 deletions atm/src/atm/AtmMainDriver.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
package atm;
import java.awt.Color;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;

public class AtmMainDriver
Expand All @@ -17,3 +14,4 @@ public static void main(String[] args)
}

}

Loading