![Java-銀行管理系統(tǒng)源代碼_第1頁](http://file4.renrendoc.com/view/66d6f8ff893251ef7e8268ddcaaae2f9/66d6f8ff893251ef7e8268ddcaaae2f91.gif)
![Java-銀行管理系統(tǒng)源代碼_第2頁](http://file4.renrendoc.com/view/66d6f8ff893251ef7e8268ddcaaae2f9/66d6f8ff893251ef7e8268ddcaaae2f92.gif)
![Java-銀行管理系統(tǒng)源代碼_第3頁](http://file4.renrendoc.com/view/66d6f8ff893251ef7e8268ddcaaae2f9/66d6f8ff893251ef7e8268ddcaaae2f93.gif)
![Java-銀行管理系統(tǒng)源代碼_第4頁](http://file4.renrendoc.com/view/66d6f8ff893251ef7e8268ddcaaae2f9/66d6f8ff893251ef7e8268ddcaaae2f94.gif)
![Java-銀行管理系統(tǒng)源代碼_第5頁](http://file4.renrendoc.com/view/66d6f8ff893251ef7e8268ddcaaae2f9/66d6f8ff893251ef7e8268ddcaaae2f95.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
-.zJava小型銀行管理系統(tǒng)源代碼〔圖形界面〕accounts.javapackageAccount;publicclassaccounts{ protectedintid;//銀行賬號protectedStringpassword;//用戶密碼protectedStringname;//用戶型號protectedStringpersonId;//身份賬號protectedintaccountType;//賬號類型,0代表儲蓄卡,1代表信用卡protecteddoublebalance;//賬戶余額。之所以定義為protected是讓他的子類可以直接用,不需要通過方法來賦值。protecteddoubleceiling; publicStringgetPassword(){ returnpassword; } publicvoidsetPassword(Stringpassword){ this.password=password; } publicStringgetName(){ returnname; } publicvoidsetName(Stringname){ =name; } publicStringgetPersonId(){ returnpersonId; } publicvoidsetPersonId(StringpersonId){ this.personId=personId; } publicintgetAccountType(){ returnaccountType; } publicvoidsetAccountType(intaccountType){ this.accountType=accountType; } publicdoublegetBalance(){ returnbalance; } publicvoidsetBalance(doublebalance){ this.balance=balance; } publicintgetId(){ returnid; } publicvoidsetId(intid){this.id=id; } publicdoublegetCeiling(){ returnceiling; } publicvoidsetCeiling(doubleceiling){ this.ceiling=ceiling; } //無參數(shù)構(gòu)造方法publicaccounts(){ } //構(gòu)造方法publicaccounts(Stringpassword,Stringname,StringpersonId,intaccountType,doublebalance,doubleceiling){ super(); this.password=password; =name; this.personId=personId; this.accountType=accountType; this.balance=balance; this.ceiling=ceiling; } //存款publicvoiddeposit(doublemoney){ balance+=money; } //取款publicvoidwithdraw(doublemoney){ if(accountType==1){ if((balance+ceiling)<money){ System.out.println("對不起,已超出您的信用額度!"); } else{ balance-=money; } }else{ if(balance<money){ System.out.println("對不起,賬戶余額缺乏!"); }else{ balance-=money; } } }}DBoper.javapackageDB;importjava.sql.*;importjava.util.ArrayList;importAccount.accounts;publicclassDBoper{ privateConnectionconn=null; privateStatementst=null; privatePreparedStatementpstmt=null; privateResultSetrs=null; privateArrayList<accounts>result; //連接數(shù)據(jù)庫publicConnectiongetConnection(){ try{ Class.forName(".mysql.jdbc.Driver"); conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bankmanager?useUnicode=true&characterEncoding=utf8","root","*uewei"); }catch(E*ceptione){ System.out.println("數(shù)據(jù)庫連接失敗"); } returnconn; } //修改刪除用戶數(shù)據(jù)publicbooleanaccountDataUpdate(Stringsql){ conn=getConnection(); try{ pstmt=conn.prepareStatement(sql); pstmt.e*ecuteUpdate(); //System.out.println("數(shù)據(jù)更新成功"); conn.close(); returntrue; }catch(SQLE*ceptione){ e.printStackTrace(); //System.out.println("更新失敗"); returnfalse; } } //依據(jù)id來修改記錄publicbooleandataupdateid(accountsuser,intid){ conn=getConnection(); try{ Stringsql="updateaccountsetusername=?,userpwd=?,personId=?,accountType=?,balance=?,ceiling=?whereid=" +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.e*ecuteUpdate(); System.out.println("操作成功"); returntrue; } catch(SQLE*ceptione){ e.printStackTrace();System.out.println("操作失敗"); returnfalse; } } //插入用戶數(shù)據(jù)publicbooleanaccountDataInsert(accountsaccount){ conn=getConnection(); try{ pstmt=conn.prepareStatement("insertintoaccount(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.e*ecuteUpdate(); System.out.println("新用戶數(shù)據(jù)插入成功"); conn.close(); returntrue; }catch(SQLE*ceptione){ e.printStackTrace(); System.out.println("插入失敗"); returnfalse; } } //查詢數(shù)據(jù)publicResultSetdataquery(Stringsql){conn=getConnection(); try{ pstmt=conn.prepareStatement(sql); rs=pstmt.e*ecuteQuery(); } catch(SQLE*ceptione){ e.printStackTrace(); System.out.println("檢索失敗"); } returnrs; } publicResultSettestlist(){ try{ Stringsql="select*fromaccountwhereid=1001"; pstmt=conn.prepareStatement(sql); System.out.println(sql); rs=pstmt.e*ecuteQuery(); }catch(SQLE*ceptione){ e.printStackTrace(); System.out.println("檢索失敗"); } returnrs; } publicArrayList<accounts>testt(intid){ ArrayList<accounts>list=newArrayList<accounts>(); conn=getConnection(); try{ Stringsql="select*fromaccountwhereid="+id; pstmt=conn.prepareStatement(sql); rs=pstmt.e*ecuteQuery(); while(rs.ne*t()){ accountsuser=newaccounts(); user.setName(rs.getString("username")); user.setPassword(rs.getString("userpwd")); user.setPersonId(rs.getString("personId")); user.setAccountType(rs.getInt("accountType")); user.setBalance(rs.getDouble("balance")); user.setCeiling(rs.getDouble("ceiling")); list.add(user); } } catch(SQLE*ceptione){ e.printStackTrace(); System.out.println("檢索失敗"); } returnlist; } //根據(jù)卡號和密碼驗證用戶是否存在publicbooleanverify(intid,Stringpassword){ conn=getConnection(); try{pstmt=conn.prepareStatement("select*fromaccountwhereid=?anduserpwd=?"); pstmt.setInt(1,id); pstmt.setString(2,password); rs=pstmt.e*ecuteQuery(); if(rs.ne*t()){ returntrue; }else{ returnfalse; } }catch(SQLE*ceptione){ e.printStackTrace(); returnfalse; } } /** *登錄驗證*/ publicaccountsverifyAccount(intid,Stringpassword){ booleanflag=verify(id,password); if(flag){ accountsaccount=queryByIDandPassword(id,password); returnaccount; } else {System.out.println("用戶不存在!"); returnnull; } } //根據(jù)卡號和密碼查詢信息publicaccountsqueryByIDandPassword(intid,Stringpassword){ conn=getConnection(); try{ pstmt=conn.prepareStatement("select*fromaccountwhereid=?anduserpwd=?"); pstmt.setInt(1,id); pstmt.setString(2,password); rs=pstmt.e*ecuteQuery(); accountsaccount=newaccounts(); while(rs.ne*t()){ account.setId(rs.getInt("id")); account.setName(rs.getString("username")); account.setPassword(rs.getString("userpwd")); account.setPersonId(rs.getString("personId")); account.setAccountType(rs.getInt("accountType")); account.setBalance(rs.getDouble("balance")); account.setCeiling(rs.getDouble("ceiling")); } returnaccount; }catch(SQLE*ceptione){ e.printStackTrace(); returnnull; } } //根據(jù)卡號查詢信息publicaccountsqueryByID(intid){ conn=getConnection(); try{ pstmt=conn.prepareStatement("select*fromaccountwhereid=?"); pstmt.setInt(1,id); rs=pstmt.e*ecuteQuery(); accountsaccount=newaccounts(); while(rs.ne*t()){ account.setId(rs.getInt("id")); account.setName(rs.getString("username")); account.setPassword(rs.getString("userpwd")); account.setPersonId(rs.getString("personId")); account.setAccountType(rs.getInt("accountType")); account.setBalance(rs.getDouble("balance")); account.setCeiling(rs.getDouble("ceiling")); } returnaccount; }catch(SQLE*ceptione){ e.printStackTrace(); returnnull; } } publicstaticvoidmain(String[]args){ //TODOAuto-generatedmethodstub DBoperop=newDBoper(); ArrayList<accounts>list=op.testt(1001); for(inti=0;i<list.size();i++){ accountsuser=newaccounts(); user=list.get(i); System.out.println(user.getName()); System.out.println(user.getPassword()); System.out.println(user.getPersonId());System.out.println(user.getAccountType()); System.out.println(user.getBalance()); System.out.println(user.getCeiling()); } }}//圖像界面文件夾DN_SYSTEMDefault.java//主界面packageDN_SYSTEM;importjava.awt.Color;importjava.awt.Container;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava*.swing.JButton;importjava*.swing.JFrame;importjava*.swing.JLabel;importjava*.swing.JOptionPane;importjava*.swing.JPanel;importjava*.swing.WindowConstants;importAccount.accounts;importDB.DBoper;publicclassDefaulte*tendsJFrameimplementsActionListener{ accountsaccount=DN_ATM.client; DBoperdb=newDBoper(); privateJFramejf; privateJButtonbtn0,btn1,btn2,btn3,btn4,btn5; privateContainerc; publicvoiddefaltDemo(){ //添加主界面卡片//DN_ATM.id; intid=DN_ATM.id; //account=db.queryByID(id); jf=newJFrame("DEFAULT"); c=jf.getContentPane(); c.setLayout(null); c.setBackground(newColor(119,119,253)); JLabellblwel=newJLabel("歡迎"+account.getName()+"用達能銀行ATM系統(tǒng)"); lblwel.setBounds(20,15,350,30); c.add(lblwel); JLabellblwel1=newJLabel("請選擇您需要的交易類型"); lblwel1.setBounds(120,45,350,30); c.add(lblwel1); btn1=newJButton("取款效勞"); btn1.addActionListener(this); btn1.setBounds(70,90,100,30); c.add(btn1); btn2=newJButton("存款效勞"); btn2.addActionListener(this); btn2.setBounds(210,90,100,30); c.add(btn2); btn3=newJButton("查詢余額"); btn3.addActionListener(this); btn3.setBounds(70,150,100,30); c.add(btn3); btn4=newJButton("轉(zhuǎn)賬效勞"); btn4.addActionListener(this); btn4.setBounds(210,150,100,30); c.add(btn4); btn5=newJButton("注銷賬戶"); btn5.addActionListener(this); btn5.setBounds(70,210,100,30); c.add(btn5); btn0=newJButton("退出操作");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.E*IT_ON_CLOSE); } //事件處理Override publicvoidactionPerformed(ActionEvente){ //取款效勞if(e.getSource().equals(btn1)){ OutMoneyoutmoney=newOutMoney(); outmoney.outMoney(); jf.dispose(); } //存款效勞if(e.getSource().equals(btn2)){ InMoneyinmoney=newInMoney(); inmoney.InMoney(); jf.dispose(); } //查詢余額if(e.getSource().equals(btn3)){ GetBalancegetbalance=newGetBalance(); getbalance.getBalance(); jf.dispose(); } //轉(zhuǎn)賬效勞if(e.getSource().equals(btn4)){ TransferAccountstranfer=newTransferAccounts(); tranfer.transferAccounts();jf.dispose(); } //注銷賬戶if(e.getSource().equals(btn5)){ Stringsql="deletefromaccountwhereid="+account.getId(); booleanflag=db.accountDataUpdate(sql); if(flag){ JOptionPane.showMessageDialog(this,"注銷成功!"); } else{ JOptionPane.showMessageDialog(this,"注銷失敗!"); } } if(e.getSource().equals(btn0)){ System.e*it(0); } } publicstaticvoidmain(String[]args){ //TODOAuto-generatedmethodstub Defaultdefaults=newDefault(); defaults.defaltDemo(); }}DN_ATM.java//功能界面packageDN_SYSTEM;importjava.awt.CardLayout;importjava.awt.Color;importjava.awt.Container;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava*.swing.AbstractButton;importjava*.swing.JButton;importjava*.swing.JFrame;importjava*.swing.JLabel;importjava*.swing.JOptionPane;importjava*.swing.JPanel;importjava*.swing.JPasswordField;importjava*.swing.JTe*tField;importDB.DBoper;importAccount.accounts;publicclassDN_ATMe*tendsJFrameimplementsActionListener{ privateJLabellblji*u; privateJButtonbtngetcard; privateJButtonbtncard,btn010,btn_addAccount,btnsure,btnback; privateJTe*tFieldt*t1; privateJPasswordFieldt*t2; privateContainercontainer; privateCardLayoutLayout; privateJLabellblwrong; privateJPanelpanelfirst,panelmain; publicstaticintid; staticaccountsclient=null; publicDN_ATM(){ super("達能銀行"); this.setSize(435,350); this.setLocation(500,250); this.setDefaultCloseOperation(JFrame.E*IT_ON_CLOSE); //設(shè)置不可改變窗口大小this.setResizable(false); } //布局publicvoidsetLayout(){ //用卡片布局Layout=newCardLayout(); container=getContentPane(); container.setLayout(Layout); //添加第一卡片panelfirst=newJPanel(null); //設(shè)置卡片的背景顏色panelfirst.setBackground(newColor(119,119,253)); lblji*u=newJLabel("請放入磁卡,然后繼續(xù)操作"); //設(shè)置卡片在Panel中的位置lblji*u.setBounds(140,90,350,30); //為第一卡片添加一個Label panelfirst.add(lblji*u); //為第一卡片添加一個按鈕btncard=newJButton("繼續(xù)"); btncard.setBounds(310,180,80,30); //為按鈕注冊事件監(jiān)聽器btncard.addActionListener(this); //開場時設(shè)置按鈕不可按btncard.setEnabled(false); panelfirst.add(btncard); //為第一卡片添加一個按鈕btngetcard=newJButton("取卡"); btngetcard.setEnabled(false); btngetcard.setBounds(310,220,80,30); btngetcard.addActionListener(this); panelfirst.add(btngetcard); //添加登錄輸入卡片panelmain=newJPanel(null); panelmain.setBackground(newColor(119,119,253)); //添加登錄輸入卡號JLabellblnumber=newJLabel("請輸入您的銀行卡卡號:"); panelmain.add(lblnumber); lblnumber.setBounds(30,30,150,30); //設(shè)置文本框為密碼型t*t1=newJTe*tField(12); //文本框不可選中//t*t1.enable(false); panelmain.add(t*t1); t*t1.setBounds(170,30,200,30); JLabellblpwd=newJLabel("請輸入您的銀行卡密碼:"); panelmain.add(lblpwd); lblpwd.setBounds(30,80,150,30); //設(shè)置文本框為密碼型t*t2=newJPasswordField(12); //文本框不可選中//t*t2.enable(false); panelmain.add(t*t2); //文本框的輸入容用*顯示t*t2.setEchoChar('*'); t*t2.setBounds(170,80,200,30); //添加選擇按鈕btnsure=newJButton("確定"); btnsure.addActionListener(this); panelmain.add(btnsure);btnsure.setBounds(70,160,80,30); //添加重輸按鈕btn010=newJButton("重輸"); btn010.addActionListener(this); panelmain.add(btn010); btn010.setBounds(175,160,80,30); btnback=newJButton("退出"); btnback.addActionListener(this); panelmain.add(btnback); btnback.setBounds(280,160,80,30); //開戶btn_addAccount=newJButton("開戶"); btn_addAccount.setBounds(70,220,80,30); btn_addAccount.addActionListener(this); panelmain.add(btn_addAccount); lblwrong=newJLabel("請注意保護好您的密碼!"); panelmain.add(lblwrong); lblwrong.setBounds(180,110,200,30); container.add(panelmain,"main"); } //事件處理 SuppressWarnings("deprecation") Override publicvoidactionPerformed(ActionEvente){ DBoperdb=newDBoper(); if(e.getSource().equals(btn_addAccount)){OpenAccountopen=newOpenAccount(); open.adduser(); } //磁卡插入后,驗證銀行登錄卡號與密碼if(e.getSource().equals(btnsure)) { client=db.verifyAccount(Integer.parseInt(t*t1.getTe*t()),t*t2.getTe*t()); if(client!=null){ Defaultdefa=newDefault(); defa.defaltDemo(); this.dispose(); id=Integer.parseInt(t*t1.getTe*t()); t*t1.setTe*t("); t*t2.setTe*t("); }else{ lblwrong.setTe*t("卡號或密碼不正確,請重新輸入!"); t*t1.setTe*t("); t*t2.setTe*t("); } } //重置輸入卡號和密碼if(e.getSource()==btn010) { t*t1.setTe*t("); t*t2.setTe*t("); lblwrong.setTe*t("請注意保護好您的密碼!"); } //退出if(e.getSource().equals(btnback)){ System.e*it(0); } } publicstaticvoidmain(String[]args){ //TODOAuto-generatedmethodstub DN_ATMATM=newDN_ATM(); ATM.setLayout(); ATM.setVisible(true); }}GetBalance.java//查詢余額packageDN_SYSTEM;importjava.awt.CardLayout;importjava.awt.Color;importjava.awt.Container;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava*.swing.JButton;importjava*.swing.JFrame;importjava*.swing.JLabel;importjava*.swing.JPanel;importjava*.swing.WindowConstants;importAccount.accounts;importDB.DBoper;publicclassGetBalancee*tendsJFrameimplementsActionListener{ privateJFramejf; privateContainerc; privateJLabellblremain1,lblremain; privateJButtonbtnremain,btnremain1; accountsaccount=newaccounts(); DBoperdb=newDBoper(); privateintid=DN_ATM.id; //添加查詢余額界面卡片publicvoidgetBalance(){ account=db.queryByID(id); jf=newJFrame("FINDDALANCE"); c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); c.setBackground(newColor(119,119,253)); lblremain1=newJLabel("尊敬的達能用戶您好!"); lblremain1.setBounds(90,70,350,30); c.add(lblremain1); lblremain=newJLabel("請點擊繼續(xù)操作查詢余額:"); lblremain.setBounds(90,110,350,30); c.add(lblremain); btnremain=newJButton("繼續(xù)操作"); btnremain.setBounds(95,150,90,30); btnremain.addActionListener(this); c.add(btnremain); btnremain1=newJButton("退出操作"); btnremain1.setBounds(200,150,90,30); btnremain1.addActionListener(this); c.add(btnremain1); jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.E*IT_ON_CLOSE); } Override publicvoidactionPerformed(ActionEvente){ //查詢余額if(e.getSource()==btnremain) { lblremain1.setTe*t("卡號:"+account.getId()+"用戶名:"+account.getName()); lblremain.setTe*t("您的余額為"+account.getBalance()+"元,是否繼續(xù)操作?"); } if(e.getSource()==btnremain1){Defaultdefa=newDefault(); defa.defaltDemo(); jf.dispose(); } } publicstaticvoidmain(String[]args){ //TODOAuto-generatedmethodstub GetBalancebalance=newGetBalance(); balance.getBalance(); }}InMoney.java//存款packageDN_SYSTEM;importjava.awt.CardLayout;importjava.awt.Color;importjava.awt.Container;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava*.swing.JButton;importjava*.swing.JFrame;importjava*.swing.JLabel;importjava*.swing.JOptionPane;importjava*.swing.JTe*tField;importjava*.swing.WindowConstants;importAccount.accounts;importDB.DBoper;publicclassInMoneye*tendsJFrameimplementsActionListener{ privateJLabellblsave,lblsave1; privateJButtonbtnsave,btnsave2; privateJTe*tFieldt*t2; privatedoublesavemoney; privatedoublelastmoney; privatebooleanflag; privateJFramejf; privateContainerc; accountsaccount=newaccounts(); DBoperdb=newDBoper(); privateintid=DN_ATM.id;publicvoidInMoney(){ account=db.queryByID(id); jf=newJFrame("INMONEY"); c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); //添加存款顯示界面卡片c.setBackground(newColor(119,119,253)); lblsave=newJLabel("請在存款口處放入存款"); lblsave.setBounds(60,30,350,30); c.add(lblsave); lblsave1=newJLabel("請注意:只接收100元或100元的整數(shù)倍存款"); lblsave1.setBounds(90,110,350,30); c.add(lblsave1); t*t2=newJTe*tField(12); c.add(t*t2); t*t2.setBounds(95,80,200,30); btnsave=newJButton("放入存款完畢"); btnsave.setBounds(90,160,120,30); btnsave.addActionListener(this); c.add(btnsave); btnsave2=newJButton("返回"); btnsave2.setBounds(240,160,60,30); btnsave2.addActionListener(this); c.add(btnsave2); jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.E*IT_ON_CLOSE); } Override publicvoidactionPerformed(ActionEvente){ if(e.getSource()==btnsave) { savemoney=Double.parseDouble(t*t2.getTe*t()); lastmoney=account.getBalance(); lastmoney+=savemoney; Stringsql="updateaccountsetbalance="+lastmoney+"whereid=" +id; flag=db.accountDataUpdate(sql); if(flag){ JOptionPane.showMessageDialog(this,"存款成功!"); t*t2.setTe*t("); Defaultdefa=newDefault(); defa.defaltDemo(); jf.dispose(); } else { JOptionPane.showMessageDialog(this,"存款失?。?); } } if(e.getSource()==btnsave2) { Defaultdefa=newDefault(); defa.defaltDemo(); jf.dispose(); } } publicstaticvoidmain(String[]args){ //TODOAuto-generatedmethodstub InMoneyinmoney=newInMoney(); inmoney.InMoney(); }}OpenAccount.java//開戶packageDN_SYSTEM;importjava.awt.Component;importjava.awt.Container;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava*.swing.ButtonGroup;importjava*.swing.JButton;importjava*.swing.JFrame;importjava*.swing.JLabel;importjava*.swing.JOptionPane;importjava*.swing.JPasswordField;importjava*.swing.JRadioButton;importjava*.swing.JTe*tField;importjava*.swing.WindowConstants;importDB.DBoper;importAccount.accounts;publicclassOpenAccounte*tendsJFrameimplementsActionListener{ privateJFramejf; privateContainerc; privateJTe*tFieldt*tname,t*t_personId; privateJPasswordFieldt*tpwd,t*tpwd1; privateJRadioButtonrbt1; privateJRadioButtonrbt2; StringaccountType; //開戶,增加新用戶publicvoidadduser(){ jf=newJFrame("OpenAccount"); c=jf.getContentPane(); c.setLayout(null); jf.setResizable(false); JLabellbname=newJLabel("用戶名:"); lbname.setBounds(100,40,80,20); t*tname=newJTe*tField(); t*tname.setBounds(160,40,130,20); c.add(lbname); c.add(t*tname); JLabellbpwd=newJLabel("密碼:"); lbpwd.setBounds(110,65,80,20); t*tpwd=newJPasswordField(); t*tpwd.setBounds(160,65,130,20); t*tpwd.setEchoChar('*'); c.add(lbpwd);c.add(t*tpwd);JLabellbpwd1=newJLabel("確認密碼:"); lbpwd1.setBounds(86,90,80,20); t*tpwd1=newJPasswordField(); t*tpwd1.setBounds(160,90,130,20); t*tpwd1.setEchoChar('*'); c.add(lbpwd1);c.add(t*tpwd1);JLabellbpersonId=newJLabel("號:");lbpersonId.setBounds(86,115,80,20); t*t_personId=newJTe*tField(); t*t_personId.setBounds(160,115,130,20); c.add(lbpersonId);c.add(t*t_personId);JLabellbtype=newJLabel("賬戶類型:"); lbtype.setBounds(86,120,80,60); rbt1=newJRadioButton("信用卡"); rbt1.setBounds(160,135,70,30); rbt2=newJRadioButton("儲蓄卡"); rbt2.setBounds(225,135,70,30);ButtonGroupgroup=newButtonGroup(); group.add(rbt2); group.add(rbt1); c.add(lbtype); c.add(rbt2); c.add(rbt1); JButtonbtnsubmit=newJButton("提交"); btnsubmit.setBounds(100,190,80,20); JButtonbtnreset=newJButton("重置");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.E*IT_ON_CLOSE); } publicstaticvoidmain(String[]args){ //TODOAuto-generatedmethodstub OpenAccountopenA=newOpenAccount(); openA.adduser(); } Override publicvoidactionPerformed(ActionEvente){accountsaccount=newaccounts(); account.setName(t*tname.getTe*t()); if(t*tpwd.getTe*t().equals(t*tpwd1.getTe*t())){ account.setPassword(t*tpwd.getTe*t()); }else{ JOptionPane.showMessageDialog(this,"兩次輸入的密碼不一致,請重新輸入!"); } account.setPersonId(t*t_personId.getTe*t()); if(rbt1.isSelected()) accountType="1"; if(rbt2.isSelected()) accountType="0"; account.setAccountType(Integer.parseInt(accountType)); account.setBalance(0); if(accountType.equals("1")){ account.setCeiling(5000.0); }else{ account.setCeiling(0); } DBoperdb=newDBoper(); if(db.accountDataInsert(account)){ JOptionPane.showMessageDialog(this,"開戶成功!"); jf.dispose();//關(guān)閉當(dāng)前登錄窗體return; }else{ JOptionPane.showMessageDialog(this,"開戶失??!"); return; } }}OutMoney.java//取款packageDN_SYSTEM;importjava.awt.CardLayout;importjava.awt.Color;importjava.awt.Container;importjava*.swing.JButton;importjava*.swing.JFrame;importjava*.swing.JLabel;importjava*.swing.JOptionPane;importjava*.swing.JPanel;importjava*.swing.JTe*tField;importjava*.swing.WindowConstants;importAccount.accounts;importDB.DBoper;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;publicclassOutMoneye*tendsJFrameimplementsActionListener{ privateJFramejf;privateJButtonbtn100,btn200,btn300,btn500,btn1000; privateJButtonbtn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009,btn000; privateJButtonbtnsure1,btn0010,btnback2; privateJTe*tFieldt*t2; privateContainerc; privateJLabellblqukuan; privateintmoney; privatedoublelastmoney; accountsaccount=newaccounts(); DBoperdb=newDBoper(); privateintid=DN_ATM.id; publicvoidoutMoney(){ account=db.queryByID(id); jf=newJFrame("OUTMONEY"); c=jf.getContentPane();c.setLayout(null); jf.setResizable(false); //添加取款頁面卡片//panel4=newJPanel(null); c.setBackground(newColor(119,119,253)); lblqukuan=newJLabel("請輸入您的取款金額:"); c.add(lblqukuan); lblqukuan.setBounds(115,20,150,30); lblqukuan=newJLabel("提示:只能是100元或100元的整數(shù)倍"); c.add(lblqukuan); lblqukuan.setBounds(115,50,300,30); t*t2=newJTe*tField(12); t*t2.enable(false); c.add(t*t2); t*t2.setBounds(115,90,200,30); btn100=newJButton("100"); c.add(btn100); btn100.addActionListener(this);btn100.setBounds(45,190,60,30); btn200=newJButton("200"); c.add(btn200); btn200.addActionListener(this); btn200.setBounds(115,190,60,30); btn300=newJButton("300"); c.add(btn300); btn300.addActionListener(this); btn300.setBounds(185,190,60,30); btn500=newJButton("500"); btn500=newJButton("500"); c.add(btn500); btn500.addActionListener(this); btn500.setBounds(255,190,60,30); btn1000=newJButton("1000"); c.add(btn1000); btn1000.addActionListener(this);btn1000.setBounds(325,190,65,30); btn001=newJButton("1"); c.add(btn001); btn001.addActionListener(this); btn001.setBounds(45,230,60,30); btn002=newJButton("2"); c.add(btn002); btn002.addActionListener(this); btn002.setBounds(115,230,60,30); btn003=newJButton("3"); c.add(btn003); btn003.addActionListener(this); btn003.setBounds(185,230,60,30); btn004=newJButton("4"); c.add(btn004); btn004.addActionListener(this); btn004.setBounds(255,230,60,30); btn005=newJButton("5"); c.add(btn005); btn005.addActionListener(this); btn005.setBounds(325,230,65,30); btn006=newJButton("6"); c.add(btn006); btn006.addActionListener(this); btn006.setBounds(45,270,60,30); btn007=newJButton("7"); c.add(btn007); btn007.addActionListener(this); btn007.setBounds(115,270,60,30); btn008=newJButton("8"); c.add(btn008); btn008.addActionListener(this); btn008.setBounds(185,270,60,30); btn009=newJButton("9"); c.add(btn009); btn009.addActionListener(this); btn009.setBounds(255,270,60,30); btn000=newJButton("0"); c.add(btn000); btn000.addActionListener(this); btn000.setBounds(325,270,65,30); btnsure1=newJButton("確定"); c.add(btnsure1); btnsure1.addActionListener(this);btnsure1.setBounds(70,140,80,30); btn0010=newJButton("重輸"); c.add(btn0010); btn0010.addActionListener(this); btn0010.setBounds(175,140,80,30); btnback2=newJButton("返回"); c.add(btnback2); btnback2.addActionListener(this); btnback2.setBounds(280,140,80,30); jf.setVisible(true);jf.setSize(460,350);jf.setDefaultCloseOperation(WindowConstants.E*IT_ON_CLOSE); } Override publicvoidactionPerformed(ActionEvente){ if(e.getSource()==btn000) {Stringa=t*t2.getTe*t(); if(a.equals(")) { t*t2.setTe*t("); } else { t*t2.setTe*t(a+"0"); } } if(e.getSource()==btn001) { t*t2.setTe*t(t*t2.getTe*t()+"1"); } if(e.getSource()==btn002) { t*t2.setTe*t(t*t2.getTe*t()+"2"); } if(e.getSource()==btn003) {t*t2.setTe*t(t*t2.getTe*t()+"3");} if(e.getSource()==btn004) {t*t2.setTe*t(t*t2.getTe*t()+"4");} if(e.getSource()==btn005){t*t2.setTe*t(t*t2.getTe*t()+"5");} if(e.getSource()==btn006) {t*t2.setTe*t(t*t2.getTe*t()+"6");} if(e.getSource()==btn007) {t*t2.setTe*t(t*t2.getTe*t()+"7");} if(e.getSource()==btn008) {t*t2.setTe*t(t*t2.getTe*t()+"8");} if(e.getSource()==btn009) {t*t2.setTe*t(t*t2.getTe*t()+"9");} if(e.getSource()==btn100) {t*t2.setTe*t("100");} if(e.getSource()==btn200) {t*t2.setTe*t("200");} if(e.getSource()==btn300) {t*t2.setTe*t("300");} if(e.getSource()==btn500) {t*t2.setTe*t("500");} if(e.getSource()==btn1000) {t*t2.setTe*t("1000");} //返回if(e.getSource()==btnback2) { Defaultdefa=newDefault();defa.defaltDemo(); jf.dispose(); } //重輸if(e.getSource()==btn0010) { t*t2.setTe*t("); } //取款確定if(e.getSource()==btnsure1) { if(!t*t2.getTe*t().equals(")) { money=newInteger(t*t2.getTe*t()); }t*t2.setTe*t("); lastmoney=account.getBalance(); if((money%100)==0&&money<=lastmoney&&money!=0) { try { Thread.sleep(1000); }catch(InterruptedE*ceptione1) { e1.printStackTrace(); }lastmoney=lastmoney-money; Stringsql="updateaccountsetbalance="+lastmoney+"whereid=" +id; booleanflag=db.accountDataUpdate(sql); if(flag){ JOptionPane.showMessageDialog(this,"取款成功!"); Defaultdefa=n
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 陜西省安康市2024-2025學(xué)年八年級(上)期末語文試卷
- 2025年全球及中國氯雷他定片行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025-2030全球工商用管道除濕機行業(yè)調(diào)研及趨勢分析報告
- 2025年全球及中國劃線輪(描線輪)行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025-2030全球PTFE化學(xué)鍍鎳行業(yè)調(diào)研及趨勢分析報告
- 2025年全球及中國汽車超高頻天線行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025年全球及中國多托盤貨叉行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025-2030全球汽車行業(yè)用生物基聚酰胺行業(yè)調(diào)研及趨勢分析報告
- 2025年全球及中國樹木介紹牌行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025-2030全球醫(yī)美用A型肉毒毒素行業(yè)調(diào)研及趨勢分析報告
- 2025-2030年中國納米氧化鋁行業(yè)發(fā)展前景與投資戰(zhàn)略研究報告新版
- 2025年度正規(guī)離婚協(xié)議書電子版下載服務(wù)
- 2025年貴州蔬菜集團有限公司招聘筆試參考題庫含答案解析
- 煤礦安全生產(chǎn)方針及法律法規(guī)課件
- 2025年教科室工作計劃樣本(四篇)
- 2024年版古董古玩買賣合同:古玩交易稅費及支付規(guī)定
- 【7歷期末】安徽省宣城市2023-2024學(xué)年七年級上學(xué)期期末考試歷史試題
- 春節(jié)后安全生產(chǎn)開工第一課
- 2025光伏組件清洗合同
- 電力電纜工程施工組織設(shè)計
- 2024年網(wǎng)格員考試題庫完美版
評論
0/150
提交評論