/**
 * Copyright (c) 2003-2006 System Integrator Corporation.
 *                 All Rights Reserved.
 */
package jp.co.sint.beans.mallmgr;

import javax.servlet.http.*;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import org.apache.log4j.Category;
import jp.co.sint.database.*;
import jp.co.sint.basic.*;
import jp.co.sint.config.*;
import jp.co.sint.tools.*;
import jp.co.sint.tools.SIURLParameter;

/**
 * @version $Id : UIOtherOrderListCond.java,v 1.0 Exp $
 * @author      : Naotaka Ohsugi
 * <br>Description :入庫管理・出庫管理の一覧画面に対するbeansクラスを作成します。
 * <p>History</p>
 * <p>Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reason</p>
 * ============&nbsp;&nbsp;&nbsp;==========&nbsp;&nbsp;===========================<br>
 * Naotaka Ohsugi 2006/03/30  Original
 */

public class UIOtherOrderListCond extends SIBasic{

  //ログ用のインスタンスの生成
  private static Category log=Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  //顧客コード
  private String custCodeTxt = "";
  
  //顧客名
  private String custNameTxt = "";
  
  //顧客名カナ
  private String custPronNameTxt = "";
  
  //電話番号
  private String telTxt = "";
  
  //メールアドレス
  private String emailTxt = "";
  
  //在庫コード
  private String individualCodeTxt = "";
  
  //サロン名
  private String companyNameTxt = "";
  
  //会社名
  private String corporationNameTxt = "";
  
  //管理番号（その他販売コード）
  private String otherOrderCodeTxt = "";
  
  //受注日の年(To)
  private String orderDateYearToCbo = "";

  //受注日の月(To)
  private String orderDateMonthToCbo = "";

  //受注日の日(To)
  private String orderDateDayToCbo = "";

  //受注日の年(From)
  private String orderDateYearFromCbo = "";

  //受注日の月(From)
  private String orderDateMonthFromCbo = "";

  //受注日の日(From)
  private String orderDateDayFromCbo = "";
  
  //親商品名（ジョブ名）
  private String motherCmdtyNameTxt = "";
  
  //受注状態
  private String statusRdo = "";
  
  //部門
  private String cmdtySectionRdo = "";
  
  //売上区分
  private String sellTypeRdo = "";
  
  //検索条件SQL
  private String conditionSQL = "";
  
  /**
   * UIOtherOrderListCond
   * コンストラクタ
   * @param なし
   * @return なし
   * @throws なし
   */
  public UIOtherOrderListCond(){
    SIDateTime lDateTime = new SIDateTime();
    
    //月初日付をゲットします
    String Month=lDateTime.getMonthStr();
    String Day="01";
    String Today=lDateTime.getDayStr();
    if(Month.length()==1) Month="0"+Month;
    if(Today.length()==1) Today="0"+Today;
    
    //受注日の年(From)
    orderDateYearFromCbo=lDateTime.getYearStr();
    //受注日の月(From)
    orderDateMonthFromCbo=Month;
    //受注日の日(From)
    orderDateDayFromCbo=Day;
    
    //受注日の年(To)
    orderDateYearToCbo=lDateTime.getYearStr();
    //受注日の月(To)
    orderDateMonthToCbo=Month;
    //受注日の日(To)
    orderDateDayToCbo=Today;
    
    //条件文の設定
    this.conditionSQL=" AND (b.initdatetime IS NULL OR b.initdatetime >= "+SIDBUtil.SQL2Str(getOrderDateFrom())+") AND (b.initdatetime IS NULL OR b.initdatetime <= "+SIDBUtil.SQL2Str(getOrderDateTo()+" 23:59:59",") ");
  }

  /**
   * UIOtherOrderListCond
   * コンストラクタ
   * @param lRequest リクエスト
   * @param lUrlParam
   * @return なし
   * @throws なし
   */
  public UIOtherOrderListCond(HttpServletRequest lRequest,SIURLParameter lUrlParam){
    this.init(lRequest,lUrlParam);
  }
  
  public String getCmdtySectionRdo() {
    return cmdtySectionRdo;
  }
  
  public String getMotherCmdtyNameTxt() {
    return motherCmdtyNameTxt;
  }
  
  public String getOrderDateDayFromCbo() {
    return orderDateDayFromCbo;
  }
  
