http://rapidshare.com/files/96373605/Adapter_Demo__Mini_.zip
Best Projects
Bug Trackingsystem,Books online shopping,college management system,HR management system,Internet banking,Online chat room ,Online exam,Telephone billing system,Banking application,ATM database,airways reservation system,virtual network computing ,calculator,SMTP(simple mail transfer protocol)
Archives
-
▼
2008
(101)
-
▼
July
(67)
- Adapter_Demo__Mini
- Applet_Add__Mini
- Applet_Frame__Mini
- Applet_Window__Mini
- Banner__Mini
- Browser__Mini
- Choice_List__Mini
- Clint_Test__Mini
- Color_Demo__Mini
- Double_Buffer__Mini
- First_Applet__Mini
- Grid__Mini
- HServlet__Mini
- Image_Load__Mini
- Image_Swing__Mini
- Inetaddress_Demo1__Mini
- InnerClassdemo__Mini
- Java_Buttons__Mini
- Java_Label__Mini
- Jdbc_test1__Mini
- Jdbc update__Mini
- Jlabeldemo__Mini
- JScrollPaneDemo_Mini
- Key_Events_Mini
- Lawte_Mini
- List_Demo_Mini
- Logo_Mini
- Observed_ImageLoad_Mini
- Rectangles_Mini
- Resize_Me_Mini
- Sample_Applet_Mini
- Sb_Demo_Mini
- Server_Test_Mini
- Servlet_Database_Mini
- servlet_To_Applet_Mini
- Simple_Key_Mini
- Text_Demo_Mini
- Textarea_Demo_Mini
- UDP_Server_Mini
- UDPClient_Mini
- Window_Events_Mini
- Advertising Agency
- Books Online Shopping
- BugTracking System
- College Management Sysyetm
- Doctors
- Human Resource Management System
- Internet Banking
- Intranet Chatting
- Java_Mail_Filter
- MIS Coding Nokia Soft
- Online Cources
- Online Exam
- Power Point Sliding
- Practical_Aircraft_Position
- project planning management
- Puyo Puyo game
- Sliding Window Protocol
- Telephone Billing system
- Voice over internet protocol
- No title
- Banking Application
- ATM Database
- airways reservation system
- Chat Room Application
- Snake(applet)
- Poor Man's PaintShop
-
▼
July
(67)
Advertising Agency
The Software Functions
User Applications
Advertising Details
Advertising users
Net Charges
Flight Desclogout
DownloadLink:
http://rapidshare.com/files/96377710/Advertising_Agency.zip
User Applications
Advertising Details
Advertising users
Net Charges
Flight Desclogout
DownloadLink:
http://rapidshare.com/files/96377710/Advertising_Agency.zip
Books Online Shopping
The Software Functions
User Applications
Create New account
Software
Hardware
Book Categories
Music
Mail
DownloadLink:
http://rapidshare.com/files/96377767/Books_online_shopping.zip
User Applications
Create New account
Software
Hardware
Book Categories
Music
DownloadLink:
http://rapidshare.com/files/96377767/Books_online_shopping.zip
Doctors
The Software Performance
1Users
Doctors
Patients
Hospitals
Medical Quiz
Change Password
DownloadLink:
http://rapidshare.com/files/96378056/Doctors.zip
1Users
Doctors
Patients
Hospitals
Medical Quiz
Change Password
DownloadLink:
http://rapidshare.com/files/96378056/Doctors.zip
Internet Banking
The Software Performance
Loging
add member
statement
loan
Transaction
query
logout
DownloadLink:
http://rapidshare.com/files/96378145/Internet_Banking.zip
Loging
add member
statement
loan
Transaction
query
logout
DownloadLink:
http://rapidshare.com/files/96378145/Internet_Banking.zip
Intranet Chatting
Intranet Chatting
This Project Entitled as INTRANET CHATTING is used basically for chatting purpose with the remote clients or users on Internet or local networks. Here in this project a java client / server combination is used to chat with remote users. When a Client wants to chat with a user on a remote host, he sends a request to the Server with a identification name like chat-id, the server responds to the request by identifying the client-id which is already registered in the server domain and when matched his request is granted and the client can begin to chat with the remote users present on the internet or local network.
DownloadLink:
http://rapidshare.com/files/96378245/Intranet_Chatting.zip
This Project Entitled as INTRANET CHATTING is used basically for chatting purpose with the remote clients or users on Internet or local networks. Here in this project a java client / server combination is used to chat with remote users. When a Client wants to chat with a user on a remote host, he sends a request to the Server with a identification name like chat-id, the server responds to the request by identifying the client-id which is already registered in the server domain and when matched his request is granted and the client can begin to chat with the remote users present on the internet or local network.
DownloadLink:
http://rapidshare.com/files/96378245/Intranet_Chatting.zip
Online Exam
Loging
examination
exam rules
student Report
subjectlist
answerlist
logout
DownloadLink:
http://rapidshare.com/files/96378374/Online_Exam.zip
Puyo Puyo game
Discription: 1) Spheres(puyos) come down from the top of the game board in pairs. A player can move(left & right & down) and rotate them on their way down.
2) Spheres come in 4 different colors: red, blue, green, and yellow
3) Linking four or more spheres of the same color (horizontally, vertically or both(as in tetris)) removes them from the game board, allowing any sphere remaining to drop and fill the vacated space. This may lead to several possible "chain combos" if additional colors match.
4) The scoring is depends on the number of same color spheres forming tetris or chain combo and numberof chain combos formed at a single time. More the number more the score.
5) The level of the game automatically increased in the game progress depending on the number of spheres removed till.
DownloadLink:
http://rapidshare.com/files/96378749/Puyo_game.zip
2) Spheres come in 4 different colors: red, blue, green, and yellow
3) Linking four or more spheres of the same color (horizontally, vertically or both(as in tetris)) removes them from the game board, allowing any sphere remaining to drop and fill the vacated space. This may lead to several possible "chain combos" if additional colors match.
4) The scoring is depends on the number of same color spheres forming tetris or chain combo and numberof chain combos formed at a single time. More the number more the score.
5) The level of the game automatically increased in the game progress depending on the number of spheres removed till.
DownloadLink:
http://rapidshare.com/files/96378749/Puyo_game.zip
Sliding Window Protocol
Discription: Routing Algorithm is Part of the network layer software responsible for deciding which
output line an incoming packet should be transmitted on.
If the subnet uses datagrams internally,the decision must be made for each data packet.
If the subnet uses virtual circuits internally, routing decisions are made only when a new virtual circuit is being set up.
download link:
http://rapidshare.com/files/96378813/Sliding_Window_Protocol.zip
output line an incoming packet should be transmitted on.
If the subnet uses datagrams internally,the decision must be made for each data packet.
If the subnet uses virtual circuits internally, routing decisions are made only when a new virtual circuit is being set up.
download link:
http://rapidshare.com/files/96378813/Sliding_Window_Protocol.zip
Telephone Billing system
Discription:The Software Functions
User Applications
Create New account
login
Billing
Etc
Download link:
http://rapidshare.com/files/96378860/Telephone_Billing_System.zip
User Applications
Create New account
login
Billing
Etc
Download link:
http://rapidshare.com/files/96378860/Telephone_Billing_System.zip
Voice over internet protocol
Discription: This s/w is designed to provide support for voice communications using Internet protocol over internet at low cost with high quality of service. This is called VOIP. The feasibility of carrying voice and call signaling messages over Internet has already been demonstrated but delivering high quality commercial products and establishing public services has just begin. VOIP can be defined as the ability to make telephone calls over the IP-based data n/ws with a suitable Qos at low cost. Voice communications will certainly remain a basic form of interaction for all of us. The PSTN simply can not be replaced in a short period. The immediate Goal of VOIP service providers is to reproduce existing telephone capabilities at low cost and to offer a technically competitive alternative to the PSTN.
Download link
http://rapidshare.com/files/96378881/Voice_Over_Internet_protocol.
Download link
http://rapidshare.com/files/96378881/Voice_Over_Internet_protocol.
Banking Application
Description: Application to implement a Banking system that has the following details for a current account customer:
ľ Account Name
ľ Account Number
ľ Sort Code
The system also provides the following services to a customer:
ľ Opening an account
ľ Depositing money in an account
ľ Withdraw money from an account with the condition that the customer cannot withdraw more money than the amount that is present in the account
ľ Ask for a balance of the account
ľ Provide a mini statement showing a maximum of the last 10 transactions
ľ Close an account
ľ The customer can open a joint account that can be shared by 3 people
ľ The customer can have an overdraft of $5000
Assumptions
The program does not save the data of a customer permanently. Thus all data related to a particular session is deleted once the application ends.
The task does not require the application to be a multi user application thus the application is started by opening an account and ended by closing that particular account.
//main
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//BANKS CLASS INHERITS FROM THE JFRAME CLASS AND IMPLEMENTS ACTIONLISTENERS INTERFACE
public class Banks extends JFrame implements ActionListener{
//DECLARATION SECTION
//DECLARING IMAGEICONS FOR THE BUTTONS
private ImageIcon image1;
private ImageIcon image2;
private ImageIcon image3;
private ImageIcon image4;
private ImageIcon image5;
private ImageIcon image6;
//DECLARING COMPONENTS
private JButton openButton, depositButton, withDrawButton, balanceButton, miniStaButton, closeButton;
private JToolBar bar;
private JTextArea txtTextArea;
private JScrollPane scrBarForTextArea;
//DECLARING THE DIMENSIONS FOR THE BUTTONS
private Dimension buttonSize = new Dimension(200,50);
//DECLARING COLOR THAT ARE TO BE USED
private Color blue = new Color(10,110,255);
private Color white = new Color(255,255,255);
//DECLARING THE FONTS
private Font head = new Font("Castellar",Font.ITALIC,17);
//DECLARING VARIABLES
private String strTemp=null;
private String strAmount = "";
private float amount = 0;
//CREATING OBJECTS OF OTHER CLASSES
private Account current = new Account();
private JAccount joint = new JAccount();
//CONSTRUCTOR FOR THE BANKS CLASS
public Banks(){
super("GENIUSDIP'S BANKS");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = getContentPane();
con.setLayout(new BorderLayout());
con.add(getScrBarForTextArea(),BorderLayout.CENTER);
JToolBar bar = new JToolBar(SwingConstants.VERTICAL);
//ADDING BUTTONS TO THE TOOL BAR
bar.add(getOpenButton());
bar.add(getDepositButton());
bar.add(getWithDrawButton());
bar.add(getBalanceButton());
bar.add(getMinaStaButton());
bar.add(getCloseButton());
//DISABLING SOME BUTTONS
setAllBtnsEnabled(false);
//ADDING ACTION LISTENERS TO ALL THE BUTTONS
addActionListenerAllBtns();
//ADDING THE BAR TO THE CONTENT PANE
con.add(bar,BorderLayout.WEST);
}
//FUNCTION THAT RETURNS A TEXTAREA WITH SOME PROPERTIES SET
private JTextArea getTxtTextArea(){
if(txtTextArea==null){
txtTextArea=new JTextArea(10,10);
txtTextArea.setBackground(white);
txtTextArea.setForeground(blue);
txtTextArea.setEditable(false);
txtTextArea.setFont(head);
txtTextArea.setText("\t Geniusdip's Banks \n\n");
}
return txtTextArea;
}
//FUNCTION THAT RETURNS A SCROLLPANE WITH SOME PROPERTIES SET
private JScrollPane getScrBarForTextArea(){
if(scrBarForTextArea==null){
//VIEWING THE TEXTAREA FROM THE SCROLLPANE
scrBarForTextArea=new JScrollPane(getTxtTextArea());
}
return scrBarForTextArea;
}
//FUNCTION THAT RETURNS A BUTTON WITH SOME PROPERTIES SET
private JButton getOpenButton()
{
if(openButton==null)
{
ImageIcon image1 = new ImageIcon("OPENANACCOUNTANI.gif");
openButton=new JButton("",image1);
openButton.setPreferredSize(buttonSize);
}
return openButton;
}
//FUNCTION THAT RETURNS A BUTTON WITH SOME PROPERTIES SET
private JButton getDepositButton()
{
if(depositButton==null)
{
ImageIcon image2 = new ImageIcon("DEPOSIT.gif");
depositButton=new JButton("",image2);
depositButton.setPreferredSize(buttonSize);
}
return depositButton;
}
//FUNCTION THAT RETURNS A BUTTON WITH SOME PROPERTIES SET
private JButton getWithDrawButton()
{
if(withDrawButton==null)
{
ImageIcon image3 = new ImageIcon("WITHDRAW.gif");
withDrawButton=new JButton("",image3);
withDrawButton.setPreferredSize(buttonSize);
}
return withDrawButton;
}
//FUNCTION THAT RETURNS A BUTTON WITH SOME PROPERTIES SET
private JButton getBalanceButton()
{
if(balanceButton==null)
{
ImageIcon image4 = new ImageIcon("BALANCE.gif");
balanceButton=new JButton("",image4);
balanceButton.setPreferredSize(buttonSize);
}
return balanceButton;
}
//FUNCTION THAT RETURNS A BUTTON WITH SOME PROPERTIES SET
private JButton getMinaStaButton()
{
if(miniStaButton==null)
{
ImageIcon image5 = new ImageIcon("MINI.gif");
miniStaButton=new JButton("",image5);
miniStaButton.setPreferredSize(buttonSize);
}
return miniStaButton;
}
//FUNCTION THAT RETURNS A BUTTON WITH SOME PROPERTIES SET
private JButton getCloseButton()
{
if(closeButton==null)
{
ImageIcon image6 = new ImageIcon("CLOSE.gif");
closeButton=new JButton("",image6);
closeButton.setPreferredSize(buttonSize);
}
return closeButton;
}
//FUNCTION TO ENABLE OR DISABLE BUTTONS
private void setAllBtnsEnabled(boolean bool){
getDepositButton().setEnabled(bool);
getWithDrawButton().setEnabled(bool);
getBalanceButton().setEnabled(bool);
getMinaStaButton().setEnabled(bool);
getCloseButton().setEnabled(bool);
}
//FUNCTION TO ADD ACTIONLISTENERS TO BUTTONS
private void addActionListenerAllBtns(){
getOpenButton().addActionListener(this);
getDepositButton().addActionListener(this);
getWithDrawButton().addActionListener(this);
getBalanceButton().addActionListener(this);
getMinaStaButton().addActionListener(this);
getCloseButton().addActionListener(this);
}
//FUNCTION TO SET VARIABLES TO POINT TO NOTHING
private void setVariables(){
strTemp=null;
strAmount = "";
amount = 0;
current = null;
joint = null;
}
//THE ACTION PERFORMED METHOD
//EXECUTES WHEN THE CLICK EVENT IS FIRED
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
//OPEN BUTTON CLICKED
if(source==openButton){
String Name = "";
String ANumber = "";
String Name2 = "";
String Name3= "";
//QUERY THE USER FOR THE NEEDED INFORMATION
do
{
strTemp = JOptionPane.showInputDialog(null,"Please Enter C To Open A Current Account \n Or J To Open A Joint Account");
}while(strTemp==null || strTemp.length()==0);
switch(strTemp.charAt(0)){
case 'c':
case 'C':
//ENABLE ALL OTHER BUTTON EXCEPT THE OPEN BUTTON
setAllBtnsEnabled(true);
openButton.setEnabled(false);
do
{
Name = JOptionPane.showInputDialog(null,"Please Enter The Account Holder's Name");
}while(Name==null || Name.length()==0);
do
{
ANumber = JOptionPane.showInputDialog(null,"Please Enter The Account Number");
}while(ANumber==null || ANumber.length()==0);
current.openAnAccount(Name,ANumber,"Current Account");
txtTextArea.append("Current Account Created With The Following Details \n");
txtTextArea.append("Account Holder's Name:::" + current.getAccountName() + "\n");
txtTextArea.append("Account Number::::::::::" + current.getAccountNumber()+ "\n");
txtTextArea.append("Account Sort Code:::::::" + current.getSortCode()+ "\n");
break;
case 'j':
case 'J':
setAllBtnsEnabled(true);
openButton.setEnabled(false);
String choice = null;
do
{
choice = JOptionPane.showInputDialog(null,"Please Enter 2 If They Are 2 Account Holders For The Joint Account \n Or 3 If They Are 3 Account Holders For The Joint Account");
}while(choice==null || choice.length()==0);
switch(choice.charAt(0)){
case '2':
do
{
Name = JOptionPane.showInputDialog(null,"Please Enter The First Account Holder's Name");
}while(Name==null || Name.length()==0);
do
{
Name2 = JOptionPane.showInputDialog(null,"Please Enter The Second Account Holder's Name");
}while(Name2==null || Name2.length()==0);
do
{
ANumber = JOptionPane.showInputDialog(null,"Please Enter The Account Number");
}while(ANumber==null || ANumber.length()==0);
joint.openAnAccount(Name,Name2,ANumber,"Joint Account");
txtTextArea.append("Joint Account Created With The Following Details \n");
txtTextArea.append("First Account Holder's Name:::" + joint.getAccountName() + "\n");
txtTextArea.append("Second Account Holder's Name:::" + joint.getAccountName2() + "\n");
txtTextArea.append("Account Number::::::::::" + joint.getAccountNumber()+ "\n");
txtTextArea.append("Account Sort Code:::::::" + joint.getSortCode()+ "\n");
break;
case '3':
do
{
Name = JOptionPane.showInputDialog(null,"Please Enter The First Account Holder's Name");
}while(Name==null || Name.length()==0);
do
{
Name2 = JOptionPane.showInputDialog(null,"Please Enter The Second Account Holder's Name");
}while(Name2==null || Name2.length()==0);
do
{
Name3 = JOptionPane.showInputDialog(null,"Please Enter The Third Account Holder's Name");
}while(Name3==null || Name3.length()==0);
do
{
ANumber = JOptionPane.showInputDialog(null,"Please Enter The Account Number");
}while(ANumber==null || ANumber.length()==0);
joint.openAnAccount(Name,Name2,Name3,ANumber,"Joint Account");
txtTextArea.append("Joint Account Created With The Following Details \n");
txtTextArea.append("First Account Holder's Name:::" + joint.getAccountName() + "\n");
txtTextArea.append("Second Account Holder's Name:::" + joint.getAccountName2() + "\n");
txtTextArea.append("Third Account Holder's Name:::" + joint.getAccountName3() + "\n");
txtTextArea.append("Account Number::::::::::" + joint.getAccountNumber()+ "\n");
txtTextArea.append("Account Sort Code:::::::" + joint.getSortCode()+ "\n");
break;
default:
do
{
Name = JOptionPane.showInputDialog(null,"Please Enter The First Account Holder's Name");
}while(Name==null || Name.length()==0);
do
{
Name2 = JOptionPane.showInputDialog(null,"Please Enter The Second Account Holder's Name");
}while(Name2==null || Name2.length()==0);
do
{
Name3 = JOptionPane.showInputDialog(null,"Please Enter The Third Account Holder's Name");
}while(Name3==null || Name3.length()==0);
do
{
ANumber = JOptionPane.showInputDialog(null,"Please Enter The Account Number");
}while(ANumber==null || ANumber.length()==0); joint.openAnAccount(Name,Name2,Name3,ANumber,"Joint Account");
txtTextArea.append("Joint Account Created With The Following Details \n");
txtTextArea.append("First Account Holder's Name:::" + joint.getAccountName() + "\n");
txtTextArea.append("Second Account Holder's Name:::" + joint.getAccountName2() + "\n");
txtTextArea.append("Third Account Holder's Name:::" + joint.getAccountName3() + "\n");
txtTextArea.append("Account Number::::::::::" + joint.getAccountNumber()+ "\n");
txtTextArea.append("Account Sort Code:::::::" + joint.getSortCode()+ "\n");
}
break;
default:
setAllBtnsEnabled(true);
current = new Account();
do
{
Name = JOptionPane.showInputDialog(null,"Please Enter The Account Holder's Name");
}while(Name==null || Name.length()==0);
do
{
ANumber = JOptionPane.showInputDialog(null,"Please Enter The Account Number");
}while(ANumber==null || ANumber.length()==0);
current.openAnAccount(Name,ANumber,"Current Account");
txtTextArea.append("Current Account Created With The Following Details \n");
txtTextArea.append("Account Holder's Name:::" + current.getAccountName() + "\n");
txtTextArea.append("Account Number::::::::::" + current.getAccountNumber()+ "\n");
txtTextArea.append("Account Sort Code:::::::" + current.getSortCode()+ "\n");
}
//DEPOSIT BUTTON CLICKED
}else if(source==depositButton){
boolean success = false;
while(success == false){
try{
strAmount = JOptionPane.showInputDialog(null,"Please Enter The Amount To Deposit");
amount = Float.parseFloat(strAmount);
success = true;
}catch(Exception am){
JOptionPane.showMessageDialog(null,"Invalid Numerals Added");
}
}
switch(strTemp.charAt(0)){
case 'c':
case 'C':
current.deposit(amount);
txtTextArea.append(Float.toString(amount) + " Deposited Into Current Account \n");
break;
case 'j':
case 'J':
joint.deposit(amount);
txtTextArea.append(Float.toString(amount) + " Deposited Into Joint Account \n");
break;
}
//WITHDRAW BUTTON CLICKED
}else if(source==withDrawButton){
boolean success = false;
while(success == false){
try{
strAmount = JOptionPane.showInputDialog(null,"Please Enter The Amount To WithDraw");
amount = Float.parseFloat(strAmount);
success = true;
}catch(Exception amo){
JOptionPane.showMessageDialog(null,"Invalid Numerals Added");
}
}
switch(strTemp.charAt(0)){
case 'c':
case 'C':
String strTemp2 = current.withDraw(amount);
txtTextArea.append(strTemp2 + "\n");
break;
case 'j':
case 'J':
String strTemp3 = joint.withDraw(amount);
txtTextArea.append(strTemp3 + "\n");
break;
}
//BALANCE BUTTON CLICKED
}else if(source==balanceButton){
switch(strTemp.charAt(0)){
case 'c':
case 'C':
txtTextArea.append(Float.toString(current.askBalance()) + "\n");
break;
case 'j':
case 'J':
txtTextArea.append(Float.toString(joint.askBalance()) + "\n");
break;
}
//MINI STATEMENT BUTTON CLICKED
}else if(source==miniStaButton){
switch(strTemp.charAt(0)){
case 'c':
case 'C':
txtTextArea.append(current.askMiniStatement() + "\n");
break;
case 'j':
case 'J':
txtTextArea.append(joint.askMiniStatement() + "\n");
break;
}
//CLOSE BUTTON CLICKED
}else if(source==closeButton){
openButton.setEnabled(true);
switch(strTemp.charAt(0)){
case 'c':
case 'C':
current.closeAnAccount();
setVariables();
System.exit(0);
break;
case 'j':
case 'J':
//SET ALL VARIABLES TO POINT AT NOTHING
joint.closeAnAccount();
setVariables();
//EXIT THE SYSTEM
System.exit(0);
break;
}
txtTextArea.setText("\t Geniusdip's Banks \n\n");
}
}
//MAIN METHOD
public static void main(String[] args){
Banks fram=new Banks();
fram.setBounds(0,0,900,500);
fram.show();
}
}
//CLASS ACCOUNT TO HANDLE CURRENT ACCOUNT
class Account{
private String accountName="", accountNumber="", sortCode="";
private Transaction trans = new Transaction();
private float amountDeposited=0, amountWithDrawn=0, currentBalance=0;
private int x=0;
//PUBLIC PROPERTY TO GET ACCOUNT NAME
public String getAccountName()
{
return accountName;
}
//PUBLIC PROPERTY TO GET ACCOUNT NUMBER
public String getAccountNumber()
{
return accountNumber;
}
//PUBLIC PROPERTY TO GET SORT CODE
public String getSortCode()
{
return sortCode;
}
//PUBLIC PROPERTY TO SET ACCOUNT NAME
public void setAccountName(String accountName)
{
this.accountName = accountName;
}
//PUBLIC PROPERTY TO SET ACCOUNT NUMBER
public void setAccountNumber(String accountNumber)
{
this.accountNumber = accountNumber;
}
//PUBLIC PROPERTY TO SET SORTCODE
public void setSortCode(String sortCode)
{
this.sortCode = sortCode;
}
//FUNCTION TO OPEN AN ACCOUNT
public void openAnAccount(String accountName, String accountNumber, String sortCode)
{
this.setAccountName(accountName);
this.setAccountNumber(accountNumber);
this.setSortCode(sortCode);
}
//FUNCTION TO DEPOSIT
public void deposit(float amountDeposited){
trans.depositInToAccount(amountDeposited,x);
x++;
}
//OVERLOADED FUNCTION TO WITHDRAW WITH ONE ARGUMENT
public String withDraw(float amountWithDrawn){
String strWD="";
if(trans.queryCurrentBalance()>=amountWithDrawn){
trans.withDrawFromAnAccount(amountWithDrawn,x);
x++;
strWD=Float.toString(amountWithDrawn) + " Amount Withdrawn";
}else{
strWD="Insufficient Funds In Account";
}
return strWD;
}
//OVERLOADED FUNCTION TO WITHDRAW WITH 2 ARGUMENTS
public String withDraw(float amountWithDrawn, float overDrawnAmount){
trans.withDrawFromAnAccount(amountWithDrawn,x);
x++;
return Float.toString(overDrawnAmount);
}
//FUNCTION TO RETURN CURRENT BALANCE
public float askBalance(){
float balance = trans.queryCurrentBalance();
return balance;
}
//FUNCTION TO RETURN MINI STATEMENT
public String askMiniStatement(){
String strStatement = trans.showMiniStatement();
return strStatement;
}
//FUNCTION TO CLOSE AN ACCOUNT
public void closeAnAccount()
{
setAccountName(null);
setAccountNumber(null);
setSortCode(null);
trans = null;
}
//FUNCTION THAT RETURNS THE NEXT TRANSACTION NUMBER
public int getX(){
x++;
return x;
}
}
//CLASS TRANSACTIONS FOR ALL THE BANKING TRANSACTIONS
//INCLUDING ASK BALANCE, DEPOSIT, WITHDRAW & MINI STATEMENT
class Transaction{
private float amountDeposited=0, amountWithDrawn=0, currentBalance=0;
private float[] transactionAmount = new float[10];
private int[] transactionNumber = new int[10];
private String[] transactionType = new String[10];
public void depositInToAccount(float amountDeposited, int transactionNumber) throws IndexOutOfBoundsException
{
try{
if(amountDeposited>0)
{
this.amountDeposited = amountDeposited;
this.currentBalance = this.currentBalance + amountDeposited;
if(transactionNumber > 9){
for(int i=0;i<9;++i){> 9
//ALL THE ELEMENTS SHOULD GO ONE STEP BACK WARDS
//THE FIRST ELEMENT IS DELETED
this.transactionNumber[i] = this.transactionNumber[i+1];
this.transactionType[i] = this.transactionType[i+1];
this.transactionAmount[i] = this.transactionAmount[i+1];
}
//THE NEW ELEMENT IS ADDED AT THE END
this.transactionNumber[9] = transactionNumber;
this.transactionType[9] = "Deposited";
this.transactionAmount[9] = amountDeposited;
}else{
//ELSE JUST ADD IT AT THE INDEX SPECIFIED
this.transactionNumber[transactionNumber] = transactionNumber;
this.transactionType[transactionNumber] = "Deposited";
this.transactionAmount[transactionNumber] = amountDeposited;
}
}
}catch(IndexOutOfBoundsException a){
}
}
//WITHDRAW FROM ACCOUNT FUNCTION
public String withDrawFromAnAccount(float amountWithDrawn,int transactionNumber)
{
String strWithDraw="";
currentBalance = currentBalance - amountWithDrawn;
if(transactionNumber > 9){
//REINITIALIZE THE ARRAY IF THE TRANSACTION NUMBER IS > 9
//ALL THE ELEMENTS SHOULD GO ONE STEP BACK WARDS
//THE FIRST ELEMENT IS DELETED
for(int i=0;i<9;i++){ str="Transaction Number \t Transaction Type \t Transaction Amount \n" i =" 0;i<="9;++i){" str =" str" accountname2="" accountname3="" accountname2 =" accountName2;" accountname3 =" accountName2;" strwd="" test =" askBalance()-amountWithDrawn;">=0){
strWD=super.withDraw(amountWithDrawn);
}else if(test>=-5000 & test<0){
super.withDraw(amountWithDrawn,test);
strWD="Amount Withdrawn Utilized Over Draft Facility";
}else{
strWD="Insufficient Funds In Account Even With Over Draft Facility";
}
return strWD;
}
//FUNCTION TO CLOSE THE ACCOUNT
public void closeAnAccount(){
setAccountName2("");
setAccountName3("");
super.closeAnAccount();
}
}
END
ATM Database
Description: it runs like a ATM machine. you can withdraw money from bank or transfer money to other account
//Mainmenu.java
import java.awt.event.* ; //
import javax.swing.* ; // PACKAGES
import java.awt.* ; //
import java.sql.*; //
//-----------------THE MAIN MENU---------------------
public class MainMenu extends JFrame implements ActionListener {
private JButton but1, but2, but3, but4, but5, but6,but7,but8,but9 ;
private JLabel labb,label,label2,label3,label4,label4a,label5,label6,label6a,label7;
private JTextArea textarea;
private JPasswordField pwordfield;
private int pw,intt;
static String url = "jdbc:odbc:abc";
private String str1;
Container c;
//--Constructor----
public MainMenu() {
super("ATM");
}
//----Method Main(The main Method)-----
public void Main(){
c = getContentPane() ;
c.setLayout(null) ;
but1 = new JButton(">>>") ;
but1.setPreferredSize( new Dimension(100,30) ) ;
but1.setSize( but1.getPreferredSize() ) ;
but1.setLocation(50,50) ;
but1.addActionListener(this) ;
c.add(but1) ;
but2 = new JButton(">>>") ;
but2.setPreferredSize( new Dimension(100,30) ) ;
but2.setSize( but2.getPreferredSize() ) ;
but2.setLocation(50,100) ;
but2.addActionListener(this) ;
c.add(but2) ;
but3=new JButton(">>>");
but3.setPreferredSize(new Dimension(100,30));
but3.setSize(but3.getPreferredSize());
but3.addActionListener(this);
but3.setLocation(50,150);
c.add(but3);
but4 = new JButton("<<<");
but4.setPreferredSize(new Dimension(100,30));
but4.setSize(but4.getPreferredSize());
but4.addActionListener(this);
but4.setLocation(375,50);
c.add(but4);
but5 = new JButton("<<<");
but5.setPreferredSize(new Dimension(100,30));
but5.setSize(but5.getPreferredSize());
but5.setLocation(375,100);
but5.addActionListener(this);
c.add(but5);
but6 = new JButton("<<<");
but6.setPreferredSize(new Dimension(100,30));
but6.setSize(but6.getPreferredSize());
but6.setLocation(375,150);
but6.addActionListener(this);
but6.addActionListener(new ActionListener(){
//----Creating the odbc Driver for but6-----
public void actionPerformed(ActionEvent event){
if(event.getSource()==but6){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(
null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
}
}
});
c.add(but6);
but7 = new JButton("CANCEL");
but7.setPreferredSize(new Dimension(100,30));
but7.setSize(but7.getPreferredSize());
but7.setLocation(200,212);
but7.addActionListener(this);
c.add(but7);
label=new JLabel("CASH");
label.setPreferredSize(new Dimension(75,50));
label.setSize(label.getPreferredSize());
label.setLocation(160,40);
label.setToolTipText("to draw money,please click on the left button");
c.add(label);
label2 = new JLabel(" INFORMATION");
label2.setPreferredSize(new Dimension(85,50));
label2.setSize(label2.getPreferredSize());
label2.setLocation(280,40);
label2.setToolTipText("For information,please click on the left button");
c.add(label2);
label3 = new JLabel("TRANSFER");
label3.setPreferredSize(new Dimension(85,50));
label3.setSize(label3.getPreferredSize());
label3.setLocation(160,90);
label3.setToolTipText("for referring money,click on the right button");
c.add(label3);
label4 = new JLabel("CARD ");
label4.setPreferredSize(new Dimension(85,50));
label4.setSize(label4.getPreferredSize());
label4.setLocation(160,132);
label4.setToolTipText(
"For password,dept operations,please click on the left button");
c.add(label4);
label4a = new JLabel("TRANSACTIONS");
label4a.setPreferredSize(new Dimension(100,50));
label4a.setSize(label4a.getPreferredSize());
label4a.setLocation(160,148);
c.add(label4a);
label5 = new JLabel(" INVESTMENT");
label5.setPreferredSize(new Dimension(95,50));
label5.setSize(label5.getPreferredSize());
label5.setLocation(280,90);
label5.setToolTipText(
"To buy fund,bond etc.,please click on the right button");
c.add(label5);
label6 = new JLabel(" STANDARD");
label6.setPreferredSize(new Dimension(75,50));
label6.setSize(label6.getPreferredSize());
label6.setLocation(280,132);
label6.setToolTipText("To get 10$ rapidly,please click");
c.add(label6);
label6a = new JLabel(" CASH");
label6a.setPreferredSize(new Dimension(75,50));
label6a.setSize(label6a.getPreferredSize());
label6a.setLocation(280,147);
label6a.setToolTipText("To get 10$ rapidly please click");
c.add(label6a);
setSize(500,410) ;
show();
}
//------actionPerformed method for ActionListener-----
public void actionPerformed( ActionEvent event ){
if( event.getSource()==but7 )
System.exit(0) ;
else if( event.getSource() == but1 ){
new Cash();this.hide();}
else if(event.getSource()== but2 ){
new Transfer();this.hide();}
else if(event.getSource()==but3){
new CardTransactions();this.hide();}
else if(event.getSource()==but4 ){
new Information();this.hide();}
else if(event.getSource()==but6){
new StandardCash();this.hide();}
else if(event.getSource()==but9)
System.exit(0);
else if(event.getSource()==but8){
//----Select operation for comparison of first password entered----
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(
null, url,"CLASS NOT FOUND EXCEPTION !!!",
JOptionPane.INFORMATION_MESSAGE);
}
try{
String string = new String(pwordfield.getPassword());
intt=Integer.parseInt(string);
String run = "SELECT * FROM abc " +"WHERE password = " +intt;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
pw=password;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(
null,url,"SQL EXCEPTION AT SELECT OPERATION",
JOptionPane.INFORMATION_MESSAGE);
} this.hide();
//---Comparison---if there is not equivalent MainMenu does not appear-----
if(pw==intt){MainMenu s=new MainMenu();s.Main();}
else if(pw!=intt){
JOptionPane.showMessageDialog(
null,"Invalid Password,Please try again",
"EXCEPTION",JOptionPane.ERROR_MESSAGE);
MainMenu s=new MainMenu();s.Password();
}
}
}//-----method main---Executes the password asking--------
public static void main(String args[]){
MainMenu s=new MainMenu();
s.Password();
}//-----password method----------
public void Password(){
c = getContentPane() ;
c.setLayout(new FlowLayout()) ;
c.setBackground(Color.lightGray);
pwordfield=new JPasswordField(17);
c.add(pwordfield);
but8=new JButton("OK");
but8.setPreferredSize(new Dimension(90,25));
but8.setSize(but8.getPreferredSize());
but8.addActionListener(this);
c.add(but8);
but9=new JButton("CANCEL");
but9.setPreferredSize(new Dimension(90,25));
but9.setSize(but9.getPreferredSize());
but9.addActionListener(this);
c.add(but9);
//-----Informations about the program-----
String sttr=" W E L C O M E!\n"+
" Please write your password:\n"+
"----------------------------------------------\n"+
" This product is a\n"+
" guarenteed trade mark of\n"+
" 'SP COMPUTER SYSTEMS INC.\n"+
" For information we are on web:\n"+
" www.spcomputer.com\n"+
"----------------------------------------------\n"+
" Producer: ÖNER EKIZ";
//-----set up textarea----------------
textarea = new JTextArea(sttr,10,17);
c.add(new JScrollPane(textarea));
textarea.setBackground(Color.lightGray);
textarea.setEditable(false);
setSize(250,300) ;
show();
}
}
//Transfer.java
import java.awt.*; //
import java.awt.event.*; //
import javax.swing.*; // PACKAGES
import java.sql.*; //
import sun.jdbc.odbc.*; //
public class Transfer extends JFrame implements ActionListener{
private JTextField textfield1,textfield2,textfield3,textfield4,textfield5;
private JButton OKButton,ExitButton;
private JLabel label;
private int int1,int2,int3,Amount,Amount1,Password;
private String str1,str2,str3;
static String url = "jdbc:odbc:abc";
//SET UP GUI
public Transfer(){
super("Money Transfer");
Container container = getContentPane();
container.setLayout(new FlowLayout() );
label=new JLabel("Password of the user:");
label.setLocation(200,50);
container.add(label);
textfield5 = new JTextField(15);
container.add(textfield5);
textfield1 = new JTextField("Password of the receiver:");
textfield1.setEditable(false);
container.add(textfield1);
textfield2 = new JTextField(15);
container.add(textfield2);
textfield3 = new JTextField("Amount of the sent:",15);
textfield3.setEditable(false);
container.add(textfield3);
textfield4 = new JTextField(15);
container.add(textfield4);
OKButton = new JButton("OK");
OKButton.setPreferredSize(new Dimension(80,20));
OKButton.setSize(OKButton.getPreferredSize());
OKButton.addActionListener(this);
container.add(OKButton);
ExitButton = new JButton("Exit");
ExitButton.setPreferredSize(new Dimension(80,20));
ExitButton.setSize(ExitButton.getPreferredSize());
ExitButton.addActionListener(this);
container.add(ExitButton);
setSize(400,150);
setVisible(true);
}//-------------actionPerformed----------------------------------------
public void actionPerformed(ActionEvent event){
if(event.getSource()==ExitButton){
this.hide();MainMenu s=new MainMenu();s.Main();
}
else if(event.getSource()==OKButton){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
}
try{ //Select operation:
str3=textfield5.getText(); // gets password of user
int1=Integer.parseInt(str3);
String run = "SELECT * FROM abc " +"WHERE password = " +int1;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount=amount;
}
connection.close();
}
catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
str2=textfield4.getText(); //amount of sent
int3=Integer.parseInt(str2);
Amount=Amount-int3;
//--------------Updating values of the database-------------
String run = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+int1;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
//---Select operation for the person (the money transferred to)------
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
try{
str1=textfield2.getText();//password of receiver
int2=Integer.parseInt(str1);
String run2 = "SELECT * FROM abc " +"WHERE password = " +int2;
System.out.println(run2 + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run2);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount1=amount;
}
connection.close();
}
catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
Amount1=Amount1+int3;
//---------Updating the values for the person,money transferred to--
String run1 = "UPDATE abc SET " +
"amount='" +Amount1+"' WHERE password="+int2;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}
}
//Standardcash.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class StandardCash extends JFrame implements ActionListener {
private JButton button1,button2;
private JLabel label1;
private String str1;
private int Amount,Password;
private JTextField text1;
static String url = "jdbc:odbc:abc";
Container container;
//SET UP GUI
public StandardCash(){
super("Standard Cash (10$)");
Container container = getContentPane();
container.setLayout(null);
button1 = new JButton("OK");
button1.setPreferredSize(new Dimension (90,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(50,100);
button1.addActionListener(this);
container.add(button1);
text1=new JTextField(10);
text1.setPreferredSize(new Dimension(10,22));
text1.setSize(text1.getPreferredSize());
text1.setLocation(50,60);
container.add(text1);
button2 = new JButton("CANCEL");
button2.setPreferredSize(new Dimension (90,30));
button2.setSize(button2.getPreferredSize());
button2.addActionListener(this);
button2.setLocation(150,100);
container.add(button2);
label1 = new JLabel("Please enter your password:");
label1.setPreferredSize(new Dimension(250,20));
label1.setSize(label1.getPreferredSize());
label1.setLocation(50,40);
container.add(label1);
setSize(350,300);
show();
}//------Method for ActionListener-----------------
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
//Selecting the values for the user--------
try{
str1=text1.getText();
int int1=Integer.parseInt(str1);
String run = "SELECT * FROM abc " +"WHERE password = " +int1;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Password=password;
Amount=amount-10;
}
connection.close();
}
catch(SQLException a){
JOptionPane.showMessageDialog(
null,url,"SQL EXCEPTION AT SELECT OPERATION",
JOptionPane.INFORMATION_MESSAGE);
}
//-----Updating the Amount that is reduced up ^^----------
String run = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+Password;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(
null,url,"SQL EXCEPTION AT UPDATE OPERATION",
JOptionPane.INFORMATION_MESSAGE);
}
}
else if(event.getSource()==button2){
this.hide();
MainMenu s=new MainMenu();s.Main();
}
}
}
//Information.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class Information extends JFrame implements ActionListener {
private JButton button1,button2;
private JLabel label1,label2;
static String url = "jdbc:odbc:abc";
//-----Constructor------
public Information(){
super();
Container container = getContentPane();
container.setLayout(null);
button1 = new JButton(" >>> ");
button1.setPreferredSize(new Dimension(100,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(30,50);
button1.addActionListener(this);
container.add(button1);
button2 = new JButton(" CANCEL ");
button2.setPreferredSize(new Dimension(100,30));
button2.setSize(button2.getPreferredSize());
button2.setLocation(30,100);
button2.addActionListener(this);
container.add(button2);
label1 = new JLabel("Demonstration");
label1.setPreferredSize(new Dimension(120,30));
label1.setSize(label1.getPreferredSize());
label1.setLocation(150,43);
container.add(label1);
label2 = new JLabel("of Remainder");
label2.setPreferredSize(new Dimension(120,30));
label2.setSize(label2.getPreferredSize());
label2.setLocation(150,56);
container.add(label2);
setSize(400,300);
setVisible(true);
}//------actionPerformed method for ActionListener-----
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
DB2 s=new DB2();s.Demonstration();
}
else if(event.getSource()==button2){
//--Closes the present window--
this.hide();
//--Going to DB2 class for execution
DB2 s=new DB2();s.Back();
}
}
}
//DB.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class DB extends JFrame implements ActionListener {
static String url = "jdbc:odbc:abc";
private JTextField text1,text2,text3;
private JButton but1,but2,but3,but4;
private JLabel label1,label2,label3;
private int Amount,Amount1,pword,int1;
private String str1,str2,str3;
private String run;
Container c;
//---Constructor---
public DB(){
}//---Method for getting different amount--called from class Cash--
public void ExecutionForAnother(){
Container c=getContentPane();
c.setLayout(new FlowLayout());
label2=new JLabel(" Write the money you want to get and your password:");
c.add(label2);
text1=new JTextField(10);
c.add(text1);
label1=new JLabel("<>");
c.add(label1);
text2=new JTextField(10);
c.add(text2);
but1=new JButton(" OK ");
but1.addActionListener(this);
but1.setBackground(Color.white);
c.add(but1);
but4=new JButton(" BACK ");
but4.addActionListener(this);
but4.setBackground(Color.white);
c.add(but4);
setSize(400,250);
setResizable(true);
show();
}//----Method for getting one of the value(money) that is seen
//---on the screen--Called from class Cash---
public void CashScreen(){
c=getContentPane();
c.setLayout(new FlowLayout());
label3 = new JLabel("PLEASE WRITE Pword & PRESS OK:");
c.add(label3);
text3=new JTextField(10);
c.add(text3);
but2 = new JButton("OK");
but2.setPreferredSize(new Dimension(80,25));
but2.setSize(but2.getPreferredSize());
but2.setBackground(Color.white);
but2.addActionListener(this);
c.add(but2);
but3 = new JButton("CANCEL");
but3.setPreferredSize(new Dimension(80,25));
but3.setSize(but3.getPreferredSize());
but3.setBackground(Color.white);
but3.addActionListener(this);
c.add(but3);
setSize(350,200);
show();
}//--------Method for the ActionListener---------
public void actionPerformed(ActionEvent event){
if(event.getSource()==but2){// for CashScreen
str3=text3.getText();
int int8=Integer.parseInt(str3);
try{ //--Selection for CashScreen---
String run = "SELECT * FROM abc " +"WHERE password=" +int8;
System.out.println(run+"SQL Operatýon Executed..");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while (result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount = amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECTION OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
Amount=Amount-20; //reducing the user's money
//---Updating the new values----
String run1 = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+int8;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}//--------------------------------------------------------
else if(event.getSource()==but4){
this.hide();}
else if(event.getSource()==but1){ //for another
str2=text1.getText(); // gets password
pword=Integer.parseInt(str2);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
//---Selection for ExecutionForAnother----
try{
String run = "SELECT * FROM abc " +"WHERE password = " +pword;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount1=amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
str1=text2.getText(); //gets the wanted money
int1 =Integer.parseInt(str1);
Amount1=Amount1-int1; //and subtract it from the total money
//--Update the Amount after operations above--
String run1 = "UPDATE abc SET " +
"amount='" +Amount1+"' WHERE password="+pword;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}
else if(event.getSource()==but3){
this.hide();
}
}//--end of method actionPerformed---
}//--end of class.
//Cardtransactions.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class CardTransactions extends JFrame {
private JButton button1,button2,button3;
private JLabel label1,label2;
static String url = "jdbc:odbc:abc";
Container container;
//---Constructor---
public CardTransactions(){
super(" Card Transactions");
Container container = getContentPane();
container.setLayout(null);
button1 = new JButton(">>>");
button1.setPreferredSize(new Dimension(100,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(30,50);
//---making connection with the database---
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
//--goes to DB2-ChangePword to execute changing password--
DB2 s=new DB2();s.ChangePword();
}
});
container.add(button1);
button2 = new JButton(">>>");
button2.setPreferredSize(new Dimension(100,30));
button2.setSize(button2.getPreferredSize());
button2.setLocation(30,100);
//--makes the connection with the database
//--and goes to DB2 to execute paying dept
button2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
DB2 s=new DB2();s.DeptPaying();
}
});
container.add(button2);
button3 = new JButton("");
button3.setPreferredSize(new Dimension(100,30));
button3.setSize(button3.getPreferredSize());
button3.setLocation(30,150);
button3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
DB2 s=new DB2();s.Back();
}
});
container.add(button3);
label1 = new JLabel("Change Password");
label1.setPreferredSize(new Dimension(120,30));
label1.setSize(label1.getPreferredSize());
label1.setLocation(130,45);
container.add(label1);
label2 = new JLabel("Dept paying");
label2.setPreferredSize(new Dimension(120,30));
label2.setSize(label2.getPreferredSize());
label2.setLocation(130,98);
container.add(label2);
setSize(400,350);
setVisible(true);
}//--end of constructor
}
//Cash.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class Cash extends JFrame implements ActionListener{
public JButton button1,button2,button3,button4,button5,button6,cancelBut;
private JLabel label1,label2,label3,label4,label5,label6;
private JTextField textField;
static String url = "jdbc:odbc:abc";
//---Constructor---
public Cash(){
super("Cash");
Container container=getContentPane() ;
container.setLayout(null);
textField=new JTextField(10);
button1 = new JButton(">>>");
button1.setPreferredSize(new Dimension(100,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(50,50);
button1.addActionListener(this);
container.add(button1);
button2 = new JButton(">>>");
button2.setPreferredSize(new Dimension(100,30));
button2.setSize(button2.getPreferredSize());
button2.setLocation(50,100);
button2.addActionListener(this);
container.add(button2);
button3 = new JButton(">>>");
button3.setPreferredSize(new Dimension(100,30));
button3.setSize(button3.getPreferredSize());
button3.setLocation(50,150);
button3.addActionListener(this);
container.add(button3);
button4 = new JButton("<<<");
button4.setPreferredSize(new Dimension(100,30));
button4.setSize(button4.getPreferredSize());
button4.setLocation(375,50);
//---makes the communication with the odbc Driver---
button4.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}}DB s=new DB();s.CashScreen();}
});
container.add(button4);
button5 = new JButton("<<<");
button5.setPreferredSize(new Dimension(100,30));
button5.setSize(button5.getPreferredSize());
button5.setLocation(375,100);
button5.addActionListener(this);
container.add(button5);
button6 = new JButton("<<<");
button6.setPreferredSize(new Dimension(100,30));
button6.setSize(button6.getPreferredSize());
button6.setLocation(375,150);
//---makes the communication with the odbc Driver---
button6.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}}DB s=new DB();s.ExecutionForAnother();}
});
container.add(button6);
cancelBut = new JButton("CANCEL");
cancelBut.setPreferredSize(new Dimension(100,30));
cancelBut.setSize(cancelBut.getPreferredSize());
cancelBut.setLocation(375,200);
cancelBut.addActionListener(this);
container.add(cancelBut);
label1=new JLabel(" 10 $");
label1.setPreferredSize(new Dimension(75,30));
label1.setSize(label1.getPreferredSize());
label1.setLocation(150,50);
container.add(label1);
label2=new JLabel(" 20 $");
label2.setPreferredSize(new Dimension(75,30));
label2.setSize(label2.getPreferredSize());
label2.setLocation(300,50);
container.add(label2);
label3=new JLabel(" 40 $");
label3.setPreferredSize(new Dimension(75,30));
label3.setSize(label3.getPreferredSize());
label3.setLocation(150,100);
container.add(label3);
label4=new JLabel(" 50 $");
label4.setPreferredSize(new Dimension(75,30));
label4.setSize(label4.getPreferredSize());
label4.setLocation(300,100);
container.add(label4);
label5=new JLabel(" 100 $");
label5.setPreferredSize(new Dimension(75,30));
label5.setSize(label5.getPreferredSize());
label5.setLocation(150,150);
container.add(label5);
label6=new JLabel(" Another..");
label6.setPreferredSize(new Dimension(85,30));
label6.setSize(label6.getPreferredSize());
label6.setLocation(300,150);
container.add(label6);
setSize(500,400);
setVisible(true);
}//---Method for Actionlistener---
public void actionPerformed(ActionEvent event){
if(event.getSource()==cancelBut){
this.hide();//closes the present application
MainMenu s=new MainMenu();s.Main();//and goes to MainMenu
}
}
}
//DB-1
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class DB extends JFrame implements ActionListener {
static String url = "jdbc:odbc:abc";
private JTextField text1,text2,text3;
private JButton but1,but2,but3,but4;
private JLabel label1,label2,label3;
private int Amount,Amount1,pword,int1;
private String str1,str2,str3;
private String run;
Container c;
//---Constructor---
public DB(){
}//---Method for getting different amount--called from class Cash--
public void ExecutionForAnother(){
Container c=getContentPane();
c.setLayout(new FlowLayout());
label2=new JLabel(" Write the money you want to get and your password:");
c.add(label2);
text1=new JTextField(10);
c.add(text1);
label1=new JLabel("<>");
c.add(label1);
text2=new JTextField(10);
c.add(text2);
but1=new JButton(" OK ");
but1.addActionListener(this);
but1.setBackground(Color.white);
c.add(but1);
but4=new JButton(" BACK ");
but4.addActionListener(this);
but4.setBackground(Color.white);
c.add(but4);
setSize(400,250);
setResizable(true);
show();
}//----Method for getting one of the value(money) that is seen
//---on the screen--Called from class Cash---
public void CashScreen(){
c=getContentPane();
c.setLayout(new FlowLayout());
label3 = new JLabel("PLEASE WRITE Pword & PRESS OK:");
c.add(label3);
text3=new JTextField(10);
c.add(text3);
but2 = new JButton("OK");
but2.setPreferredSize(new Dimension(80,25));
but2.setSize(but2.getPreferredSize());
but2.setBackground(Color.white);
but2.addActionListener(this);
c.add(but2);
but3 = new JButton("CANCEL");
but3.setPreferredSize(new Dimension(80,25));
but3.setSize(but3.getPreferredSize());
but3.setBackground(Color.white);
but3.addActionListener(this);
c.add(but3);
setSize(350,200);
show();
}//--------Method for the ActionListener---------
public void actionPerformed(ActionEvent event){
if(event.getSource()==but2){// for CashScreen
str3=text3.getText();
int int8=Integer.parseInt(str3);
try{ //--Selection for CashScreen---
String run = "SELECT * FROM abc " +"WHERE password=" +int8;
System.out.println(run+"SQL Operatýon Executed..");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while (result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount = amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECTION OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
Amount=Amount-20; //reducing the user's money
//---Updating the new values----
String run1 = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+int8;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}//--------------------------------------------------------
else if(event.getSource()==but4){
this.hide();}
else if(event.getSource()==but1){ //for another
str2=text1.getText(); // gets password
pword=Integer.parseInt(str2);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
//---Selection for ExecutionForAnother----
try{
String run = "SELECT * FROM abc " +"WHERE password = " +pword;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount1=amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
str1=text2.getText(); //gets the wanted money
int1 =Integer.parseInt(str1);
Amount1=Amount1-int1; //and subtract it from the total money
//--Update the Amount after operations above--
String run1 = "UPDATE abc SET " +
"amount='" +Amount1+"' WHERE password="+pword;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}
else if(event.getSource()==but3){
this.hide();
}
}//--end of method actionPerformed---
}//--end of class.
END
//Mainmenu.java
import java.awt.event.* ; //
import javax.swing.* ; // PACKAGES
import java.awt.* ; //
import java.sql.*; //
//-----------------THE MAIN MENU---------------------
public class MainMenu extends JFrame implements ActionListener {
private JButton but1, but2, but3, but4, but5, but6,but7,but8,but9 ;
private JLabel labb,label,label2,label3,label4,label4a,label5,label6,label6a,label7;
private JTextArea textarea;
private JPasswordField pwordfield;
private int pw,intt;
static String url = "jdbc:odbc:abc";
private String str1;
Container c;
//--Constructor----
public MainMenu() {
super("ATM");
}
//----Method Main(The main Method)-----
public void Main(){
c = getContentPane() ;
c.setLayout(null) ;
but1 = new JButton(">>>") ;
but1.setPreferredSize( new Dimension(100,30) ) ;
but1.setSize( but1.getPreferredSize() ) ;
but1.setLocation(50,50) ;
but1.addActionListener(this) ;
c.add(but1) ;
but2 = new JButton(">>>") ;
but2.setPreferredSize( new Dimension(100,30) ) ;
but2.setSize( but2.getPreferredSize() ) ;
but2.setLocation(50,100) ;
but2.addActionListener(this) ;
c.add(but2) ;
but3=new JButton(">>>");
but3.setPreferredSize(new Dimension(100,30));
but3.setSize(but3.getPreferredSize());
but3.addActionListener(this);
but3.setLocation(50,150);
c.add(but3);
but4 = new JButton("<<<");
but4.setPreferredSize(new Dimension(100,30));
but4.setSize(but4.getPreferredSize());
but4.addActionListener(this);
but4.setLocation(375,50);
c.add(but4);
but5 = new JButton("<<<");
but5.setPreferredSize(new Dimension(100,30));
but5.setSize(but5.getPreferredSize());
but5.setLocation(375,100);
but5.addActionListener(this);
c.add(but5);
but6 = new JButton("<<<");
but6.setPreferredSize(new Dimension(100,30));
but6.setSize(but6.getPreferredSize());
but6.setLocation(375,150);
but6.addActionListener(this);
but6.addActionListener(new ActionListener(){
//----Creating the odbc Driver for but6-----
public void actionPerformed(ActionEvent event){
if(event.getSource()==but6){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(
null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
}
}
});
c.add(but6);
but7 = new JButton("CANCEL");
but7.setPreferredSize(new Dimension(100,30));
but7.setSize(but7.getPreferredSize());
but7.setLocation(200,212);
but7.addActionListener(this);
c.add(but7);
label=new JLabel("CASH");
label.setPreferredSize(new Dimension(75,50));
label.setSize(label.getPreferredSize());
label.setLocation(160,40);
label.setToolTipText("to draw money,please click on the left button");
c.add(label);
label2 = new JLabel(" INFORMATION");
label2.setPreferredSize(new Dimension(85,50));
label2.setSize(label2.getPreferredSize());
label2.setLocation(280,40);
label2.setToolTipText("For information,please click on the left button");
c.add(label2);
label3 = new JLabel("TRANSFER");
label3.setPreferredSize(new Dimension(85,50));
label3.setSize(label3.getPreferredSize());
label3.setLocation(160,90);
label3.setToolTipText("for referring money,click on the right button");
c.add(label3);
label4 = new JLabel("CARD ");
label4.setPreferredSize(new Dimension(85,50));
label4.setSize(label4.getPreferredSize());
label4.setLocation(160,132);
label4.setToolTipText(
"For password,dept operations,please click on the left button");
c.add(label4);
label4a = new JLabel("TRANSACTIONS");
label4a.setPreferredSize(new Dimension(100,50));
label4a.setSize(label4a.getPreferredSize());
label4a.setLocation(160,148);
c.add(label4a);
label5 = new JLabel(" INVESTMENT");
label5.setPreferredSize(new Dimension(95,50));
label5.setSize(label5.getPreferredSize());
label5.setLocation(280,90);
label5.setToolTipText(
"To buy fund,bond etc.,please click on the right button");
c.add(label5);
label6 = new JLabel(" STANDARD");
label6.setPreferredSize(new Dimension(75,50));
label6.setSize(label6.getPreferredSize());
label6.setLocation(280,132);
label6.setToolTipText("To get 10$ rapidly,please click");
c.add(label6);
label6a = new JLabel(" CASH");
label6a.setPreferredSize(new Dimension(75,50));
label6a.setSize(label6a.getPreferredSize());
label6a.setLocation(280,147);
label6a.setToolTipText("To get 10$ rapidly please click");
c.add(label6a);
setSize(500,410) ;
show();
}
//------actionPerformed method for ActionListener-----
public void actionPerformed( ActionEvent event ){
if( event.getSource()==but7 )
System.exit(0) ;
else if( event.getSource() == but1 ){
new Cash();this.hide();}
else if(event.getSource()== but2 ){
new Transfer();this.hide();}
else if(event.getSource()==but3){
new CardTransactions();this.hide();}
else if(event.getSource()==but4 ){
new Information();this.hide();}
else if(event.getSource()==but6){
new StandardCash();this.hide();}
else if(event.getSource()==but9)
System.exit(0);
else if(event.getSource()==but8){
//----Select operation for comparison of first password entered----
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(
null, url,"CLASS NOT FOUND EXCEPTION !!!",
JOptionPane.INFORMATION_MESSAGE);
}
try{
String string = new String(pwordfield.getPassword());
intt=Integer.parseInt(string);
String run = "SELECT * FROM abc " +"WHERE password = " +intt;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
pw=password;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(
null,url,"SQL EXCEPTION AT SELECT OPERATION",
JOptionPane.INFORMATION_MESSAGE);
} this.hide();
//---Comparison---if there is not equivalent MainMenu does not appear-----
if(pw==intt){MainMenu s=new MainMenu();s.Main();}
else if(pw!=intt){
JOptionPane.showMessageDialog(
null,"Invalid Password,Please try again",
"EXCEPTION",JOptionPane.ERROR_MESSAGE);
MainMenu s=new MainMenu();s.Password();
}
}
}//-----method main---Executes the password asking--------
public static void main(String args[]){
MainMenu s=new MainMenu();
s.Password();
}//-----password method----------
public void Password(){
c = getContentPane() ;
c.setLayout(new FlowLayout()) ;
c.setBackground(Color.lightGray);
pwordfield=new JPasswordField(17);
c.add(pwordfield);
but8=new JButton("OK");
but8.setPreferredSize(new Dimension(90,25));
but8.setSize(but8.getPreferredSize());
but8.addActionListener(this);
c.add(but8);
but9=new JButton("CANCEL");
but9.setPreferredSize(new Dimension(90,25));
but9.setSize(but9.getPreferredSize());
but9.addActionListener(this);
c.add(but9);
//-----Informations about the program-----
String sttr=" W E L C O M E!\n"+
" Please write your password:\n"+
"----------------------------------------------\n"+
" This product is a\n"+
" guarenteed trade mark of\n"+
" 'SP COMPUTER SYSTEMS INC.\n"+
" For information we are on web:\n"+
" www.spcomputer.com\n"+
"----------------------------------------------\n"+
" Producer: ÖNER EKIZ";
//-----set up textarea----------------
textarea = new JTextArea(sttr,10,17);
c.add(new JScrollPane(textarea));
textarea.setBackground(Color.lightGray);
textarea.setEditable(false);
setSize(250,300) ;
show();
}
}
//Transfer.java
import java.awt.*; //
import java.awt.event.*; //
import javax.swing.*; // PACKAGES
import java.sql.*; //
import sun.jdbc.odbc.*; //
public class Transfer extends JFrame implements ActionListener{
private JTextField textfield1,textfield2,textfield3,textfield4,textfield5;
private JButton OKButton,ExitButton;
private JLabel label;
private int int1,int2,int3,Amount,Amount1,Password;
private String str1,str2,str3;
static String url = "jdbc:odbc:abc";
//SET UP GUI
public Transfer(){
super("Money Transfer");
Container container = getContentPane();
container.setLayout(new FlowLayout() );
label=new JLabel("Password of the user:");
label.setLocation(200,50);
container.add(label);
textfield5 = new JTextField(15);
container.add(textfield5);
textfield1 = new JTextField("Password of the receiver:");
textfield1.setEditable(false);
container.add(textfield1);
textfield2 = new JTextField(15);
container.add(textfield2);
textfield3 = new JTextField("Amount of the sent:",15);
textfield3.setEditable(false);
container.add(textfield3);
textfield4 = new JTextField(15);
container.add(textfield4);
OKButton = new JButton("OK");
OKButton.setPreferredSize(new Dimension(80,20));
OKButton.setSize(OKButton.getPreferredSize());
OKButton.addActionListener(this);
container.add(OKButton);
ExitButton = new JButton("Exit");
ExitButton.setPreferredSize(new Dimension(80,20));
ExitButton.setSize(ExitButton.getPreferredSize());
ExitButton.addActionListener(this);
container.add(ExitButton);
setSize(400,150);
setVisible(true);
}//-------------actionPerformed----------------------------------------
public void actionPerformed(ActionEvent event){
if(event.getSource()==ExitButton){
this.hide();MainMenu s=new MainMenu();s.Main();
}
else if(event.getSource()==OKButton){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
}
try{ //Select operation:
str3=textfield5.getText(); // gets password of user
int1=Integer.parseInt(str3);
String run = "SELECT * FROM abc " +"WHERE password = " +int1;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount=amount;
}
connection.close();
}
catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
str2=textfield4.getText(); //amount of sent
int3=Integer.parseInt(str2);
Amount=Amount-int3;
//--------------Updating values of the database-------------
String run = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+int1;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
//---Select operation for the person (the money transferred to)------
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
try{
str1=textfield2.getText();//password of receiver
int2=Integer.parseInt(str1);
String run2 = "SELECT * FROM abc " +"WHERE password = " +int2;
System.out.println(run2 + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run2);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount1=amount;
}
connection.close();
}
catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
Amount1=Amount1+int3;
//---------Updating the values for the person,money transferred to--
String run1 = "UPDATE abc SET " +
"amount='" +Amount1+"' WHERE password="+int2;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}
}
//Standardcash.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class StandardCash extends JFrame implements ActionListener {
private JButton button1,button2;
private JLabel label1;
private String str1;
private int Amount,Password;
private JTextField text1;
static String url = "jdbc:odbc:abc";
Container container;
//SET UP GUI
public StandardCash(){
super("Standard Cash (10$)");
Container container = getContentPane();
container.setLayout(null);
button1 = new JButton("OK");
button1.setPreferredSize(new Dimension (90,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(50,100);
button1.addActionListener(this);
container.add(button1);
text1=new JTextField(10);
text1.setPreferredSize(new Dimension(10,22));
text1.setSize(text1.getPreferredSize());
text1.setLocation(50,60);
container.add(text1);
button2 = new JButton("CANCEL");
button2.setPreferredSize(new Dimension (90,30));
button2.setSize(button2.getPreferredSize());
button2.addActionListener(this);
button2.setLocation(150,100);
container.add(button2);
label1 = new JLabel("Please enter your password:");
label1.setPreferredSize(new Dimension(250,20));
label1.setSize(label1.getPreferredSize());
label1.setLocation(50,40);
container.add(label1);
setSize(350,300);
show();
}//------Method for ActionListener-----------------
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
//Selecting the values for the user--------
try{
str1=text1.getText();
int int1=Integer.parseInt(str1);
String run = "SELECT * FROM abc " +"WHERE password = " +int1;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Password=password;
Amount=amount-10;
}
connection.close();
}
catch(SQLException a){
JOptionPane.showMessageDialog(
null,url,"SQL EXCEPTION AT SELECT OPERATION",
JOptionPane.INFORMATION_MESSAGE);
}
//-----Updating the Amount that is reduced up ^^----------
String run = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+Password;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(
null,url,"SQL EXCEPTION AT UPDATE OPERATION",
JOptionPane.INFORMATION_MESSAGE);
}
}
else if(event.getSource()==button2){
this.hide();
MainMenu s=new MainMenu();s.Main();
}
}
}
//Information.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class Information extends JFrame implements ActionListener {
private JButton button1,button2;
private JLabel label1,label2;
static String url = "jdbc:odbc:abc";
//-----Constructor------
public Information(){
super();
Container container = getContentPane();
container.setLayout(null);
button1 = new JButton(" >>> ");
button1.setPreferredSize(new Dimension(100,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(30,50);
button1.addActionListener(this);
container.add(button1);
button2 = new JButton(" CANCEL ");
button2.setPreferredSize(new Dimension(100,30));
button2.setSize(button2.getPreferredSize());
button2.setLocation(30,100);
button2.addActionListener(this);
container.add(button2);
label1 = new JLabel("Demonstration");
label1.setPreferredSize(new Dimension(120,30));
label1.setSize(label1.getPreferredSize());
label1.setLocation(150,43);
container.add(label1);
label2 = new JLabel("of Remainder");
label2.setPreferredSize(new Dimension(120,30));
label2.setSize(label2.getPreferredSize());
label2.setLocation(150,56);
container.add(label2);
setSize(400,300);
setVisible(true);
}//------actionPerformed method for ActionListener-----
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
DB2 s=new DB2();s.Demonstration();
}
else if(event.getSource()==button2){
//--Closes the present window--
this.hide();
//--Going to DB2 class for execution
DB2 s=new DB2();s.Back();
}
}
}
//DB.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class DB extends JFrame implements ActionListener {
static String url = "jdbc:odbc:abc";
private JTextField text1,text2,text3;
private JButton but1,but2,but3,but4;
private JLabel label1,label2,label3;
private int Amount,Amount1,pword,int1;
private String str1,str2,str3;
private String run;
Container c;
//---Constructor---
public DB(){
}//---Method for getting different amount--called from class Cash--
public void ExecutionForAnother(){
Container c=getContentPane();
c.setLayout(new FlowLayout());
label2=new JLabel(" Write the money you want to get and your password:");
c.add(label2);
text1=new JTextField(10);
c.add(text1);
label1=new JLabel("<
c.add(label1);
text2=new JTextField(10);
c.add(text2);
but1=new JButton(" OK ");
but1.addActionListener(this);
but1.setBackground(Color.white);
c.add(but1);
but4=new JButton(" BACK ");
but4.addActionListener(this);
but4.setBackground(Color.white);
c.add(but4);
setSize(400,250);
setResizable(true);
show();
}//----Method for getting one of the value(money) that is seen
//---on the screen--Called from class Cash---
public void CashScreen(){
c=getContentPane();
c.setLayout(new FlowLayout());
label3 = new JLabel("PLEASE WRITE Pword & PRESS OK:");
c.add(label3);
text3=new JTextField(10);
c.add(text3);
but2 = new JButton("OK");
but2.setPreferredSize(new Dimension(80,25));
but2.setSize(but2.getPreferredSize());
but2.setBackground(Color.white);
but2.addActionListener(this);
c.add(but2);
but3 = new JButton("CANCEL");
but3.setPreferredSize(new Dimension(80,25));
but3.setSize(but3.getPreferredSize());
but3.setBackground(Color.white);
but3.addActionListener(this);
c.add(but3);
setSize(350,200);
show();
}//--------Method for the ActionListener---------
public void actionPerformed(ActionEvent event){
if(event.getSource()==but2){// for CashScreen
str3=text3.getText();
int int8=Integer.parseInt(str3);
try{ //--Selection for CashScreen---
String run = "SELECT * FROM abc " +"WHERE password=" +int8;
System.out.println(run+"SQL Operatýon Executed..");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while (result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount = amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECTION OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
Amount=Amount-20; //reducing the user's money
//---Updating the new values----
String run1 = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+int8;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}//--------------------------------------------------------
else if(event.getSource()==but4){
this.hide();}
else if(event.getSource()==but1){ //for another
str2=text1.getText(); // gets password
pword=Integer.parseInt(str2);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
//---Selection for ExecutionForAnother----
try{
String run = "SELECT * FROM abc " +"WHERE password = " +pword;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount1=amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
str1=text2.getText(); //gets the wanted money
int1 =Integer.parseInt(str1);
Amount1=Amount1-int1; //and subtract it from the total money
//--Update the Amount after operations above--
String run1 = "UPDATE abc SET " +
"amount='" +Amount1+"' WHERE password="+pword;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}
else if(event.getSource()==but3){
this.hide();
}
}//--end of method actionPerformed---
}//--end of class.
//Cardtransactions.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class CardTransactions extends JFrame {
private JButton button1,button2,button3;
private JLabel label1,label2;
static String url = "jdbc:odbc:abc";
Container container;
//---Constructor---
public CardTransactions(){
super(" Card Transactions");
Container container = getContentPane();
container.setLayout(null);
button1 = new JButton(">>>");
button1.setPreferredSize(new Dimension(100,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(30,50);
//---making connection with the database---
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
//--goes to DB2-ChangePword to execute changing password--
DB2 s=new DB2();s.ChangePword();
}
});
container.add(button1);
button2 = new JButton(">>>");
button2.setPreferredSize(new Dimension(100,30));
button2.setSize(button2.getPreferredSize());
button2.setLocation(30,100);
//--makes the connection with the database
//--and goes to DB2 to execute paying dept
button2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
DB2 s=new DB2();s.DeptPaying();
}
});
container.add(button2);
button3 = new JButton("
button3.setPreferredSize(new Dimension(100,30));
button3.setSize(button3.getPreferredSize());
button3.setLocation(30,150);
button3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
DB2 s=new DB2();s.Back();
}
});
container.add(button3);
label1 = new JLabel("Change Password");
label1.setPreferredSize(new Dimension(120,30));
label1.setSize(label1.getPreferredSize());
label1.setLocation(130,45);
container.add(label1);
label2 = new JLabel("Dept paying");
label2.setPreferredSize(new Dimension(120,30));
label2.setSize(label2.getPreferredSize());
label2.setLocation(130,98);
container.add(label2);
setSize(400,350);
setVisible(true);
}//--end of constructor
}
//Cash.java
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class Cash extends JFrame implements ActionListener{
public JButton button1,button2,button3,button4,button5,button6,cancelBut;
private JLabel label1,label2,label3,label4,label5,label6;
private JTextField textField;
static String url = "jdbc:odbc:abc";
//---Constructor---
public Cash(){
super("Cash");
Container container=getContentPane() ;
container.setLayout(null);
textField=new JTextField(10);
button1 = new JButton(">>>");
button1.setPreferredSize(new Dimension(100,30));
button1.setSize(button1.getPreferredSize());
button1.setLocation(50,50);
button1.addActionListener(this);
container.add(button1);
button2 = new JButton(">>>");
button2.setPreferredSize(new Dimension(100,30));
button2.setSize(button2.getPreferredSize());
button2.setLocation(50,100);
button2.addActionListener(this);
container.add(button2);
button3 = new JButton(">>>");
button3.setPreferredSize(new Dimension(100,30));
button3.setSize(button3.getPreferredSize());
button3.setLocation(50,150);
button3.addActionListener(this);
container.add(button3);
button4 = new JButton("<<<");
button4.setPreferredSize(new Dimension(100,30));
button4.setSize(button4.getPreferredSize());
button4.setLocation(375,50);
//---makes the communication with the odbc Driver---
button4.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}}DB s=new DB();s.CashScreen();}
});
container.add(button4);
button5 = new JButton("<<<");
button5.setPreferredSize(new Dimension(100,30));
button5.setSize(button5.getPreferredSize());
button5.setLocation(375,100);
button5.addActionListener(this);
container.add(button5);
button6 = new JButton("<<<");
button6.setPreferredSize(new Dimension(100,30));
button6.setSize(button6.getPreferredSize());
button6.setLocation(375,150);
//---makes the communication with the odbc Driver---
button6.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
if(event.getSource()==button1){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}}DB s=new DB();s.ExecutionForAnother();}
});
container.add(button6);
cancelBut = new JButton("CANCEL");
cancelBut.setPreferredSize(new Dimension(100,30));
cancelBut.setSize(cancelBut.getPreferredSize());
cancelBut.setLocation(375,200);
cancelBut.addActionListener(this);
container.add(cancelBut);
label1=new JLabel(" 10 $");
label1.setPreferredSize(new Dimension(75,30));
label1.setSize(label1.getPreferredSize());
label1.setLocation(150,50);
container.add(label1);
label2=new JLabel(" 20 $");
label2.setPreferredSize(new Dimension(75,30));
label2.setSize(label2.getPreferredSize());
label2.setLocation(300,50);
container.add(label2);
label3=new JLabel(" 40 $");
label3.setPreferredSize(new Dimension(75,30));
label3.setSize(label3.getPreferredSize());
label3.setLocation(150,100);
container.add(label3);
label4=new JLabel(" 50 $");
label4.setPreferredSize(new Dimension(75,30));
label4.setSize(label4.getPreferredSize());
label4.setLocation(300,100);
container.add(label4);
label5=new JLabel(" 100 $");
label5.setPreferredSize(new Dimension(75,30));
label5.setSize(label5.getPreferredSize());
label5.setLocation(150,150);
container.add(label5);
label6=new JLabel(" Another..");
label6.setPreferredSize(new Dimension(85,30));
label6.setSize(label6.getPreferredSize());
label6.setLocation(300,150);
container.add(label6);
setSize(500,400);
setVisible(true);
}//---Method for Actionlistener---
public void actionPerformed(ActionEvent event){
if(event.getSource()==cancelBut){
this.hide();//closes the present application
MainMenu s=new MainMenu();s.Main();//and goes to MainMenu
}
}
}
//DB-1
import java.awt.*; //
import java.awt.event.*; // PACKAGES
import javax.swing.*; //
import java.sql.*; //
public class DB extends JFrame implements ActionListener {
static String url = "jdbc:odbc:abc";
private JTextField text1,text2,text3;
private JButton but1,but2,but3,but4;
private JLabel label1,label2,label3;
private int Amount,Amount1,pword,int1;
private String str1,str2,str3;
private String run;
Container c;
//---Constructor---
public DB(){
}//---Method for getting different amount--called from class Cash--
public void ExecutionForAnother(){
Container c=getContentPane();
c.setLayout(new FlowLayout());
label2=new JLabel(" Write the money you want to get and your password:");
c.add(label2);
text1=new JTextField(10);
c.add(text1);
label1=new JLabel("<
c.add(label1);
text2=new JTextField(10);
c.add(text2);
but1=new JButton(" OK ");
but1.addActionListener(this);
but1.setBackground(Color.white);
c.add(but1);
but4=new JButton(" BACK ");
but4.addActionListener(this);
but4.setBackground(Color.white);
c.add(but4);
setSize(400,250);
setResizable(true);
show();
}//----Method for getting one of the value(money) that is seen
//---on the screen--Called from class Cash---
public void CashScreen(){
c=getContentPane();
c.setLayout(new FlowLayout());
label3 = new JLabel("PLEASE WRITE Pword & PRESS OK:");
c.add(label3);
text3=new JTextField(10);
c.add(text3);
but2 = new JButton("OK");
but2.setPreferredSize(new Dimension(80,25));
but2.setSize(but2.getPreferredSize());
but2.setBackground(Color.white);
but2.addActionListener(this);
c.add(but2);
but3 = new JButton("CANCEL");
but3.setPreferredSize(new Dimension(80,25));
but3.setSize(but3.getPreferredSize());
but3.setBackground(Color.white);
but3.addActionListener(this);
c.add(but3);
setSize(350,200);
show();
}//--------Method for the ActionListener---------
public void actionPerformed(ActionEvent event){
if(event.getSource()==but2){// for CashScreen
str3=text3.getText();
int int8=Integer.parseInt(str3);
try{ //--Selection for CashScreen---
String run = "SELECT * FROM abc " +"WHERE password=" +int8;
System.out.println(run+"SQL Operatýon Executed..");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while (result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount = amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECTION OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
Amount=Amount-20; //reducing the user's money
//---Updating the new values----
String run1 = "UPDATE abc SET " +
"amount='" +Amount+"' WHERE password="+int8;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}//--------------------------------------------------------
else if(event.getSource()==but4){
this.hide();}
else if(event.getSource()==but1){ //for another
str2=text1.getText(); // gets password
pword=Integer.parseInt(str2);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException a){
JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
}
//---Selection for ExecutionForAnother----
try{
String run = "SELECT * FROM abc " +"WHERE password = " +pword;
System.out.println(run + "SQL string executed");
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
ResultSet result=stmt.executeQuery(run);
while(result.next()){
String name = result.getString(1);
String surname = result.getString(2);
int amount = result.getInt(3);
int password = result.getInt(4);
Amount1=amount;
}
connection.close();
}catch(SQLException a){
JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
str1=text2.getText(); //gets the wanted money
int1 =Integer.parseInt(str1);
Amount1=Amount1-int1; //and subtract it from the total money
//--Update the Amount after operations above--
String run1 = "UPDATE abc SET " +
"amount='" +Amount1+"' WHERE password="+pword;
try{
Connection connection = DriverManager.getConnection(url,"","");
Statement stmt = connection.createStatement();
stmt.executeUpdate(run1);
System.out.println("Operation completed...");
connection.close();
}catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
}
}
else if(event.getSource()==but3){
this.hide();
}
}//--end of method actionPerformed---
}//--end of class.
END
Subscribe to:
Posts (Atom)