Example #1
0
 public static void dg1PrintDataBind(DataGridAction dga) {
   String sql1 = "select * from ZSOrderItem where OrderID = ? order by GoodsID";
   DataTable dt = new QueryBuilder(sql1, dga.getParam("OrderID")).executeDataTable();
   Mapx factoryMap =
       new QueryBuilder(
               "select id,Factory from zsgoods where exists(select * from zsorderitem where orderID = ? and GoodsID = zsgoods.ID)",
               dga.getParam("OrderID"))
           .executeDataTable()
           .toMapx(0, 1);
   dt.insertColumn("Factory");
   for (int i = 0; (dt != null) && (i < dt.getRowCount()); ++i) {
     dt.set(i, "Factory", factoryMap.getString(dt.getString(i, "GoodsID")));
   }
   dga.bindData(dt);
 }
Example #2
0
 public static void historyDataBind(DataGridAction dga) {
   QueryBuilder qb =
       new QueryBuilder(
           "select ZCMessage.*,case readFlag when 1 then '已读' else '未读' end as ReadFlagStr,case readFlag when 1 then '' else 'red' end as color from ZCMessage where fromuser=?",
           User.getUserName());
   qb.append(dga.getSortString());
   DataTable dt = qb.executePagedDataTable(dga.getPageSize(), dga.getPageIndex());
   dt.insertColumn("ReadFlagIcon");
   for (int i = 0; i < dt.getRowCount(); ++i) {
     String flag = dt.getString(i, "ReadFlag");
     if (!"1".equals(flag)) dt.set(i, "ReadFlagIcon", "<img src='../Icons/icon037a7.gif'>");
     else {
       dt.set(i, "ReadFlagIcon", "<img src='../Icons/icon037a17.gif'>");
     }
   }
   dga.setTotal(qb);
   dga.bindData(dt);
 }
 public void dataBindAllColumns(DataListAction dla) {
   ZCCustomTableSchema table = new ZCCustomTableSchema();
   table.setSiteID($V("SiteID"));
   table.setCode($V("TableCode"));
   ZCCustomTableSet set = table.query();
   if ((set == null) || (set.size() < 1)) {
     LogUtil.warn("ID为" + table.getSiteID() + "的站点下没有代码为" + table.getCode() + "的表!");
     return;
   }
   table = set.get(0);
   if (!"Y".equals(table.getAllowView())) {
     LogUtil.warn("ID为" + table.getSiteID() + "的站点下代码为" + table.getCode() + "的表不允许前台查看!");
     return;
   }
   DataTable dt = CustomTableUtil.getData(set.get(0), null, dla.getPageSize(), dla.getPageIndex());
   ZCCustomTableColumnSet cset =
       new ZCCustomTableColumnSchema().query(new QueryBuilder("where TableID=?", table.getID()));
   HtmlTR tr = new HtmlTR();
   ArrayList list = new ArrayList();
   for (int i = 0; i < cset.size(); ++i) {
     HtmlTD td = new HtmlTD();
     td.setInnerHTML(cset.get(i).getName());
     tr.addTD(td);
   }
   list.add(tr);
   for (int i = 0; i < dt.getRowCount(); ++i) {
     tr = new HtmlTR();
     for (int j = 0; j < dt.getColCount(); ++j) {
       HtmlTD td = new HtmlTD();
       td.setInnerHTML(dt.getString(i, j));
       tr.addTD(td);
     }
     list.add(tr);
   }
   dt = new DataTable();
   dt.insertColumn("RowHTML");
   for (int i = 0; i < list.size(); ++i) {
     tr = (HtmlTR) list.get(i);
     dt.insertRow(new Object[] {tr.getOuterHtml()});
   }
   dla.setTotal(CustomTableUtil.getTotal(table, "where 1=1"));
   dla.bindData(dt);
 }
Example #4
0
  public void add() {
    String toUser = $V("ToUser");
    if (!StringUtil.checkID(toUser)) {
      this.Response.setLogInfo(0, "传入参数错误!");
      return;
    }
    String[] userList = toUser.split(",");

    String toRole = $V("ToRole");
    if (!StringUtil.checkID(toRole)) {
      this.Response.setLogInfo(0, "传入参数错误!");
      return;
    }
    String[] roleList = toRole.split(",");

    if (roleList.length > 0) {
      String roleStr = "";
      for (int j = 0; j < roleList.length; ++j) {
        if (StringUtil.isNotEmpty(roleList[j])) {
          if (j == 0) roleStr = roleStr + "'" + roleList[j] + "'";
          else {
            roleStr = roleStr + ",'" + roleList[j] + "'";
          }
        }
      }
      if (StringUtil.isNotEmpty(roleStr)) {
        DataTable dt =
            new QueryBuilder("select UserName from zduserRole where rolecode in (" + roleStr + ")")
                .executeDataTable();
        for (int k = 0; k < dt.getRowCount(); ++k) {
          String userName = dt.getString(k, "UserName");
          if ((!User.getUserName().equals(userName))
              && (!ArrayUtils.contains(userList, userName))) {
            userList = (String[]) ArrayUtils.add(userList, userName);
          }
        }
      }
    }

    if (MessageCache.addMessage($V("Subject"), $V("Content"), userList, User.getUserName()))
      this.Response.setLogInfo(1, "新建成功!");
    else this.Response.setLogInfo(0, "新建失败!");
  }
Example #5
0
 private void dealCustomTable(DataTable dt, QueryBuilder qb) throws Exception {
   try {
     qb.clearBatches();
     qb.getParams().clear();
     for (int i = 0; i < dt.getRowCount(); ++i) {
       for (int j = 0; j < dt.getColCount() - 1; ++j) {
         String v = dt.getString(i, j);
         if (StringUtil.isEmpty(v)) {
           v = null;
         }
         qb.add(v);
       }
       qb.addBatch();
     }
     this.da.executeNoQuery(qb);
   } catch (Throwable t) {
     t.printStackTrace();
   }
 }