Exemple #1
0
  public CoreList count(String dept_name) throws SQLException {
    CoreList ch = new CoreList();
    ch.clear();
    PreparedStatement pst = null;
    ResultSet rs = null;
    DBConn conn = new DBConn();

    con = conn.getConnection();
    try {

      pst =
          con.prepareStatement(
              "select count(*) from employee_reg where dept_name='" + dept_name + "'");
      System.out.println("chai");
      rs = pst.executeQuery();
      while (rs.next()) {
        EmployeeRegForm psf = new EmployeeRegForm();
        psf.setCount(rs.getInt(1));

        ch.add(psf);
      }
    } catch (Exception e) {
      con.close();
      System.out.println("Connection Closed");
      e.printStackTrace();
    }
    return ch;
  }
Exemple #2
0
  public CoreList View_DeptName(int ps_id) throws SQLException {
    CoreList ch = new CoreList();
    ch.clear();
    PreparedStatement pst = null;
    ResultSet rs = null;
    DBConn conn = new DBConn();

    con = conn.getConnection();
    try {

      pst = con.prepareStatement("select dept_name from employee_reg where ps_id=?");
      pst.setInt(1, ps_id);
      rs = pst.executeQuery();
      while (rs.next()) {
        System.out.println("chai=============================" + ps_id);
        EmployeeRegForm psf = new EmployeeRegForm();
        psf.setDept_name(rs.getString(1));
        ch.add(psf);
      }
    } catch (Exception e) {
      con.close();
      System.out.println("Connection Closed");
      e.printStackTrace();

    } finally {
      releaseResources(con, pst);
    }
    return ch;
  }
Exemple #3
0
  public boolean update_Employee(EmployeeRegForm er) throws SQLException {
    PreparedStatement ps = null, ps2 = null;
    DBConn db = new DBConn();
    String ps_name = null;
    System.out.println("hia");
    con = db.getConnection();
    System.out.println(er.getEmp_firstname());
    boolean flag = false;
    try {
      ps =
          con.prepareStatement(
              "update Employee_reg set ps_id=?,dept_name=?,emp_id=?,emp_firstname=?,emp_lastname=?,sex=?,join_date=?,designation=? where emp_id='"
                  + er.getDemp_id()
                  + "'");

      ps.setInt(1, er.getPs_id());
      ps.setString(2, er.getDept_name());
      ps.setString(3, er.getEmp_id());
      ps.setString(4, er.getEmp_firstname());
      ps.setString(5, er.getEmp_lastname());
      ps.setString(6, er.getSex());
      ps.setString(7, er.getJoin_date());
      ps.setString(8, er.getDesignation());

      int i = ps.executeUpdate();

      if (i > 0) {
        flag = true;
        con.commit();
        System.out.println("NO");
      }

    } catch (Exception e) {
      e.printStackTrace();
      try {
        con.close();
      } catch (Exception e1) {
        e1.printStackTrace();
      }
    } finally {
      releaseResources(con, ps);
    }
    return flag;
  }
Exemple #4
0
  public CoreList View_Employee(String emp_id) throws SQLException {
    CoreList ch = new CoreList();
    ch.clear();
    PreparedStatement pst = null;
    ResultSet rs = null;
    DBConn conn = new DBConn();
    System.out.println(emp_id);
    con = conn.getConnection();
    try {

      pst = con.prepareStatement("select * from employee_reg where emp_id='" + emp_id + "'");
      System.out.println("chai");
      rs = pst.executeQuery();
      while (rs.next()) {
        EmployeeRegForm psf = new EmployeeRegForm();
        psf.setPs_id(rs.getInt(1));
        psf.setDept_name(rs.getString(2));
        System.out.println(rs.getString(2));
        psf.setEmp_id(rs.getString(3));
        psf.setEmp_firstname(rs.getString(4));
        psf.setEmp_lastname(rs.getString(5));
        psf.setSex(rs.getString(6));
        psf.setJoin_date(rs.getString(7));
        psf.setDesignation(rs.getString(8));

        ch.add(psf);
      }
    } catch (Exception e) {
      con.close();
      System.out.println("Connection Closed");
      e.printStackTrace();

    } finally {
      releaseResources(con, pst);
    }
    return ch;
  }
Exemple #5
0
  public boolean empreg_insert(EmployeeRegForm ef) throws SQLException {
    PreparedStatement ps1 = null, ps2 = null;
    DBConn db = new DBConn();
    String ps_name = null;

    con = db.getConnection();

    boolean flag = false;
    try {

      ps1 = con.prepareStatement("insert into employee_reg values(?,?,?,?,?,?,?,?,?)");

      ps1.setInt(1, ef.getPs_id());
      ps1.setString(2, ef.getDept_name());
      ps1.setString(3, ef.getEmp_id());
      ps1.setString(4, ef.getEmp_firstname());
      ps1.setString(5, ef.getEmp_lastname());
      ps1.setString(6, ef.getSex());
      ps1.setString(7, ef.getJoin_date());
      ps1.setString(8, ef.getDesignation());
      ps1.setString(9, ef.getLoginid());
      System.out.println("I am executed chai");

      int i = ps1.executeUpdate();

      if (i > 0) {
        flag = true;
        con.commit();
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      releaseResources(con, ps1);
    }
    return flag;
  }