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.

486 lines
14 KiB

package com.bean;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import com.util.CheckCode;
import com.util.Constant;
import com.util.DBO;
import com.util.MD5;
/**
* ǰ̨<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>½ ע<EFBFBD><EFBFBD> <EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @author Administrator
*
*/
public class MemberBean {
private List list;
private ResultSet rs;
private String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
/****************************************************************
* <EFBFBD><EFBFBD>Աע<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>Աͨ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>
*
* @return
********************************************************************/
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
public int checkRegName(String username){
String sql = "select * from member where username='"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
return Constant.SAME_NAME;
}
else{
return Constant.SUCCESS;
}
}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>
*
* @return
********************************************************************/
// <09><>Ա<EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
public int editPassword(String username,String oldpwd,String newpwd){
String sql="select * from member where username = '"+username+"' and password = '"+oldpwd+"'";
String sql2="update member set password = '"+newpwd+"' where username = '"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
int i = dbo.executeUpdate(sql2);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}
else{
return Constant.PASSWORD_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
// <09><>Ա<EFBFBD><D4B1>½
public int memberLogin(String username,String password,String type){
password=MD5.MD5(password);
String sql = "select password from member where username='"+username+"' and type='"+type+"' and ifuse='1' ";
//String sql2 = "update member set logintimes=logintimes+1,lasttime='"+date+"',lastip='"+lastip+"' where username='"+username+"' ";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){//<2F><><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8>û<EFBFBD><C3BB><EFBFBD>
String str = rs.getString("password");
if(str.trim().equals(password)){
//dbo.executeUpdate(sql2);
return Constant.SUCCESS;
}
else{
return Constant.PASSWORD_ERROR;
}
}
else{//<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>
return Constant.NAME_ERROR;
}
}catch(Exception e){
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
// <09><>½<EFBFBD><C2BD>Ϣ
public String getLastTimeIP(String username){
String sql = "select lasttime,lastip from member where username='"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
String str=rs.getString(1)+"/"+rs.getString(2);
return str;
}catch(Exception e){
return null;
}finally{
dbo.close();
}
}
//<2F><><EFBFBD>µ<EFBFBD>½<EFBFBD><C2BD>Ϣ
public int upmemberLogin(String username,String lastip ){
String sql = "update member set logintimes=logintimes+1,lasttime='"+date+"',lastip='"+lastip+"' where username='"+username+"' ";
DBO dbo = new DBO();
dbo.open();
try{
int i = dbo.executeUpdate(sql);
if(i == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}catch(Exception e){
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//<2F><>½<EFBFBD><C2BD><EFBFBD><EFBFBD> <20><><EFBFBD>ε<EFBFBD>½ʱ<C2BD><CAB1>
public String getLogintimes(String username){
String sql = "select lasttime,logintimes from member where username='"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
String str=rs.getString(1)+"/"+rs.getString(2);
return str;
}catch(Exception e){
return null;
}finally{
dbo.close();
}
}
/****************************************************************
* <EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>Աע<EFBFBD><EFBFBD> <EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>½ <EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @return
********************************************************************/
//<2F><><EFBFBD>˻<EFBFBD>Աע<D4B1><D7A2>
public int personReg(String username,String password,String type,String realname,String sex,String bir,
String sheng,String city,String telphone,String email,String question,String answer,String lastip,int off,String address){
password=MD5.MD5(password);
String sql = "insert into member(username,password,type,regtime,ifuse,logintimes,lasttime,lastip)" +
" values('"+username+"','"+password+"','"+type+"','"+date+"','"+off+"','0','"+date+"','"+lastip+"') ";
DBO dbo = new DBO();
dbo.open();
try{
int i = dbo.executeUpdate(sql);
if(i == 1){
rs = dbo.executeQuery("select id from member where username='"+username+"'");
rs.next();
int mid = rs.getInt(1);
String sql2 = "insert into pmember(mid,realname,sex,bir,sheng,city,telphone,email,question,answer,address)" +
"values('"+mid+"','"+realname+"','"+sex+"','"+bir+"','"+sheng+"','"+city+"','"+telphone+"','"+email+"','"+question+"','"+answer+"','"+address+"') ";
int j = dbo.executeUpdate(sql2);
if(j == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//ij<><C4B3><EFBFBD>˻<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
public List getRegInfo(String username){
String sql = "select * from pmember where mid=(select id from member where username='"+username+"') ";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getInt("mid"));//0
list.add(rs.getString("realname"));//1
list.add(rs.getString("sex"));//2
list.add(rs.getString("bir"));//3
list.add(rs.getString("sheng"));//4
list.add(rs.getString("city"));//5
list.add(rs.getString("telphone"));//6
list.add(rs.getString("email"));//7
list.add(rs.getString("question"));//8
list.add(rs.getString("answer"));//9
list.add(rs.getString("address"));//9
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//<2F><><EFBFBD>˻<EFBFBD>Ա<EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
public int uppersonReg(String username,String realname,String sex,String bir,String sheng,String city,String telphone,String email,String question,String answer,String address){
String sql = "select id from member where username='"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
int mid = rs.getInt(1);
String sql2 = "update pmember set realname='"+realname+"',sex='"+sex+"',bir='"+bir+"',sheng='"+sheng+"',city='"+city+"',telphone='"+telphone+"'," +
"email='"+email+"',question='"+question+"',answer='"+answer+"',address='"+address+"' where mid='"+mid+"' ";
int i = dbo.executeUpdate(sql2);
if(i == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
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>
*
* @return
********************************************************************/
//<2F><>ҵ<EFBFBD><D2B5>Աע<D4B1><D7A2>
public int coReg(String username,String password,String type,String coname,String address,String postnum,
String tel,String email,String question,String answer,String intro,String lastip,int off){
password=MD5.MD5(password);
String sql = "insert into member(username,password,type,regtime,ifuse,logintimes,lasttime,lastip)" +
" values('"+username+"','"+password+"','"+type+"','"+date+"','"+off+"','0','"+date+"','"+lastip+"') ";
DBO dbo = new DBO();
dbo.open();
try{
int i = dbo.executeUpdate(sql);
if(i == 1){
rs = dbo.executeQuery("select id from member where username='"+username+"'");
rs.next();
int mid = rs.getInt(1);
String sql2 = "insert into cmember(mid,coname,address,postnum,tel,email,question,answer,intro)" +
"values('"+mid+"','"+coname+"','"+address+"','"+postnum+"','"+tel+"','"+email+"','"+question+"','"+answer+"','"+intro+"') ";
int j = dbo.executeUpdate(sql2);
if(j == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
// ij<><C4B3>ҵ<EFBFBD><D2B5>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
public List getCoRegInfo(String username){
String sql = "select * from cmember where mid=(select id from member where username='"+username+"') ";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getInt("mid"));//0
list.add(rs.getString("coname"));//1
list.add(rs.getString("address"));//2
list.add(rs.getString("postnum"));//3
list.add(rs.getString("tel"));//4
list.add(rs.getString("email"));//5
list.add(rs.getString("question"));//6
list.add(rs.getString("answer"));//7
list.add(rs.getString("intro"));//8
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//<2F><>ҵ<EFBFBD><D2B5>Ա<EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
public int upCoReg(String username,String coname,String address,String postnum,String tel,String email,String question,String answer,String intro){
String sql = "select id from member where username='"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
int mid = rs.getInt(1);
String sql2 = "update cmember set coname='"+coname+"',address='"+address+"',postnum='"+postnum+"',tel='"+tel+"',email='"+email+"'," +
"question='"+question+"',answer='"+answer+"',intro='"+intro+"' where mid='"+mid+"' ";
int i = dbo.executeUpdate(sql2);
if(i == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
public int findPwd(String username){
String sql="select id from member where username='"+username+"'";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
return rs.getInt(1);
}
else{
return 0;
}
}catch(Exception e){
e.printStackTrace();
return 0;
}finally{
dbo.close();
}
}
public String returnPwd(String username,String question,String answer,String type){
int i=this.findPwd(username);
if(i!=0){
if(type.equals("person")){
type="pmember";
}
else{
type="cmember";
}
String sql ="select * from "+type+" where mid='"+i+"' and question='"+question+"' and answer='"+answer+"'";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
String yzm=new CheckCode().getCheckCode()+"123";
String pwd=MD5.MD5(yzm);
int k=dbo.executeUpdate("update member set password='"+pwd+"' where username='"+username+"'");
if(k==1){
return yzm;
}
else{System.out.print("aaaaaaaaaaaaaa");
return "error";
}
}
else{
return "error";
}
}catch(Exception e){
e.printStackTrace();
return "error";
}finally{
dbo.close();
}
}
else{
return "nameerror";
}
}
//<2F><><EFBFBD>˻<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int upJianLi(String member,String picurl,String mname,String sex,String age,String school,String bir,String address,String linkman,String tel,String email,String intro){
String sql = "select * from resume where member='"+member+"'";
String upsql = "update resume set picurl='"+picurl+"',mname='"+mname+"',sex='"+sex+"',age='"+age+"',school='"+school+"',bir='"+bir+"',address='"+address+"',linkman='"+linkman+"',tel='"+tel+"',email='"+email+"',intro='"+intro+"' where member='"+member+"'";
String addsql = "insert into resume(member,picurl,mname,sex,age,school,bir,address,linkman,tel,email,intro,addtime) " +
"values('"+member+"','"+picurl+"','"+mname+"','"+sex+"','"+age+"','"+school+"','"+bir+"','"+address+"','"+linkman+"','"+tel+"','"+email+"','"+intro+"','"+date+"')";
DBO dbo=new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
int i = dbo.executeUpdate(upsql);
if(i == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
else{
int i = dbo.executeUpdate(addsql);
if(i == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return 0;
}finally{
dbo.close();
}
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>
public List getResume(String member){
String sql = "select * from resume where member='"+member+"'";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getString(2));//0
list.add(rs.getString(3));//1
list.add(rs.getString(4));//2
list.add(rs.getString(5));//3
list.add(rs.getString(6));//4
list.add(rs.getString(7));//5
list.add(rs.getString(8));//6
list.add(rs.getString(9));//7
list.add(rs.getString(10));//8
list.add(rs.getString(11));//9
list.add(rs.getString(12));//10
list.add(rs.getString(13));//11
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//<2F><>ҳ7<D2B3><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ƭ
public List getTop7(){
String sql = "select top 7 picurl,member from resume";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
while(rs.next()){
List list2=new ArrayList();
list2.add(rs.getString(1));//0
list2.add(rs.getString(2));//1
list.add(list2);
}
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
}