Exemplo n.º 1
0
  public String QuerySQL(String xmlStr) {
    String outstr = "";
    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();

      String SqlStr = "select " + rootNode.getAttributeValue("fieldStr");
      SqlStr = SqlStr + "  from  " + rootNode.getAttributeValue("tableStr");
      SqlStr = SqlStr + "  where (1=1) " + rootNode.getAttributeValue("whereStr");

      DBTable datatable = new DBTable();

      RecordSet rs = datatable.queryData(SqlStr);
      String[] fieldArr = rootNode.getAttributeValue("fieldStr").split(",");

      outstr = "<queryDataS success=\"true\">";
      while (rs.next()) {
        outstr = outstr + "<queryData";
        for (int i = 0; i < fieldArr.length; i++) {
          outstr =
              outstr + "  " + fieldArr[i].trim() + "=\"" + rs.getString(fieldArr[i].trim()) + "\"";
        }
        outstr = outstr + "/>";
      }
      outstr = outstr + "</queryDataS>";

    } catch (JDOMException ex) {
      outstr = "<queryDataS success=false>";
      outstr = outstr + ex.getMessage() + "</queryDataS>";
    }
    return Basic.encode(outstr);
  }
Exemplo n.º 2
0
  public String getDataTableXML(String xmlStr) {
    String outstr = "";
    Document doc;
    Element rootNode, child;

    ConnectionManager cm = ConnectionManager.getInstance();

    try {
      cm.get();

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

      rootNode = doc.getRootElement();

      List list = rootNode.getChildren();

      Element childRoot = (Element) list.get(0);

      DBGrid dbGrid = new DBGrid();
      dbGrid.setGridID(childRoot.getAttributeValue("id"));
      dbGrid.setGridType(childRoot.getAttributeValue("gridType"));
      dbGrid.setfieldSQL(childRoot.getAttributeValue("SQLStr"));
      dbGrid.setfieldcn(childRoot.getAttributeValue("fieldCN"));
      dbGrid.setenumType(childRoot.getAttributeValue("enumType"));
      dbGrid.setvisible(childRoot.getAttributeValue("visible"));
      dbGrid.setfieldName(childRoot.getAttributeValue("fieldname"));
      dbGrid.setfieldWidth(childRoot.getAttributeValue("fieldwidth"));
      dbGrid.setfieldType(childRoot.getAttributeValue("fieldtype"));
      dbGrid.setfieldCheck(childRoot.getAttributeValue("fieldCheck"));
      dbGrid.setcountSQL(childRoot.getAttributeValue("countSQL"));

      dbGrid.setpagesize(Integer.parseInt(childRoot.getAttributeValue("pageSize")));
      dbGrid.setAbsolutePage(Integer.parseInt(childRoot.getAttributeValue("AbsolutePage")));
      dbGrid.setRecordCount(Integer.parseInt(childRoot.getAttributeValue("RecordCount")));
      dbGrid.setCheck(childRoot.getAttributeValue("checkbl").toLowerCase().trim().equals("true"));
      dbGrid.setAlign(childRoot.getAttributeValue("tralign"));

      /*
            if (childRoot.getAttributeValue("bottomVisible").toLowerCase().equals("true"))
              dbGrid.setGridBottomVisible(true);
            else
              dbGrid.setGridBottomVisible(false);
      */
      // zr
      if (childRoot.getAttributeValue("bottomVisible").toLowerCase().equals("true")) {
        dbGrid.setGridBottomVisible(true);
        //            dbGrid.setSumfield(childRoot.getAttributeValue("sumfield"));
      } else dbGrid.setGridBottomVisible(false);

      dbGrid.setWhereStr(Basic.decode(childRoot.getAttributeValue("whereStr")));

      outstr = dbGrid.getEditDataTable();
      // System.out.println(outstr);

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

    } finally {
      cm.release();
    }
    return outstr;
  }
Exemplo n.º 3
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;
  }