/**
   * 将指定类代码内容传入显示FormBeen(小表格)
   *
   * @param ActionForm 显示FormBeen
   * @param String 工资卡号
   * @return String 1、成功;0、不成功;
   * @exception Exception
   */
  public String setFormbeen(ActionForm form, HttpServletRequest request, String where, String uname)
      throws Exception {

    CommDate cd = new CommDate();
    DataBean dbBean = new DataBean();

    String strsql = "";

    int maxpage = 0;
    int count = 0;
    strsql =
        "SELECT * FROM eipdtl LEFT OUTER JOIN eivdtl ON (eipstr = eivstr and eipnum=eivnum and eiptyp=eivtyp ) where eipflg='2' and  eipvdr='"
            + uname
            + "' order by EIPSTR,EIPNUM,EIPTYP";
    try {
      dbBean.executeSelect(strsql);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
      return "0";
    }
    log.debug("执行sql语句");

    String temp = "";
    String[] db = new String[dbBean.getRowCount()];
    for (int j = 0; j < dbBean.getRowCount(); j++) {
      temp = dbBean.getElementValue(j, "EIPSTR").trim();
      temp = temp + dbBean.getElementValue(j, "EIPNUM").trim();
      temp = temp + dbBean.getElementValue(j, "EIPTYP").trim();
      db[j] = temp;
    }

    String[] row = getArray(where, db);

    // count=dbBean.getRowCount();
    count = row.length;

    // count=dbBean.getRowCount();
    int pagerow = Integer.parseInt((String) PropertyUtils.getSimpleProperty(form, "pagerow"));

    // 计算分页显示的最大页数
    log.debug("数组大小" + String.valueOf(count + maxpage));
    String[] seq = new String[count + maxpage]; // 序号
    String[] eipstr = new String[count + maxpage]; // 商店号
    String[] eipnum = new String[count + maxpage]; // 单号
    String[] eipamt = new String[count + maxpage]; // 金额
    String[] eipdta = new String[count + maxpage]; // 交易日期
    String[] eiptyp = new String[count + maxpage]; // 交易类型
    String[] eipvdr = new String[count + maxpage]; // 供货商号
    String[] eipyta = new String[count + maxpage]; // 应付日期
    String[] eipflg = new String[count + maxpage]; // 标志

    String[] eivtrk = new String[count + maxpage]; // 	发票字轨
    String[] eivivn = new String[count + maxpage]; // 	发票号
    String[] eivamt = new String[count + maxpage]; // 	开票日期

    String[] eivtax = new String[count + maxpage]; // 应付日期

    int i = 0;
    int j = 0;

    String key = "";
    for (; i < count + maxpage; i++) {
      log.debug("数组循环" + String.valueOf(i));
      j = Integer.parseInt(row[i]);
      // if((i==jk*pagerow-1)||(i==count+maxpage-1)){
      //						if(!( tempstr.equals(dbBean.getElementValue(j,"eipstr"  ).trim()) &&
      // tempnum.equals(dbBean.getElementValue(j,"eipnum"  ).trim()) &&
      // temptyp.equals(dbBean.getElementValue(j,"eiptyp"  ).trim()))){
      //							seq[i]="";
      //							eipstr[i]="";
      //							eipnum[i]="";
      //							eipamt[i]="";
      //							eipdta[i]="";
      //							eiptyp[i]="";
      //							eipvdr[i]="";
      //							eipyta[i]="";
      //							eipflg[i]="";
      //
      //							eivtrk[i]="";
      //							eivivn[i]="";
      //							eivamt[i]="";
      //							eivtax[i]="";
      //
      //							tempstr=dbBean.getElementValue(j,"eipstr"  ).trim();
      //							tempnum=dbBean.getElementValue(j,"eipnum"  ).trim();
      //							temptyp=dbBean.getElementValue(j,"eiptyp"  ).trim();
      //
      //							i++;
      //							if(i >=count+maxpage){
      //								break;
      //							}
      //						}
      seq[i] = String.valueOf(i + 1);
      eipstr[i] = dbBean.getElementValue(j, "eipstr").trim();
      eipnum[i] = dbBean.getElementValue(j, "eipnum").trim();
      eipamt[i] = DecimalTools.format(dbBean.getElementValue(j, "eipamt").trim(), "###,##0.00");
      eipdta[i] = cd.dateFormat(dbBean.getElementValue(j, "eipdta").trim(), "L");
      eiptyp[i] = dbBean.getElementValue(j, "eiptyp").trim();
      if (!eiptyp[i].equals("")) eiptyp[i] = CodesManager.getCodeValue("20", eiptyp[i]);

      eipvdr[i] = dbBean.getElementValue(j, "eipvdr").trim();
      eipyta[i] = cd.dateFormat(dbBean.getElementValue(j, "eipyta").trim(), "L");
      eipflg[i] = dbBean.getElementValue(j, "eipflg").trim();

      eivtrk[i] = dbBean.getElementValue(j, "eivtrk").trim();
      eivivn[i] = dbBean.getElementValue(j, "eivivn").trim();
      eivtax[i] = dbBean.getElementValue(j, "eivtax").trim();
      key = dbBean.getElementValue(j, "eivser").trim();
      if (!dbBean.getElementValue(j, "eivamt").trim().equals(""))
        eivamt[i] = DecimalTools.format(dbBean.getElementValue(j, "eivamt").trim(), "###,##0.00");
    }

    log.debug("填充数组");
    PropertyUtils.setSimpleProperty(form, "seq", seq);
    PropertyUtils.setSimpleProperty(form, "eipstr", eipstr);
    PropertyUtils.setSimpleProperty(form, "eipnum", eipnum);
    PropertyUtils.setSimpleProperty(form, "eipamt", eipamt);
    PropertyUtils.setSimpleProperty(form, "eipdta", eipdta);
    PropertyUtils.setSimpleProperty(form, "eiptyp", eiptyp);
    PropertyUtils.setSimpleProperty(form, "eipvdr", eipvdr);
    PropertyUtils.setSimpleProperty(form, "eipyta", eipyta);

    PropertyUtils.setSimpleProperty(form, "eivtrk", eivtrk);
    PropertyUtils.setSimpleProperty(form, "eivivn", eivivn);
    PropertyUtils.setSimpleProperty(form, "eivamt", eivamt);
    PropertyUtils.setSimpleProperty(form, "eivtax", eivtax);

    strsql =
        "SELECT distinct eivser FROM eipdtl LEFT OUTER JOIN ( select eivstr,eivnum,eivtyp,eivdtl2.eivtrk,eivdtl2.eivivn,eivseq,eivdtl2.eivamt,eivdtl2.eivtax,eivdtl2.eivser,eivdtl2.eivdat  from eivdtl,eivdtl2 where eivdtl.eivser=eivdtl2.eivser) as a ON (eipstr = eivstr and eipnum=eivnum and eiptyp=eivtyp) where eipflg='2' and eivser='"
            + key
            + "' and  eipvdr='"
            + uname
            + "' ";
    try {
      dbBean.executeSelect(strsql);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
      return "0";
    }
    maxpage = dbBean.getRowCount();

    strsql =
        "SELECT distinct eivtrk,eivivn,eivseq,eivamt,eivtax,eivser,a.eivdat FROM eipdtl LEFT OUTER JOIN ( select eivstr,eivnum,eivtyp,eivdtl2.eivtrk,eivdtl2.eivivn,eivseq,eivdtl2.eivamt,eivdtl2.eivtax,eivdtl2.eivser ,eivdtl2.eivdat from eivdtl,eivdtl2 where eivdtl.eivser=eivdtl2.eivser) as a ON (eipstr = eivstr and eipnum=eivnum and eiptyp=eivtyp) where eipflg='2' and eivser='"
            + key
            + "' and eipvdr='"
            + uname
            + "' order by eivser,eivseq";
    try {
      dbBean.executeSelect(strsql);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
      return "0";
    }
    count = dbBean.getRowCount();
    String[] seqmx = new String[count + maxpage]; // 应付日期
    String[] eivtrkmx = new String[count + maxpage]; // 	发票字轨
    String[] eivivnmx = new String[count + maxpage]; // 	发票号
    String[] eivamtmx = new String[count + maxpage]; // 	开票日期
    String[] eivtaxmx = new String[count + maxpage]; // 应付日期
    String[] eivdat = new String[count + maxpage]; // 应付日期

    String tempser = dbBean.getElementValue(0, "eivser").trim();

    j = 0;
    i = 0;
    int k = 0;
    for (; i < count + maxpage; i++) {
      log.debug("数组循环" + String.valueOf(i));
      if (!(tempser.equals(dbBean.getElementValue(j, "eivser").trim()))) {
        seqmx[i] = "";
        eivtrkmx[i] = "";
        eivivnmx[i] = "";
        eivamtmx[i] = "";
        eivtaxmx[i] = "";
        eivdat[i] = "";

        tempser = dbBean.getElementValue(j, "eivser").trim();
        i++;
        if (i >= count + maxpage) {
          break;
        }
        k = 0;
      }
      seqmx[i] = String.valueOf(k + 1);

      eivtrkmx[i] = dbBean.getElementValue(j, "eivtrk").trim();
      eivivnmx[i] = dbBean.getElementValue(j, "eivivn").trim();
      if (!dbBean.getElementValue(j, "eivamt").trim().equals(""))
        eivamtmx[i] = DecimalTools.format(dbBean.getElementValue(j, "eivamt").trim(), "###,##0.00");
      eivtaxmx[i] = dbBean.getElementValue(j, "eivtax").trim();
      eivdat[i] = cd.dateFormat(dbBean.getElementValue(j, "eivdat").trim(), "L");
      j++;
      k++;
    }

    PropertyUtils.setSimpleProperty(form, "seqmx", seqmx);
    PropertyUtils.setSimpleProperty(form, "eivtrkmx", eivtrkmx);
    PropertyUtils.setSimpleProperty(form, "eivivnmx", eivivnmx);
    PropertyUtils.setSimpleProperty(form, "eivamtmx", eivamtmx);
    PropertyUtils.setSimpleProperty(form, "eivtaxmx", eivtaxmx);
    PropertyUtils.setSimpleProperty(form, "eivdat", eivdat);

    log.debug("填充formbeen");
    return "1";
  }
  /**
   * 将指定类代码内容传入显示FormBeen(小表格)
   *
   * @param ActionForm 显示FormBeen
   * @param String 工资卡号
   * @return String 1、成功;0、不成功;
   * @exception Exception
   */
  public String setFormbeen(ActionForm form, HttpServletRequest request, String where, String uname)
      throws Exception {
    CommDate cd = new CommDate();
    DataBean dbBean = new DataBean();
    String strsql = "select * from EPOHDR where " + where + "	and epovnd='" + uname + "'";
    try {
      dbBean.executeSelect(strsql);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
      return "0";
    }

    String eponum = dbBean.getElementValue(0, "eponum").trim();
    String epostr = dbBean.getElementValue(0, "epostr").trim();
    String epostn = dbBean.getElementValue(0, "epostn").trim();
    String eposdt = cd.dateFormat(dbBean.getElementValue(0, "eposdt").trim(), "L");
    String epoqdt = cd.dateFormat(dbBean.getElementValue(0, "epoqdt").trim(), "L");

    PropertyUtils.setSimpleProperty(form, "epoqdt", epoqdt);
    PropertyUtils.setSimpleProperty(form, "eponum", eponum);
    PropertyUtils.setSimpleProperty(form, "epostr", epostr);
    PropertyUtils.setSimpleProperty(form, "epostn", epostn);
    PropertyUtils.setSimpleProperty(form, "eposdt", eposdt);

    String strsql1 = "select * from ORDERR where " + where + " and operator='" + uname + "'";
    try {
      dbBean.executeSelect(strsql1);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Datebase.readdb"));
    }
    int count = dbBean.getRowCount();

    String epordt = cd.dateFormat(dbBean.getElementValue(0, "epordt").trim(), "L");

    String epordtm = dbBean.getElementValue(0, "epordtm").trim();
    String epordtm2 = dbBean.getElementValue(0, "epordtm2").trim();

    String epoflg = dbBean.getElementValue(0, "epoflg").trim();

    String operator = dbBean.getElementValue(0, "operator").trim();
    String operdate = dbBean.getElementValue(0, "operdate").trim();
    String opertime = dbBean.getElementValue(0, "opertime").trim();

    Date now = new Date();
    String freeformstate = "0";

    if (count == 0) {
      epoflg = "0";
      operator = uname;
      operdate = com.idn.util.FormatDate.format(now, "yyyy-MM-dd");
      opertime = com.idn.util.FormatDate.format(now, "hh:mm:ss");
      freeformstate = "3";
    }

    PropertyUtils.setSimpleProperty(form, "freeformstate", freeformstate);
    PropertyUtils.setSimpleProperty(form, "epordt", epordt);
    PropertyUtils.setSimpleProperty(form, "epordtmshow", epordtm);
    PropertyUtils.setSimpleProperty(form, "epordtm2show", epordtm2);
    PropertyUtils.setSimpleProperty(form, "epoflg", epoflg);

    PropertyUtils.setSimpleProperty(form, "operatorid", operator);
    PropertyUtils.setSimpleProperty(form, "operatorshow", operator);
    //	PropertyUtils.setSimpleProperty(form, "operatorshow" ,getNamec(operator));

    PropertyUtils.setSimpleProperty(form, "operdate", operdate);
    PropertyUtils.setSimpleProperty(form, "opertime", opertime);

    return "1";
  }