📄 classofemployee.java~4~
字号:
//该类实现InterfaceOfEmployee接口,用于实现员工各种操作的方法
package com.richard.dao;
import java.util.*;
import com.richard.dto.*;
import java.sql.*;
public class ClassOfEmployee implements InterfaceOfEmployee {
DBOperate objDBOperate = new DBOperate();
public ClassOfEmployee() {
}
public boolean check(Employee objEmployee) { //该方法用于验证用户登陆信息
boolean flag = false;
String employeeName = objEmployee.getName();
String employeePassword = objEmployee.getPwssword();
String sqlCommand = "select * from employee where name='" +
employeeName + "' and password='" +
employeePassword + "'";
try {
ResultSet rs = objDBOperate.getResultSet("petclinic", sqlCommand);
if (rs.next()) {
flag = true;
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return flag;
}
public void employeeDelete(Employee objEmployee) { //该方法用于根据员工姓名删除一条员工记录
String employeeName = objEmployee.getName();
String sqlCommand = "delete employee where name='" + employeeName + "'";
PreparedStatement objStatement = objDBOperate.getPreparedStatement(
"petclinic", sqlCommand);
try {
objStatement.execute();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
public void employeeInsert(Employee objEmployee) { //该方法用于插入一条新的员工记录
String employeeName = objEmployee.getName();
String employeePassword = objEmployee.getPwssword();
String sqlCommand = "insert into employee (name,password) values ('" +
employeeName + "','" + employeePassword + "')";
PreparedStatement objStatement = objDBOperate.getPreparedStatement(
"petclinic", sqlCommand);
try {
objStatement.execute();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
public ArrayList employeeQuery(Employee objEmployee) { //该方法用于根据员工姓名查询相关的员工记录
return null;
}
public ArrayList employeeQueryAll() {
return null;
}
public void employeeUpdate(Employee objEmployee) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -