Exemplo n.º 1
0
 @Override
 public Task findById(int task_id) throws Exception {
   Task Task = null;
   String sql = "SELECT * FROM t_task WHERE task_id=?";
   this.pstmt = this.conn.prepareStatement(sql);
   this.pstmt.setInt(1, task_id);
   ResultSet rs = this.pstmt.executeQuery();
   if (rs.next()) {
     Task = new Task();
     Task.setTask_id(rs.getInt("task_id"));
     Task.setTask_staffid(rs.getInt("task_staffid"));
     Task.setTask_supplierid(rs.getInt("task_supplierid"));
     Task.setTask_num(rs.getInt("task_num"));
     Task.setTask_unit(rs.getString("task_unit"));
     Task.setTask_state(rs.getString("task_state"));
     Task.setTask_categoryid(rs.getInt("task_categoryid"));
     Task.setTask_time(rs.getTimestamp("task_time"));
     Task.setTask_offtime(rs.getTimestamp("task_offtime"));
   }
   this.pstmt.close();
   return Task;
 }
Exemplo n.º 2
0
 @Override
 public List<Task> findAll(String keyWord) throws Exception {
   List<Task> result = new ArrayList<Task>();
   String sql = "SELECT * FROM t_task WHERE  supplierid  LIKE ?";
   this.pstmt = this.conn.prepareStatement(sql);
   this.pstmt.setString(1, "%" + keyWord + "%");
   ResultSet rs = this.pstmt.executeQuery();
   Task Task = null;
   while (rs.next()) {
     Task = new Task();
     Task.setTask_id(rs.getInt("task_id"));
     Task.setTask_staffid(rs.getInt("task_staffid"));
     Task.setTask_supplierid(rs.getInt("task_supplierid"));
     Task.setTask_num(rs.getInt("task_num"));
     Task.setTask_unit(rs.getString("task_unit"));
     Task.setTask_state(rs.getString("task_state"));
     Task.setTask_categoryid(rs.getInt("task_categoryid"));
     Task.setTask_time(rs.getTimestamp("task_time"));
     Task.setTask_offtime(rs.getTimestamp("task_offtime"));
     result.add(Task);
   }
   this.pstmt.close();
   return result;
 }