You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
restaurant/com/bean/MemberManageBean.java

544 lines
16 KiB

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;
/**
*
* <EFBFBD><EFBFBD>վ<EFBFBD><EFBFBD>̨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա <EFBFBD><EFBFBD>ѯ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
*/
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 member where type='person'";
private String sql2="select * from member where type='person' order by id desc ";
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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());
//<2F><>ҳ<EFBFBD><D2B3>ѯ<EFBFBD><D1AF><EFBFBD>и<EFBFBD><D0B8>˻<EFBFBD>Ա
public void setEVERYPAGENUM(int EVERYPAGENUM){
this.EVERYPAGENUM=EVERYPAGENUM;
}
public int getMessageCount() { //<2F>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
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() { //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿҳҪ<D2B3><D2AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
if (count % EVERYPAGENUM == 0) {
return count / EVERYPAGENUM;
} else {
return count / EVERYPAGENUM + 1;
}
}
public List getMessage(int page) { //<2F>õ<EFBFBD>ÿҳҪ<D2B3><D2AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϣ
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"));
list.add(list2);
} else {
break; //<2F><><EFBFBD>ٿ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>Ա////////////////////
public int getMessageCountCO() { //<2F>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery("select count(*) from member where type='co'");
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public List getMessageCO(int page) { //<2F>õ<EFBFBD>ÿҳҪ<D2B3><D2AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϣ
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery("select * from member where type='co' 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"));
list.add(list2);
} else {
break; //<2F><><EFBFBD>ٿ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>Ա
public int getMessageCountUS() { //<2F>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery("select count(*) from 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) { //<2F>õ<EFBFBD>ÿҳҪ<D2B3><D2AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϣ
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery("select * from 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; //<2F><><EFBFBD>ٿ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
// <20><><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>Ա
public int getMessageCountCL() { //<2F>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery("select count(*) from 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) { //<2F>õ<EFBFBD>ÿҳҪ<D2B3><D2AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϣ
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery("select * from 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; //<2F><><EFBFBD>ٿ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
// <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Ա
public int getMessageCountTODAY() { //<2F>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery("select count(*) from 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) { //<2F>õ<EFBFBD>ÿҳҪ<D2B3><D2AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϣ
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery("select * from 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"));
list.add(list2);
} else {
break; //<2F><><EFBFBD>ٿ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return null;
} finally {
dbo.close();
}
}
/*********************************************************************************************************************************
* ɾ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
* @param id
* @return
*********************************************************************/
// ɾ<><C9BE><EFBFBD><EFBFBD>Ա
public int delMember(int id[]){
DBO dbo=new DBO();
dbo.open();
try{
for(int i = 0;i<id.length;i++){
dbo.executeUpdate("delete from member where id = '"+id[i]+"'");
dbo.executeUpdate("delete from pmember where mid = '"+id[i]+"'");
dbo.executeUpdate("delete from cmember where mid = '"+id[i]+"'");
}
return Constant.SUCCESS;
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
public int closeMember(int id){
String sql = "select ifuse from member where id='"+id+"' ";
String sql2 = "update member set ifuse='0' where id='"+id+"'";
String sql3 = "update member set ifuse='1' where id='"+id+"'";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
int ifuse=rs.getInt(1);
if(ifuse == 1){
int j = dbo.executeUpdate(sql2);
if(j == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
else{
int j = dbo.executeUpdate(sql3);
if(j == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
/**********************************************************************
* <EFBFBD><EFBFBD>̨<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>Ϣ <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param id
* @return
*********************************************************************/
//<2F><>idΪ<64><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
public String getType(int id){
String sql = "select type from member where id='"+id+"'";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
String type = rs.getString(1);
return type;
}
else
return null;
}catch(Exception e){
e.printStackTrace();
return null;
}finally{
dbo.close();
}
}
//<2F><>idΪ<64><CEAA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>½<EFBFBD><C2BD>Ϣ
public List getMemberLogin(int id){
String sql = "select * from member where id='"+id+"'";
DBO dbo=new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getString("username"));
list.add(rs.getString("type"));
list.add(rs.getString("regtime"));
list.add(rs.getString("ifuse"));
list.add(rs.getString("logintimes"));
list.add(rs.getString("lasttime"));
list.add(rs.getString("lastip"));
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//<2F><>idΪ<64><CEAA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>Ա<EFBFBD><D4B1>Ϣ
public List getPerSonMember(int id){
String sql = "select * from pmember where mid='"+id+"'";
DBO dbo=new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getString("realname"));
list.add(rs.getString("sex"));
list.add(rs.getString("bir"));
list.add(rs.getString("sheng"));
list.add(rs.getString("city"));
list.add(rs.getString("telphone"));
list.add(rs.getString("email"));
list.add(rs.getString("question"));
list.add(rs.getString("answer"));
list.add(rs.getString("address"));
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
// <09><>idΪ<64><CEAA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>Ա<EFBFBD><D4B1>Ϣ
public List getCoMember(int id){
String sql = "select * from cmember where mid='"+id+"'";
DBO dbo=new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getString("coname"));
list.add(rs.getString("address"));
list.add(rs.getString("postnum"));
list.add(rs.getString("tel"));
list.add(rs.getString("email"));
list.add(rs.getString("question"));
list.add(rs.getString("answer"));
list.add(rs.getString("intro"));
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//////////////<2F><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ///////////////
// <09><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
public String getType(String name){
String sql = "select type from member where username='"+name+"'";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
String type = rs.getString(1);
return type;
}
else
return null;
}catch(Exception e){
e.printStackTrace();
return null;
}finally{
dbo.close();
}
}
//<2F><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>û<EFBFBD>id<69><64>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>id<69><64><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ա<EFBFBD><D4B1>Ϣ <20><>ת<EFBFBD><D7AA>//<2F><>idΪ<64><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
public int getID(String name){
String sql = "select id from member where username='"+name+"'";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
int id = rs.getInt(1);
return id;
}
else
return 0;
}catch(Exception e){
e.printStackTrace();
return 0;
}finally{
dbo.close();
}
}
//////////////<2F><><EFBFBD>û<EFBFBD><C3BB><EFBFBD> idΪ<64><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ///////////////
// <09><><EFBFBD>û<EFBFBD><C3BB><EFBFBD> idΪ<64><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ա<EFBFBD><D4B1><EFBFBD>ͣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>id<69><64><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ա<EFBFBD><D4B1>Ϣ <20><>ת<EFBFBD><D7AA>//<2F><>idΪ<64><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ա
public String getType(int id,String name){
String sql = "select type from member where id='"+id+"' and username='"+name+"'";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
String type = rs.getString(1);
return type;
}
else
return null;
}catch(Exception e){
e.printStackTrace();
return null;
}finally{
dbo.close();
}
}
/////////////////////<2F><>ע<EFBFBD><D7A2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ѯ/////////////////////
public List getMemberByTime(String stime,String etime){
String sql = "select * from member where regtime between '"+stime+"' and '"+etime+" 23:59:59' ";
DBO dbo=new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
while(rs.next()){
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);
}
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
}