package com.bean;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import com.util.Constant;
import com.util.DBO;
/**
*
* 网站后台管理注册会员 查询 冻结 删除会员
*/
public class MemberManageBean {
private List list;
private ResultSet rs = null;
private int EVERYPAGENUM = 2;
private int count = -1;
private int qq = 0;
private String sql="select count(*) from fz_member where type='person'";
private String sql2="select * from fz_member where type='person' order by id desc ";
//声明时间变量
String date1=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
//分页查询所有个人会员
public void setEVERYPAGENUM(int EVERYPAGENUM){
this.EVERYPAGENUM=EVERYPAGENUM;
}
public int getMessageCount() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery(sql);
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public int getPageCount() { //得到共多少页(根据每页要显示几条信息)
if (count % EVERYPAGENUM == 0) {
return count / EVERYPAGENUM;
} else {
return count / EVERYPAGENUM + 1;
}
}
public List getMessage(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery(sql2);
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
qq++;
List list2=new ArrayList();
list2.add(rs.getInt("id"));
list2.add(rs.getString("username"));
list2.add(rs.getString("regtime"));
list2.add(rs.getString("ifuse"));
list2.add(rs.getString("logintimes"));
list2.add(rs.getString("lasttime"));
list2.add(rs.getString("lastip"));
list2.add(rs.getString("flag"));
list.add(list2);
} else {
break; //减少空循环的时间
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
//所有在用会员
public int getMessageCountUS() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery("select count(*) from fz_member where ifuse='1'");
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public List getMessageUS(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery("select * from fz_member where ifuse='1' order by id desc ");
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
qq++;
List list2=new ArrayList();
list2.add(rs.getInt("id"));
list2.add(rs.getString("username"));
list2.add(rs.getString("regtime"));
list2.add(rs.getString("ifuse"));
list2.add(rs.getString("logintimes"));
list2.add(rs.getString("lasttime"));
list2.add(rs.getString("lastip"));
list2.add(rs.getString("type"));
list.add(list2);
} else {
break; //减少空循环的时间
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
// 所有冻结会员
public int getMessageCountCL() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery("select count(*) from fz_member where ifuse='0'");
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public List getMessageCL(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery("select * from fz_member where ifuse='0' order by id desc ");
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
qq++;
List list2=new ArrayList();
list2.add(rs.getInt("id"));
list2.add(rs.getString("username"));
list2.add(rs.getString("regtime"));
list2.add(rs.getString("ifuse"));
list2.add(rs.getString("logintimes"));
list2.add(rs.getString("lasttime"));
list2.add(rs.getString("lastip"));
list2.add(rs.getString("type"));
list.add(list2);
} else {
break; //减少空循环的时间
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
// 今日注册会员
public int getMessageCountTODAY() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery("select count(*) from fz_member where regtime between '"+date1+"' and '"+date+"'");
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public List getMessageTODAY(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery("select * from fz_member where regtime between '"+date1+"' and '"+date+"' order by id desc ");
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
qq++;
List list2=new ArrayList();
list2.add(rs.getInt("id"));
list2.add(rs.getString("username"));
list2.add(rs.getString("regtime"));
list2.add(rs.getString("ifuse"));
list2.add(rs.getString("logintimes"));
list2.add(rs.getString("lasttime"));
list2.add(rs.getString("lastip"));
list2.add(rs.getString("type