📄 staff_c.java
字号:
package project;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Staff_C {
String sql=null;
int id;
String name;
String birth;
int sex;
int dep;
int position;
String telephone;
String address;
String hiredate;
String contract;
int salary;
String education;
public Staff_C() {
}
public int staff_add(Staff_obj_M ob){
DataBase db = new DataBase();
id = ob.getId();
name = ob.getName();
birth = ob.getBirth();
sex = ob.getSex();
dep = ob.getDep();
position = ob.getPosition();
telephone = ob.getTelephone();
address = ob.getAddress();
hiredate = ob.getHiredate();
contract = ob.getContract();
salary = ob.getSalary();
education = ob.getEducation();
sql = "insert into employee_table values("+ id+",'" + name + "','" + birth + "',"+
sex + "," + dep + "," + position + ",'"+telephone+"','"+address+"','"+hiredate+"','"+contract+"',"+salary+",'"+education+"',1)";
int n = db.executeUpdate(sql);
db.close();
return n;
}
public int staff_edit(Staff_obj_M ob){
DataBase db = new DataBase();
id = ob.getId();
name = ob.getName();
birth = ob.getBirth();
sex = ob.getSex();
dep = ob.getDep();
position = ob.getPosition();
telephone = ob.getTelephone();
address = ob.getAddress();
hiredate = ob.getHiredate();
contract = ob.getContract();
salary = ob.getSalary();
education = ob.getEducation();
sql = "update employee_table set name = '" + name + "', birth_date = '" +
birth + "',sex =" + sex + " ,dep_id =" + dep + " , position_id =" +
position +
", telephone = '" + telephone + "',address = '" + address +
"',hire_date='" + hiredate +
"',contract_expire_date = '" + contract + "',salary=" + salary +
",education='" + education + "' where employee_id=" + id;
int m = db.executeUpdate(sql);
db.close();
return m;
}
/**
* depart
* 提取部门数据
*/
public Object[][] depart() {
DataBase db3 = new DataBase();
String sql = "select * from depart_table";
ResultSet rs = db3.executeQuery(sql);
DataMap mp_depart = new DataMap(rs);
Object[][] depart = mp_depart.get_DataMap_Array();
return depart;
}
//提取职位数据
public Object[][] position(int pid) {
DataBase db4 = new DataBase();
String sql = "select * from position_table where depart_id="+pid+" or depart_id="+ -1 ;
ResultSet rs = db4.executeQuery(sql);
DataMap mp_position= new DataMap(rs);
Object[][] position = mp_position.get_DataMap_Array();
return position;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -