Пример #1
0
  public String SqlExcute(String xmlStr) {
    String outstr = "false";
    Document doc;
    Element rootNode;
    String intStr = Basic.decode(xmlStr);

    try {
      Reader reader = new StringReader(intStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      List list = rootNode.getChildren();

      DBTable datatable = new DBTable();

      for (int i = 0; i < list.size(); i++) {
        Element childRoot = (Element) list.get(i);
        // System.out.print(childRoot.getText());
        outstr = String.valueOf(datatable.SaveDateStr(childRoot.getText()));
      }

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());
    }
    return outstr;
  }
Пример #2
0
  public String doExcelHou(String xmlStr, WritableWorkbook wwb) {
    String outstr = "";
    Document doc;
    Element rootNode, child;
    // System.out.println(xmlStr);

    try {
      Reader reader = new StringReader(xmlStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      if (rootNode.getAttributeValue("type").equals("lp")) {
        return getloadspell(rootNode.getText());
      }

      if (rootNode.getAttributeValue("type").equals("lm")) {
        return getLoadName(rootNode.getText());
      }

      List list = rootNode.getChildren();

      Element childRoot = (Element) list.get(0);
      String fieldTitle = childRoot.getAttributeValue("fieldTitle");

      if (rootNode.getAttributeValue("type").equals("enum")) {
        String enumType = childRoot.getAttributeValue("enumType");

        return getEnumType(enumType, fieldTitle);
      }
      if (rootNode.getAttributeValue("type").equals("sql")) {
        String SqlStr = childRoot.getAttributeValue("SqlStr");
        DBTable datatable = new DBTable();
        return datatable.getDropDownStr(SqlStr, fieldTitle);
      }

      if (rootNode.getAttributeValue("type").equals("excel")) {
        String SqlStr = childRoot.getAttributeValue("SQLStr");
        // System.out.println(SqlStr);

        String whereStr = Basic.decode(childRoot.getAttributeValue("whereStr"));
        // System.out.println(whereStr);
        DBTable datatable = new DBTable();
        return datatable.getExcel(SqlStr, whereStr);
      }

      // !
      if (rootNode.getAttributeValue("type").equals("excelhou")) {
        String SqlStr = childRoot.getAttributeValue("SQLStr");
        String fieldCN = childRoot.getAttributeValue("fieldCN");
        String fieldType = childRoot.getAttributeValue("fieldType");
        String fieldWidth = childRoot.getAttributeValue("fieldWidth");
        String visible = childRoot.getAttributeValue("visible");
        String enumType = childRoot.getAttributeValue("enumType");
        String whereStr = Basic.decode(childRoot.getAttributeValue("whereStr"));

        DBTable datatable = new DBTable();
        return datatable.writeExcel_new(
            wwb, SqlStr, whereStr, fieldCN, fieldType, fieldWidth, visible, enumType);
      }
      if (rootNode.getAttributeValue("type").equals("comboBox")) {

        String comboBoxID = childRoot.getAttributeValue("comboBoxID");

        JOption jOption = new JOption(comboBoxID);

        String enumType = childRoot.getAttributeValue("enumType");
        String titleStr = childRoot.getAttributeValue("titleStr");
        String sqlStr = childRoot.getAttributeValue("sqlStr");
        String defaultoption = childRoot.getAttributeValue("defaultOption");

        String titleVisible = childRoot.getAttributeValue("titleVisible");
        String keyVisible = childRoot.getAttributeValue("keyVisible");

        if (defaultoption != null) {
          String[] options = defaultoption.split(",", -2);

          if (options.length == 2) {
            jOption.addOption(options[0], options[1]);
          }
        }
        if (titleVisible.toLowerCase().trim().equals("false")) jOption.setTitleVisible(false);
        if (keyVisible.toLowerCase().trim().equals("false")) jOption.setKeyVisible(false);

        jOption.setEnumType(enumType);
        jOption.setSQlStr(sqlStr);
        jOption.setTitleStr(titleStr);
        return jOption.getDropHtml();
      }

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());
    }

    return outstr;
  }