/**
   * 说明:更新给定的部门对象
   *
   * @param con 数据库连接对象
   * @param source 部门对象
   * @throws LawyerException
   */
  public void updateDepartment(Connection con, Department source) throws LawyerException {
    String sql =
        "UPDATE "
            + DEPTABLE
            + " SET NAME=?,STATUS=?,SDATE=?,EDATE=?,REMARKS=?,PRINCIPAl=? WHERE ID='"
            + source.getId()
            + "' AND SYSID='"
            + source.getSysID()
            + "'";
    PreparedStatement psment = null;
    try {
      psment = con.prepareStatement(sql);
      // 清除参数
      psment.clearBatch();

      psment.setString(1, source.getName());
      psment.setString(2, source.getStatus());
      psment.setDate(
          3,
          null == source.getSdate()
              ? new java.sql.Date(new Date().getTime())
              : new java.sql.Date(source.getSdate().getTime()));
      psment.setDate(
          4,
          null == source.getEdate()
              ? new java.sql.Date(new Date().getTime())
              : new java.sql.Date(source.getEdate().getTime()));
      psment.setString(5, source.getRemarks());
      psment.setString(6, source.getPrincipal());

      psment.addBatch();

      // 执行数据库插入处理
      psment.execute();
    } catch (SQLException e) {
      throw new LawyerException("Update Department is error! " + e.getMessage());
    } finally {
      try {
        psment.close();
      } catch (SQLException e) {
      }
      psment = null;
    }
  }
  /**
   * 说明:存储给定的部门对象
   *
   * @param con 数据库连接对象
   * @param source 部门对象
   * @throws LawyerException
   */
  public void saveDepartment(Connection con, Department source) throws LawyerException {
    String sql =
        "INSERT INTO "
            + DEPTABLE
            + "(ID,NAME,STATUS,SDATE,EDATE,REMARKS,PRINCIPAl,SYSID) VALUES(?,?,?,?,?,?,?,?)";
    PreparedStatement psment = null;
    try {
      psment = con.prepareStatement(sql);
      // 清除参数
      psment.clearBatch();

      psment.setString(1, source.getId());
      psment.setString(2, source.getName());
      psment.setString(3, source.getStatus());
      psment.setDate(
          4,
          null == source.getSdate()
              ? new java.sql.Date(new Date().getTime())
              : new java.sql.Date(source.getSdate().getTime()));
      psment.setDate(
          5,
          null == source.getEdate()
              ? new java.sql.Date(new Date().getTime())
              : new java.sql.Date(source.getEdate().getTime()));
      psment.setString(6, source.getRemarks());
      psment.setString(7, source.getPrincipal());
      psment.setString(8, source.getSysID());

      psment.addBatch();

      // 执行数据库插入处理
      psment.execute();
    } catch (SQLException e) {
      throw new LawyerException("Save Department is error! " + e.getMessage());
    } finally {
      try {
        psment.close();
      } catch (SQLException e) {
      }
      psment = null;
    }
  }