📄 employee.java
字号:
String _Address, String _Incumbency, String _IncumbencyType,
String _Resume, String _Birthday, String _GraduateDate) {
DBConnect dbc = null;
//System.out.println("11111-here!");
try {
dbc = new DBConnect();
//System.out.println("1-here!");
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
stmt.executeUpdate("INSERT INTO employee (EmployeeID,UserName,Sex,Branch,NativePlace,"
+ "Marriage,IdentityID,Politics,Folk,Education,Department,University,AccumulateID,"
+ "AdministrationLevel,Duty,Position,ForeignLanguage,FLLevel,ComputerLevel,Phone,"
+ "MobilePhone,Address,Incumbency,IncumbencyType,Resume,Birthday,GraduateDate) VALUES "
+ "('"+_EmployeeID+"','"+_UserName+"','"+_Sex+"','"+_Branch+"','"+_NativePlace+"','"+_Marriage+"',"
+"'"+_IdentityID+"','"+_Politics+"','"+_Folk+"','"+_Education+"','"+_Department+"',"
+"'"+_University+"','"+_AccumulateID+"','"+_AdministrationLevel+"','"+_Duty+"','"+_Position+"',"
+"'"+_ForeignLanguage+"','"+_FLLevel+"','"+_ComputerLevel+"','"+_Phone+"','"+_MobilePhone+"','"+_Address+"',"
+"'"+_Incumbency+"','"+_IncumbencyType+"','"+_Resume+"','"+_Birthday+"','"+_GraduateDate+"')");
//System.out.println(DataConvert.StrTosqlDate(_Birthday));
//System.out.println(DataConvert.StrTosqlDate(_GraduateDate));
dbc.close();
return "1";
} catch (Exception e) {
System.err.println(e);
return e.toString();
}
}
/*
* Modify Employee
*/
public static String Modify(String _EmployeeID, String _UserName,
String _Sex, String _Branch, String _NativePlace, String _Marriage,
String _IdentityID, String _Politics, String _Folk,
String _Education, String _Department, String _University,
String _AccumulateID, String _AdministrationLevel, String _Duty,
String _Position, String _ForeignLanguage, String _FLLevel,
String _ComputerLevel, String _Phone, String _MobilePhone,
String _Address, String _Incumbency, String _IncumbencyType,
String _Resume, String _Birthday, String _GraduateDate) {
DBConnect dbc = null;
try {
dbc = new DBConnect();
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
stmt.executeUpdate("UPDATE Employee SET UserName='"+_UserName+"',Sex='"+_Sex+"',Branch='"+_Branch+"',NativePlace='"+_NativePlace+"',"
+ "Marriage='"+_Marriage+"',IdentityID='"+_IdentityID+"',Politics='"+_Politics+"',Folk='"+_Folk+"',Education='"+_Education+"',"
+ "Department='"+_Department+"',University='"+_University+"',AccumulateID='"+_AccumulateID+"',AdministrationLevel='"+_AdministrationLevel+"',"
+ "Duty='"+_Duty+"',Position='"+_Position+"',ForeignLanguage='"+_ForeignLanguage+"',FLLevel='"+_FLLevel+"',ComputerLevel='"+_ComputerLevel+"',"
+ "Phone='"+_Phone+"',MobilePhone='"+_MobilePhone+"',Address='"+_Address+"',Incumbency='"+_Incumbency+"',IncumbencyType='"+_IncumbencyType+"',"
+ "Resume='"+_Resume+"',Birthday='"+_Birthday+"',GraduateDate='"+_GraduateDate+"'"
+ " WHERE EmployeeID='"+_EmployeeID+"'");
dbc.close();
return "1";
} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}
/*
* Delete Employee
*/
public static String Delete(String _EmployeeID) {
try {
DBConnect dbc = new DBConnect();
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
stmt.executeUpdate("DELETE FROM employee WHERE EmployeeID='"+_EmployeeID+"'");
dbc.close();
return "1";
} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}
/*
* the Employee exists?
*/
public static boolean IsExist(String _EmployeeID) throws Exception {
DBConnect dbc = null;
boolean IsExist = false;
try {
dbc = new DBConnect();
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
ResultSet rs = null;
rs = stmt.executeQuery("SELECT * FROM employee WHERE EmployeeID='"+_EmployeeID+"'");
if (!rs.next()) {
IsExist = false;
} else {
IsExist = true;
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return IsExist;
}
/*
* List All Employee
*/
public static Vector ListAll() {
DBConnect dbc = null;
Vector EmployeeVector = new Vector();
String strSQL = "SELECT * FROM employee ORDER BY EmployeeID ASC";
try {
dbc = new DBConnect();
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
ResultSet rs = null;
rs = stmt.executeQuery(strSQL);
while (rs.next()) {
Employee employee = new Employee();
employee.setEmployeeID(rs.getString("EmployeeID"));
employee.setUserName(rs.getString("UserName"));
employee.setSex(rs.getString("Sex"));
employee.setBranch(rs.getString("Branch"));
employee.setBirthday(rs.getString("Birthday"));
employee.setNativePlace(rs.getString("NativePlace"));
employee.setMarriage(rs.getString("Marriage"));
employee.setIdentityID(rs.getString("IdentityID"));
employee.setPolitics(rs.getString("Politics"));
employee.setFolk(rs.getString("Folk"));
employee.setEducation(rs.getString("Education"));
employee.setDepartment(rs.getString("Department"));
employee.setGraduateDate(rs.getString("GraduateDate"));
employee.setUniversity(rs.getString("University"));
employee.setAccumulateID(rs.getString("AccumulateID"));
employee.setAdministrationLevel(rs.getString("AdministrationLevel"));
employee.setDuty(rs.getString("Duty"));
employee.setPosition(rs.getString("Position"));
employee.setForeignLanguage(rs.getString("ForeignLanguage"));
employee.setFLLevel(rs.getString("FLLevel"));
employee.setComputerLevel(rs.getString("ComputerLevel"));
employee.setPhone(rs.getString("Phone"));
employee.setMobilePhone(rs.getString("MobilePhone"));
employee.setAddress(rs.getString("Address"));
employee.setIncumbency(rs.getString("Incumbency"));
employee.setIncumbencyType(rs.getString("IncumbencyType"));
employee.setResume(rs.getString("Resume"));
EmployeeVector.add(employee);
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return EmployeeVector;
}
/*
* search Employee
*/
public static Vector Search(String _EmployeeID, String _UserName, String _Sex,
String _Branch, String _NativePlace, String _Marriage,
String _Politics, String _Folk, String _Education,
String _AdministrationLevel, String _Duty, String _Position,
String _Incumbency, String _IncumbencyType) {
DBConnect dbc = null;
Vector EmployeeVector = new Vector();
String strSQL = "SELECT * FROM employee WHERE";
if ((_EmployeeID.equals("")) & (_UserName.equals("")) & (_Sex.equals(""))
& (_Branch.equals("")) & (_NativePlace.equals("")) & (_Marriage.equals("")) & (_Politics.equals(""))
& (_Folk.equals("")) & (_Education.equals("")) & (_AdministrationLevel.equals("")) & (_Duty.equals(""))
& (_Position.equals("")) & (_Incumbency.equals("")) & (_IncumbencyType.equals(""))) {
strSQL = "SELECT * FROM employee ";
} else {
if (!_EmployeeID.equals(""))
strSQL = strSQL + " EmployeeID LIKE '%" + _EmployeeID + "%' AND";
if (!_UserName.equals(""))
strSQL = strSQL + " UserName='" + _UserName + "' AND";
if (!_Sex.equals(""))
strSQL = strSQL + " Sex='" + _Sex + "' AND";
if (!_Branch.equals(""))
strSQL = strSQL + " Branch='" + _Branch + "' AND";
if (!_NativePlace.equals(""))
strSQL = strSQL + " NativePlace LIKE '%" + _NativePlace + "%' AND";
if (!_Marriage.equals(""))
strSQL = strSQL + " Marriage='" + _Marriage + "' AND";
if (!_Politics.equals(""))
strSQL = strSQL + " Politics='" + _Politics + "' AND";
if (!_Folk.equals(""))
strSQL = strSQL + " Folk LIKE '%" + _Folk + "%' AND";
if (!_Education.equals(""))
strSQL = strSQL + " Education='" + _Education + "' AND";
if (!_AdministrationLevel.equals(""))
strSQL = strSQL + " AdministrationLevel='" + _AdministrationLevel + "' AND";
if (!_Duty.equals(""))
strSQL = strSQL + " Duty='" + _Duty + "' AND";
if (!_Position.equals(""))
strSQL = strSQL + " Position='" + _Position + "' AND";
if (!_Incumbency.equals(""))
strSQL = strSQL + " Incumbency='" + _Incumbency + "' AND";
if (!_IncumbencyType.equals(""))
strSQL = strSQL + " IncumbencyType='" + _IncumbencyType + "' AND";
strSQL = strSQL + " 1=1 ";
}
strSQL = strSQL + "ORDER BY EmployeeID ASC";
System.out.println(strSQL);
try {
dbc = new DBConnect();
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
ResultSet rs = null;
rs = stmt.executeQuery(strSQL);
while (rs.next()) {
Employee employee = new Employee();
employee.setEmployeeID(rs.getString("EmployeeID"));
employee.setUserName(rs.getString("UserName"));
employee.setSex(rs.getString("Sex"));
employee.setBranch(rs.getString("Branch"));
employee.setBirthday(rs.getString("Birthday"));
employee.setNativePlace(rs.getString("NativePlace"));
employee.setMarriage(rs.getString("Marriage"));
employee.setIdentityID(rs.getString("IdentityID"));
employee.setPolitics(rs.getString("Politics"));
employee.setFolk(rs.getString("Folk"));
employee.setEducation(rs.getString("Education"));
employee.setDepartment(rs.getString("Department"));
employee.setGraduateDate(rs.getString("GraduateDate"));
employee.setUniversity(rs.getString("University"));
employee.setAccumulateID(rs.getString("AccumulateID"));
employee.setAdministrationLevel(rs.getString("AdministrationLevel"));
employee.setDuty(rs.getString("Duty"));
employee.setPosition(rs.getString("Position"));
employee.setForeignLanguage(rs.getString("ForeignLanguage"));
employee.setFLLevel(rs.getString("FLLevel"));
employee.setComputerLevel(rs.getString("ComputerLevel"));
employee.setPhone(rs.getString("Phone"));
employee.setMobilePhone(rs.getString("MobilePhone"));
employee.setAddress(rs.getString("Address"));
employee.setIncumbency(rs.getString("Incumbency"));
employee.setIncumbencyType(rs.getString("IncumbencyType"));
employee.setResume(rs.getString("Resume"));
EmployeeVector.add(employee);
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return EmployeeVector;
}
/*
* Update Employee Duty
*/
public static String UpdateDuty(String _EmployeeID, String _Duty) {
DBConnect dbc = null;
try {
dbc = new DBConnect();
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
stmt.executeUpdate("UPDATE Employee SET Duty='"+_Duty+"' WHERE EmployeeID='"+_EmployeeID+"'");
dbc.close();
return "1";
} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}
/*
* Update Employee
*/
public static String UpdateBranch(String _EmployeeID, String _Branch) {
DBConnect dbc = null;
try {
dbc = new DBConnect();
Connection conn =dbc.getDBConnection();
Statement stmt = null;
stmt=conn.createStatement();
stmt.executeUpdate("UPDATE Employee SET Branch='"+_Branch+"' WHERE EmployeeID='"+_EmployeeID+"'");
dbc.close();
return "1";
} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -