/**
  * 使用另外一个 SearchRecordSchema 对象给 Schema 赋值
  *
  * @param: aSearchRecordSchema SearchRecordSchema
  */
 public void setSchema(SearchRecordSchema aSearchRecordSchema) {
   this.tradeNo = aSearchRecordSchema.getTradeNo();
   this.contNo = aSearchRecordSchema.getContNo();
   this.userCode = aSearchRecordSchema.getUserCode();
   this.name = aSearchRecordSchema.getName();
   this.gender = aSearchRecordSchema.getGender();
   this.birthday = fDate.getDate(aSearchRecordSchema.getBirthday());
   this.province = aSearchRecordSchema.getProvince();
   this.city = aSearchRecordSchema.getCity();
   this.mobile = aSearchRecordSchema.getMobile();
   this.userIDType = aSearchRecordSchema.getUserIDType();
   this.userIDNo = aSearchRecordSchema.getUserIDNo();
   this.riskname = aSearchRecordSchema.getRiskname();
   this.riskcode = aSearchRecordSchema.getRiskcode();
   this.userState = aSearchRecordSchema.getUserState();
   this.userSource = aSearchRecordSchema.getUserSource();
   this.field1 = aSearchRecordSchema.getField1();
   this.field2 = aSearchRecordSchema.getField2();
   this.field3 = aSearchRecordSchema.getField3();
   this.field4 = aSearchRecordSchema.getField4();
   this.field5 = aSearchRecordSchema.getField5();
   this.field6 = aSearchRecordSchema.getField6();
   this.searchDate = fDate.getDate(aSearchRecordSchema.getSearchDate());
   this.searchTime = aSearchRecordSchema.getSearchTime();
   this.makedate = fDate.getDate(aSearchRecordSchema.getMakedate());
   this.maketime = aSearchRecordSchema.getMaketime();
 }
 public boolean equals(Object otherObject) {
   if (otherObject == null) return false;
   if (this == otherObject) return true;
   if (this.getClass() != otherObject.getClass()) return false;
   SearchRecordSchema other = (SearchRecordSchema) otherObject;
   if (tradeNo == null && other.getTradeNo() != null) return false;
   if (tradeNo != null && !tradeNo.equals(other.getTradeNo())) return false;
   if (contNo == null && other.getContNo() != null) return false;
   if (contNo != null && !contNo.equals(other.getContNo())) return false;
   if (userCode == null && other.getUserCode() != null) return false;
   if (userCode != null && !userCode.equals(other.getUserCode())) return false;
   if (name == null && other.getName() != null) return false;
   if (name != null && !name.equals(other.getName())) return false;
   if (gender == null && other.getGender() != null) return false;
   if (gender != null && !gender.equals(other.getGender())) return false;
   if (birthday == null && other.getBirthday() != null) return false;
   if (birthday != null && !fDate.getString(birthday).equals(other.getBirthday())) return false;
   if (province == null && other.getProvince() != null) return false;
   if (province != null && !province.equals(other.getProvince())) return false;
   if (city == null && other.getCity() != null) return false;
   if (city != null && !city.equals(other.getCity())) return false;
   if (mobile == null && other.getMobile() != null) return false;
   if (mobile != null && !mobile.equals(other.getMobile())) return false;
   if (userIDType == null && other.getUserIDType() != null) return false;
   if (userIDType != null && !userIDType.equals(other.getUserIDType())) return false;
   if (userIDNo == null && other.getUserIDNo() != null) return false;
   if (userIDNo != null && !userIDNo.equals(other.getUserIDNo())) return false;
   if (riskname == null && other.getRiskname() != null) return false;
   if (riskname != null && !riskname.equals(other.getRiskname())) return false;
   if (riskcode == null && other.getRiskcode() != null) return false;
   if (riskcode != null && !riskcode.equals(other.getRiskcode())) return false;
   if (userState == null && other.getUserState() != null) return false;
   if (userState != null && !userState.equals(other.getUserState())) return false;
   if (userSource == null && other.getUserSource() != null) return false;
   if (userSource != null && !userSource.equals(other.getUserSource())) return false;
   if (field1 == null && other.getField1() != null) return false;
   if (field1 != null && !field1.equals(other.getField1())) return false;
   if (field2 == null && other.getField2() != null) return false;
   if (field2 != null && !field2.equals(other.getField2())) return false;
   if (field3 == null && other.getField3() != null) return false;
   if (field3 != null && !field3.equals(other.getField3())) return false;
   if (field4 == null && other.getField4() != null) return false;
   if (field4 != null && !field4.equals(other.getField4())) return false;
   if (field5 == null && other.getField5() != null) return false;
   if (field5 != null && !field5.equals(other.getField5())) return false;
   if (field6 == null && other.getField6() != null) return false;
   if (field6 != null && !field6.equals(other.getField6())) return false;
   if (searchDate == null && other.getSearchDate() != null) return false;
   if (searchDate != null && !fDate.getString(searchDate).equals(other.getSearchDate()))
     return false;
   if (searchTime == null && other.getSearchTime() != null) return false;
   if (searchTime != null && !searchTime.equals(other.getSearchTime())) return false;
   if (makedate == null && other.getMakedate() != null) return false;
   if (makedate != null && !fDate.getString(makedate).equals(other.getMakedate())) return false;
   if (maketime == null && other.getMaketime() != null) return false;
   if (maketime != null && !maketime.equals(other.getMaketime())) return false;
   return true;
 }
 /**
  * 数据打包,按 XML 格式打包,顺序参见<A href ={@docRoot}/dataStructure/tb.html#PrpSearchRecord描述/A>表字段
  *
  * @return: String 返回打包后字符串
  */
 public String encode() {
   StringBuffer strReturn = new StringBuffer(256);
   strReturn.append(StrTool.cTrim(tradeNo));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(contNo));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(userCode));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(name));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(gender));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(fDate.getString(birthday)));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(province));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(city));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(mobile));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(userIDType));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(userIDNo));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(riskname));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(riskcode));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(userState));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(userSource));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(field1));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(field2));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(field3));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(field4));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(field5));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(field6));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(fDate.getString(searchDate)));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(searchTime));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(fDate.getString(makedate)));
   strReturn.append(SysConst.PACKAGESPILTER);
   strReturn.append(StrTool.cTrim(maketime));
   return strReturn.toString();
 }
  /**
   * 数据解包,解包顺序参见<A href ={@docRoot}/dataStructure/tb.html#PrpSearchRecord>历史记账凭证主表信息</A>表字段
   *
   * @param: strMessage String 包含一条纪录数据的字符串
   * @return: boolean
   */
  public boolean decode(String strMessage) {
    try {
      tradeNo = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 1, SysConst.PACKAGESPILTER);
      contNo = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 2, SysConst.PACKAGESPILTER);
      userCode = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 3, SysConst.PACKAGESPILTER);
      name = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 4, SysConst.PACKAGESPILTER);
      gender = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 5, SysConst.PACKAGESPILTER);
      birthday =
          fDate.getDate(
              StrTool.getStr(StrTool.GBKToUnicode(strMessage), 6, SysConst.PACKAGESPILTER));
      province = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 7, SysConst.PACKAGESPILTER);
      city = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 8, SysConst.PACKAGESPILTER);
      mobile = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 9, SysConst.PACKAGESPILTER);
      userIDType = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 10, SysConst.PACKAGESPILTER);
      userIDNo = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 11, SysConst.PACKAGESPILTER);
      riskname = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 12, SysConst.PACKAGESPILTER);
      riskcode = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 13, SysConst.PACKAGESPILTER);
      userState = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 14, SysConst.PACKAGESPILTER);
      userSource = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 15, SysConst.PACKAGESPILTER);
      field1 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 16, SysConst.PACKAGESPILTER);
      field2 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 17, SysConst.PACKAGESPILTER);
      field3 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 18, SysConst.PACKAGESPILTER);
      field4 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 19, SysConst.PACKAGESPILTER);
      field5 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 20, SysConst.PACKAGESPILTER);
      field6 = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 21, SysConst.PACKAGESPILTER);
      searchDate =
          fDate.getDate(
              StrTool.getStr(StrTool.GBKToUnicode(strMessage), 22, SysConst.PACKAGESPILTER));
      searchTime = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 23, SysConst.PACKAGESPILTER);
      makedate =
          fDate.getDate(
              StrTool.getStr(StrTool.GBKToUnicode(strMessage), 24, SysConst.PACKAGESPILTER));
      maketime = StrTool.getStr(StrTool.GBKToUnicode(strMessage), 25, SysConst.PACKAGESPILTER);
    } catch (NumberFormatException ex) {
      // @@错误处理
      CError tError = new CError();
      tError.moduleName = "SearchRecordSchema";
      tError.functionName = "decode";
      tError.errorMessage = ex.toString();
      this.mErrors.addOneError(tError);

      return false;
    }
    return true;
  }
  @SuppressWarnings("deprecation")
  private boolean checkData() {
    // 校验停售日期不能小于当前日期
    boolean flag = true;
    boolean isNum = true;
    for (int i = timeoutDef.length(); --i >= 0; ) {
      int chr = timeoutDef.charAt(i);
      if (chr < 48 || chr > 57) {
        errorMessage.append("超时时间必须是大于0的整数!");
        flag = false;
        isNum = false;
        break;
      }
    }
    /*
    if(!"".equals(timeoutDef)&&isNum&&Integer.parseInt(timeoutDef)<=0){
    	errorMessage.append("超时时间必须是大于0的整数!");
    	flag=false;
    }
    */
    String startdate = "";
    String enddate = "";
    FDate fDate = new FDate();
    if (null != endDate) {
      enddate = fDate.getString(endDate);
    }
    if (null != startDate) {
      startdate = fDate.getString(startDate);
    }
    /*
    if (null!=endDate
    		&& PubFun.calInterval(PubFun.getCurrentDate(), enddate, "D") <= 0) {
    	operateResult = "checkfail";
    	errorMessage.append("销售止期必须大于当前日期!");
    	flag = false;
    }
    if (null!=endDate && null!=startDate
    		&& PubFun.calInterval(startdate, enddate, "D") < 0) {
    	operateResult = "checkfail";
    	errorMessage.append("销售止期不能小于销售起期!");
    	flag = false;
    }
    */
    // 校验险种的相关信息
    int n = risks.length;
    if (n == 0) {
      operateResult = "checkfail";
      errorMessage.append("请选择计划要包含的产品!");
      flag = false;
    } else {
      ExeSQL tExeSql = new ExeSQL();
      int mainRiskCount = 0;
      for (int i = 0; i < n; i++) {
        String sql =
            "select subriskflag,startdate,enddate,riskname from leprisk where riskcode='"
                + risks[i]
                + "'";
        SSRS tSSRS = tExeSql.execSQL(sql);
        // 每个产品组合有且仅有一个主险
        if (tSSRS.GetText(1, 1).equals("M")) {
          planMainRisk = risks[i];
          mainRiskCount++;
        }
        // 销售起期要在产品的销售起期之后,停售日期要在所有产品停售之前
        int s = PubFun.calInterval(tSSRS.GetText(1, 2), startdate, "D");
        if (null != startDate && s < 0) {
          operateResult = "checkfail";
          errorMessage.append(
              tSSRS.GetText(1, 4) + "的销售起期是" + tSSRS.GetText(1, 2) + ",产品组合的销售起期不能早于产品的销售起期!");
          flag = false;
        }
        int e = PubFun.calInterval(tSSRS.GetText(1, 3), enddate, "D");
        if (null != endDate && e > 0) {
          operateResult = "checkfail";
          errorMessage.append(
              tSSRS.GetText(1, 4) + "的销售止期是" + tSSRS.GetText(1, 3) + ",产品组合的销售止期不能晚于产品的销售止期!");
          flag = false;
        }
      }
      if (mainRiskCount < 1) {
        operateResult = "checkfail";
        errorMessage.append("保险计划必须包含一个主险!");
        flag = false;
      } else if (mainRiskCount > 1) {
        operateResult = "checkfail";
        errorMessage.append("保险计划仅可包含一个主险!");
        flag = false;
      }
    }
    /*
    if (!introduce.equals("") && introduce.trim().getBytes().length > 1600) {
    	operateResult = "checkfail";
    	errorMessage.append("产品组合介绍不能多于800个汉字!");
    	flag = false;
    }
    if (!rule.equals("") && rule.trim().getBytes().length > 1600) {
    	operateResult = "checkfail";
    	errorMessage.append("产品组合投保规则不能多于800个汉字!");
    	flag = false;
    }
    */

    if (upfile != null && !("".equals(upfile))) {
      String fileName = new File(upfile.getName()).getName();
      String endwith = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
      endwith = endwith.toUpperCase();
      if (endwith == null
          || (!endwith.equals("JPG") && !endwith.equals("GIF") && !endwith.equals("BMP"))) {
        operateResult = "checkfail";
        errorMessage.append("您上载图片类型" + endwith + "有误,只能上载jpg格式文件");
        System.out.println("上载图片类型错误!");
        flag = false;
      }
    } else {
      operateResult = "checkfail";
      errorMessage.append("请选择要上传的图片");
      flag = false;
    }

    return flag;
  }
 /**
  * Schema克隆
  *
  * @return Object
  * @throws CloneNotSupportedException
  */
 public Object clone() throws CloneNotSupportedException {
   SearchRecordSchema cloned = (SearchRecordSchema) super.clone();
   cloned.fDate = (FDate) fDate.clone();
   cloned.mErrors = (CErrors) mErrors.clone();
   return cloned;
 }
  /**
   * 设置对应传入参数的String形式的字段值
   *
   * @param: FCode String 需要赋值的对象
   * @param: FValue String 要赋的值
   * @return: boolean
   */
  public boolean setV(String FCode, String FValue) {
    if (StrTool.cTrim(FCode).equals("")) return false;

    if (FCode.equalsIgnoreCase("tradeNo")) {
      if (FValue != null && !FValue.equals("")) {
        tradeNo = FValue.trim();
      } else tradeNo = null;
    }
    if (FCode.equalsIgnoreCase("contNo")) {
      if (FValue != null && !FValue.equals("")) {
        contNo = FValue.trim();
      } else contNo = null;
    }
    if (FCode.equalsIgnoreCase("userCode")) {
      if (FValue != null && !FValue.equals("")) {
        userCode = FValue.trim();
      } else userCode = null;
    }
    if (FCode.equalsIgnoreCase("name")) {
      if (FValue != null && !FValue.equals("")) {
        name = FValue.trim();
      } else name = null;
    }
    if (FCode.equalsIgnoreCase("gender")) {
      if (FValue != null && !FValue.equals("")) {
        gender = FValue.trim();
      } else gender = null;
    }
    if (FCode.equalsIgnoreCase("birthday")) {
      if (FValue != null && !FValue.equals("")) {
        birthday = fDate.getDate(FValue);
      } else birthday = null;
    }
    if (FCode.equalsIgnoreCase("province")) {
      if (FValue != null && !FValue.equals("")) {
        province = FValue.trim();
      } else province = null;
    }
    if (FCode.equalsIgnoreCase("city")) {
      if (FValue != null && !FValue.equals("")) {
        city = FValue.trim();
      } else city = null;
    }
    if (FCode.equalsIgnoreCase("mobile")) {
      if (FValue != null && !FValue.equals("")) {
        mobile = FValue.trim();
      } else mobile = null;
    }
    if (FCode.equalsIgnoreCase("userIDType")) {
      if (FValue != null && !FValue.equals("")) {
        userIDType = FValue.trim();
      } else userIDType = null;
    }
    if (FCode.equalsIgnoreCase("userIDNo")) {
      if (FValue != null && !FValue.equals("")) {
        userIDNo = FValue.trim();
      } else userIDNo = null;
    }
    if (FCode.equalsIgnoreCase("riskname")) {
      if (FValue != null && !FValue.equals("")) {
        riskname = FValue.trim();
      } else riskname = null;
    }
    if (FCode.equalsIgnoreCase("riskcode")) {
      if (FValue != null && !FValue.equals("")) {
        riskcode = FValue.trim();
      } else riskcode = null;
    }
    if (FCode.equalsIgnoreCase("userState")) {
      if (FValue != null && !FValue.equals("")) {
        userState = FValue.trim();
      } else userState = null;
    }
    if (FCode.equalsIgnoreCase("userSource")) {
      if (FValue != null && !FValue.equals("")) {
        userSource = FValue.trim();
      } else userSource = null;
    }
    if (FCode.equalsIgnoreCase("field1")) {
      if (FValue != null && !FValue.equals("")) {
        field1 = FValue.trim();
      } else field1 = null;
    }
    if (FCode.equalsIgnoreCase("field2")) {
      if (FValue != null && !FValue.equals("")) {
        field2 = FValue.trim();
      } else field2 = null;
    }
    if (FCode.equalsIgnoreCase("field3")) {
      if (FValue != null && !FValue.equals("")) {
        field3 = FValue.trim();
      } else field3 = null;
    }
    if (FCode.equalsIgnoreCase("field4")) {
      if (FValue != null && !FValue.equals("")) {
        field4 = FValue.trim();
      } else field4 = null;
    }
    if (FCode.equalsIgnoreCase("field5")) {
      if (FValue != null && !FValue.equals("")) {
        field5 = FValue.trim();
      } else field5 = null;
    }
    if (FCode.equalsIgnoreCase("field6")) {
      if (FValue != null && !FValue.equals("")) {
        field6 = FValue.trim();
      } else field6 = null;
    }
    if (FCode.equalsIgnoreCase("searchDate")) {
      if (FValue != null && !FValue.equals("")) {
        searchDate = fDate.getDate(FValue);
      } else searchDate = null;
    }
    if (FCode.equalsIgnoreCase("searchTime")) {
      if (FValue != null && !FValue.equals("")) {
        searchTime = FValue.trim();
      } else searchTime = null;
    }
    if (FCode.equalsIgnoreCase("makedate")) {
      if (FValue != null && !FValue.equals("")) {
        makedate = fDate.getDate(FValue);
      } else makedate = null;
    }
    if (FCode.equalsIgnoreCase("maketime")) {
      if (FValue != null && !FValue.equals("")) {
        maketime = FValue.trim();
      } else maketime = null;
    }
    return true;
  }
 public void setMakedate(String aMakedate) {
   if (aMakedate != null && !aMakedate.equals("")) {
     makedate = fDate.getDate(aMakedate);
   } else makedate = null;
 }
 public String getMakedate() {
   if (makedate != null) return fDate.getString(makedate);
   else return null;
 }
 public void setSearchDate(String aSearchDate) {
   if (aSearchDate != null && !aSearchDate.equals("")) {
     searchDate = fDate.getDate(aSearchDate);
   } else searchDate = null;
 }
 public String getSearchDate() {
   if (searchDate != null) return fDate.getString(searchDate);
   else return null;
 }
 public void setBirthday(String aBirthday) {
   if (aBirthday != null && !aBirthday.equals("")) {
     birthday = fDate.getDate(aBirthday);
   } else birthday = null;
 }
 public String getBirthday() {
   if (birthday != null) return fDate.getString(birthday);
   else return null;
 }