Beispiel #1
0
 public static Mapx initDialog(Mapx params) {
   String Code = params.getString("Code");
   if (XString.isEmpty(Code)) {
     params.put("VerifyType", HtmlUtil.mapxToOptions(VerifyTypeMap));
     params.put("InputType", HtmlUtil.mapxToOptions(InputTypeMap));
     params.put("IsMandatory", HtmlUtil.codeToRadios("IsMandatory", "YesOrNo", "N"));
     params.put("MaxLength", "100");
     params.put("Cols", "265");
     params.put("Rows", "90");
   } else {
     ZDMemberFieldSchema field = new ZDMemberFieldSchema();
     field.setCode(Code);
     field.setSiteID(ApplicationPage.getCurrentSiteID());
     field.fill();
     params = field.toMapx();
     params.put("VerifyType", HtmlUtil.mapxToOptions(VerifyTypeMap, field.getVerifyType()));
     params.put("InputType", HtmlUtil.mapxToOptions(InputTypeMap, field.getInputType()));
     params.put(
         "IsMandatory", HtmlUtil.codeToRadios("IsMandatory", "YesOrNo", field.getIsMandatory()));
   }
   return params;
 }
Beispiel #2
0
  public void add() {
    String hCode = $V("hCode");
    boolean update = false;
    int FieldCount =
        new QueryBuilder(
                "select count(*) from ZDMemberField where SiteID = ?",
                ApplicationPage.getCurrentSiteID())
            .executeInt();
    ZDMemberFieldSchema field = new ZDMemberFieldSchema();
    field.setCode($V("Code").trim());
    field.setSiteID(ApplicationPage.getCurrentSiteID());
    if ((XString.isEmpty(hCode)) && (field.fill())) {
      this.response.setLogInfo(0, "已有相同字段");
      return;
    }
    if ((XString.isNotEmpty(hCode)) && (field.fill())) {
      update = true;
    }
    if (!update) {
      if (FieldCount < 20) {
        int index = 1;
        for (int i = 1; i <= 20; i++) {
          if (new QueryBuilder(
                      "select count(*) from ZDMemberField where SiteID = ? and RealField = 'Prop"
                          + i
                          + "'",
                      ApplicationPage.getCurrentSiteID())
                  .executeInt()
              == 0) {
            index = i;
            break;
          }
        }
        field.setRealField("Prop" + index);
      } else {
        this.response.setLogInfo(0, "达到扩展字段上限");
        return;
      }
    }
    field.setValue(this.request);
    field.setName($V("Name"));
    field.setCode($V("Code"));
    field.setAddUser(User.getUserName());
    field.setAddTime(new Date());

    String defaultValue = field.getDefaultValue();
    defaultValue = defaultValue.replaceAll("  ", ",");
    defaultValue = defaultValue.replaceAll(" ", ",");
    defaultValue = defaultValue.replaceAll("  ", ",");
    defaultValue = defaultValue.replaceAll(" ", ",");
    defaultValue = defaultValue.replaceAll(",,", ",");
    defaultValue = defaultValue.replaceAll(",,", ",");
    defaultValue = defaultValue.replaceAll(",", ",");
    if (XString.isEmpty(defaultValue)) {
      defaultValue = "";
    }
    field.setDefaultValue(defaultValue);

    if (Input.equals(field.getInputType())) {
      field.setColSize(null);
      field.setRowSize(null);
      field.setListOption("");
    } else if (Text.equals(field.getInputType())) {
      field.setListOption("");
    } else if (Selecter.equals(field.getInputType())) {
      field.setColSize(null);
      field.setRowSize(null);
      field.setMaxLength(null);
      field.setVerifyType(STRING);
    } else if (Radio.equals(field.getInputType())) {
      field.setIsMandatory("N");
      field.setColSize(null);
      field.setRowSize(null);
      field.setMaxLength(null);
      field.setVerifyType(STRING);
    } else if (Checkbox.equals(field.getInputType())) {
      field.setIsMandatory("N");
      field.setColSize(null);
      field.setRowSize(null);
      field.setMaxLength(null);
      field.setVerifyType(STRING);
    } else if ((DateInput.equals(field.getInputType()))
        || (TimeInput.equals(field.getInputType()))) {
      field.setColSize(null);
      field.setRowSize(null);
      field.setMaxLength(null);
      field.setListOption("");
      field.setVerifyType(STRING);
    } else if (HTMLInput.equals(field.getInputType())) {
      field.setIsMandatory("N");
      field.setColSize(null);
      field.setRowSize(null);
      field.setMaxLength(null);
      field.setListOption("");
      field.setVerifyType(STRING);
    }

    Transaction trans = new Transaction();
    if (update) trans.add(field, OperateType.UPDATE);
    else {
      trans.add(field, OperateType.INSERT);
    }
    if (trans.commit()) this.response.setLogInfo(1, "保存会员扩展字段成功!");
    else this.response.setLogInfo(0, "发生错误!");
  }