Esempio n. 1
0
  public boolean addEmp(EmpVO emp) {
    conn = getConn();
    String sql = "insert into emp2(empno,ename,deptno,sal,hiredate,job,mgr) values(?,?,?,?,?,?,?)";

    try {
      pstmt = conn.prepareStatement(sql);
      pstmt.setInt(1, emp.getEmpno());
      pstmt.setString(2, emp.getEname());
      pstmt.setInt(3, emp.getDeptno());
      pstmt.setInt(4, emp.getSal());
      pstmt.setDate(5, emp.getHiredate());
      pstmt.setString(6, "PARTTIME");
      pstmt.setInt(7, 7839);
      pstmt.executeUpdate();

      // FreeboardVO FreeData=new FreeboardVO();
      // FreeData.setHitcnt(rs.getInt("f_hitcnt"));
      return true;
    } catch (SQLException e) {

      e.printStackTrace();
    } finally {

      closeAll();
    }
    return false;
  }
Esempio n. 2
0
  /**
   * Method called by the Form panel to delete existing data.
   *
   * @param persistentObject value object to delete
   * @return an ErrorResponse value object in case of errors, VOResponse if the operation is
   *     successfully completed
   */
  public Response deleteRecord(ValueObject persistentObject) throws Exception {
    PreparedStatement stmt = null;
    try {
      EmpVO vo = (EmpVO) persistentObject;

      // delete from WORKING_DAYS...
      stmt = conn.prepareStatement("delete from WORKING_DAYS where EMP_CODE=?");
      stmt.setString(1, vo.getEmpCode());
      stmt.execute();
      stmt.close();

      // delete from EMP...
      stmt = conn.prepareStatement("delete from EMP where EMP_CODE=?");
      stmt.setString(1, vo.getEmpCode());
      stmt.execute();
      gridFrame.reloadData();

      frame.getGrid().clearData();

      return new VOResponse(vo);
    } catch (SQLException ex) {
      ex.printStackTrace();
      return new ErrorResponse(ex.getMessage());
    } finally {
      try {
        stmt.close();
        conn.commit();
      } catch (SQLException ex1) {
      }
    }
  }
Esempio n. 3
0
  /**
   * Callback method called when the data loading is completed.
   *
   * @param error <code>true</code> if an error occours during data loading, <code>false</code> if
   *     data loading is successfully completed
   */
  public void loadDataCompleted(boolean error) {
    frame.getControlCurrency().setCurrencySymbol("$");
    frame.getControlCurrency().setDecimals(2);
    frame.getControlCurrency().setDecimalSymbol('.');
    frame.getControlCurrency().setGroupingSymbol(',');

    EmpVO vo = (EmpVO) frame.getMainPanel().getVOModel().getValueObject();
    frame.getGrid().getOtherGridParams().put("empCode", vo.getEmpCode());
    frame.getGrid().reloadData();
  }
Esempio n. 4
0
 public List<EmpVO> getPageEmp(int empno) {
   conn = getConn();
   String sql =
       "select * from"
           + "(select trunc((rownum-1)/12)+1 as page,"
           + "lpad('¡¡',(level-1)*5,'¡¡')||DECODE(LEVEL,1,'','¦¦')||ename as ename,"
           + "empno,hiredate,sal,deptno "
           + "from emp2 "
           + "start with ename='KING'connect by prior empno=mgr"
           + ")"
           + "where empno=?";
   try {
     pstmt = conn.prepareStatement(sql);
     pstmt.setInt(1, empno);
     rs = pstmt.executeQuery();
     List<EmpVO> list = new ArrayList<>();
     while (rs.next()) {
       EmpVO emp = new EmpVO();
       emp.setEmpno(rs.getInt("EMPNO"));
       emp.setEname(rs.getString("ENAME"));
       emp.setHiredate(rs.getDate("HIREDATE"));
       emp.setSal(rs.getInt("SAL"));
       emp.setDeptno(rs.getInt("DEPTNO"));
       list.add(emp);
     }
     return list;
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     closeAll();
   }
   return null;
 }
Esempio n. 5
0
 public List<EmpVO> getEmpList() {
   conn = getConn();
   String sql = "SELECT * FROM emp2";
   try {
     pstmt = conn.prepareStatement(sql);
     rs = pstmt.executeQuery();
     List<EmpVO> list = new ArrayList<>();
     while (rs.next()) {
       EmpVO emp = new EmpVO();
       emp.setEmpno(rs.getInt("EMPNO"));
       emp.setEname(rs.getString("ENAME"));
       emp.setHiredate(rs.getDate("HIREDATE"));
       emp.setSal(rs.getInt("SAL"));
       emp.setDeptno(rs.getInt("DEPTNO"));
       list.add(emp);
     }
     return list;
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     closeAll();
   }
   return null;
 }
Esempio n. 6
0
  public boolean bgetEmp(int empno, String ename) {

    conn = getConn();
    String sql = "select * from emp2 where empno=? and ename =?";
    try {
      pstmt = conn.prepareStatement(sql);
      pstmt.setInt(1, empno);
      pstmt.setString(2, ename);
      rs = pstmt.executeQuery();
      List<EmpVO> list = new ArrayList<>();
      while (rs.next()) {
        EmpVO emp = new EmpVO();
        emp.setEmpno(rs.getInt("EMPNO"));
        emp.setEname(rs.getString("ENAME"));
        emp.setHiredate(rs.getDate("HIREDATE"));
        emp.setSal(rs.getInt("SAL"));
        emp.setDeptno(rs.getInt("DEPTNO"));
        list.add(emp);
      }
      if (list.size() > 0) {
        return true;
      } else {
        return false;
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      closeAll();
    }
    return false;
  }
Esempio n. 7
0
  public EmpVO getEmp(int empno) {

    conn = getConn();
    String sql = "select * from emp2 where empno=?";
    try {
      pstmt = conn.prepareStatement(sql);
      pstmt.setInt(1, empno);
      rs = pstmt.executeQuery();
      EmpVO emp = new EmpVO();
      while (rs.next()) {
        emp.setEmpno(rs.getInt("EMPNO"));
        emp.setEname(rs.getString("ENAME"));
        emp.setHiredate(rs.getDate("HIREDATE"));
        emp.setSal(rs.getInt("SAL"));
        emp.setDeptno(rs.getInt("DEPTNO"));
      }
      return emp;
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      closeAll();
    }
    return null;
  }