Exemplo n.º 1
0
 /** 修改数据 */
 public int udpate(Position position) {
   String sql = "update Position  ";
   List params = new ArrayList();
   // 用户保存 要修改列的sql语句
   String set = "";
   if (position.getPositionName() != null && !"".equals(position.getPositionName())) {
     set += ",PositionName=?";
     params.add(position.getPositionName());
   }
   if (position.getCompanyId() != 0 && !"".equals(position.getCompanyId())) {
     set += ",CompanyId=?";
     params.add(position.getCompanyId());
   }
   if (position.getDepartmentId() != 0 && !"".equals(position.getDepartmentId())) {
     set += ",DepartmentId=?";
     params.add(position.getDepartmentId());
   }
   if (position.getPowerId() != 0 && !"".equals(position.getPowerId())) {
     set += ",PowerId=?";
     params.add(position.getPowerId());
   }
   // 重新拼接,构建完成的sql语句
   sql += " set " + set.substring(1);
   sql += " where PositionId=?";
   params.add(position.getPositionId());
   int i = super.executeUpdate(sql, params);
   return i;
 }
Exemplo n.º 2
0
 /** 添加数据 */
 public int insert(Position position) {
   String sql =
       "insert into Position(CompanyId,DepartmentId,PositionName,PowerId) values(?,?,?,?)";
   List params = new ArrayList();
   params.add(position.getCompanyId());
   params.add(position.getDepartmentId());
   params.add(position.getPositionName());
   params.add(position.getPowerId());
   int i = super.executeUpdate(sql, params);
   return i;
 }