Java_银行管理系统源代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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){

=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;

=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(".mysql.jdbc.Driver");

conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bankmanager?u seUnicode=true&characterEncoding=utf8","root","xuewei");

}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 = "update account set 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();

相关文档
最新文档