@Override
  public void createSqlQuery() {
    String sqlWhere = "";
    String table = "";
    String columns = "";
    String innerJoin = "";
    String orderBy = "";
    STableSetting setting = null;

    for (int i = 0; i < mvTableSettings.size(); i++) {
      setting = (erp.lib.table.STableSetting) mvTableSettings.get(i);
      if (setting.getType() == STableConstants.SETTING_FILTER_DELETED
          && setting.getStatus() == STableConstants.STATUS_ON) {
        sqlWhere += (sqlWhere.length() == 0 ? "" : "AND ") + "d.b_del = FALSE ";
      }
    }

    switch (mnTabTypeAux01) {
      case SDataConstants.TRN_DNS_DPS:
        table = "trn_dns_dps ";
        columns = "c.ct_dps, l.cl_dps, t.tp_dps, ";
        innerJoin =
            "INNER JOIN erp.trns_ct_dps AS c ON "
                + "d.fid_ct_dps = c.id_ct_dps "
                + "INNER JOIN erp.trns_cl_dps AS l ON "
                + "d.fid_ct_dps = l.id_ct_dps AND d.fid_cl_dps = l.id_cl_dps "
                + "INNER JOIN erp.trnu_tp_dps AS t ON "
                + "d.fid_ct_dps = t.id_ct_dps AND d.fid_cl_dps = t.id_cl_dps AND d.fid_tp_dps = t.id_tp_dps ";
        orderBy =
            "ORDER BY c.id_ct_dps, c.ct_dps, l.id_cl_dps, l.cl_dps, t.id_tp_dps, t.tp_dps, d.dns, d.id_dns ";
        break;
      case SDataConstants.TRN_DNS_DIOG:
        table = "trn_dns_diog ";
        columns = "c.ct_iog, l.cl_iog, ";
        innerJoin =
            "INNER JOIN erp.trns_ct_iog AS c ON "
                + "d.fid_ct_iog = c.id_ct_iog "
                + "INNER JOIN erp.trns_cl_iog AS l ON "
                + "d.fid_ct_iog = l.id_ct_iog AND d.fid_cl_iog = l.id_cl_iog ";
        orderBy = "ORDER BY c.id_ct_iog, c.ct_iog, l.id_cl_iog, l.cl_iog, d.dns, d.id_dns ";
        break;
      default:
    }

    msSql =
        "SELECT d.id_dns, d.dns, d.b_del, "
            + columns
            + "d.ts_new, d.ts_edit, d.ts_del, un.usr, ue.usr, ud.usr "
            + "FROM "
            + table
            + "AS d "
            + innerJoin
            + "INNER JOIN erp.usru_usr AS un ON d.fid_usr_new = un.id_usr "
            + "INNER JOIN erp.usru_usr AS ue ON d.fid_usr_edit = ue.id_usr "
            + "INNER JOIN erp.usru_usr AS ud ON d.fid_usr_del = ud.id_usr "
            + (sqlWhere.length() == 0 ? "" : "WHERE " + sqlWhere)
            + orderBy;
  }
  @Override
  public void createSqlQuery() {
    String sqlWhere = "";
    STableSetting setting = null;

    for (int i = 0; i < mvTableSettings.size(); i++) {
      setting = (erp.lib.table.STableSetting) mvTableSettings.get(i);
      if (setting.getType() == STableConstants.SETTING_FILTER_DELETED
          && setting.getStatus() == STableConstants.STATUS_ON) {
        sqlWhere += (sqlWhere.length() == 0 ? "" : "AND ") + "g.b_del = FALSE ";
      }
    }

    msSql =
        "SELECT g.num, g.des, t.turn, b.bp, g.* "
            + "FROM mfgu_gang AS g "
            + "INNER JOIN mfgu_gang_ety AS ge ON g.id_gang = ge.id_gang "
            + "INNER JOIN erp.mfgu_turn AS t ON g.fid_turn = t.id_turn "
            + "INNER JOIN erp.bpsu_bp AS b ON ge.fid_bp = b.id_bp "
            + (sqlWhere.length() == 0 ? "" : "WHERE " + sqlWhere)
            + "ORDER BY g.num, g.des, t.turn, b.bp ";
  }