Esempio n. 1
0
  public void postField(
      SessionContext ctx,
      FormInstance instance,
      String fieldname,
      ErrorMessages msgs,
      EventManager manager) {

    String id = (String) ctx.getRequestAttribute("ID");
    if (id == null || id.trim().length() <= 0) {
      instance.setHTMLShowMessage("错误", "必须输入身份证号码!");
      return;
    }

    id = id.trim();
    if (id.length() != 15 && id.length() != 18) {
      instance.setHTMLShowMessage("错误", "身份证号码长度必须为15或18位!");
      instance.setHTMLFieldValue("ID", "");
      return;
    }

    if (id.length() == 15) {
      if (util.isDate("19" + id.substring(6, 12)) == false) {
        instance.setHTMLShowMessage("警告", "证件号码日期格式非法!");
        return;
      }
    } else {
      if (id.charAt(17) == 'x') {
        instance.setHTMLShowMessage("错误", "证件号码的校验位不能是小写x!");
        instance.setHTMLFieldValue("ID", "");
        return;
      }

      if (util.isDate(id.substring(6, 14)) == false) {
        instance.setHTMLShowMessage("警告", "证件号码日期格式非法!");
        return;
      }

      int iS = 0, iY;
      int iW[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
      String szVerCode = "10X98765432";

      int i;
      for (i = 0; i < 17; i++) {
        iS += (int) (id.charAt(i) - '0') * iW[i];
      }
      iY = iS % 11;
      if (szVerCode.charAt(iY) != id.charAt(i)) {
        instance.setHTMLShowMessage("警告", "身份证号码校验码错误!");
        return;
      }
    }

    //    String year = null;
    //    if(id.length() == 15)
    //      year = "19" + id.substring(6,8);
    //    else
    //      year = id.substring(6,10);
    //    int iYear;
    //
    //    try
    //    {
    //      iYear = Integer.parseInt(year);
    //    }
    //    catch(Exception e)
    //    {
    //      instance.setHTMLShowMessage("警告","身份证号码生日格式错误!");
    //      return;
    //    }
    //
    //    if(iYear <= 1900)
    //    {
    //      instance.setHTMLShowMessage("警告","身份证号码生日早于1900年!");
    //      return;
    //    }

    return;
  }
Esempio n. 2
0
  /** 扩展基类的beforeInsert方法,点击“添加”按钮后响应的事件 */
  public int beforeInsert(
      SessionContext ctx,
      DatabaseConnection conn,
      FormInstance instance,
      ErrorMessages msgs,
      EventManager manager) {

    String GID = (String) ctx.getRequestAttribute("GID");
    String GIDTYPE = (String) ctx.getRequestAttribute("GIDTYPE");
    String GNAME = (String) ctx.getRequestAttribute("GNAME");
    String GCREDITCLASS = (String) ctx.getRequestAttribute("GCREDITCLASS");
    if (GID != null) {
      instance.setReadonly(false);
      instance.setValue("NAME", GNAME);
      instance.setValue("IDTYPE", GIDTYPE);
      instance.setValue("ID", GID);
      instance.setValue("CREDITCLASS", GCREDITCLASS);
      instance.setFieldReadonly("NAME", true);
      instance.setFieldReadonly("IDTYPE", true);
      instance.setFieldReadonly("ID", true);
      instance.setFieldReadonly("CREDITCLASS", true);
      this.isG = true;
    }

    UserManager um = (UserManager) ctx.getAttribute(SystemAttributeNames.USER_INFO_NAME);
    String BrhId = SCUser.getBrhId(um.getUserName());
    String APPDATE = SystemDate.getSystemDate5("");
    String OPERATOR = null;
    try {
      OPERATOR = um.getUserName();
    } catch (Exception ex) {
      return -1;
    }
    if (BrhId != null) {
      instance.setValue("MNTBRHID", BrhId);
      if (!SCBranch.getBrhtype(BrhId).trim().equals("9")) {
        instance.setValue("APPBRHID", BrhId);
      }
      instance.setValue("OPERATOR", OPERATOR);
      instance.setValue("APPDATE", APPDATE);
      instance.setValue("INVESTDATE", APPDATE);
      instance.setValue("LASTMODIFIED", APPDATE);
    }

    if (this.initClientNo != null) {
      MyDB.getInstance().addDBConn(conn);
      InitClientData initdata = InitClientMan.getInitClient(initClientNo);
      MyDB.getInstance().releaseDBConn();

      if (initdata == null) {
        msgs.add("移行客户信息不存在,请检查数据!");
        return -1;
      } else {
        if (initdata.appBrhID != null) {
          instance.setValue("APPBRHID", initdata.appBrhID);
        }
        if (initdata.appDate != null) {
          instance.setValue("APPDATE", util.calToString(initdata.appDate, null));
        }
        if (initdata.clientType != null) {
          instance.setValue("CLIENTTYPE", initdata.clientType.intValue());
        }
        if (initdata.ecomDeptType != null) {
          instance.setValue("ECOMDEPTTYPE", initdata.ecomDeptType.intValue());
        }
        if (initdata.ecomType != null) {
          instance.setValue("ECOMTYPE", initdata.ecomType.intValue());
        }
        if (initdata.etpScopType != null) {
          instance.setValue("ETPSCOPTYPE", initdata.etpScopType.intValue());
        }
        if (initdata.gender != null) {
          instance.setValue("GENDER", initdata.gender.intValue());
        }
        if (initdata.ID != null) {
          instance.setValue("ID", initdata.ID);
        }
        if (initdata.IDType != null) {
          // instance.setValue("IDTYPE", initdata.IDType.intValue());
        }
        if (initdata.name != null) {
          instance.setValue("NAME", initdata.name);
        }
        if (initdata.sectorCat1 != null) {
          instance.setValue("SECTORCAT1", initdata.sectorCat1.intValue());
        }
      }
    }
    return 0;
  }
Esempio n. 3
0
  public int load(
      SessionContext ctx,
      DatabaseConnection conn,
      FormInstance instance,
      ErrorMessages msgs,
      EventManager manager,
      String parameter) {

    int userNo = SessionInfo.getLoginUserNo(ctx);
    String roleStr = "select * from scuserrole where userno=" + userNo + " and roleno=1";
    RecordSet roleRs = conn.executeQuery(roleStr);
    if (roleRs.next()) {
      instance.useCloneFormBean();
      instance.getFormBean().setUseDelete(true);
    }

    // flag
    flag = (String) ctx.getRequestAttribute("flag");
    if (flag == null) {
      flag = "read";
    }
    flag = flag.toLowerCase();
    if (flag.equals("write")) {
      instance.setReadonly(false);
    } else {
      instance.setReadonly(true);
    }
    // CLIENTNO
    String CLIENTNO = ctx.getParameter("CLIENTNO");
    if (CLIENTNO == null) {
      CLIENTNO = (String) ctx.getRequestAttribute("CLIENTNO");
    }
    initClientNo = (String) ctx.getRequestAttribute("INITCLIENTNO");
    guarantorID = (String) ctx.getRequestAttribute("GID");
    String sql = "select * from cmindvclient where ";
    if (CLIENTNO != null && CLIENTNO.length() > 0) {
      strClientNo = CLIENTNO;
      sql += "clientno='" + CLIENTNO + "'";
    } else if (guarantorID != null && guarantorID.trim().length() > 0) {
      sql += "id='" + guarantorID + "'";
    }
    if (sql.endsWith("where ")) {
      return 0;
    }

    RecordSet rs = conn.executeQuery(sql);
    if (rs.next()) {
      // lj del in 20090316
      //      UserManager um = (UserManager) ctx.getAttribute(SystemAttributeNames.USER_INFO_NAME);
      //      String BRHID = SCUser.getBrhId(um.getUserName()); //登录用户所在网点
      //      String APPBRHID = rs.getString("APPBRHID").trim(); //客户资料的登记网点
      //      if ( strClientNo!=null && ! (SCBranch.checkSub(APPBRHID, BRHID) ||
      // APPBRHID.equals(BRHID))) {
      //        flag = "read";
      //        msgs.add("该客户不在本网点维护范围内!");
      //        instance.setReadonly(true);
      //      }
      //      else
      if (guarantorID != null && guarantorID.trim().length() > 0) {
        flag = "read";
        msgs.add("客户信息已经存在,不需要再做转移,请删除原来的保证人信息即可!");
        instance.setReadonly(true);
        strClientNo = rs.getString("clientno");
      }
      // trigger
      instance.setValue("CLIENTNO", strClientNo);
      trigger(manager, instance, EventType.EDIT_VIEW_EVENT_TYPE, Event.BRANCH_CONTINUE_TYPE);
    }
    return 0;
  }
Esempio n. 4
0
  public String format(SessionContext ctx, ElementBean eb1, FormInstance fi, RecordSet values) {
    String name = eb1.getName();
    FormBean fb = FormBeanManager.getForm(fi.getFormid());
    String[] names = fb.getElementKeys();
    String value =
        SessionAttributes.REQUEST_INSATNCE_ID_NAME
            + "="
            + fi.getInstanceid()
            + "&"
            + SessionAttributes.REQUEST_EVENT_ID_NAME
            + "="
            + EventType.BUTTON_EVENT_TYPE
            + "&"
            + SessionAttributes.REQUEST_BUTTON_EVENT_NAME
            + "="
            + SessionAttributes.REQUEST_EDIT_BUTTON_VALUE
            + "&";
    int length = value.length();
    if (names != null) {
      for (int i = 0; i < names.length; i++) {
        ElementBean eb = fb.getElement(names[i]);
        if (eb.isIsPrimaryKey()) {
          if (value.length() != 0 && !value.endsWith("&")) {
            value += " &";
          }
          String fldvalue = values.getString(eb.getName());
          if (fldvalue != null) {
            fldvalue = fldvalue.trim();
          }
          value += eb.getName() + "=" + fldvalue;
        }
      }
    }

    if (value.length() == length) {
      return "使用修改功能,请定义主键";
    }
    String actionurl = "";

    try {
      String targetFormId = eb1.getDefaultValue();

      if (targetFormId != null) {
        FormBean fb1 = FormBeanManager.getForm(targetFormId);
        if (fb1 != null) {
          if (fb1.getUrl() != null) {
            actionurl = fb1.getUrl();
          }
        }
      }
    } catch (Exception e) {

    }
    if (actionurl.trim().length() > 0) {
      actionurl = actionurl.trim();
    } else {
      actionurl = PageGenerator.DEFAULT_URL_LOCATE;
    }
    //        if ( fi.isReadonly() ) {
    //            String body = "<a class='list_edit_href' href='#' >" + eb1.getCaption() +
    //                "</a>";
    //
    //            return body;
    //        } else {
    String body =
        "<a class=\"list_edit_href\" href=\"#\" onclick=\"window.open('"
            + ctx.getUrl(actionurl)
            + "?"
            + value
            + "','FI"
            + fi.getInstanceid()
            + "','height=600,width=800,toolbar=no,scrollbars=yes,resizable=yes');\">"
            + "修改"
            + "</a>";

    return body;
    //        }
  }