首页>代码>java swing银行管理系统,java实现的毕业设计>/银行系统(0524)/BankManager/src/com/bank/dao/CusFundsDao.java
package com.bank.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.bank.model.CusFunds;
import com.bank.util.StringUtil;

public class CusFundsDao {
	
	/**
	 * 更新账户资金(取款)
	 * @param con
	 * @param 
	 * @return
	 * @throws Exception
	 */
	public int noraddupdate(Connection con,double balance,String AccoutID)throws Exception{
		String sql="update customer_funds set TotalFunds=TotalFunds-? where cu_fAccount=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setDouble(1,balance);
		pstmt.setString(2,AccoutID);
		return pstmt.executeUpdate();
	}
	
	/**
	 * 更新账户资金(存款)
	 * @param con
	 * @param 
	 * @return
	 * @throws Exception
	 */
	public int norsubupdate(Connection con,double balance,String AccoutID)throws Exception{
		String sql="update customer_funds set TotalFunds=TotalFunds+? where cu_fAccount=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setDouble(1,balance);
		pstmt.setString(2,AccoutID);
		return pstmt.executeUpdate();
	}
	
	
	/**
	 * 查询客户资金情况
	 * @param con
	 * @param cusFunds
	 * @return
	 * @throws Exception
	 */
	public ResultSet list(Connection con,CusFunds cusFunds)throws Exception{
		StringBuffer sb=new StringBuffer("select * from customer_funds");
		if(StringUtil.isNotEmpty(cusFunds.getCu_fAccount())){
			//先用and 为后续多个条件方便使用
			sb.append(" and cu_fAccount ="+cusFunds.getCu_fAccount().trim()+"");
		}
		//替换语句 将and 处理转为where
		PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where"));
		return pstmt.executeQuery();
	}
	
	
	/**
	 * 冻结客户资金
	 * @param con
	 * @param cusFunds
	 * @return
	 * @throws Exception
	 */
	public int frozeupdate(Connection con,CusFunds cusFunds)throws Exception{
		String sql="update customer_funds set TotalFunds=?,FrozenCapital=? where cu_fAccount=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setDouble(1,0.00);
		pstmt.setDouble(2,cusFunds.getTotalFunds());
		pstmt.setString(3,cusFunds.getCu_fAccount());
		return pstmt.executeUpdate();
	}
	
	/**
	 * 解冻客户资金
	 * @param con
	 * @param cusFunds
	 * @return
	 * @throws Exception
	 */
	public int unfreupdate(Connection con,CusFunds cusFunds)throws Exception{
		String sql="update customer_funds set TotalFunds=?,FrozenCapital=? where cu_fAccount=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setDouble(1,cusFunds.getFrozenCapital());
		pstmt.setDouble(2,0.00);
		pstmt.setString(3,cusFunds.getCu_fAccount());
		return pstmt.executeUpdate();
	}
}
最近下载更多
WDWDWD123  LV2 6月18日
胡棋俊  LV4 2024年11月17日
zvcbnlk  LV2 2024年9月24日
baowanhong  LV2 2023年6月11日
微信网友_6212133351690240  LV2 2022年12月27日
做你的景天  LV7 2022年11月23日
罗清晨  LV13 2022年9月27日
qwqiwiw  LV4 2022年9月19日
testuser1234567  LV24 2022年5月31日
微信网友_5981140928106496  LV5 2022年5月30日
最近浏览更多
WDWDWD123  LV2 6月18日
DoustrongWU  LV5 3月7日
ma406805131  LV19 1月31日
ybbydwf  LV2 1月8日
微信网友_7306808533962752 2024年12月22日
暂无贡献等级
yimaoermao  LV1 2024年11月28日
胡棋俊  LV4 2024年11月17日
zwn258000 2024年10月24日
暂无贡献等级
zvcbnlk  LV2 2024年9月16日
xzg123456  LV6 2024年6月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友