Java-银行管理系统源代码
更新时间:2024-02-02 22:14:01 阅读量: 教育文库 文档下载
Java小型银行管理系统源代码(图形界面)
accounts.java
package Account;
public class accounts { protected int id;//银行账号 protected String password;//用户密码 protected String name;//用户型号 protected String personId;//身份账号 protected int accountType;//账号类型,0代表储蓄卡,1代表信用卡 protected double balance;//账户余额。之所以定义为protected是让他的子类可以直接用,不需要通过方法来赋值。 protected double ceiling; public String getPassword(){ return password; } public void setPassword(String password){ this.password=password; } public String getName(){ return name; } public void setName(String name){ this.name=name; } public String getPersonId(){ return personId; } public void setPersonId(String personId){ this.personId=personId; } public int getAccountType(){ return accountType; }
public void setAccountType(int accountType){ this.accountType=accountType; }
public double getBalance(){ return balance; }
public void setBalance(double balance){ this.balance=balance; }
public int getId(){ return id; }
public void setId(int id){ this.id=id; }
public double getCeiling(){ return ceiling; }
public void setCeiling(double ceiling){ this.ceiling=ceiling; }
//无参数构造方法 public accounts(){ }
//构造方法
public accounts(String password,String name,String personId,int accountType, double balance,double ceiling){ super(); this.password=password; this.name=name; this.personId=personId; this.accountType=accountType; this.balance=balance; this.ceiling=ceiling; }
}
//存款
public void deposit(double money){ balance+=money; }
//取款
public void withdraw(double money){ if(accountType==1){ if((balance+ceiling) System.out.println(\对不起,已超出您的信用额度!\ } else{ balance-=money; } }else{ if(balance System.out.println(\对不起,账户余额不足!\}else{ balance-=money; } DBoper.java package DB; import java.sql.*; import java.util.ArrayList; import Account.accounts; public class DBoper { private Connection conn = null; private Statement st = null; private PreparedStatement pstmt = null; private ResultSet rs = null; private ArrayList result; //连接数据库 public Connection getConnection(){ try{ Class.forName(\ conn=DriverManager.getConnection(\e=true&characterEncoding=utf8\ }catch(Exception e){ System.out.println(\数据库连接失败\ } return conn; } //修改删除用户数据 public boolean accountDataUpdate(String sql){ conn=getConnection(); try{ pstmt=conn.prepareStatement(sql); pstmt.executeUpdate(); //System.out.println(\数据更新成功\ conn.close(); return true; }catch(SQLException e){ e.printStackTrace(); //System.out.println(\更新失败\ return false; } } //依据id来修改记录 public boolean dataupdateid(accounts user, int id) { conn = getConnection(); try { String sql = \account username=?,userpwd=?,personId=?,accountType=?,balance=?,ceiling=? where id=\ + id; pstmt = conn.prepareStatement(sql); pstmt.setString(1, user.getName()); pstmt.setString(2, user.getPassword()); pstmt.setString(3, user.getPersonId()); pstmt.setInt(4, user.getAccountType()); pstmt.setDouble(5, user.getBalance()); pstmt.setDouble(6, user.getCeiling()); pstmt.executeUpdate(); set System.out.println(\操作成功\ return true; } catch (SQLException e) { e.printStackTrace(); System.out.println(\操作失败\ return false; } } //插入用户数据 public boolean accountDataInsert(accounts account){ conn=getConnection(); try{ pstmt=conn.prepareStatement(\into (username,userpwd,personId,accountType,balance,ceiling) values (?,?,?,?,?,?)\ pstmt.setString(1, account.getName()); pstmt.setString(2, account.getPassword()); pstmt.setString(3, account.getPersonId()); pstmt.setInt(4, account.getAccountType()); pstmt.setDouble(5, account.getBalance()); pstmt.setDouble(6, account.getCeiling()); pstmt.executeUpdate(); System.out.println(\新用户数据插入成功\ conn.close(); return true; }catch(SQLException e){ e.printStackTrace(); System.out.println(\插入失败\ return false; } } //查询数据 public ResultSet dataquery(String sql) { conn = getConnection(); try { pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); } account catch (SQLException e) { e.printStackTrace(); System.out.println(\检索失败\ } return rs; } public ResultSet testlist() { try { String sql = \ pstmt = conn.prepareStatement(sql); System.out.println(sql); rs = pstmt.executeQuery(); } catch (SQLException e) { e.printStackTrace(); System.out.println(\检索失败\} return rs; } public ArrayList testt(int id) { ArrayList list = new ArrayList(); conn = getConnection(); try { String sql = \ pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()) { accounts user = new accounts(); user.setName(rs.getString(\ user.setPassword(rs.getString(\ user.setPersonId(rs.getString(\ user.setAccountType(rs.getInt(\ user.setBalance(rs.getDouble(\ user.setCeiling(rs.getDouble(\ list.add(user); } } catch (SQLException e) { e.printStackTrace(); System.out.println(\检索失败\ } return list; } //根据卡号和密码验证用户是否存在 public boolean verify(int id,String password){ conn=getConnection(); try{ pstmt=conn.prepareStatement(\* from account userpwd=?\ pstmt.setInt(1, id); pstmt.setString(2, password); rs=pstmt.executeQuery(); if(rs.next()){ return true; }else{ return false; } }catch(SQLException e){ e.printStackTrace(); return false; } } /** * 登录验证 */ public accounts verifyAccount(int id, String password) { boolean flag = verify(id, password); if(flag){ accounts account=queryByIDandPassword(id, password); return account; } else { System.out.println(\用户不存在!\ return null; } } //根据卡号和密码查询信息 public accounts queryByIDandPassword(int id,String password){ where id=? and conn=getConnection(); try{ pstmt=conn.prepareStatement(\* from account where id=? and userpwd=?\ pstmt.setInt(1, id); pstmt.setString(2, password); rs=pstmt.executeQuery(); accounts account=new accounts(); while(rs.next()){ account.setId(rs.getInt(\ account.setName(rs.getString(\ account.setPassword(rs.getString(\ account.setPersonId(rs.getString(\ account.setAccountType(rs.getInt(\ account.setBalance(rs.getDouble(\ account.setCeiling(rs.getDouble(\ } return account; }catch(SQLException e){ e.printStackTrace(); return null; } } //根据卡号查询信息 public accounts queryByID(int id){ conn=getConnection(); try{ pstmt=conn.prepareStatement(\ pstmt.setInt(1, id); rs=pstmt.executeQuery(); accounts account=new accounts(); while(rs.next()){ account.setId(rs.getInt(\ account.setName(rs.getString(\ account.setPassword(rs.getString(\ account.setPersonId(rs.getString(\ account.setAccountType(rs.getInt(\ account.setBalance(rs.getDouble(\ account.setCeiling(rs.getDouble(\ } return account; }catch(SQLException e){ e.printStackTrace(); return null; } } public static void main(String[] args) { // TODO Auto-generated method stub DBoper op=new DBoper(); ArrayList list=op.testt(1001); for(int i=0;i //图像界面文件夹 DN_SYSTEM Default.java //主界面 package DN_SYSTEM; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.WindowConstants; import Account.accounts; import DB.DBoper; public class Default extends JFrame implements ActionListener{ accounts account=DN_ATM.client; DBoper db=new DBoper(); private JFrame jf; private JButton btn0,btn1,btn2,btn3,btn4,btn5; private Container c; public void defaltDemo() { //添加主界面卡片 //DN_ATM.id; int id=DN_ATM.id; //account=db.queryByID(id); jf=new JFrame(\c=jf.getContentPane(); c.setLayout(null); c.setBackground(new Color(119,119,253)); JLabel lblwel = new JLabel(\欢迎\用达能银行ATM系统\lblwel.setBounds(20, 15, 350, 30); c.add(lblwel); JLabel lblwel1 = new JLabel(\请选择您需要的交易类型\lblwel1.setBounds(120, 45, 350, 30); c.add(lblwel1); btn1 = new JButton(\取款服务\btn1.addActionListener(this); btn1.setBounds(70, 90, 100, 30); c.add(btn1); btn2=new JButton(\存款服务\btn2.addActionListener(this); btn2.setBounds(210, 90, 100, 30); c.add(btn2); btn3 = new JButton(\查询余额\btn3.addActionListener(this); btn3.setBounds(70, 150, 100, 30); c.add(btn3); btn4 = new JButton(\转账服务\btn4.addActionListener(this); btn4.setBounds(210, 150, 100, 30); c.add(btn4); btn5 = new JButton(\注销账户\btn5.addActionListener(this); btn5.setBounds(70, 210, 100, 30); c.add(btn5); btn0 = new JButton(\退出操作\ btn0.addActionListener(this); btn0.setBounds(210, 210, 100, 30); c.add(btn0); jf.setVisible(true); jf.setResizable(false); jf.setSize(400,300); jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } //事件处理 @Override public void actionPerformed(ActionEvent e){ //取款服务 if(e.getSource().equals(btn1)){ OutMoney outmoney=new OutMoney(); outmoney.outMoney(); jf.dispose(); } //存款服务 if(e.getSource().equals(btn2)){ InMoney inmoney=new InMoney(); inmoney.InMoney(); jf.dispose(); } //查询余额 if(e.getSource().equals(btn3)){ GetBalance getbalance=new GetBalance(); getbalance.getBalance(); jf.dispose(); } } } //转账服务 if(e.getSource().equals(btn4)){ TransferAccounts tranfer=new TransferAccounts(); tranfer.transferAccounts(); jf.dispose(); } //注销账户 if(e.getSource().equals(btn5)){ String sql=\ boolean flag=db.accountDataUpdate(sql); if(flag){ JOptionPane.showMessageDialog(this,\注销成功!\} else{ JOptionPane.showMessageDialog(this, \注销失败!\ } } if(e.getSource().equals(btn0)){ System.exit(0); } public static void main(String[] args) { // TODO Auto-generated method stub Default defaults=new Default(); defaults.defaltDemo(); } DN_ATM.java //功能界面 package DN_SYSTEM; import java.awt.CardLayout; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import DB.DBoper; import Account.accounts; public class DN_ATM extends JFrame implements ActionListener{ private JLabel lbljixu; private JButton btngetcard; private JButton btncard,btn010,btn_addAccount,btnsure,btnback; private JTextField txt1; private JPasswordField txt2; private Container container; private CardLayout Layout; private JLabel lblwrong; private JPanel panelfirst,panelmain; public static int id; static accounts client = null; public DN_ATM(){ } super(\达能银行\this.setSize(435, 350); this.setLocation(500,250); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置不可改变窗口大小 this.setResizable(false); //布局 public void setLayout(){ //用卡片布局 Layout = new CardLayout(); container = getContentPane(); container.setLayout(Layout); //添加第一张卡片 panelfirst = new JPanel(null); //设置卡片的背景颜色 panelfirst.setBackground(new Color(119,119,253)); lbljixu = new JLabel(\请放入磁卡,然后继续操作\//设置卡片在Panel中的位置 lbljixu.setBounds(140, 90, 350, 30); //为第一张卡片添加一个Label panelfirst.add(lbljixu); //为第一张卡片添加一个按钮 btncard = new JButton(\继续\ btncard.setBounds(310, 180, 80, 30); //为按钮注册事件监听器 btncard.addActionListener(this); //开始时设置按钮不可按 btncard.setEnabled(false); panelfirst.add(btncard); //为第一张卡片添加一个按钮 btngetcard = new JButton(\取卡\btngetcard.setEnabled(false); btngetcard.setBounds(310, 220, 80, 30); btngetcard.addActionListener(this); panelfirst.add(btngetcard); //添加登录输入卡片 panelmain = new JPanel(null); panelmain.setBackground(new Color(119,119,253)); //添加登录输入卡号 JLabel lblnumber = new JLabel(\请输入您的银行卡卡号:\panelmain.add(lblnumber); lblnumber.setBounds(30, 30, 150, 30); //设置文本框为密码型 txt1 = new JTextField(12); //文本框不可选中 //txt1.enable(false); panelmain.add(txt1); txt1.setBounds(170, 30, 200, 30); JLabel lblpwd = new JLabel(\请输入您的银行卡密码:\panelmain.add(lblpwd); lblpwd.setBounds(30, 80, 150, 30); //设置文本框为密码型 txt2 = new JPasswordField(12); //文本框不可选中 //txt2.enable(false); panelmain.add(txt2); //文本框的输入内容用*显示 txt2.setEchoChar('*'); txt2.setBounds(170, 80, 200, 30); //添加选择按钮 btnsure = new JButton(\确定\btnsure.addActionListener(this); panelmain.add(btnsure); btnsure.setBounds(70, 160, 80, 30); //添加重输按钮 btn010 = new JButton(\重输\btn010.addActionListener(this); panelmain.add(btn010); btn010.setBounds(175,160,80,30); btnback = new JButton(\退出\btnback.addActionListener(this); panelmain.add(btnback); btnback.setBounds(280, 160, 80, 30); //开户 btn_addAccount = new JButton(\开户\btn_addAccount.setBounds(70, 220, 80, 30); btn_addAccount.addActionListener(this); panelmain.add(btn_addAccount); lblwrong = new JLabel(\请注意保护好您的密码!\ panelmain.add(lblwrong); lblwrong.setBounds(180, 110, 200, 30); container.add(panelmain, \} //事件处理 @SuppressWarnings(\@Override public void actionPerformed(ActionEvent e){ DBoper db=new DBoper(); if(e.getSource().equals(btn_addAccount)){ OpenAccount open=new OpenAccount(); open.adduser(); } //磁卡插入后,验证银行登录卡号与密码 if(e.getSource().equals(btnsure)) { client = db.verifyAccount(Integer.parseInt(txt1.getText()), txt2.getText()); if(client!=null){ Default defa=new Default(); defa.defaltDemo(); this.dispose(); id=Integer.parseInt(txt1.getText()); txt1.setText(\ txt2.setText(\ }else{ lblwrong.setText(\卡号或密码不正确,请重新输入!\ txt1.setText(\ txt2.setText(\ } } //重置输入卡号和密码 if(e.getSource()==btn010) { txt1.setText(\ txt2.setText(\ lblwrong.setText(\请注意保护好您的密码!\ } //退出 if(e.getSource().equals(btnback)){ System.exit(0); } } public static void main(String[] args) { // TODO Auto-generated method stub DN_ATM ATM=new DN_ATM(); ATM.setLayout(); ATM.setVisible(true); } } GetBalance.java //查询余额 package DN_SYSTEM; import java.awt.CardLayout; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.WindowConstants; import Account.accounts; import DB.DBoper; public class GetBalance extends JFrame implements ActionListener{ private JFrame jf; private Container c; private JLabel lblremain1,lblremain; private JButton btnremain,btnremain1; accounts account=new accounts(); DBoper db=new DBoper(); private int id=DN_ATM.id; //添加查询余额界面卡片 public void getBalance(){ account=db.queryByID(id); jf=new JFrame(\ c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); c.setBackground(new Color(119,119,253)); lblremain1 = new JLabel(\尊敬的达能用户您好!\lblremain1.setBounds(90,70,350,30); c.add(lblremain1); lblremain = new JLabel(\请点击继续操作查询余额:\lblremain.setBounds(90,110,350,30); c.add(lblremain); btnremain = new JButton(\继续操作\btnremain.setBounds(95,150,90,30); btnremain.addActionListener(this); c.add(btnremain); btnremain1 = new JButton(\退出操作\ btnremain1.setBounds(200,150,90,30); btnremain1.addActionListener(this); c.add(btnremain1); jf.setVisible(true); jf.setSize(400,300); jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } @Override public void actionPerformed(ActionEvent e){ //查询余额 if(e.getSource()==btnremain) { lblremain1.setText(\卡号:\ 用户名:\ lblremain.setText(\您的余额为\元,是否继续操作?\ } if(e.getSource()==btnremain1){ Default defa=new Default(); defa.defaltDemo(); jf.dispose(); } } public static void main(String[] args) { // TODO Auto-generated method stub GetBalance balance=new GetBalance(); balance.getBalance(); } } InMoney.java //存款 package DN_SYSTEM; import java.awt.CardLayout; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import javax.swing.WindowConstants; import Account.accounts; import DB.DBoper; public class InMoney extends JFrame implements ActionListener{ private JLabel lblsave,lblsave1; private JButton btnsave,btnsave2; private JTextField txt2; private double savemoney ; private double lastmoney; private boolean flag; private JFrame jf; private Container c; accounts account=new accounts(); DBoper db=new DBoper(); private int id=DN_ATM.id; public void InMoney(){ account=db.queryByID(id); jf=new JFrame(\ c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); //添加存款显示界面卡片 c.setBackground(new Color(119,119,253)); lblsave = new JLabel(\请在存款口处放入存款\lblsave.setBounds(60,30,350,30); c.add(lblsave); lblsave1 = new JLabel(\请注意:只接收100元或100元的整数倍存款\lblsave1.setBounds(90,110,350,30); c.add(lblsave1); txt2 = new JTextField(12); c.add(txt2); txt2.setBounds(95, 80, 200, 30); btnsave = new JButton(\放入存款完毕\ btnsave.setBounds(90,160,120,30); btnsave.addActionListener(this); c.add(btnsave); btnsave2 = new JButton(\返回\ btnsave2.setBounds(240,160,60,30); btnsave2.addActionListener(this); c.add(btnsave2); jf.setVisible(true); jf.setSize(400,300); jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } @Override public void actionPerformed(ActionEvent e){ if(e.getSource()==btnsave) { savemoney=Double.parseDouble(txt2.getText()); lastmoney=account.getBalance(); lastmoney+=savemoney; String sql = \ + id; flag=db.accountDataUpdate(sql); if(flag){ JOptionPane.showMessageDialog(this, \存款成功!\ } txt2.setText(\ Default defa=new Default(); defa.defaltDemo(); jf.dispose(); } else { JOptionPane.showMessageDialog(this, \存款失败!\ } } if(e.getSource()==btnsave2) { Default defa=new Default(); defa.defaltDemo(); jf.dispose(); } } public static void main(String[] args) { // TODO Auto-generated method stub InMoney inmoney=new InMoney(); inmoney.InMoney(); } OpenAccount.java //开户 package DN_SYSTEM; import java.awt.Component; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPasswordField; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.WindowConstants; import DB.DBoper; import Account.accounts; public class OpenAccount extends JFrame implements ActionListener{ private JFrame jf; private Container c; private JTextField txtname,txt_personId; private JPasswordField txtpwd,txtpwd1; private JRadioButton rbt1; private JRadioButton rbt2; String accountType; //开户,增加新用户 public void adduser(){ jf=new JFrame(\ c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); JLabel lbname=new JLabel(\用户名:\ lbname.setBounds(100, 40, 80, 20); txtname=new JTextField(); txtname.setBounds(160, 40, 130, 20); c.add(lbname); c.add(txtname); JLabel lbpwd=new JLabel(\密码:\ lbpwd.setBounds(110, 65, 80, 20); txtpwd=new JPasswordField(); txtpwd.setBounds(160, 65, 130, 20); txtpwd.setEchoChar('*'); c.add(lbpwd); c.add(txtpwd); JLabel lbpwd1=new JLabel(\确认密码:\ lbpwd1.setBounds(86, 90, 80, 20); txtpwd1 = new JPasswordField(); txtpwd1.setBounds(160, 90, 130, 20); txtpwd1.setEchoChar('*'); c.add(lbpwd1); c.add(txtpwd1); JLabel lbpersonId=new JLabel(\身份证号:\lbpersonId.setBounds(86, 115, 80, 20); txt_personId = new JTextField(); txt_personId.setBounds(160, 115, 130, 20); c.add(lbpersonId); c.add(txt_personId); JLabel lbtype=new JLabel(\账户类型:\ lbtype.setBounds(86, 120, 80, 60); rbt1=new JRadioButton(\信用卡\ rbt1.setBounds(160, 135, 70, 30); rbt2=new JRadioButton(\储蓄卡\rbt2.setBounds(225, 135, 70, 30); ButtonGroup group=new ButtonGroup(); group.add(rbt2); group.add(rbt1); c.add(lbtype); c.add(rbt2); c.add(rbt1); JButton btnsubmit=new JButton(\提交\btnsubmit.setBounds(100, 190, 80, 20); JButton btnreset=new JButton(\重置\ btnreset.setBounds(205, 190, 80, 20); c.add(btnsubmit); c.add(btnreset); btnsubmit.addActionListener(this); btnreset.addActionListener(this); jf.setVisible(true); jf.setSize(400,300); jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { // TODO Auto-generated method stub OpenAccount openA=new OpenAccount(); openA.adduser(); } @Override } public void actionPerformed(ActionEvent e){ accounts account=new accounts(); account.setName(txtname.getText()); if(txtpwd.getText().equals(txtpwd1.getText())){ account.setPassword(txtpwd.getText()); }else{ JOptionPane.showMessageDialog(this,\两次输入的密码不一致,请重新输入!\ } account.setPersonId(txt_personId.getText()); if(rbt1.isSelected()) accountType=\ if(rbt2.isSelected()) accountType=\ account.setAccountType(Integer.parseInt(accountType)); account.setBalance(0); if(accountType.equals(\ account.setCeiling(5000.0); }else{ account.setCeiling(0); } DBoper db=new DBoper(); if(db.accountDataInsert(account)){ JOptionPane.showMessageDialog(this,\开户成功!\ } jf.dispose();//关闭当前登录窗体 return; }else{ JOptionPane.showMessageDialog(this,\开户失败!\ return; } OutMoney.java package DN_SYSTEM; import java.awt.CardLayout; import java.awt.Color; import java.awt.Container; //取款 import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.WindowConstants; import Account.accounts; import DB.DBoper; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class OutMoney extends JFrame implements ActionListener{ private JFrame jf; private JButton btn100,btn200,btn300,btn500,btn1000; private btn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009,btn000; private JButton btnsure1,btn0010,btnback2; private JTextField txt2; private Container c; private JLabel lblqukuan; private int money; private double lastmoney; accounts account=new accounts(); DBoper db=new DBoper(); private int id=DN_ATM.id; public void outMoney(){ account=db.queryByID(id); jf=new JFrame(\ c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); //添加取款页面卡片 //panel4=new JPanel(null); c.setBackground(new Color(119,119,253)); lblqukuan = new JLabel(\请输入您的取款金额:\ c.add(lblqukuan); JButton } } outmoney1.outMoney();; TransferAccounts.java //转账 package DN_SYSTEM; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.WindowConstants; import Account.accounts; import DB.DBoper; public class TransferAccounts extends JFrame implements ActionListener{ private JFrame jf; private Container c; accounts account=new accounts(); DBoper db=new DBoper(); private int id=DN_ATM.id; private JTextField txttrans,txttrans1,txttrans2; private JButton btntra,btntra1,btntra2; private JLabel lbltra,lbltra1,lbltra2; public void transferAccounts(){ account=db.queryByID(id); jf=new JFrame(\ c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); //添加转账卡片界面 c.setBackground(new Color(119,119,253)); lbltra = new JLabel(\请输入对方的银行帐号:\ lbltra.setBounds(20, 30, 160, 30); c.add(lbltra); lbltra1 = new JLabel(\请再次输入对方的银行帐号:\ lbltra1.setBounds(20, 80, 190, 30); c.add(lbltra1); lbltra2 = new JLabel(\请输入您的转账金额:\lbltra2.setBounds(20, 130, 160, 30); c.add(lbltra2); txttrans = new JTextField(); c.add(txttrans); txttrans.setBounds(200,30,200,30); txttrans1 = new JTextField(); c.add(txttrans1); txttrans1.setBounds(200,80,200,30); txttrans2 = new JTextField(); c.add(txttrans2); txttrans2.setBounds(200,130,200,30); btntra = new JButton(\确定\ c.add(btntra); btntra.addActionListener(this); btntra.setBounds(70,190,80,30); btntra1 = new JButton(\重输\ c.add(btntra1); btntra1.addActionListener(this); btntra1.setBounds(175,190,80,30); btntra2 = new JButton(\返回\ c.add(btntra2); btntra2.addActionListener(this); btntra2.setBounds(280,190,80,30); jf.setVisible(true); jf.setSize(450,300); jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } @Override public void actionPerformed(ActionEvent e){ //转账确认 if(e.getSource()==btntra) { //符合条件要求 if(txttrans.getText().equals(txttrans1.getText()) && txttrans2.getText().length()!=0 && Double.valueOf(txttrans2.getText()).doubleValue()<=account.getBalance()) { double trainsmoney = Double.valueOf(txttrans2.getText()).doubleValue(); double lastmoney=account.getBalance(); lastmoney=lastmoney-trainsmoney; String sql = \ db.accountDataUpdate(sql); int opid=db.queryByID(Integer.parseInt(txttrans.getText())).getId(); double opbalance=db.queryByID(Integer.parseInt(txttrans.getText())).getBalance(); double opmoney=opbalance+trainsmoney; String sql1 = \ db.accountDataUpdate(sql1); JOptionPane.showMessageDialog(this, \转账成功!\ Default defa=new Default(); defa.defaltDemo(); jf.dispose(); }else{ //不符合要求 JOptionPane.showMessageDialog(null, \帐号不一致或帐号与金额输入有误,请确认\转账失败!\ } } //重输 if(e.getSource().equals(btntra1)){ this.txttrans.setText(\ this.txttrans1.setText(\ this.txttrans2.setText(\ } //返回 if(e.getSource().equals(btntra2)){ Default defa=new Default(); } defa.defaltDemo(); jf.dispose(); } } public static void main(String[] args) { // TODO Auto-generated method stub TransferAccounts tranfer=new TransferAccounts(); tranfer.transferAccounts(); }
正在阅读:
Java-银行管理系统源代码02-02
脚手架主要构配件质量检查验收表 - 图文10-19
加强和改善车险理赔服务的若干策略(1)04-11
电力监控系统安全防护检查指导卡 - 图文04-19
第二批宜昌名师工作室简介09-20
变压器渗漏油的处理办法08-19
2021年八年级政治下册 权利与义务教案 人教新课标版04-30
高中《史记》文言文字词梳理04-04
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 源代码
- 银行
- 系统
- 管理
- Java
- 马克思主义基本原理概论课后习题以及选择题答案(老师课上资料)
- 湘潭大学物理化学复习指导
- 2018国家消防员理论考试全真题必过含答案
- 免费共享-环境保护-监测--基础试题集
- 大众车故障码表
- 自然资源利用与保护论文--关于生物多样性的保护的思考
- 平面photoshop参考题
- 浅谈科学课上如何培养学生严谨的科学思维
- 无机及分析化学课后习题第十二章答案
- 公共关系1
- 宗地代码编制规则(试行)
- 东财《保险学概论》全部作业题及答案
- 初级建构筑物消防员理论考试习题集(附答案)
- 贵州大学2015-2016学年上学期公共课期末考试时间安排
- C语言复习题-2014
- 控制要求
- 科技部、财政部、国家税务总局关于高新技术企业认定管理工作重点检查有关情况及处理意见的通知-国家规范性
- 学生守则教育说明报告
- 发展党员政审外调函
- 每天涨点小知识:电工口诀三百首 简便快捷心口算(一)