⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 departmentoperate.java

📁 java+sql2000企业人力管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package managersystem.Emp;
import managersystem.DBGet;
import java.sql.*;
import java.util.*;
import javax.swing.JOptionPane;


public class DepartmentOperate {
    public DepartmentOperate() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


    public Vector getAllDept() {
        Vector data = new Vector();
        Connection con = null;
        PreparedStatement ptmt = null;
        ResultSet rs = null;
        String strSQL = "select * from Department";
        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));
            }
            rs.close();
            ptmt.close();
            con.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        return data;

    }

//获取数据库Employees表数据
    public Vector getAllEmployee() {
        Vector data = new Vector();
        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()) {
                data.add(new Integer(rs.getInt(1)));
                for (int i = 2; i <= 22; i++) {
                    data.add(rs.getString(i));
                }
                data.add(new Integer(rs.getInt(23)));
                data.add(new Integer(rs.getInt(24)));
                data.add(rs.getString(25));
                data.add(rs.getString(26));
                data.add(rs.getString(27));

                data.add(rs.getString(28));
                data.add(new Integer(rs.getInt(29)));
                data.add(new Integer(rs.getInt(30)));
                data.add(rs.getString(31));
                data.add(rs.getString(32));
                data.add(rs.getString(33));

            }
            rs.close();
            ptmt.close();
            con.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return data;
    }

    //添加新员工
    public boolean inserEmployee(EmployeeBean objE) {
        Connection con = null;
        PreparedStatement ptmt = null;
        String sql =
                "insert into Employees (Emp_Id,Emp_NAME,Sex,Nationality,Birth,Political_Party," +
                "Culture_Level,Marital_Condition,Family_Place,Id_Card,PcID," +
                "BadgeID,Office_phone,Home_phone,Mobile,Files_Keep_Org," +
                "Residence,Hukou,Postcode,Police_Post,Street_Office," +
                "HireDate,Working_Years,dep_id,Position,Title,State," +
                "Contract_Sign_Date,Base_Wage,Base_Prize,Memo,Fillin_Person,Fillin_Time)"
                +
                "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

        try {
            DBGet objG = new DBGet();
            con = objG.getConnection();
            ptmt = con.prepareStatement(sql);
            ptmt.setInt(1, objE.getEmp_Id());
            ptmt.setString(2, objE.getEmp_NAME());
            ptmt.setString(3, objE.getSex());
            ptmt.setString(4, objE.getNationality());
            ptmt.setString(5, objE.getBirth());
            ptmt.setString(6, objE.getPolitical_Party());
            ptmt.setString(7, objE.getCulture_Level());
            ptmt.setString(8, objE.getMarital_Condition());
            ptmt.setString(9, objE.getFamily_Place());
            ptmt.setString(10, objE.getId_Card());
            ptmt.setString(11, objE.getPcID());
            ptmt.setString(12, objE.getBadgeID());
            ptmt.setString(13, objE.getOffice_phone());
            ptmt.setString(14, objE.getHome_phone());
            ptmt.setString(15, objE.getMobile());
            ptmt.setString(16, objE.getFiles_Keep_Org());
            ptmt.setString(17, objE.getResidence());
            ptmt.setString(18, objE.getHukou());
            ptmt.setString(19, objE.getPostcode());
            ptmt.setString(20, objE.getPolice_Post());
            ptmt.setString(21, objE.getStreet_Office());
            ptmt.setString(22, objE.getHireDate());
            ptmt.setInt(23, objE.getWorking_Years());
            ptmt.setInt(24,objE.getDep_Id());
            ptmt.setString(25, objE.getPosition());
            ptmt.setString(26, objE.getTitle());
            ptmt.setString(27, objE.getState());
            ptmt.setString(28, objE.getContract_Sign_Date());
            ptmt.setDouble(29, objE.getBase_Wage());
            ptmt.setDouble(30, objE.getBase_Prize());
            ptmt.setString(31, objE.getMemo());
            ptmt.setString(32, objE.getFillin_Person());
            ptmt.setString(33,objE.getFillin_Time());
            try {
                if (ptmt.executeUpdate() > 0) {
                    return true;
                }
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "该员工已存在");
            }
             ptmt.close();
             con.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return false;
    }

    //获得Experience数据,员工学习工作经历表的数据
    public Vector getAllExperience() {
        Vector data = new Vector();
        Connection con = null;
        PreparedStatement ptmt = null;
        ResultSet rs = null;
        String strSQL = "select * from Experience";
        try {
            DBGet objG = new DBGet();
            con = objG.getConnection();
            ptmt = con.prepareStatement(strSQL);
            rs = ptmt.executeQuery();
            while (rs.next()) {
                data.add(new Integer(rs.getInt(1)));
                data.add(rs.getString(3));
                data.add(rs.getString(4));
                data.add(rs.getString(5));
                data.add(rs.getString(6));
            }
            rs.close();
            ptmt.close();
            con.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return data;
    }

    // 更新员工数据
    public boolean updateEmployee(EmployeeBean objE) {
        Connection con = null;
        PreparedStatement ptmt = null;
        String strSQL =
                "update Employees set Emp_NAME=?, Sex=?, Nationality=?, " +
                "Birth=?, Political_Party=?, Culture_Level=?, Marital_Condition=?,Family_Place=?," +
                "Id_Card=?,PcID=?,BadgeID=?,Office_phone=?," +
                "Home_phone=?,Mobile=?,Files_Keep_Org=?,Residence=?," +
                "Hukou=?,Postcode=?,Police_Post=?,Street_Office=?," +
                "HireDate=?,Working_Years=?,dep_id=?,Position=?,Title=?,State=?," +
                "Contract_Sign_Date=?,Base_Wage=?,Base_Prize=?,Memo=?,Fillin_Person=?,Fillin_Time=?" +
                " where emp_Id=?";
        try {
            DBGet objG = new DBGet();
            con = objG.getConnection();
            ptmt = con.prepareStatement(strSQL);
            ptmt.setString(1, objE.getEmp_NAME());
            ptmt.setString(2, objE.getSex());
            ptmt.setString(3, objE.getNationality());
            ptmt.setString(4, objE.getBirth());
            ptmt.setString(5, objE.getPolitical_Party());
            ptmt.setString(6, objE.getCulture_Level());
            ptmt.setString(7, objE.getMarital_Condition());
            ptmt.setString(8, objE.getFamily_Place());
            ptmt.setString(9, objE.getId_Card());
            ptmt.setString(10, objE.getPcID());
            ptmt.setString(11, objE.getBadgeID());
            ptmt.setString(12, objE.getOffice_phone());
            ptmt.setString(13, objE.getHome_phone());
            ptmt.setString(14, objE.getMobile());
            ptmt.setString(15, objE.getFiles_Keep_Org());
            ptmt.setString(16, objE.getResidence());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -