package com.hrm.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.hrm.bean.*;
public class CondbUsers {
private Connection conn;
private String username = "root";
private String password = "";
private String url = "jdbc:mysql://localhost/hrm_system";
private String driver = "com.mysql.jdbc.Driver";
public Connection GetConnDB() throws Exception {
Class.forName(driver);
conn = DriverManager.getConnection(url, username, password);
return conn;
}
public Statement getStatement() {
Statement st = null;
try {
st = GetConnDB().createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return st;
}
// 显示所有职工信息
public List<UserBean> getusers() {
List<UserBean> list = new ArrayList<UserBean>();
try {
String sql = "SELECT * FROM userinformation ";
ResultSet rs = getStatement().executeQuery(sql);
while (rs.next()) {
UserBean usercontent= new UserBean(0,null,null,0,null,null,null,null,null,null);
int userid= rs.getInt("userid");
String username = rs.getString("username");
String sex = rs.getString("sex");
int age = rs.getInt("age");
String department = rs.getString("department");
String position = rs.getString("position");
String phonenumber=rs.getString("phonenumber");
String state=rs.getString("state");
String others=rs.getString("others");
String introduce=rs.getString("introduce");
usercontent.setUserid(userid);
usercontent.setUsername(username);
usercontent.setAge(age);
usercontent.setSex(sex);
usercontent.setDepartment(department);
usercontent.setPosition(position);
usercontent.setPhonenumber(phonenumber);
usercontent.setState(state);
usercontent.setOthers(others);
usercontent.setIntroduce(introduce);
// 添加到数组中
list.add(usercontent);
}
rs.close();
getStatement().close();
GetConnDB().close();
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
// /插入新职工信息
public void insertuser( String username,int age, String sex,String department,
String position,String phonenumber,String state,String others,String introduce) {
try {
String sql = "insert into userinformation(username,age,sex,department,position,phonenumber,state,others,introduce) "
+ "values('"+username+"',age,'"+sex+"','"+department+"','"+position+"','"+phonenumber+"','"+state+"','"+others+"','"+introduce+"')";
getStatement().execute(sql);
getStatement().close();
GetConnDB().close();
} catch (Exception e) {
e.printStackTrace();
}
}
// ///准备更新职工信息,先取出原来的信息
public UserBean prepareUpdateUser(int userids) {
UserBean usercontent = new UserBean(0, null,null,0,null,null,null,null,null,null);
try {
String sql = "select * from userinformation where userid=" + userids;
ResultSet rs = getStatement().executeQuery(sql);
while (rs.next()) {
int userid= rs.getInt("userid");
String username = rs.getString("username");
String sex = rs.getString("sex");
int age = rs.getInt("age");
String department = rs.getString("department");
String position = rs.getString("position");
String phonenumber=rs.getString("phonenumber");
String state=rs.getString("state");
String others=rs.getString("others");
String introduce=rs.getString("introduce");
usercontent.setUserid(userid);
usercontent.setUsername(username);
usercontent.setAge(age);
usercontent.setSex(sex);
usercontent.setDepartment(department);
usercontent.setPosition(position);
usercontent.setPhonenumber(phonenumber);
usercontent.setState(state);
usercontent.setOthers(others);
usercontent.setIntroduce(introduce);
}
rs.close();
getStatement().close();
GetConnDB().close();
} catch (Exception e) {
e.printStackTrace();
}
return usercontent;
}
// 更新职工信息
public void updateuser(int userid, String username,int age, String sex,
String department,String position,String phonenumber,String state,String others,String introduce) {
try {
String sql = "update userinformation set username='" + username
+ "',age="+age+",sex='" +sex
+ "',department='" + department + "',position='"+position+"',phonenumber='"+phonenumber+"',state='"+state+"',others='"+others+"',introduce='"+introduce+"' where userid="
+ userid;
getStatement().executeUpdate(sql);
getStatement().close();
GetConnDB().close();
} catch (Exception e) {
e.printStackTrace();
}
}
// /删除职员信息
public void deleteuser(int userids) {
try {
String sql = "delete from userinformation where userid=" + userids;
getStatement().execute(sql);
getStatement().close();
GetConnDB().close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 管理员类型登陆验证
public String CheckAdminuser(String username, String password) {
String id = null;
String sql = "select * from adminuser where adminusername='" + username
+ "' and password='" + password + "'";
ResultSet rs = null;
try {
rs = getStatement().executeQuery(sql);
while (rs.next()) {
id = rs.getString("adminid");
}
} catch (SQLException ex) {
ex.getMessage();
}
return id;
}
// 普通用户类型登陆验证
public String CheckUsers(String username, String password) {
String id = null;
String sql = "select * from userinformation where username='" + username
+ "' and userid='" + password + "'";
ResultSet rs = null;
try {
rs = getStatement().executeQuery(sql);
while (rs.next()) {
id = rs.getString("userid");
}
} catch (SQLException ex) {
ex.getMessage();
}
return id;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该人力资源管理系统功能强大,分为企业管理员和内部员工多种角色登陆。企业管理员可以实现对内部员工的增加、删除、修改、查看、发布企业公告、常见企业培训班、审核内部员工信息、员工内部岗位调度等等; 内部员工可以实现状态信息的查看、出勤表、修改个人信息、查看公司公告、接收公司通知、参加企业培训报名等等,注册模块加入了很多限制,只能本公司内部员工才能注册,并且不能重复注册。 该管理系统为毕业设计,为个人原创,付出了不少心血,因此积分自然高一点 另外,压缩包内附数据库文件,无需手动创建数据库,只需把.sql文件在数据库中运行即可创建数据库和生成相应的的数据表。本系统开发使用的技术是java+jsp+javascript+jquery+css
资源推荐
资源详情
资源评论
收起资源包目录
企业人力资源管理系统(毕业设计)(Struts2+Tomcat+mysql)内附数据库 (177个子文件)
ScriptResource.axd 254KB
ScriptResource.axd 254KB
ScriptResource(1).axd 64KB
ScriptResource(1).axd 64KB
WebResource(1).axd 21KB
WebResource(1).axd 21KB
WebResource.axd 21KB
WebResource.axd 21KB
CondbUsers.class 7KB
CondbUsers.class 6KB
UserAction.class 5KB
UserAction.class 5KB
CondbEducation.class 5KB
GoLoginAction.class 3KB
UserBean.class 3KB
UserBean.class 3KB
CultivateAction.class 2KB
CondbEnroll.class 2KB
GoLoginAction.class 2KB
EnrollAction.class 2KB
EnrollBean.class 2KB
EducationBean.class 1KB
.classpath 850B
.classpath 850B
org.eclipse.wst.common.component 489B
org.eclipse.wst.common.component 489B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.container 49B
Manage.css 3KB
Manage.css 3KB
Style.css 2KB
Style.css 2KB
login_1.gif 9KB
login_1.gif 9KB
login_button.gif 2KB
login_button.gif 2KB
start.gif 231B
start.gif 231B
freemarker-2.3.19.jar 909KB
freemarker-2.3.19.jar 909KB
struts2-core-2.3.4.1.jar 765KB
struts2-core-2.3.4.1.jar 765KB
mysql-connector-java-5.1.6-bin.jar 687KB
mysql-connector-java-5.1.6-bin.jar 687KB
xwork-core-2.3.4.1.jar 614KB
xwork-core-2.3.4.1.jar 614KB
javassist-3.11.0.GA.jar 600KB
javassist-3.11.0.GA.jar 600KB
commons-lang3-3.1.jar 308KB
commons-lang3-3.1.jar 308KB
ognl-3.0.5.jar 222KB
ognl-3.0.5.jar 222KB
commons-io-2.0.1.jar 156KB
commons-io-2.0.1.jar 156KB
commons-logging-1.1.1.jar 59KB
commons-logging-1.1.1.jar 59KB
commons-fileupload-1.2.2.jar 58KB
commons-fileupload-1.2.2.jar 58KB
CondbUsers.java 6KB
CondbUsers.java 6KB
UserAction.java 5KB
UserAction.java 5KB
CondbEducation.java 4KB
GoLoginAction.java 3KB
CultivateAction.java 2KB
UserBean.java 2KB
UserBean.java 2KB
GoLoginAction.java 2KB
EnrollAction.java 1KB
CondbEnroll.java 1KB
EnrollBean.java 1KB
EducationBean.java 948B
login_2.jpg 88KB
login_2.jpg 88KB
login_3.jpg 17KB
login_3.jpg 17KB
new_001.jpg 1KB
new_001.jpg 1KB
new_003.jpg 1KB
new_003.jpg 1KB
new_005.jpg 847B
new_005.jpg 847B
new_007.jpg 836B
new_007.jpg 836B
new_021.jpg 714B
new_021.jpg 714B
new_019.jpg 709B
new_019.jpg 709B
new_026.jpg 612B
new_026.jpg 612B
new_012.jpg 612B
new_012.jpg 612B
new_024.jpg 611B
new_024.jpg 611B
new_010.jpg 608B
new_010.jpg 608B
new_002.jpg 521B
new_002.jpg 521B
new_006.jpg 502B
new_006.jpg 502B
共 177 条
- 1
- 2
资源评论
- soul432337522016-04-29貌似跑不起来,是我没配置好吗。。
- itsss世界2017-04-11我也跑不起来,可能自己的功夫不到家吧
爱雨一夏
- 粉丝: 14
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功