package dao.Impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import db.DBCon;

import model.PageBean;
import model.UsRole;
import model.User;

public class EmpBiz {
   DBCon dbCon=new DBCon();
   UsRole usRole;
   PageBean pageBean;
	public EmpBiz() {
		super();
	
	}
	
	//具体实现分页的方法,传递两个参数,一个第几页,一个每页的数量
	public PageBean listEmps(int pageNo, int pageCount){
		
		ResultSet rs=null;
		ArrayList<UsRole> list=new ArrayList<UsRole>();
		String sqlCount="select count(*) from user";
		String sql="select user_id,user_num,user_name,password,phone,role_name " +
				"from user,role " +
				"where user.role_id=role.role_id " +
				"limit "+((pageNo-1)*pageCount)+","+pageCount;
		rs=dbCon.find(sql);
		try {
		/*	con=dbCon.dbCon();
			st=con.createStatement();
			rs=st.executeQuery(sql);*/
			while(rs.next()){
				int userID = rs.getInt("user_id");
				String userNum = rs.getString("user_num");
				String userName = rs.getString("user_name");
				String pwd = rs.getString("password");
				String phone = rs.getString("phone");
				String roleName = rs.getString("role_name");
				usRole = new UsRole(userID, userNum, userName, pwd, phone,
						roleName);
				list.add(usRole);
			}
			
			rs=dbCon.find(sqlCount);
			
		//	rs=st.executeQuery(sqlCount);
			int totalCount=0;
			while(rs.next()){
				totalCount=rs.getInt(1);
			}
			
			pageBean=new PageBean(list,totalCount,pageNo,pageCount);
			return pageBean;
		} catch (SQLException e) {
			
			e.printStackTrace();
		//	return null;
		}
		return pageBean;
	}

}
最近下载更多
爱学习的涵  LV7 2024年6月22日
kaikai11111  LV2 2023年12月6日
jiemomo  LV12 2023年11月2日
zj20020510  LV5 2023年9月24日
唐钰小宝A  LV13 2023年9月12日
vilychan  LV2 2023年9月11日
hongdongdong  LV14 2023年6月29日
ziv5466123  LV7 2023年6月28日
1122213  LV1 2023年6月6日
liu0820  LV1 2022年12月19日
最近浏览更多
GuanYang551 6月21日
暂无贡献等级
lkke23047  LV1 5月26日
2297224153 3月27日
暂无贡献等级
571818771  LV3 2024年12月16日
qpzmla 2024年12月13日
暂无贡献等级
微信网友_7290996505972736  LV4 2024年12月11日
曾多次  LV1 2024年12月8日
11onerr 2024年11月22日
暂无贡献等级
111rose  LV1 2024年11月21日
wuyanmingsi  LV1 2024年9月7日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友