Day20190610:简易的银行管理系统

工具类:

package com.yang.Dao;

import java.sql.ResultSet;
import java.sql.SQLException;

public class AdministerDao extends BaseDao{

	/**
	 * 01-管理员登录 
	 * @param id 管理员账号
	 * @param custPwd 管理员密码
	 * @return 是否登录成功
	 */
	public boolean login(String name,String Pwd) {
		try {
			String sql = "select * from administrator where adminName=? and adminPwd=?";
			Object[] params = {name,Pwd};
			ResultSet rs = this.myexecuteQuery(sql, params);
			if(rs.next()) {
				return true;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}
	
	/**
	 * 02-增加用户
	 */
	public int addCustomer(Object[] params) {
		String sql = "insert into customer values (?,?,?,?,?,now())";
		return this.myexecuteUpdate(sql, params);
	}
	
	/**
	 * 03-查询存储总额
	 */
	public double sumMoney() {
		String sql = "select sum(custMoney) from customer";
		try {
			ResultSet rs = this.myexecuteQuery(sql,null);
			if(rs.next()) {
				return rs.getDouble(1);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return 0;
	}
	/**
	 * 04-查询有钱人
	 */
	public void richMan() {
		String sql = "select * from customer order by custMoney desc limit 0,10";
		ResultSet rs = this.myexecuteQuery(sql, null);
		System.out.println("------------------------------------");
		System.out.println("卡号\t姓名\t拥有财富");
		try {
			while(rs.next()) {
				String custNumber = rs.getString("custNumber");
				String custName = rs.getString("custName");
				String custMoney = rs.getString("custMoney");
				System.out.println(custNumber+"\t"+custName+"\t"+custMoney);
			}
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
	}
	
}
package com.yang.Dao;

import java.sql.ResultSet;
import java.sql.SQLException;

public class CustomerDao extends BaseDao{

	/**
	 * 01-储户登录 
	 * @param id 储户账号
	 * @param custPwd 储户密码
	 * @return 是否登录成功
	 */
	public boolean login(String id,String custPwd) {
		try {
			String sql = "select * from customer where custNumber=? and custPwd=?";
			Object[] params = {id,custPwd};
			ResultSet rs = this.myexecuteQuery(sql, params);
			if(rs.next()) {
				return true;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

	/**
	 * 02-存款
	 */
	public int addMoney(String custNum,Double Money) {
		String sql = "update customer set custMoney=custMoney+? where custNumber=?";
		Object[] params = {Money,custNum};
		int count = this.myexecuteUpdate(sql, params);
		return count;
	}
	/**
	 * 03-查询储户余额
	 */
	public double queryMoney(String custNum) {
		try {
			String sql = "select custMoney from customer where custNumber
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值