/*
 * Created on 2003/09/16
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package jp.co.sint.basic;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;

import jp.co.sint.config.SIConfig;
import jp.co.sint.config.SIDBMultiConf;
import jp.co.sint.database.SIDBUtil;
import jp.co.sint.database.SIDBAccessException;
import jp.co.sint.tools.SICheckUtil;
import jp.co.sint.tools.SIDateTime;
import jp.co.sint.tools.SIException;
import jp.co.sint.tools.SIFatalException;
import jp.co.sint.tools.SIUtil;
import jp.co.sint.tools.SIBGUtil;

import org.apache.log4j.Category;

/**
 * @author asakura
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class SIReserveOrder extends SIBasic {
  //ログ用のインスタンスの生成
  private static Category log=Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  //予約番号
  private String reserveCode ="";
  
  //顧客コード
  private String custCode ="";
  
  //顧客名
  private String custName ="";
  
  //顧客名カナ
  private String custPronName="";
  
  //EMAIL
  private String email ="";
  
  //現在のEMAIL（送信用）
  private String currentEmail;
  private String[] currentEmails;
  
  private String tel="";
  
  private String postCode="";
  
  private String address="";
  
  //ショップコード
  private String shopCode ="";
  
  //ショップ名
  private String shopName ="";
  
  //商品コード
  private String cmdtyCode ="";
  
  //商品コード(個別)
  private String individualCode ="";
  
  //色コード
  private String colorCode ="";
  
  //色名
  private String colorName ="";
  
  //中古・新品フラグ
  private int usedNewFlg;
  
  //商品名
  private String cmdtyFullName ="";
  
  //商品名
  private String cmdtyName ="";
  
  //規格コード１
  private String stndrdCode1 ="";
  
  //エレメントコード１
  private String elementCode1 ="";
  
  //規格コード２
  private String stndrdCode2 ="";
  
  //エレメントコード２
  private String elementCode2 ="";
  
  //数量
  private String amount ="1";
  
  //数量
  private String rsrvAmount ="";
  
  //割当数
  private String assignAmount="0";
  
  //一部分割の可能
  private String splitFlg="1";
  
  //出荷メールの送信時刻
  private String shipMailDateTime="";
  
  //未出荷メールの送信時刻
  private String nshipMailDateTime="";
  
  //在庫数量
  private String stockAmount="0";
  
  //予約日時
  private String reserveDateTime ="";
  
  //規格名１
  private String stndrdName1 ="";
  
  //規格名２
  private String stndrdName2 ="";
  
  //エレメント名１
  private String elementName1 ="";
  
  //エレメント名２
  private String elementName2 ="";
  
  //勘定価格
  private String calcUnitPrice ="";
  
  //税区分
  private String taxFlg ="";
  
  //税率
  private String taxRate ="0";
  
  //値引期間From
  private String discountFromDate ="";
  
  //値引期間To
  private String discountToDate ="";
  
  //値引率
  private String discountRate ="";
  
  //予約状態フラグ
  private String reserveFlg ="";
  
  //発売開始日
  private String sellFromDate="";
  
  private String memberLevelName="";
  
  private String custCompanyFlg="0";
  
  private String amountFlg ="";
  
  //割当支店コード
  private String reserveBranchCode="";
  
  //割当支店名
  private String reserveBranchName="";
  
  private String unitPrice="0";
  
  private String memberDiscountFlg="0";
  
  private String memberDiscountRate="0";
  
  private String limitFlg = "0";
  
  private String arrivalScheduleMsg = "";
  
  public SIReserveOrder(){
  }
  
  public SIReserveOrder(String lReserveCode){
    setReserveCode(lReserveCode);
  }
  
  //割当未数
  private String noAssignAmount="0";
  
  //登録ユーザ名
  private String initUserName="";
  
  /**
   * @return amountFlg を戻します。
   */
  public String getAmountFlg() {
    return amountFlg;
  }
  
  /**
   * @param amountFlg amountFlg を設定。
   */
  public void setAmountFlg(String amountFlg) {
    this.amountFlg = amountFlg;
  }
  
  //setter of 予約番号
  public void setReserveCode(String lReserveCode){
    if (SIUtil.isNull(lReserveCode)) lReserveCode="";
    this.reserveCode=SIUtil.changeTo(lReserveCode.trim(),this.encode);
  }

  //setter of 顧客コード
  public void setCustCode(String lCustCode){
    if (SIUtil.isNull(lCustCode)) lCustCode="";
    this.custCode=SIUtil.changeTo(lCustCode.trim(),this.encode);
  }
  
  //setter of 顧客名
  public void setCustName(String lCustName){
    if (SIUtil.isNull(lCustName)) lCustName="";
    this.custName=SIUtil.changeTo(lCustName.trim(),this.encode);
  }
  
  //setter of 顧客名カナ
  public void setCustPronName(String lCustPronName){
    if (SIUtil.isNull(lCustPronName)) lCustPronName="";
    this.custPronName=SIUtil.changeTo(lCustPronName.trim(),this.encode);
  }
  
  //setter of EMAIL
  public void setEmail(String lEmail){
    if (SIUtil.isNull(lEmail)) lEmail="";
    this.email=SIUtil.changeTo(lEmail.trim(),this.encode);
  }
  
  //setter of 現在のEMAIL
  public void setCurrentEmail(String lCurrentEmail){
    if (SIUtil.isNull(lCurrentEmail)) lCurrentEmail="";
    this.currentEmail=SIUtil.changeTo(lCurrentEmail.trim(),this.encode);
  }
  
  public void setCurrentEmails(String[] lCurrentEmails){
    this.currentEmails=lCurrentEmails;
  }
  
  //setter of TEL
  public void setTel(String lTel){
    if (SIUtil.isNull(lTel)) lTel="";
    this.tel=SIUtil.changeTo(lTel.trim(),this.encode);
  }
  
  //setter of PostCode
  public void setPostCode(String lPostCode){
    if (SIUtil.isNull(lPostCode)) lPostCode="";
    this.postCode=SIUtil.changeTo(lPostCode.trim(),this.encode);
  }
  
  //setter of PostCode
  public void setAddress(String lAddress){
    if (SIUtil.isNull(lAddress)) lAddress="";
    this.address=SIUtil.changeTo(lAddress.trim(),this.encode);
  }
  
  //setter of ショップコード
  public void setShopCode(String lShopCode){
    if (SIUtil.isNull(lShopCode)) lShopCode="";
    this.shopCode=SIUtil.changeTo(lShopCode.trim(),this.encode);
  }
  
  //setter of ショップ名
  public void setShopName(String lShopName){
    if (SIUtil.isNull(lShopName)) lShopName="";
    this.shopName=SIUtil.changeTo(lShopName.trim(),this.encode);
  }
  
  //setter of 商品コード
  public void setCmdtyCode(String lCmdtyCode){
    if (SIUtil.isNull(lCmdtyCode)) lCmdtyCode="";
    this.cmdtyCode=SIUtil.changeTo(lCmdtyCode.trim(),this.encode);
  }
  
  //setter of 商品名
  public void setCmdtyName(String lCmdtyName){
    if (SIUtil.isNull(lCmdtyName)) lCmdtyName="";
    this.cmdtyName=SIUtil.changeTo(lCmdtyName.trim(),this.encode);
  }
  
  //setter of 規格コード１
  public void setStndrdCode1(String lStndrdCode1){
    if (SIUtil.isNull(lStndrdCode1)) lStndrdCode1="";
    this.stndrdCode1=SIUtil.changeTo(lStndrdCode1.trim(),this.encode);
  }
  
  //setter of エレメントコード１
  public void setElementCode1(String lElementCode1){
    if (SIUtil.isNull(lElementCode1)) lElementCode1="";
    this.elementCode1=SIUtil.changeTo(lElementCode1.trim(),this.encode);
  }
  
  //setter of 規格コード２
  public void setStndrdCode2(String lStndrdCode2){
    if (SIUtil.isNull(lStndrdCode2)) lStndrdCode2="";
    this.stndrdCode2=SIUtil.changeTo(lStndrdCode2.trim(),this.encode);
  }
  
  //setter of エレメントコード２
  public void setElementCode2(String lElementCode2){
    if (SIUtil.isNull(lElementCode2)) lElementCode2="";
    this.elementCode2=SIUtil.changeTo(lElementCode2.trim(),this.encode);
  }
  
  //setter of 数量
  public void setAmount(String lAmount){
    if (SIUtil.isNull(lAmount)) lAmount="1";
    this.amount=SIUtil.changeTo(lAmount.trim(),this.encode);
  }
  
  //setter of 予約可能数量
  public void setRsrvAmount(String lRsrvAmount){
    if (SIUtil.isNull(lRsrvAmount)) lRsrvAmount="";
    this.rsrvAmount=SIUtil.changeTo(lRsrvAmount.trim(),this.encode);
  }
  
  //setter of 割当数量
  public void setAssignAmount(String lAssignAmount){
    if (SIUtil.isNull(lAssignAmount)) lAssignAmount="0";
    this.assignAmount=SIUtil.changeTo(lAssignAmount.trim(),this.encode);
  }
  
  //setter of 分割可能
  public void setSplitFlg(String lSplitFlg){
    if (SIUtil.isNull(lSplitFlg)) lSplitFlg="1";
    this.splitFlg=SIUtil.changeTo(lSplitFlg.trim(),this.encode);
  }
  
  //setter of 送信時間
  public void setShipMailDateTime(String lShipMailDateTime){
    if (SIUtil.isNull(lShipMailDateTime)) lShipMailDateTime="";
    this.shipMailDateTime=SIUtil.changeTo(lShipMailDateTime.trim(),this.encode);
  }
  
  //setter of 送信時間
  public void setNshipMailDateTime(String lNshipMailDateTime){
    if (SIUtil.isNull(lNshipMailDateTime)) lNshipMailDateTime="";
    this.nshipMailDateTime=SIUtil.changeTo(lNshipMailDateTime.trim(),this.encode);
  }
  
  //setter of 在庫数量
  public void setStockAmount(String lStockAmount){
    if (SIUtil.isNull(lStockAmount)) lStockAmount="0";
    this.stockAmount=SIUtil.changeTo(lStockAmount.trim(),this.encode);
  }
  
  //setter of 予約日時
  public void setReserveDateTime(String lReserveDateTime){
    if (SIUtil.isNull(lReserveDateTime)) lReserveDateTime="";
    this.reserveDateTime=SIUtil.changeTo(lReserveDateTime.trim(),this.encode);
  }
  
  //setter of 規格名１
  public void setStndrdName1(String lStndrdName1){
    if (SIUtil.isNull(lStndrdName1)) lStndrdName1="";
    this.stndrdName1=SIUtil.changeTo(lStndrdName1.trim(),this.encode);
  }
  
  //setter of 規格名２
  public void setStndrdName2(String lStndrdName2){
    if (SIUtil.isNull(lStndrdName2)) lStndrdName2="";
    this.stndrdName2=SIUtil.changeTo(lStndrdName2.trim(),this.encode);
  }
  
  //setter of エレメント名１
  public void setElementName1(String lElementName1){
    if (SIUtil.isNull(lElementName1)) lElementName1="";
    this.elementName1=SIUtil.changeTo(lElementName1.trim(),this.encode);
  }
  
  //setter of エレメント名２
  public void setElementName2(String lElementName2){
    if (SIUtil.isNull(lElementName2)) lElementName2="";
    this.elementName2=SIUtil.changeTo(lElementName2.trim(),this.encode);
  }
  
  //setter of 予約状態フラグ
  public void setReserveFlg(String lReserveFlg){
    if (SIUtil.isNull(lReserveFlg)) lReserveFlg="";
    this.reserveFlg=SIUtil.changeTo(lReserveFlg.trim(),this.encode);
  }
  
  //setter of 発売開始日
  public void setSellFromDate(String lSellFromDate){
    if (SIUtil.isNull(lSellFromDate)) lSellFromDate="";
    this.sellFromDate=SIUtil.changeTo(lSellFromDate.trim(),this.encode);
  }
  
  public void setMemberLevelName(String lMemberLevelName){
    if (SIUtil.isNull(lMemberLevelName)) lMemberLevelName="";
    this.memberLevelName=SIUtil.changeTo(lMemberLevelName.trim(),this.encode);
  }
  
  public void setCustCompanyFlg(String lCustCompanyFlg){
    if (SIUtil.isNull(lCustCompanyFlg)) lCustCompanyFlg="";
    this.custCompanyFlg=SIUtil.changeTo(lCustCompanyFlg.trim(),this.encode);
  }
  
  //setter of 割当支店コード
  public void setReserveBranchCode(String lReserveBranch){
    if (SIUtil.isNull(lReserveBranch)) lReserveBranch="";
    this.reserveBranchCode=SIUtil.changeTo(lReserveBranch.trim(),this.encode);
  }
  
  //setter of 割当支店名
  public void setReserveBranchName(String lReserveBranch){
    if (SIUtil.isNull(lReserveBranch)) lReserveBranch="";
    this.reserveBranchName=SIUtil.changeTo(lReserveBranch.trim(),this.encode);
  }
  
  //setter of 割当未済数量
  public void setNoAssignAmount(String lNoAssignAmount){
    if (SIUtil.isNull(lNoAssignAmount)) lNoAssignAmount="0";
    this.noAssignAmount=SIUtil.changeTo(lNoAssignAmount.trim(),this.encode);
  }
  
  //setter of 登録ユーザ名
  public void setInitUserName(String lInitUserName){
    if (SIUtil.isNull(lInitUserName)) lInitUserName="";
    this.initUserName=SIUtil.changeTo(lInitUserName.trim(),this.encode);
  }
  
  //getter of 割当支店コード
  public String getReserveBranchCode(){
    return this.reserveBranchCode;
  }
  
  //getter of 割当支店名
  public String getReserveBranchName(){
    return this.reserveBranchName;
  }
  
  //getter of 予約番号
  public String getReserveCode(){
    return this.reserveCode;
  }
  
  //getter of 顧客コード
  public String getCustCode(){
    return this.custCode;
  }
  
  //getter of 顧客名
  public String getCustName(){
    return this.custName;
  }
  
  //getter of 顧客名カナ
  public String getCustPronName(){
    return this.custPronName;
  }
  
  //getter of EMAIL
  public String getEmail(){
    return this.email;
  }
  
  //getter of 現在のEMAIL
  public String getCurrentEmail(){
    return this.currentEmail;
  }
  public String[] getCurrentEmails(){
    return this.currentEmails;
  }
  
  public String getTel(){
    return this.tel;
  }
  
  public String getPostCode(){
    return this.postCode;
  }
  
  public String getAddress(){
    return this.address;
  }
  
  //getter of ショップコード
  public String getShopCode(){
    return this.shopCode;
  }
  
  //getter of ショップ名
  public String getShopName(){
    return this.shopName;
  }
  
  //getter of 商品コード
  public String getCmdtyCode(){
    return this.cmdtyCode;
  }
  
  //getter of 商品名
  public String getCmdtyName(){
    return this.cmdtyName;
  }
  
  //getter of 商品名
  public String getCmdtyFullName(){
    String lColorName = getColorName();
    int lUsedNewFlg = getUsedNewFlg();
    String lUsedNewName = "";
    
    if (lUsedNewFlg == 1 || lUsedNewFlg == 6 || lUsedNewFlg == 7) {// 新品
      lUsedNewName = "新品";
    } else if (lUsedNewFlg == 2 || lUsedNewFlg == 4) {// 新古OUTLET
      lUsedNewName = "新古OUTLET";
    } else if (lUsedNewFlg == 3) {// BG認定中古
      lUsedNewName = "BG認定中古";
    } else {// 中古
      lUsedNewName = "中古";
    }
    
    String str = "";
    if (SIUtil.isNotNull(lColorName)) {
      str = "(" + lColorName + "・" + lUsedNewName + ")";
    } else {
      str = "(" + lUsedNewName + ")";
    }
    
    return getCmdtyName() + str;
  }
  
  //getter of 商品名
  public String getCmdtyFullName(Connection lConnection){
    String lCmdtyCode = this.getCmdtyCode();
    String lIndividualCode = this.getIndividualCode();
    try{
      String cmdtyFullName = SIBGUtil.getCmdtyFullName(lConnection,lCmdtyCode,lIndividualCode);
      return cmdtyFullName;
    }catch(Exception e){
      return this.cmdtyName;
    }
  }
  
  //getter of 規格コード１
  public String getStndrdCode1(){
    return this.stndrdCode1;
  }
  
  //getter of エレメントコード１
  public String getElementCode1(){
    return this.elementCode1;
  }
  
  //getter of 規格コード２
  public String getStndrdCode2(){
    return this.stndrdCode2;
  }
  
  //getter of エレメントコード２
  public String getElementCode2(){
    return this.elementCode2;
  }
  
  //getter of 数量
  public String getAmount(){
    return this.amount;
  }
  
  //getter of 数量
  public String getRsrvAmount(){
    return this.rsrvAmount;
  }
  
  //getter of 割当数量
  public String getAssignAmount(){
  return this.assignAmount;
  }
  
  //getter of 分割可能
  public String getSplitFlg(){
    return this.splitFlg;
  }
  
  //getter of 送信時刻
  public String getShipMailDateTime(){
    return this.shipMailDateTime;
  }
  
  //getter of 送信時刻
  public String getNshipMailDateTime(){
    return this.nshipMailDateTime;
  }
  
  public String getMailDateTime(){
    if (SIUtil.isNull(getShipMailDateTime())&&SIUtil.isNull( getNshipMailDateTime())) return "";
    if (SIUtil.isNull(getShipMailDateTime())&&SIUtil.isNotNull(getNshipMailDateTime())) {
      return "X&nbsp;"+getNshipMailDateTime();
    }
    if (SIUtil.isNotNull(getShipMailDateTime())&&SIUtil.isNull(getNshipMailDateTime())) {
      return "O&nbsp;"+getShipMailDateTime();
    }
    if (getShipMailDateTime().compareTo(getNshipMailDateTime())>0){
      return "O&nbsp;"+getShipMailDateTime();
    }else{
      return "X&nbsp;"+getNshipMailDateTime();
    }
  }
  
  //getter of 在庫数量
  public String getStockAmount(){
    return this.stockAmount;
  }
  
  //get of 予約日時
  public String getReserveDateTime(){
    return this.reserveDateTime;
  }
  
  //get of 規格名１
  public String getStndrdName1(){
    return this.stndrdName1;
  }
  
  //get of 規格名２
  public String getStndrdName2(){
    return this.stndrdName2;
  }
  
  //get of エレメント名１
  public String getElementName1(){
    return this.elementName1;
  }
  
  //get of エレメント名２
  public String getElementName2(){
    return this.elementName2;
  }
  
  //get of 予約状態フラグ
  public String getReserveFlg(){
    return this.reserveFlg;
  }
  
  //get of 発売開始日
  public String getSellFromDate(){
    return this.sellFromDate;
  }
  
  public String getMemberLevelName(){
    return this.memberLevelName;
  }
  
  public String getCustCompanyFlg(){
    return this.custCompanyFlg;
  }
  
  public String getColorCode() {
    return this.colorCode;
  }
  
  public String getColorName() {
    return this.colorName;
  }
  
  public String getIndividualCode() {
    return this.individualCode;
  }
  
  public int getUsedNewFlg() {
    return this.usedNewFlg;
  }
  
  public void setColorCode(String lColorCode) {
    this.colorCode = lColorCode;
  }
  
  public void setColorName(String lColorName) {
    this.colorName = lColorName;
  }
  
  public void setIndividualCode(String lIndividualCode) {
    this.individualCode = lIndividualCode;
  }
  
  public void setUsedNewFlg(int lUsedNewFlg) {
    this.usedNewFlg = lUsedNewFlg;
  }
  
  /**
   * @param cmdtyFullName cmdtyFullName を設定。
   */
  public void setCmdtyFullName(String cmdtyFullName) {
    this.cmdtyFullName = cmdtyFullName;
  }
  
  public String getCmdtyFullName2(){
    return this.cmdtyFullName;
  }
  
  //getter of 割当未済数量
  public String getNoAssignAmount(){
    return this.noAssignAmount;
  }
  
  //getter of 登録ユーザ名
  public String getInitUserName(){
    return this.initUserName;
  }
  
  /**
   * <b>getUnitPriceAftDisIncTax</b>
   * 値引き期間中の値引き後の購入値段、この値段は、税フラグを含めて、計算した後の値段
   * @param なし
   * @return なし
   * @throws なし
   */
  public String getUnitPriceAftDisIncTax(){
    String lTax="0";
    try {
      if (getTaxFlg().equals("1")){
        lTax=SIUtil.multi_LD(getUnitPriceAftDis(),SIUtil.div_DL(getTaxRate(),"100"));
      }
    } catch (SIFatalException e) {
      e.printStackTrace();
    }
    log.debug("getUnitPriceAftDisIncTax:getUnitPriceAftDis()="+getUnitPriceAftDis()+",lTax="+lTax);
    return SIUtil.add_LL(getUnitPriceAftDis(),lTax);
  }
  
  /**
   * <b>getUnitPriceAftDis</b>
   * 値引き期間中の値引き後の購入値段(税を計算しない)
   * @param なし
   * @return 値引き後の購入値段(税を計算しない)
   * @throws なし
   */
  public String getUnitPriceAftDis(){
    SIDateTime lDateTime=new SIDateTime();
    String lResPirce=getCalcUnitPrice();
    String lRate="0";
    try {
      if (!SICheckUtil.dateGreater(getDiscountFromDate(),lDateTime.getFullDate())&&
          !SICheckUtil.dateLess(getDiscountToDate(),lDateTime.getFullDate())){
        lRate=SIUtil.sub_LD("1",SIUtil.div_DL(getDiscountRate(),"100"));
        log.debug("getUnitPriceAftDis(M or S):lRate="+lRate);
        lResPirce=SIUtil.multi_LD(lResPirce,lRate);
      }
    } catch (ParseException e) {
      e.printStackTrace();
    } catch (SIException e) {
      e.printStackTrace();
    }
    
    return lResPirce;
  }
  
  /**
   * <b>getCalcUnitPrice</b>
   * 勘定の価格{本体価格とか値引き価格}
   * @param lConnection データベースへのコネンクション
   * @return なし
   * @throws なし
   */
  public String getCalcUnitPrice(){
    return this.calcUnitPrice;
  }
  
  //getter of 値引き期間From
  public String getDiscountFromDate(){
    return this.discountFromDate;
  }
  
  //getter of 値引き期間To
  public String getDiscountToDate(){
    return this.discountToDate;
  }
  
  //getter of 値引き率
  public String getDiscountRate(){
    return this.discountRate;
  }
  
  //getter of 税区分
  public String getTaxFlg(){
    return this.taxFlg;
  }
  
  //getter of 税率
  public String getTaxRate(){
    return this.taxRate;
  }
  
  //setter of 勘定価格
  public void setCalcUnitPrice(String lCalcUnitPrice){
    if (SIUtil.isNull(lCalcUnitPrice)) lCalcUnitPrice="0";
    this.calcUnitPrice=SIUtil.changeTo(lCalcUnitPrice.trim(),this.encode);
  }
  
  //setter of 税区分
  public void setTaxFlg(String lTaxFlg){
    if (SIUtil.isNull(lTaxFlg)) lTaxFlg="2";
    this.taxFlg=SIUtil.changeTo(lTaxFlg.trim(),this.encode);
  }
  
  //setter of 税率
  public void setTaxRate(String lTaxRate){
    if (SIUtil.isNull(lTaxRate)) lTaxRate="0";
    this.taxRate=SIUtil.changeTo(lTaxRate.trim(),this.encode);
  }
  
  //setter of 値引き期間From
  public void setDiscountFromDate(String lDiscountFromDate){
    if (SIConfig.SIRUNNING_MODE_CURRENT ==SIConfig.SIRUNNING_MODE_TOGETHER){
      lDiscountFromDate=SIConfig.SIMALL.getDiscountFromDate();
    }
    if (SIUtil.isNull(lDiscountFromDate)) lDiscountFromDate="";
    this.discountFromDate=lDiscountFromDate;
  }
  
  //setter of 値引き期間To
  public void setDiscountToDate(String lDiscountToDate){
    if (SIConfig.SIRUNNING_MODE_CURRENT ==SIConfig.SIRUNNING_MODE_TOGETHER){
      lDiscountToDate=SIConfig.SIMALL.getDiscountToDate();
    }
    if (SIUtil.isNull(lDiscountToDate)) lDiscountToDate="";
    this.discountToDate=lDiscountToDate;
  }
  
  //setter of 値引き率
  public void setDiscountRate(String lDiscountRate){
    if (SIConfig.SIRUNNING_MODE_CURRENT ==SIConfig.SIRUNNING_MODE_TOGETHER){
      lDiscountRate=SIConfig.SIMALL.getDiscountRate();
    }
    if (SIUtil.isNull(lDiscountRate)) lDiscountRate="0";
    this.discountRate=lDiscountRate;
  }
  
  public String getMemberDiscountFlg() {
    return memberDiscountFlg;
  }
  
  public String getMemberDiscountRate() {
    return memberDiscountRate;
  }
  
  public String getUnitPrice() {
    return unitPrice;
  }
  
  public void setMemberDiscountFlg(String memberDiscountFlg) {
    if (SIUtil.isNull(memberDiscountFlg)) memberDiscountFlg = "0";
    this.memberDiscountFlg = memberDiscountFlg;
  }
  
  public void setMemberDiscountRate(String memberDiscountRate) {
    if (SIUtil.isNull(memberDiscountRate)) memberDiscountRate = "0";
    this.memberDiscountRate = memberDiscountRate;
  }
  
  public String getCalcMemberDiscountRate() {
    if (!this.getMemberDiscountFlg().equals("0")) return getMemberDiscountRate();
    else return "0";
  }
  
  public void setUnitPrice(String unitPrice) {
    if (SIUtil.isNull(unitPrice)) unitPrice = "0";
    this.unitPrice = unitPrice;
  }
  
  public String getFinalUnitPrice() {
    String lResPirce = getCalcUnitPrice();
    String MemberDiscountRate = "0";
    
    try {
      MemberDiscountRate = SIUtil.sub_LD("1", SIUtil.div_DL(getCalcMemberDiscountRate(), "100"));
    } catch (SIFatalException e) {
      e.printStackTrace();
    }
    
    // 通常価格の取得
    String lUnitPrice = this.getUnitPrice();
    
    // 会員値引の適用
    if (!this.memberDiscountFlg.equals("0")) {
      lUnitPrice = SIUtil.multi_LD(lUnitPrice, MemberDiscountRate);
    }
    
    // 通常価格に値引適用した金額(A)が、特価（値引なし）を下回る場合には(A)を適用する
    if (Integer.parseInt(lUnitPrice) < Integer.parseInt(lResPirce)) {
      lResPirce = lUnitPrice;
    }
    
    return lResPirce;
  }
  
  public boolean reset(Connection lConnection){
    boolean lResult=false;
    if (SIUtil.isNull(this.getReserveCode())) return lResult;
    Statement lStatement=null;
    ResultSet lResultSet=null;
    
    StringBuffer lSqlBuf=new StringBuffer();
    lSqlBuf.append("SELECT aa.*,bb.postCode1||'-'||bb.postCode2 AS postCode,bb.Tel,bb.Address1||bb.Address2||bb.Address3 AS Address ");
    lSqlBuf.append(",bb.Email AS CurrentEmail,cc.AmountFlg,cc.UsedNewFlg,cc.UnitPrice,dd.ColorName,cc.MemberDiscountFlg,ch.email AS chargemail ");
    lSqlBuf.append("FROM ReserveOrderTbl aa ");
    lSqlBuf.append("LEFT OUTER JOIN (SELECT * FROM chargetbl WHERE enableflg=1) ch ON aa.initusername=ch.chargename, ");
    lSqlBuf.append("CustTbl bb, ");
    lSqlBuf.append("(SELECT CmdtyCode,IndividualCode,AmountFlg,UsedNewFlg,UnitPrice,ColorCode,MemberDiscountFlg FROM CmdtyUnitTbl) cc, ");
    lSqlBuf.append("ColorTbl dd ");
    lSqlBuf.append("WHERE aa.CustCode=bb.custCode ");
    lSqlBuf.append("AND aa.CmdtyCode=cc.CmdtyCode AND aa.IndividualCode=cc.IndividualCode AND cc.ColorCode=dd.ColorCode ");
    lSqlBuf.append("AND aa.ReserveCode=").append(SIDBUtil.SQL2Str(getReserveCode()));
    
    log.debug("reset:lSqlBuf="+lSqlBuf.toString());
    try {
      lStatement=lConnection.createStatement();
      lResultSet=lStatement.executeQuery(lSqlBuf.toString());
      
      if (lResultSet.next()){
        this.setEncode(SIConfig.SIENCODE_NONE);
        this.setCustCode(lResultSet.getString("custCode"));//顧客コード
        this.setTel(lResultSet.getString("tel"));//Tel
        this.setPostCode(lResultSet.getString("postCode"));//postcode
        this.setAddress(lResultSet.getString("address"));//address
        this.setCustName(lResultSet.getString("custName"));//顧客名
        this.setCustPronName(lResultSet.getString("custPronName"));//顧客名カナ
        this.setEmail(lResultSet.getString("email"));//Email
        String[] currentEmail = null;
        if (SIUtil.isNotNull(lResultSet.getString("chargemail"))) {
          currentEmail = new String[2];
          currentEmail[0] = lResultSet.getString("currentEmail");
          currentEmail[1] = lResultSet.getString("chargemail");
        }else{
          currentEmail = new String[1];
          currentEmail[0] = lResultSet.getString("currentEmail");
        }
        this.setCurrentEmails(currentEmail);//CurrentEmail
        this.setShopCode(lResultSet.getString("shopCode"));//ショップコード
        this.setShopName(lResultSet.getString("ShopName"));//ショップ名
        this.setCmdtyCode(lResultSet.getString("cmdtyCode"));//商品コード
        this.setIndividualCode(lResultSet.getString("individualCode"));//商品コード(個別)
        this.setCmdtyName(lResultSet.getString("cmdtyName"));//商品名
        this.setStndrdCode1(lResultSet.getString("stndrdCode1"));//規格コード1
        this.setStndrdCode2(lResultSet.getString("stndrdCode2"));//規格コード2
        this.setElementCode1(lResultSet.getString("elementCode1"));//エレメントコード1
        this.setElementCode2(lResultSet.getString("elementCode2"));//エレメントコード2
        this.setAmountFlg(lResultSet.getString("AmountFlg"));
        this.setAmount(lResultSet.getString("amount"));//数量
        this.setAssignAmount(lResultSet.getString("assignAmount"));//数量
        this.setSplitFlg(lResultSet.getString("splitFlg"));//割当分割
        this.setShipMailDateTime(SIDBUtil.getDateTime(lResultSet.getTimestamp("shipMailDateTime")));//予約時刻
        this.setNshipMailDateTime(SIDBUtil.getDateTime(lResultSet.getTimestamp("nshipMailDateTime")));//予約時刻
        this.setReserveDateTime(SIDBUtil.getDateTime(lResultSet.getTimestamp("reserveDateTime")));//予約時刻
        this.setColorName(lResultSet.getString("ColorName"));
        this.setUsedNewFlg(lResultSet.getInt("UsedNewFlg"));
        this.setUnitPrice(lResultSet.getString("UnitPrice"));
        this.setCalcUnitPrice(lResultSet.getString("UnitPrice"));
        this.setReserveFlg(lResultSet.getString("reserveFlg"));//予約状況
        this.setReserveBranchCode(lResultSet.getString("reservebranch"));
        this.setMemberDiscountFlg(lResultSet.getString("memberDiscountFlg"));
        lResult=true;
        
        StringBuffer lSqlBuf2=new StringBuffer();
        lSqlBuf2.append("SELECT Amount ");
        lSqlBuf2.append("FROM StoreStockTbl ");
        lSqlBuf2.append("WHERE CmdtyCode=").append(SIDBUtil.SQL2Str(this.getCmdtyCode()," "));
        lSqlBuf2.append("AND IndividualCode=").append(SIDBUtil.SQL2Str(this.getIndividualCode()," "));
        lSqlBuf2.append("AND BranchCode='999'");
        String amount = SIDBUtil.getFirstData(lConnection, lSqlBuf2.toString());
        if (SIUtil.isNotNull(amount)){
          this.setStockAmount(amount);//在庫数量
        }else{
          this.setStockAmount("0");//在庫数量
        }
      }else {
        log.error("not find record for ReserveCode="+getReserveCode());
      }
      /*
      //規格名を取得する。
      lSqlBuf=new StringBuffer();
      lSqlBuf.append(" SELECT a.StndrdName,b.ElementName ");
      lSqlBuf.append(" FROM StndrdNameMTbl a,StndrdContentMTbl b, ReserveOrderTbl");
      lSqlBuf.append(" WHERE a.ShopCode=").append(SIDBUtil.SQL2Str(this.getShopCode()));
      lSqlBuf.append(" AND a.ShopCode=b.ShopCode");
      lSqlBuf.append(" AND a.StndrdCode=b.StndrdCode");
      
      if(SIUtil.isNotNull(this.getStndrdCode1()) && SIUtil.isNotNull(this.getElementCode1())){
        StringBuffer lAppendBuf=new StringBuffer();
        lAppendBuf.append(" AND a.StndrdCode=").append(SIDBUtil.SQL2Str(this.getStndrdCode1()));
        lAppendBuf.append(" AND b.ElementCode=").append(SIDBUtil.SQL2Str(this.getElementCode1()));
        lResultSet=lStatement.executeQuery(lSqlBuf.toString()+lAppendBuf.toString());
        if (lResultSet.next()){
          this.setStndrdName1(lResultSet.getString("stndrdName"));//規格名1
          this.setElementName1(lResultSet.getString("elementName"));//エレメント名1
        }
      }
      
      if(SIUtil.isNotNull(this.getStndrdCode2()) && SIUtil.isNotNull(this.getElementCode2())){
        StringBuffer lAppendBuf=new StringBuffer();
        lAppendBuf.append(" AND a.StndrdCode=").append(SIDBUtil.SQL2Str(this.getStndrdCode2()));
        lAppendBuf.append(" AND b.ElementCode=").append(SIDBUtil.SQL2Str(this.getElementCode2()));
        lResultSet=lStatement.executeQuery(lSqlBuf.toString()+lAppendBuf.toString());
        if (lResultSet.next()){
          this.setStndrdName2(lResultSet.getString("stndrdName"));//規格名2
          this.setElementName2(lResultSet.getString("elementName"));//エレメント名2
        }
      }
      */
    }catch(SQLException sqle){
      sqle.printStackTrace();
      lResult=false;
    }catch(SIDBAccessException e){
      e.printStackTrace();
      lResult=false;
    }finally{
      SIDBUtil.close(lStatement,lResultSet);
    }
    return lResult;
  }
  
  public String getLimitFlg() {
    return limitFlg;
  }
  
  public void setLimitFlg(String limitFlg) {
    if (SIUtil.isNull(limitFlg)) limitFlg = "0";
    this.limitFlg = limitFlg;
  }
  
  public String getArrivalScheduleMsg() {
    return arrivalScheduleMsg;
  }
  
  public void setArrivalScheduleMsg(String arrivalScheduleMsg){
    if (SIUtil.isNull(arrivalScheduleMsg)) arrivalScheduleMsg = "";
    this.arrivalScheduleMsg=arrivalScheduleMsg;
  }
}