  public String getOrderDateDayToCbo() {
    return orderDateDayToCbo;
  }
  
  public String getOrderDateMonthFromCbo() {
    return orderDateMonthFromCbo;
  }
  
  public String getOrderDateMonthToCbo() {
    return orderDateMonthToCbo;
  }
  
  public String getOrderDateYearFromCbo() {
    return orderDateYearFromCbo;
  }
  
  public String getOrderDateYearToCbo() {
    return orderDateYearToCbo;
  }
  
  public String getOtherOrderCodeTxt() {
    return otherOrderCodeTxt;
  }
  
  public String getSellTypeRdo() {
    return sellTypeRdo;
  }
  
  public String getStatusRdo() {
    return statusRdo;
  }
  
  public String getConditionSQL() {
    return conditionSQL;
  }
  
  public String getOrderDateFrom(){
    return SIDateTime.getDate(getOrderDateYearFromCbo(),getOrderDateMonthFromCbo(),getOrderDateDayFromCbo());
  }
  
  public String getOrderDateTo(){
    return SIDateTime.getDate(getOrderDateYearToCbo(),getOrderDateMonthToCbo(),getOrderDateDayToCbo());
  }
  
  //getter of companyNameTxt
  public String getCompanyNameTxt() {
    return this.companyNameTxt;
  }
  
  //getter of corporationNameTxt
  public String getCorporationNameTxt() {
    return this.corporationNameTxt;
  }
  
  //getter of custCodeTxt
  public String getCustCodeTxt() {
    return this.custCodeTxt;
  }
  
  //getter of custNameTxt
  public String getCustNameTxt() {
    return this.custNameTxt;
  }
  
  //getter of custPronNameTxt
  public String getCustPronNameTxt() {
    return this.custPronNameTxt;
  }
  
  //getter of emailTxt
  public String getEmailTxt() {
    return this.emailTxt;
  }
  
  //getter of individualCodeTxt
  public String getIndividualCodeTxt() {
    return this.individualCodeTxt;
  }
  
  //getter of telTxt
  public String getTelTxt() {
    return this.telTxt;
  }
  
  public void setCmdtySectionRdo(String cmdtySectionRdo) {
    this.cmdtySectionRdo = cmdtySectionRdo;
  }
  
  public void setMotherCmdtyNameTxt(String motherCmdtyNameTxt) {
    this.motherCmdtyNameTxt = motherCmdtyNameTxt;
  }
  
  public void setOrderDateDayFromCbo(String orderDateDayFromCbo) {
    this.orderDateDayFromCbo = orderDateDayFromCbo;
  }
  
  public void setOrderDateDayToCbo(String orderDateDayToCbo) {
    this.orderDateDayToCbo = orderDateDayToCbo;
  }
  
  public void setOrderDateMonthFromCbo(String orderDateMonthFromCbo) {
    this.orderDateMonthFromCbo = orderDateMonthFromCbo;
  }
  
  public void setOrderDateMonthToCbo(String orderDateMonthToCbo) {
    this.orderDateMonthToCbo = orderDateMonthToCbo;
  }
  
  public void setOrderDateYearFromCbo(String orderDateYearFromCbo) {
    this.orderDateYearFromCbo = orderDateYearFromCbo;
  }
  
  public void setOrderDateYearToCbo(String orderDateYearToCbo) {
    this.orderDateYearToCbo = orderDateYearToCbo;
  }
  
  public void setOtherOrderCodeTxt(String otherOrderCodeTxt) {
    this.otherOrderCodeTxt = otherOrderCodeTxt;
  }
  
  public void setSellTypeRdo(String sellTypeRdo) {
    this.sellTypeRdo = sellTypeRdo;
  }
  
  public void setStatusRdo(String statusRdo) {
    this.statusRdo = statusRdo;
  }
  
  public void setConditionSQL(String conditionSQL) {
    this.conditionSQL = conditionSQL;
  }

  //setter of companyNameTxt
  public void setCompanyNameTxt(String companyNameTxt) {
    if (SIUtil.isNull(companyNameTxt)) companyNameTxt = "";
    this.companyNameTxt = SIUtil.changeTo(companyNameTxt.trim(), this.encode);
  }
  
  //setter of corporationNameTxt
  public void setCorporationNameTxt(String corporationNameTxt) {
    if (SIUtil.isNull(corporationNameTxt)) corporationNameTxt = "";
    this.corporationNameTxt = SIUtil.changeTo(corporationNameTxt.trim(), this.encode);
  }
  
  //setter of custCodeTxt
  public void setCustCodeTxt(String custCodeTxt) {
    if (SIUtil.isNull(custCodeTxt)) custCodeTxt = "";
    this.custCodeTxt = SIUtil.changeTo(custCodeTxt.trim(), this.encode);
  }
  
  //setter of custNameTxt
  public void setCustNameTxt(String custNameTxt) {
    if (SIUtil.isNull(custNameTxt)) custNameTxt = "";
    this.custNameTxt = SIUtil.changeTo(custNameTxt.trim(), this.encode);
  }
  
  //setter of custPronNameTxt
  public void setCustPronNameTxt(String custPronNameTxt) {
    if (SIUtil.isNull(custPronNameTxt)) custPronNameTxt = "";
    this.custPronNameTxt = SIUtil.changeTo(custPronNameTxt.trim(), this.encode);
  }
  
  //setter of emailTxt
  public void setEmailTxt(String emailTxt) {
    if (SIUtil.isNull(emailTxt)) emailTxt = "";
    this.emailTxt = SIUtil.changeTo(emailTxt.trim(), this.encode);
  }
  
  //setter of individualCodeTxt
  public void setIndividualCodeTxt(String individualCodeTxt) {
    if (SIUtil.isNull(individualCodeTxt)) individualCodeTxt = "";
    this.individualCodeTxt = SIUtil.changeTo(individualCodeTxt.trim(), this.encode);
  }
  
  //setter of telTxt
  public void setTelTxt(String telTxt) {
    if (SIUtil.isNull(telTxt)) telTxt = "";
    this.telTxt = SIUtil.changeTo(telTxt.trim(), this.encode);
  }
  
  /**
   * <b>init</b>
   * 入力したデータを基づいて、このbeansを設定します。
   * @param request クライアントからリクエスト
   * @param lUrlParam
   * @return なし
   * @throws なし
   */
  public void init(HttpServletRequest lRequest,SIURLParameter lUrlParam){
    this.setEncode(SIConfig.SIENCODE_SHIFT_JIS);
    super.init(lRequest,lUrlParam);
    this.setCustCodeTxt((String)lUrlParam.getParam("custCodeTxt"));
    this.setCustNameTxt((String)lUrlParam.getParam("custNameTxt"));
    this.setCustPronNameTxt((String)lUrlParam.getParam("custPronNameTxt"));
    this.setTelTxt((String)lUrlParam.getParam("telTxt"));
    this.setEmailTxt((String)lUrlParam.getParam("emailTxt"));
    this.setIndividualCodeTxt((String)lUrlParam.getParam("individualCodeTxt"));
    this.setCompanyNameTxt((String)lUrlParam.getParam("companyNameTxt"));
    this.setCorporationNameTxt((String)lUrlParam.getParam("corporationNameTxt"));
    this.setOrderDateYearFromCbo((String)lUrlParam.getParam("orderDateYearFromCbo"));
    this.setOrderDateMonthFromCbo((String)lUrlParam.getParam("orderDateMonthFromCbo"));
    this.setOrderDateDayFromCbo((String)lUrlParam.getParam("orderDateDayFromCbo"));
    this.setOrderDateYearToCbo((String)lUrlParam.getParam("orderDateYearToCbo"));
    this.setOrderDateMonthToCbo((String)lUrlParam.getParam("orderDateMonthToCbo"));
    this.setOrderDateDayToCbo((String)lUrlParam.getParam("orderDateDayToCbo"));
    this.setMotherCmdtyNameTxt((String)lUrlParam.getParam("motherCmdtyNameTxt"));
    this.setStatusRdo((String)lUrlParam.getParam("statusRdo"));
    this.setCmdtySectionRdo((String)lUrlParam.getParam("cmdtySectionRdo"));
    this.setSellTypeRdo((String)lUrlParam.getParam("sellTypeRdo"));
  }
  
  /**
   * <b>validate</b>
   * 入力したデータをチェックして、同時にSQLの条件文を作成します。
   * @param lRequest クライアントからのリクエスト
   * @return なし
   * @throws なし
   */
  public void validate(HttpServletRequest lRequest){
    SICustomErrors errors=new SICustomErrors();
    SITableConditionManager lConditionMan=new SITableConditionManager();
    String appendSQL="";
    
    //顧客コード
    if (SIUtil.isNotNull(this.custCodeTxt) && SICheckValid.checkValid(errors,"顧客コード",this.custCodeTxt,SICheckDataConf.SICHECK_DATA_DIGIT_TYPE)) {
      lConditionMan.add(new SITableCondition("a","custcode",this.custCodeTxt,SIConfig.SICONDITION_TYPE_EQUAL,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //顧客名
    if (SIUtil.isNotNull(this.custNameTxt)) {
      lConditionMan.add(new SITableCondition("a","custname",this.custNameTxt,SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //顧客名カナ
    if (SIUtil.isNotNull(this.custPronNameTxt) && SICheckValid.checkValid(errors,"顧客名カナ",this.custPronNameTxt,SICheckDataConf.SICHECK_DATA_ZENKAKU_KANA_TYPE)) {
      lConditionMan.add(new SITableCondition("a","custpronname",this.custPronNameTxt,SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //電話番号
    if (SIUtil.isNotNull(this.telTxt) && SICheckValid.checkValid(errors,"電話番号",this.telTxt,SICheckDataConf.SICHECK_DATA_DIGIT_TYPE)) {
      lConditionMan.add(new SITableCondition("a","tel1",this.telTxt,SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //メールアドレス
    if (SIUtil.isNotNull(this.emailTxt) && SICheckValid.checkValid(errors,"メールアドレス",this.emailTxt,SICheckDataConf.SICHECK_DATA_ASCII_TYPE)) {
      lConditionMan.add(new SITableCondition("a","email",this.emailTxt,SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //その他販売コード
    if (SIUtil.isNotNull(this.otherOrderCodeTxt) && SICheckValid.checkValid(errors,"管理番号",this.otherOrderCodeTxt,SICheckDataConf.SICHECK_DATA_DIGIT_TYPE)) {
      lConditionMan.add(new SITableCondition("a","otherordercode",this.otherOrderCodeTxt,SIConfig.SICONDITION_TYPE_EQUAL,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //在庫コード
    if (SIUtil.isNotNull(this.individualCodeTxt) && SICheckValid.checkValid(errors,"在庫コード",this.individualCodeTxt,SICheckDataConf.SICHECK_DATA_ALPHA_DIGIT_TYPE)) {
      appendSQL+=" AND a.ordercode IN (SELECT od.ordercode FROM orderdetaillatestvw od,otherordertbl oo WHERE od.ordercode = oo.ordercode AND od.individualcode LIKE '"+SIDBUtil.SQL2Like(this.individualCodeTxt)+"%') ";
    }
    
    //サロン名
    if (SIUtil.isNotNull(this.companyNameTxt)){
      lConditionMan.add(new SITableCondition("a","deliverycompanyname",this.companyNameTxt,SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //会社名
    if (SIUtil.isNotNull(this.corporationNameTxt)){
      lConditionMan.add(new SITableCondition("a","companyname",this.corporationNameTxt,SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //受注日(From)
    if (SIUtil.isNotNull(getOrderDateFrom())&&SICheckValid.checkValid(errors,"受注日From",getOrderDateFrom(),SICheckDataConf.SICHECK_DATA_DATE_TYPE)){
      appendSQL+=" AND (b.initdatetime IS NULL OR b.initdatetime >= "+SIDBUtil.SQL2Str(getOrderDateFrom(),") ");
    }
    
    //受注日(To)
    if (SIUtil.isNotNull(getOrderDateTo())&&SICheckValid.checkValid(errors,"受注日To",getOrderDateTo(),SICheckDataConf.SICHECK_DATA_DATE_TYPE)){
      appendSQL+=" AND (b.initdatetime IS NULL OR b.initdatetime <= "+SIDBUtil.SQL2Str(getOrderDateTo()+" 23:59:59",") ");
    }
    
    //受注日大小
    try{
      if(!SICheckUtil.dateEqual(this.getOrderDateFrom(),this.getOrderDateTo())){
        SICheckValid.checkValid(errors,"受注日From","受注日To",this.getOrderDateFrom(),this.getOrderDateTo(),SICheckDataConf.SICHECK_DATA_DATE_LESS_TYPE);
      }
    }catch(Exception e){}
    
    //商品名
    if (SIUtil.isNotNull(this.motherCmdtyNameTxt)) {
      lConditionMan.add(new SITableCondition("a","mothercmdtyname",this.motherCmdtyNameTxt,SIConfig.SICONDITION_TYPE_LIKE,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //受注状態
    if (SIUtil.isNotNull(this.statusRdo)){
      lConditionMan.add(new SITableCondition("a","status",this.statusRdo,SIConfig.SICONDITION_TYPE_EQUAL,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //部門
    if (SIUtil.isNotNull(this.cmdtySectionRdo)){
      lConditionMan.add(new SITableCondition("a","cmdtysection",this.cmdtySectionRdo,SIConfig.SICONDITION_TYPE_EQUAL,SIConfig.SICONDITION_TYPE_AND));
    }
    
    //売上区分
    if (SIUtil.isNotNull(this.sellTypeRdo)){
      if(this.sellTypeRdo.equals("0")||this.sellTypeRdo.equals("1")) appendSQL+=" AND (b.selltype='"+this.sellTypeRdo+"' OR b.selltype IS NULL) ";
      else appendSQL+=" AND (b.selltype IN ('2','3') OR b.selltype IS NULL) ";
    }
    
    if (!errors.isEmpty()){
      lRequest.setAttribute(SIConfig.SIERROR_ATTRIBUTE_MESSAGE_KEY,errors);
    } else {
      lRequest.removeAttribute(SIConfig.SIERROR_ATTRIBUTE_MESSAGE_KEY);
    }
    this.setConditionSQL(lConditionMan.getCondtionSQL()+appendSQL);
  }
  
  /**
   * <b>getCollection</b>
   * 条件に合ったレコードを検索して、結果のコネクションを作成して、戻します。
   * @param lConnection データベースへの接続コネクション
   * @return レコードのセット
   * @throws なし
   */
  public Collection getCollection(Connection lConnection) throws SIDBAccessException{
    Statement lStatement=null;
    ResultSet lResultSet=null;
    SIOtherOrder lOrder=new SIOtherOrder();
    StringBuffer lCountSqlBuf=new StringBuffer();//レコード数を求める
    StringBuffer lOrderSqlBuf=new StringBuffer();//その他販売レコード情報リストを求める
    
    Collection lOrders=new ArrayList();
    
    //基本のSQL
    lOrderSqlBuf.append("SELECT a.otherordercode,a.mothercmdtyname,a.cmdtysection,a.status,a.ordercode,b.initdatetime,b.selltype,b.update ");
    lOrderSqlBuf.append("FROM otherordertbl AS a ");
    lOrderSqlBuf.append("LEFT OUTER JOIN (SELECT ba.ordercode,ba.initdatetime,");
    lOrderSqlBuf.append("CASE WHEN ba.status=0 THEN 2 WHEN ba.status=2 THEN 3 ");
    lOrderSqlBuf.append("WHEN (SELECT COUNT(bb.detailcode) FROM orderdetaillatestvw AS bb WHERE bb.ordercode=ba.ordercode AND shippmentdate IS NULL)!=0 THEN 0 ");
    lOrderSqlBuf.append("WHEN (SELECT COUNT(bb.detailcode) FROM orderdetaillatestvw AS bb WHERE bb.ordercode=ba.ordercode AND shippmentdate IS NULL)=0 THEN 1 ");
    lOrderSqlBuf.append("ELSE NULL END AS selltype, ");
    lOrderSqlBuf.append("CASE WHEN (SELECT COUNT(bb.detailcode) FROM orderdetaillatestvw AS bb WHERE bb.ordercode=ba.ordercode AND shippmentdate IS NOT NULL)!=0 OR ba.status=0 OR ba.status=2 THEN 0 ");
    lOrderSqlBuf.append("ELSE 1 END AS update FROM orderlatestvw AS ba) AS b ");
    lOrderSqlBuf.append("ON(a.ordercode=b.ordercode) ");
    lOrderSqlBuf.append("WHERE 1=1 ");
    
    lCountSqlBuf.append("SELECT Count(*) FROM otherordertbl AS a ");
    lCountSqlBuf.append("LEFT OUTER JOIN (SELECT ba.ordercode,ba.initdatetime,");
    lCountSqlBuf.append("CASE WHEN ba.status=0 THEN 2 WHEN ba.status=2 THEN 3 ");
    lCountSqlBuf.append("WHEN (SELECT COUNT(bb.detailcode) FROM orderdetaillatestvw AS bb WHERE bb.ordercode=ba.ordercode AND shippmentdate IS NULL)!=0 THEN 0 ");
    lCountSqlBuf.append("WHEN (SELECT COUNT(bb.detailcode) FROM orderdetaillatestvw AS bb WHERE bb.ordercode=ba.ordercode AND shippmentdate IS NULL)=0 THEN 1 ");
    lCountSqlBuf.append("ELSE NULL END AS selltype FROM orderlatestvw AS ba) AS b ");
    lCountSqlBuf.append("ON(a.ordercode=b.ordercode) ");
    lCountSqlBuf.append("WHERE 1=1 ");
    //検索の条件
    lOrderSqlBuf.append(this.conditionSQL);
    lCountSqlBuf.append(this.conditionSQL);
    
    //ソート
    lOrderSqlBuf.append("ORDER BY a.otherordercode DESC");
    
    //実行
    try{
      String rowCnt = SIDBUtil.getFirstData(lConnection, lCountSqlBuf.toString());
      if(rowCnt.equals("") || rowCnt==null){
        rowCnt="0";
      }
      int lRecordCount=Integer.parseInt(rowCnt);//レコード数の取得
      
      int lPageSize=this.getPageSize();//ページサイズ
      int lPageNumber=this.getPageNumer();//ページ番号
      
      int lMaxPage = lRecordCount/lPageSize;
      if (lRecordCount % lPageSize > 0) {
        lMaxPage++;
      }
      if (lPageNumber>lMaxPage)lPageNumber=lMaxPage;
      
      //開始レコードの番号の設定
      int lFromInx=(lPageNumber-1)*lPageSize;
      //終止のレコード番号の設定
      int lToInx=lFromInx+lPageSize-1;
      if (lFromInx<0)lFromInx=0;
      if (lToInx<0)lToInx=0;
      
      log.debug("getCollection:lFromInx="+lFromInx+",lToInx="+lToInx+",lRecordCount="+lRecordCount);
      
      log.debug("getCollection:lCmdtySqlBuf="+lOrderSqlBuf.toString());
      if (SIDBMultiConf.SIDB_CURRENT_INX==SIDBMultiConf.SIDB_POSTGRESQL_INX){
        lStatement=lConnection.createStatement();
        lOrderSqlBuf.append(" LIMIT ").append(lPageSize).append(" OFFSET ").append(lFromInx);
        lResultSet=lStatement.executeQuery(lOrderSqlBuf.toString());
      }else{
        lStatement=lConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        lResultSet=lStatement.executeQuery(lOrderSqlBuf.toString());
        if (lFromInx>0)lResultSet.absolute(lFromInx);
      }
      
      for (int jj=0;jj<lFromInx;jj++)lOrders.add(null);
      int lIndex=0;
      
      //その他販売レコードのセットの作成
      while (lResultSet.next()&&lIndex<lPageSize){
        lOrder=new SIOtherOrder();
        lOrder.setEncode(SIConfig.SIENCODE_NONE);
        lOrder.setMotherCmdtyName(lResultSet.getString("MotherCmdtyName"));
        lOrder.setOrderDate(lResultSet.getString("InitDateTime"));
        lOrder.setOtherOrderCode(lResultSet.getString("OtherOrderCode"));
        lOrder.setCmdtySection(lResultSet.getString("CmdtySection"));
        lOrder.setStatus(lResultSet.getString("Status"));
        lOrder.setOrderCode(lResultSet.getString("OrderCode"));
        lOrder.setSellType(lResultSet.getString("SellType"));
        lOrder.setUpdateFlg(lResultSet.getString("Update"));
        lOrders.add(lOrder);
        lIndex++;
      }
      for (int jj=lFromInx+lPageSize;jj<lRecordCount;jj++)lOrders.add(null);
    }catch(SQLException ex){
      ex.printStackTrace();
      throw new SIDBAccessException(ex);
    }finally{
      SIDBUtil.close(lResultSet,lStatement);
    }
    return lOrders;
  }
}