版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
.PAGE29/NUMPAGES29Java小型銀行管理系統(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ù)構造方法 publicaccounts<>{ } //構造方法 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<"com.mysql.jdbc.Driver">; conn=DriverManager.getConnection<"jdbc:mysql://localhost:3306/bankmanager?useUnicode=true&characterEncoding=utf8","root","xuewei">; }catch<Exceptione>{ System.out.println<"數(shù)據(jù)庫連接失敗">; } returnconn; } //修改刪除用戶數(shù)據(jù) publicbooleanaccountDataUpdate<Stringsql>{ conn=getConnection<>; try{ pstmt=conn.prepareStatement<sql>; pstmt.executeUpdate<>; //System.out.println<"數(shù)據(jù)更新成功">; conn.close<>; returntrue; }catch<SQLExceptione>{ 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.executeUpdate<>; System.out.println<"操作成功">; returntrue; } catch<SQLExceptione>{ 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.executeUpdate<>; System.out.println<"新用戶數(shù)據(jù)插入成功">; conn.close<>; returntrue; }catch<SQLExceptione>{ e.printStackTrace<>; System.out.println<"插入失敗">; returnfalse; } } //查詢數(shù)據(jù) publicResultSetdataquery<Stringsql>{ conn=getConnection<>; try{ pstmt=conn.prepareStatement<sql>; rs=pstmt.executeQuery<>; } catch<SQLExceptione>{ e.printStackTrace<>; System.out.println<"檢索失敗">; } returnrs; } publicResultSettestlist<>{ try{ Stringsql="select*fromaccountwhereid=1001"; pstmt=conn.prepareStatement<sql>; System.out.println<sql>; rs=pstmt.executeQuery<>; }catch<SQLExceptione>{ 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.executeQuery<>; while<rs.next<>>{ 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<SQLExceptione>{ 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.executeQuery<>; if<rs.next<>>{ returntrue; }else{ returnfalse; } }catch<SQLExceptione>{ 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.executeQuery<>; accountsaccount=newaccounts<>; while<rs.next<>>{ 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<SQLExceptione>{ e.printStackTrace<>; returnnull; } } //根據(jù)卡號查詢信息 publicaccountsqueryByID<intid>{ conn=getConnection<>; try{ pstmt=conn.prepareStatement<"select*fromaccountwhereid=?">; pstmt.setInt<1,id>; rs=pstmt.executeQuery<>; accountsaccount=newaccounts<>; while<rs.next<>>{ 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<SQLExceptione>{ 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;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.WindowConstants;importAccount.accounts;importDB.DBoper;publicclassDefaultextendsJFrameimplementsActionListener{ 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<"轉賬服務">; 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.EXIT_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<>; } //轉賬服務 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.exit<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;importjavax.swing.AbstractButton;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JTextField;importDB.DBoper;importAccount.accounts;publicclassDN_ATMextendsJFrameimplementsActionListener{ privateJLabellbljixu; privateJButtonbtngetcard; privateJButtonbtncard,btn010,btn_addAccount,btnsure,btnback; privateJTextFieldtxt1; privateJPasswordFieldtxt2; privateContainercontainer; privateCardLayoutLayout; privateJLabellblwrong; privateJPanelpanelfirst,panelmain; publicstaticintid; staticaccountsclient=null; publicDN_ATM<>{ super<"達能銀行">; this.setSize<435,350>; this.setLocation<500,250>; this.setDefaultCloseOperation<JFrame.EXIT_ON_CLOSE>; //設置不可改變窗口大小 this.setResizable<false>; } //布局 publicvoidsetLayout<>{ //用卡片布局 Layout=newCardLayout<>; container=getContentPane<>; container.setLayout<Layout>; //添加第一張卡片 panelfirst=newJPanel<null>; //設置卡片的背景顏色 panelfirst.setBackground<newColor<119,119,253>>; lbljixu=newJLabel<"請放入磁卡,然后繼續(xù)操作">; //設置卡片在Panel中的位置 lbljixu.setBounds<140,90,350,30>; //為第一張卡片添加一個Label panelfirst.add<lbljixu>; //為第一張卡片添加一個按鈕 btncard=newJButton<"繼續(xù)">; btncard.setBounds<310,180,80,30>; //為按鈕注冊事件監(jiān)聽器 btncard.addActionListener<this>; //開始時設置按鈕不可按 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>; //設置文本框為密碼型 txt1=newJTextField<12>; //文本框不可選中 //txt1.enable<false>; panelmain.add<txt1>; txt1.setBounds<170,30,200,30>; JLabellblpwd=newJLabel<"請輸入您的銀行卡密碼:">; panelmain.add<lblpwd>; lblpwd.setBounds<30,80,150,30>; //設置文本框為密碼型 txt2=newJPasswordField<12>; //文本框不可選中 //txt2.enable<false>; panelmain.add<txt2>; //文本框的輸入內容用*顯示 txt2.setEchoChar<'*'>; txt2.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<txt1.getText<>>,txt2.getText<>>; if<client!=null>{ Defaultdefa=newDefault<>; 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>; } } 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;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.WindowConstants;importAccount.accounts;importDB.DBoper;publicclassGetBalanceextendsJFrameimplementsActionListener{ 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.EXIT_ON_CLOSE>; } @Override publicvoidactionPerformed<ActionEvente>{ //查詢余額 if<e.getSource<>==btnremain> { lblremain1.setText<"卡號:"+account.getId<>+"用戶名:"+account.getName<>>; lblremain.setText<"您的余額為"+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;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JTextField;importjavax.swing.WindowConstants;importAccount.accounts;importDB.DBoper;publicclassInMoneyextendsJFrameimplementsActionListener{ privateJLabellblsave,lblsave1; privateJButtonbtnsave,btnsave2; privateJTextFieldtxt2; 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>; txt2=newJTextField<12>; c.add<txt2>; txt2.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.EXIT_ON_CLOSE>; } @Override publicvoidactionPerformed<ActionEvente>{ if<e.getSource<>==btnsave> { savemoney=Double.parseDouble<txt2.getText<>>; lastmoney=account.getBalance<>; lastmoney+=savemoney; Stringsql="updateaccountsetbalance="+lastmoney+"whereid=" +id; flag=db.accountDataUpdate<sql>; if<flag>{ JOptionPane.showMessageDialog<this,"存款成功!">; txt2.setText<"">; 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;importjavax.swing.ButtonGroup;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPasswordField;importjavax.swing.JRadioButton;importjavax.swing.JTextField;importjavax.swing.WindowConstants;importDB.DBoper;importAccount.accounts;publicclassOpenAccountextendsJFrameimplementsActionListener{ privateJFramejf; privateContainerc; privateJTextFieldtxtname,txt_personId; privateJPasswordFieldtxtpwd,txtpwd1; privateJRadioButtonrbt1; privateJRadioButtonrbt2; StringaccountType; //開戶,增加新用戶 publicvoidadduser<>{ jf=newJFrame<"OpenAccount">; c=jf.getContentPane<>; c.setLayout<null>; jf.setResizable<false>; JLabellbname=newJLabel<"用戶名:">; lbname.setBounds<100,40,80,20>; txtname=newJTextField<>; txtname.setBounds<160,40,130,20>; c.add<lbname>; c.add<txtname>; JLabellbpwd=newJLabel<"密碼:">; lbpwd.setBounds<110,65,80,20>; txtpwd=newJPasswordField<>; txtpwd.setBounds<160,65,130,20>; txtpwd.setEchoChar<'*'>; c.add<lbpwd>;c.add<txtpwd>;JLabellbpwd1=newJLabel<"確認密碼:">; lbpwd1.setBounds<86,90,80,20>; txtpwd1=newJPasswordField<>; txtpwd1.setBounds<160,90,130,20>; txtpwd1.setEchoChar<'*'>; c.add<lbpwd1>;c.add<txtpwd1>;JLabellbpersonId=newJLabel<"身份證號:">;lbpersonId.setBounds<86,115,80,20>; txt_personId=newJTextField<>; txt_personId.setBounds<160,115,130,20>; c.add<lbpersonId>;c.add<txt_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.EXIT_ON_CLOSE>; } publicstaticvoidmain<String[]args>{ //TODOAuto-generatedmethodstub OpenAccountopenA=newOpenAccount<>; openA.adduser<>; } @Override publicvoidactionPerformed<ActionEvente>{ accountsaccount=newaccounts<>; 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="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<>;//關閉當前登錄窗體 return; }else{ JOptionPane.showMessageDialog<this,"開戶失?。?>; return; } }}OutMoney.java //取款packageDN_SYSTEM;importjava.awt.CardLayout;importjava.awt.Color;importjava.awt.Container;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JTextField;importjavax.swing.WindowConstants;importAccount.accounts;importDB.DBoper;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;publicclassOutMoneyextendsJFrameimplementsActionListener{ privateJFramejf; privateJButtonbtn100,btn200,btn300,btn500,btn1000; privateJButtonbtn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009,btn000; privateJButtonbtnsure1,btn0010,btnback2; privateJTextFieldtxt2; privateContainerc; privateJLabellblqukuan; privateintmoney; privatedoublelastmoney; accountsaccount=newaccounts<>; DBoperdb=newDBoper<>; privateintid=DN_ATM.id; publicvoid
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度市政道路照明安裝工程分包合同
- 2025年滬教版三年級語文上冊月考試卷
- 2025年人教五四新版九年級生物下冊月考試卷含答案
- 二零二五年美發(fā)師技術交流聘用合同3篇
- 2025年外研銜接版九年級科學下冊月考試卷含答案
- 個性化借款協(xié)議范本2024版詳析版A版
- 2025年滬科版選擇性必修3化學下冊階段測試試卷
- 2025年人教版(2024)九年級地理上冊階段測試試卷含答案
- 東北農田玉米購銷協(xié)議范本2024版
- 2025年北師大版選修3物理下冊階段測試試卷含答案
- 2024年浙江杭州師范大學附屬醫(yī)院招聘筆試真題
- 學校自習室管理及收費方案
- 2025年護理部護士理論培訓計劃
- 環(huán)保管家管家式管家式一站式服務合同
- 醫(yī)療廢物污水培訓
- 房地產營銷策劃 -佛山龍灣壹號學區(qū)房項目推廣策略提案方案
- 2024年執(zhí)業(yè)藥師繼續(xù)教育專業(yè)答案
- 產品共同研發(fā)合作協(xié)議范本5篇
- 吸入療法在呼吸康復應用中的中國專家共識2022版
- 1-35kV電纜技術參數(shù)表
評論
0/150
提交評論