⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysuser.java

📁 图书
💻 JAVA
字号:
package thizlinux.linuxhr;import java.sql.*;import java.text.*;import java.util.*;public class sysuser {	private String uid="";	private String loginid="";	private String password="";	private String name="";	private String instituteid="";	private String role="";	private String error="";	private ResultSet rs=null;	private String pages="";	private int institute=0;	private int lines=20;	private int records=0;	private boolean status=true;	private Vector uidl=new Vector();	private Vector loginidl=new Vector();	private Vector namel=new Vector();	private Vector institutel=new Vector();		public String getPages(){		if(((float)records/lines)>((int)records/lines)){			pages=""+(int)(records/lines+1);		}else{			pages=""+(int)records/lines;		}		return this.pages;	}		public void setInstitute(int value){		this.institute=value;		}	public int getInstitute(){		return this.institute;	}		public void setLines(int value){		this.lines=value;		}	public int getLines(){		return this.lines;	}	public void setRecords(int value){		this.records=value;	}	public int getRecords(){		return this.records;	}	public Iterator getUidl(){		return uidl.iterator();	}	public Iterator getLoginidl(){		return loginidl.iterator();	}	public Iterator getNamel(){		return namel.iterator();	}	public Iterator getInstitutel(){		return institutel.iterator();	}	public void setError(String value){		this.error=value;	}	public String getError(){		return this.error;	}	public void setUid(String value){		this.uid=value;		}	public String getUid(){		return this.uid;	}		public void setLoginid(String value){		this.loginid=value;		}	public String getLoginid(){		return this.loginid;	}		public void setName(String value){		this.name=value;		}	public String getName(){		return this.name;	}		public void setPassword(String value){		this.password=value;		}	public String getPassword(){		return this.password;	}		public void setInstituteid(String value){		this.instituteid=value;		}	public String getInstituteid(){		return this.instituteid;	}		public void setRole(String value){		this.role=value;	}	public String getRole(){		return this.role;	}		public void refresh(){		DBconnect dbconn =new DBconnect();		uidl.clear();		loginidl.clear();		namel.clear();		institutel.clear();		ResultSet rs=null;		String sql="";		try{						sql="select a.uid,a.loginid,a.name as username,b.name from tbl_sysuser a,tbl_institute b where a.instituteid=b.id and a.role=1";			rs=dbconn.executeQuery(sql);			while(rs.next()){				uidl.add(pub.datachange(rs.getString("uid")));				loginidl.add(pub.datachange(rs.getString("loginid")));				namel.add(pub.datachange(rs.getString("username")));				institutel.add(pub.datachange(rs.getString("name")));			}  						sql="select loginid,password,name,instituteid "+					   "from tbl_sysuser where uid='" +this.uid+"'";			rs=dbconn.executeQuery(sql);			if(rs.next()){  				this.loginid=pub.datachange(rs.getString("loginid"));				this.password=pub.datachange(rs.getString("password"));				this.name=pub.datachange(rs.getString("name"));				this.instituteid=pub.datachange(rs.getString("instituteid"));			}			else{				reset();			}		}catch(Exception e){			System.out.println(e+",sql="+sql);			status=false;		}finally{			try{				if(rs!=null)rs.close();				if(dbconn!=null)dbconn.close();			}catch(Exception e){				System.out.println(e);			}		}			}	public int count(){		DBconnect dbconn =new DBconnect();		String sql="";		ResultSet rs=null;		int count=0;			try{			sql="select count(*) as aa from tbl_sysuser ";			rs=dbconn.executeQuery(sql);			//Collection ret=new ArrayList();			if(rs.next()){				this.records=rs.getInt("aa");				//ret.add(this.records);				count=this.records;			}			else{ reset();}				}catch(Exception e){			System.out.println(e+",sql="+sql);			//statue=false;		}finally{			try{				if(rs!=null)rs.close();				if(dbconn!=null)dbconn.close();			}catch(Exception e){				System.out.println(e);			}		}		//return ret;		return count;	}		public boolean add(){		status=true;		DBconnect dbconn =new DBconnect();		String sql="";		try{			sql="select * from tbl_sysuser where loginid='"+this.loginid+"' and role='1' ";			rs=dbconn.executeQuery(sql);			if(rs.next()){				status=false;			}			else{			sql = "delete from tbl_sysuser where uid='" + this.uid + "'";			dbconn.executeUpdate(sql);            			java.util.Date cur_time =new java.util.Date();			SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");			String cdate =formatter.format(cur_time);			sql="insert into tbl_sysuser(uid,loginid,password,name,instituteid,role,cdate) "+                       "values('',"+			    "'"+this.loginid+"',"+			    "'"+this.password+"',"+			    "'"+this.name+"',"+			    "'"+this.instituteid+"',"+			    "1,"+			    "'"+cdate+"')";			dbconn.executeUpdate(sql);			reset();			}		}catch(Exception e){			System.out.println(e+",sql="+sql);			status=false;		}finally{			try{				if(dbconn!=null)dbconn.close();			}catch(Exception e){				System.out.println(e);			}		}		return  status;		}	public boolean update(){		status=true;		DBconnect dbconn =new DBconnect();		String sql="";		try{			sql = "delete from tbl_sysuser where uid='" + this.uid + "'";			dbconn.executeUpdate(sql);            			java.util.Date cur_time =new java.util.Date();			SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");			String cdate =formatter.format(cur_time);			sql="insert into tbl_sysuser(uid,loginid,password,name,instituteid,role,cdate) "+                       "values('',"+			    "'"+this.loginid+"',"+			    "'"+this.password+"',"+			    "'"+this.name+"',"+			    "'"+this.instituteid+"',"+			    "1,"+			    "'"+cdate+"')";			dbconn.executeUpdate(sql);			reset();		}		catch(Exception e){			System.out.println(e+",sql="+sql);			status=false;		}finally{			try{				if(dbconn!=null)dbconn.close();			}catch(Exception e){				System.out.println(e);			}		}		return  status;		}	public boolean remove(){		status=true;		DBconnect dbconn =new DBconnect();		String sql="";		try{			sql = "delete from tbl_sysuser where uid='" + this.uid + "'";			dbconn.executeUpdate(sql);			this.uid="";		}catch(Exception e){			System.out.println(e+",sql="+sql);			status=false;		}finally{			try{				if(dbconn!=null)dbconn.close();			}catch(Exception e){				System.out.println(e);			}		}		return  status;		}	public void reset(){		this.loginid="";		this.password="";		this.name="";		this.instituteid="";	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -