📄 dboperate.java
字号:
package managersystem.user;
import java.sql.*;
import java.util.*;
import managersystem.DBGet;
import managersystem.user.*;
//import manpowermanager.*;
/**
* <p>Title: 企业人力资源管理系统</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class DBoperate {
public DBoperate() {
}
public boolean getUserAndpwd(Users objU){
boolean success = false;
Connection con = null;
PreparedStatement ptmt = null;
ResultSet rs = null;
String strSQL = "select * from Users where UserName = ? and Pwd = ?";
try {
DBGet objG = new DBGet();
con =objG.getConnection();
ptmt = con.prepareStatement(strSQL);
ptmt.setString(1,objU.getUserName());
ptmt.setString(2,objU.getPwd());
rs = ptmt.executeQuery();
if(rs.next()){
success = true;
}
objG.clossConnection(con);
}
catch (Exception ex) {
ex.printStackTrace();
}
return success;
}
//添加用户信息
public ArrayList ArrayName(){
ArrayList arrayname = new ArrayList();
Connection con = null;
PreparedStatement ptmt = null;
ResultSet rs = null;
String strSQL = "select * from Users";
try {
DBGet objG = new DBGet();
con = objG.getConnection();
ptmt = con.prepareStatement(strSQL);
rs = ptmt.executeQuery();
while(rs.next()){
arrayname.add(rs.getString(1));
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return arrayname;
}
//获取用户信息
public Vector getAllUsers(){
Vector data = new Vector();
Connection con = null;
PreparedStatement ptmt = null;
ResultSet rs = null;
String strSQL = "select a.User_type,b.Emp_name,b.state,b.Dep_id,b.Title from Users a inner join Employees b on a.Emp_id = b.Emp_id ";
try {
DBGet objG = new DBGet();
con =objG.getConnection();
ptmt = con.prepareStatement(strSQL);
rs = ptmt.executeQuery();
while(rs.next()){
data.add(rs.getString(1));
data.add(rs.getString(2));
data.add(rs.getString(3));
data.add(rs.getString(4));
data.add(rs.getString(5));
}
rs.close();
ptmt.close();
con.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
return data;
}
//获取员工编号下拉框内容
public ArrayList ArrayEmpName(){
ArrayList arrayEmpName = new ArrayList();
Connection con = null;
PreparedStatement ptmt = null;
ResultSet rs = null;
String strSQL = "select * from Employees";
try {
DBGet objG = new DBGet();
con = objG.getConnection();
ptmt = con.prepareStatement(strSQL);
rs = ptmt.executeQuery();
while(rs.next()){
arrayEmpName.add(rs.getString(1)); }
}
catch (Exception ex) {
ex.printStackTrace();
}
return arrayEmpName;
}
//添加用户信息
public boolean getUserAdd(Users objU){
boolean suceess = false;
Connection con = null;
PreparedStatement ptmt = null;
String strSQL = "insert into Users values(?,?,?,?)";
try {
DBGet objD = new DBGet();
con = objD.getConnection();
ptmt = con.prepareStatement(strSQL);
ptmt.setString(1,objU.getUserName());
ptmt.setString(2,objU.getPwd());
ptmt.setInt(3,objU.getEmp_Id());
ptmt.setInt(4,objU.getUser_Type());
ptmt.executeUpdate();
ptmt.close();
con.close();
suceess = true;
}
catch (Exception ex) {
ex.printStackTrace();
suceess = false;
}
return suceess;
}
//获取用户类型
public ArrayList getType(){
ArrayList arrayname = new ArrayList();
Connection con = null;
PreparedStatement ptmt = null;
ResultSet rs = null;
String strSQL = "select * from Users";
try {
DBGet objG = new DBGet();
con = objG.getConnection();
ptmt = con.prepareStatement(strSQL);
rs = ptmt.executeQuery();
while(rs.next()){
arrayname.add(rs.getString(4));
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return arrayname;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -