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

}
最近下载更多
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  LV12 2023年6月29日
ziv5466123  LV7 2023年6月28日
1122213  LV1 2023年6月6日
liu0820  LV1 2022年12月19日
houxiongxiong  LV6 2022年12月16日
最近浏览更多
lzx602  LV3 4月15日
GJQ123  LV4 4月2日
xinnnnn  LV1 2月26日
550423p 2月18日
暂无贡献等级
3090754224  LV2 1月7日
2131234536546  LV7 1月4日
Nuyoah_L 1月3日
暂无贡献等级
颜菜菜  LV2 2023年12月29日
asddwh  LV12 2023年12月26日
lshlsh 2023年12月25日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友