/**
   * 删除操作 删除条件:主键
   *
   * @return boolean
   */
  public boolean delete() {
    PreparedStatement pstmt = null;

    if (!mflag) {
      con = DBConnPool.getConnection();
    }

    try {
      int tCount = this.size();
      pstmt = con.prepareStatement("DELETE FROM LEDOccupation WHERE  OccupationCode = ?");
      for (int i = 1; i <= tCount; i++) {
        if (this.get(i).getOccupationCode() == null
            || this.get(i).getOccupationCode().equals("null")) {
          pstmt.setString(1, null);
        } else {
          pstmt.setString(1, this.get(i).getOccupationCode());
        }
        pstmt.addBatch();
      }
      pstmt.executeBatch();
      pstmt.close();
    } catch (Exception ex) {
      // @@错误处理
      ex.printStackTrace();
      this.mErrors.copyAllErrors(db.mErrors);
      CError tError = new CError();
      tError.moduleName = "LEDOccupationDBSet";
      tError.functionName = "delete()";
      tError.errorMessage = ex.toString();
      this.mErrors.addOneError(tError);

      try {
        pstmt.close();
      } catch (Exception e) {
        e.printStackTrace();
      }

      if (!mflag) {
        try {
          con.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

      return false;
    }

    if (!mflag) {
      try {
        con.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return true;
  }
Exemplo n.º 2
0
  /**
   * 新增操作
   *
   * @return boolean
   */
  public boolean insert() {
    PreparedStatement pstmt = null;

    if (!mflag) {
      con = DBConnPool.getConnection();
    }

    try {
      int tCount = this.size();
      pstmt =
          con.prepareStatement(
              "INSERT INTO LECBnf VALUES( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?)");
      for (int i = 1; i <= tCount; i++) {
        if (this.get(i).getContNo() == null || this.get(i).getContNo().equals("null")) {
          pstmt.setString(1, null);
        } else {
          pstmt.setString(1, this.get(i).getContNo());
        }
        if (this.get(i).getPolNo() == null || this.get(i).getPolNo().equals("null")) {
          pstmt.setString(2, null);
        } else {
          pstmt.setString(2, this.get(i).getPolNo());
        }
        if (this.get(i).getInsuredNo() == null || this.get(i).getInsuredNo().equals("null")) {
          pstmt.setString(3, null);
        } else {
          pstmt.setString(3, this.get(i).getInsuredNo());
        }
        if (this.get(i).getBnfType() == null || this.get(i).getBnfType().equals("null")) {
          pstmt.setString(4, null);
        } else {
          pstmt.setString(4, this.get(i).getBnfType());
        }
        pstmt.setDouble(5, this.get(i).getBnfNo());
        if (this.get(i).getBnfGrade() == null || this.get(i).getBnfGrade().equals("null")) {
          pstmt.setString(6, null);
        } else {
          pstmt.setString(6, this.get(i).getBnfGrade());
        }
        if (this.get(i).getRelationToInsured() == null
            || this.get(i).getRelationToInsured().equals("null")) {
          pstmt.setString(7, null);
        } else {
          pstmt.setString(7, this.get(i).getRelationToInsured());
        }
        pstmt.setDouble(8, this.get(i).getBnfLot());
        if (this.get(i).getCustomerNo() == null || this.get(i).getCustomerNo().equals("null")) {
          pstmt.setString(9, null);
        } else {
          pstmt.setString(9, this.get(i).getCustomerNo());
        }
        if (this.get(i).getName() == null || this.get(i).getName().equals("null")) {
          pstmt.setString(10, null);
        } else {
          pstmt.setString(10, this.get(i).getName());
        }
        if (this.get(i).getSex() == null || this.get(i).getSex().equals("null")) {
          pstmt.setString(11, null);
        } else {
          pstmt.setString(11, this.get(i).getSex());
        }
        if (this.get(i).getBirthday() == null || this.get(i).getBirthday().equals("null")) {
          pstmt.setDate(12, null);
        } else {
          pstmt.setDate(12, Date.valueOf(this.get(i).getBirthday()));
        }
        if (this.get(i).getBnfIDType() == null || this.get(i).getBnfIDType().equals("null")) {
          pstmt.setString(13, null);
        } else {
          pstmt.setString(13, this.get(i).getBnfIDType());
        }
        if (this.get(i).getBnfIDNo() == null || this.get(i).getBnfIDNo().equals("null")) {
          pstmt.setString(14, null);
        } else {
          pstmt.setString(14, this.get(i).getBnfIDNo());
        }
        if (this.get(i).getOperator() == null || this.get(i).getOperator().equals("null")) {
          pstmt.setString(15, null);
        } else {
          pstmt.setString(15, this.get(i).getOperator());
        }
        if (this.get(i).getMakeDate() == null || this.get(i).getMakeDate().equals("null")) {
          pstmt.setDate(16, null);
        } else {
          pstmt.setDate(16, Date.valueOf(this.get(i).getMakeDate()));
        }
        if (this.get(i).getMakeTime() == null || this.get(i).getMakeTime().equals("null")) {
          pstmt.setString(17, null);
        } else {
          pstmt.setString(17, this.get(i).getMakeTime());
        }
        if (this.get(i).getModifyDate() == null || this.get(i).getModifyDate().equals("null")) {
          pstmt.setDate(18, null);
        } else {
          pstmt.setDate(18, Date.valueOf(this.get(i).getModifyDate()));
        }
        if (this.get(i).getModifyTime() == null || this.get(i).getModifyTime().equals("null")) {
          pstmt.setString(19, null);
        } else {
          pstmt.setString(19, this.get(i).getModifyTime());
        }
        pstmt.addBatch();
      }
      pstmt.executeBatch();
      pstmt.close();
    } catch (Exception ex) {
      // @@错误处理
      ex.printStackTrace();
      this.mErrors.copyAllErrors(db.mErrors);
      CError tError = new CError();
      tError.moduleName = "LECBnfDBSet";
      tError.functionName = "insert()";
      tError.errorMessage = ex.toString();
      this.mErrors.addOneError(tError);

      try {
        pstmt.close();
      } catch (Exception e) {
        e.printStackTrace();
      }

      if (!mflag) {
        try {
          con.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

      return false;
    }

    if (!mflag) {
      try {
        con.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return true;
  }