/**
 * Copyright (c) 2003-2004 System Integrator Corporation.
 *                 All Rights Reserved.
 */
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.beans.mallmgr.UIOrderBasic;
import jp.co.sint.config.SIConfig;
import jp.co.sint.config.SIDBMultiConf;// 7.2.0 ST1018 追加
import jp.co.sint.config.SIFlagConf;
import jp.co.sint.database.SIDBAccessException;
import jp.co.sint.database.SIDBUtil;
import jp.co.sint.tools.SIDateTime;
import jp.co.sint.tools.SIFatalException;
import jp.co.sint.tools.SIMismatchException;
import jp.co.sint.tools.SIUtil;
import jp.co.sint.tools.SIBGUtil;// 7.3.0 PI-NES0501 追加

import org.apache.log4j.Category;

/**
 * @version $Id: SIOrder.java,v 1.0 2003/09/19 Exp $
 * @author Jinwang Chen <br>
 * Description:
 * <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>
 * Jinwang Chen 2003/09/19 10:49:52 Original
 */
public class SIOrder extends UIOrderBasic {
  
  // ログ用のインスタンスの生成
  private static Category log = Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  // 受注番号
  private String orderCode = "";
  
  // 7.2.0 ST1030 追加 ここから
  // 受注枝番
  private String orderBranchCode = "";
  // 7.2.0 ST1030 追加 ここまで
  
  // 7.2.0 ST1035 追加ここから
  // 受注配送先項番
  private String selectedDeliveryCode = "";
  // 7.2.0 ST1035 追加ここまで
  
  // 顧客コード
  private String custCode = "";
  
  // 法人フラグ
  private String custCompanyFlg = "0";
  
  // 営業形態 PI-NES0501 追加
  private String job = "";
  
  // 顧客名
  private String custName = "";
  
  // 顧客名カナ
  private String custPronName = "";
  
  // EMAIL
  private String email = "";
  
  // 7.2.0 ST1018 追加 ここから
  // 現在のEMAIL(送信用)
  private String currentEmail = "";
  // 7.2.0 ST1018 追加 ここまで
  
  // 請求書宛名
  private String orderAddressee = "";
  
  // 郵便番号1
  private String postCode1 = "";
  
  // 郵便番号2
  private String postCode2 = "";
  
  // 請求書住所1
  private String address1 = "";
  
  // 請求書住所2
  private String address2 = "";
  
  // 請求書住所3
  private String address3 = "";
  
  // 会社名
  private String companyName = "";
  
  // サロン名
  private String salonName = "";
  
  // 電話番号
  private String tel = "";
  
  // FAX番号
  private String fax = "";
  
  // 支払方法名称
  private String payMethodName = "";
  
  // 受注日時
  private String initDateTime = "";
  
  // 修正日時
  private String updateDateTime = "";
  
  // 先後払いフラグ
  private String paymentFlg = "0";
  
  // 手数料(必須)
  private String fee = "0";
  
  // 手数料の税フラグ
  private String feeTaxFlg = "1";
  
  // 税率
  private String taxRate = "0";
  
  // 入金日
  private String receiptDate = "";
  
  // 入金日の年
  private String receiptDateYear = "";
  
  // 入金日の月
  private String receiptDateMonth = "";
  
  // 入金日の日
  private String receiptDateDay = "";
  
  // メール送信フラグ
  private String sendMailFlg = "0";
  
  // 合計価格
  private String sumOfPrice = "0";
  
  // total
  private String totalOfPrice = "0";
  
  // 値引き合計
  private String sumOfDiscount = "0";
  
  // ポイント使用額
  private String sumByPoint = "0";
  
  // 連絡事項
  private String contactMsg = "";
  
  // 備考
  private String memo = "";
  
  // 送料合計
  private String totalOfDeliveryFee = "0";
  
  // 手数料合計
  private String totalOfFee = "0";
  
  // 受注状態
  private String status = "1";
  
  // 入金メール送信フラグ
  private String receiptMailFlg = "";
  
  // ポイント使用フラグ
  private String pointEnableFlg = "0";
  
  // 7.2.0 ST0300 追加 ここから
  // コンビニコード
  private String cvsTypeCode = "";
  // 7.2.0 ST0300 追加 ここまで
  
  // 7.2.0 ST1030 追加 ここから
  // 出荷済みフラグ
  private boolean deliveryedFlg = false;
  
  // 入金済みフラグ
  private boolean receiptedFlg = false;
  // 7.2.0 ST1030 追加 ここまで
  
  private String strDelFlg = null; // 削除区分 //7.3.0 ST2027 追加
  
  // 7.4.0 ST2057 追加 ここから
  // コンビニ決済.受付番号
  private String cvsReceiptNo = "";
  // コンビニ決済.払込票URL
  private String cvsHaraikomiURL = "";
  // コンビニ決済.支払期限
  private String cvsShiharaiKigen = "";
  // 7.4.0 ST2057 追加 ここまで
  
  // PI-NES0501 追加 ここから
  // 支店コード
  private String companyCode = "";
  
  // 担当者コード
  private String chargeCode = "";
  
  // 支店名
  private String branchName = "";
  
  // 担当者名
  private String chargeName = "";
  
  // 店舗電話番号
  private String storeTel = "";
  
  // 出荷メール送信日時
  private String shippmentMail = "";
  
  // 配送先住所
  private String deliveryAddress = "";
  
  // 受注経路
  private String orderRoute = "";
  // PI-NES0501 追加 ここまで
  
  // 送料調整額
  private String discountFee = "0";
  // 手数料調整額
  private String discountDeliveryFee = "0";
  
  // 7.3.0 PI-NES0601 追加ここから
  // 入金総額
  private String totalPaymentPrice = "0";
  // 入金予定日
  private String expectedPaymentDate = "";
  // 入金日
  private String paymentDate = "";
  // 消費税
  private String taxOfPrice = "0";
  // 売上金額（税込）
  private String salesPriceInTax = "0";
  // 売上金額（税抜）
  private String salesPrice = "0";
  // 出荷合計額
  private String totalShippmentPrice = "0";
  // 出荷ステータス
  private String deliveryStatus = "";
  // 在庫コード
  private String individualCode = "";
  // 商品名
  private String cmdtyName = "";
  // 商品数量
  private String amount = "";
  // 商品単価
  private String price = "";
  // 出荷日
  private String shippmentDate = "";
  // 中古
  private String usednewFlg = "";
  // 商品コード
  private String cmdtyCode = "";
  // 商品原価（税込）
  private String cmdtyPriceInTax = "0";
  // 商品原価（税抜）
  private String cmdtyPrice = "0";
  // 粗利益
  private String profitPrice = "0";
  // 出荷店舗
  private String shipBranch = "";
  // 出荷数量
  private String shipAmount = "0";
  private String branchCode = "";
  private String orderStatus = "0";
  
  private String consignGoodsFlg = "0";
  
  private String memberLevelCode = "";
  
  private String memberLevelName = "";
  // 7.3.0 PI-NES0601 追加ここまで
  
  private String shippmentMailDate = "";
  private String keepMailDate = "";
  private String receivableFlg = "";
  private String hacchuflg = "";
  
  // EDBTG003-00 elecs-tani add start
  // セット値引き合計
  private String sumOfSetDiscount = "";
  // EDBTG003-00 elecs-tani add end
  
  public SIOrder() {}
  
  public SIOrder(String lOrderCode) {
    setOrderCode(lOrderCode);
  }
  
  // setter of 受注番号
  public void setOrderCode(String lOrderCode) {
    if (SIUtil.isNull(lOrderCode)) lOrderCode = "";
    this.orderCode = SIUtil.changeTo(lOrderCode.trim(), this.encode);
  }
  
  // 7.2.0 ST1030 追加 ここから
  // setter of 受注枝番
  public void setOrderBranchCode(String lBranchCode) {
    this.orderBranchCode = SIUtil.changeTo(lBranchCode, this.encode);
  }
  
  // 7.2.0 ST1030 追加 ここまで
  
  // 7.2.0 ST1035 追加ここから
  // setter of 受注配送先項番
  public void setSelectedDeliveryCode(String lSelectedDeliveryCode) {
    if (SIUtil.isNull(lSelectedDeliveryCode)) lSelectedDeliveryCode = "";
    this.selectedDeliveryCode = lSelectedDeliveryCode;
  }
  
  // 7.2.0 ST1035 追加ここまで
  
  // setter of 顧客コード
  public void setCustCode(String lCustCode) {
    if (SIUtil.isNull(lCustCode)) lCustCode = "";
    this.custCode = SIUtil.changeTo(lCustCode.trim(), this.encode);
  }
  
  // setter of 法人フラグ
  public void setCustCompanyFlg(String lCustCompanyFlg) {
    if (SIUtil.isNull(lCustCompanyFlg)) lCustCompanyFlg = "0";
    this.custCompanyFlg = SIUtil.changeTo(lCustCompanyFlg.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);
  }
  
  // 7.2.0 ST1018 追加 ここから
  // setter of 現在のEMAIL
  public void setCurrentEmail(String lCurrentEmail) {
    if (SIUtil.isNull(lCurrentEmail)) lCurrentEmail = this.getEmail();
    ;
    this.currentEmail = SIUtil.changeTo(lCurrentEmail.trim(), this.encode);
  }
  
  // 7.2.0 ST1018 追加 ここまで
  
  // setter of 請求書宛名
  public void setOrderAddressee(String lOrderAddressee) {
    if (SIUtil.isNull(lOrderAddressee)) lOrderAddressee = "";
    this.orderAddressee = SIUtil.changeTo(lOrderAddressee.trim(), this.encode);
  }
  
  // setter of 郵便番号1
  public void setPostCode1(String lPostCode1) {
    if (SIUtil.isNull(lPostCode1)) lPostCode1 = "";
    this.postCode1 = SIUtil.changeTo(lPostCode1.trim(), this.encode);
  }
  
  // setter of 郵便番号2
  public void setPostCode2(String lPostCode2) {
    if (SIUtil.isNull(lPostCode2)) lPostCode2 = "";
    this.postCode2 = SIUtil.changeTo(lPostCode2.trim(), this.encode);
  }
  
  // setter of 請求書住所1
  public void setAddress1(String lAddress1) {
    if (SIUtil.isNull(lAddress1)) lAddress1 = "";
    this.address1 = SIUtil.changeTo(lAddress1.trim(), this.encode);
  }
  
  // setter of 請求書住所2
  public void setAddress2(String lAddress2) {
    if (SIUtil.isNull(lAddress2)) lAddress2 = "";
    this.address2 = SIUtil.changeTo(lAddress2.trim(), this.encode);
  }
  
  // setter of 請求書住所3
  public void setAddress3(String lAddress3) {
    if (SIUtil.isNull(lAddress3)) lAddress3 = "";
    this.address3 = SIUtil.changeTo(lAddress3.trim(), this.encode);
  }
  
  // setter of 会社名
  public void setCompanyName(String lCompanyName) {
    if (SIUtil.isNull(lCompanyName)) lCompanyName = "";
    this.companyName = SIUtil.changeTo(lCompanyName.trim(), this.encode);
  }
  
  // setter of サロン名
  public void setSalonName(String lSalonName) {
    if (SIUtil.isNull(lSalonName)) lSalonName = "";
    this.salonName = SIUtil.changeTo(lSalonName.trim(), this.encode);
  }
  
  // setter of 電話番号
  public void setTel(String lTel) {
    if (SIUtil.isNull(lTel)) lTel = "";
    this.tel = SIUtil.changeTo(lTel.trim(), this.encode);
  }
  
  // setter of FAX番号
  public void setFax(String lFax) {
    if (SIUtil.isNull(lFax)) lFax = "";
    this.fax = SIUtil.changeTo(lFax.trim(), this.encode);
  }
  
  // setter of 支払方法名称
  public void setPayMethodName(String lPayMethodName) {
    if (SIUtil.isNull(lPayMethodName)) lPayMethodName = "";
    this.payMethodName = SIUtil.changeTo(lPayMethodName.trim(), this.encode);
  }
  
  // setter of 受注日時
  public void setInitDateTime(String lInitDateTime) {
    if (SIUtil.isNull(lInitDateTime)) lInitDateTime = "";
    this.initDateTime = SIUtil.changeTo(lInitDateTime.trim(), this.encode);
  }
  
  // setter of 修正日時
  public void setUpdateDateTime(String lUpdateDateTime) {
    if (SIUtil.isNull(lUpdateDateTime)) lUpdateDateTime = "";
    this.updateDateTime = SIUtil.changeTo(lUpdateDateTime.trim(), this.encode);
  }
  
  // setter of 先後払いフラグ
  public void setPaymentFlg(String lPaymentFlg) {
    if (SIUtil.isNull(lPaymentFlg)) lPaymentFlg = "0";
    this.paymentFlg = SIUtil.changeTo(lPaymentFlg.trim(), this.encode);
  }
  
  // setter of 手数料(必須)
  public void setFee(String lFee) {
    if (SIUtil.isNull(lFee)) lFee = "0";
    this.fee = SIUtil.changeTo(lFee.trim(), this.encode);
  }
  
  // setter of 手数料税フラグ
  public void setFeeTaxFlg(String lFeeTaxFlg) {
    if (SIUtil.isNull(lFeeTaxFlg)) lFeeTaxFlg = "1";
    this.feeTaxFlg = SIUtil.changeTo(lFeeTaxFlg.trim(), this.encode);
  }
  
  public String getFeeTaxName() {
    if (this.getFee().equals("0")) return "";// 7.2.0 ST1085 修正
    if (getFeeTaxFlg().equals("0")) return "(" + SIFlagConf.SIFLAG_TAX_0 + ")";
    else if (getFeeTaxFlg().equals("1")) return "(" + SIFlagConf.SIFLAG_TAX_1 + ")";
    else if (getFeeTaxFlg().equals("2")) return "(" + SIFlagConf.SIFLAG_TAX_2 + ")";
    else return "";
  }
  
  // setter of 税率
  public void setTaxRate(String lTaxRate) {
    if (SIUtil.isNull(lTaxRate)) lTaxRate = "0";
    this.taxRate = SIUtil.changeTo(lTaxRate.trim(), this.encode);
  }
  
  // setter of 入金日
  public void setReceiptDate(String lYear, String lMonth, String lDay) {
    this.setReceiptDateYear(lYear);
    this.setReceiptDateMonth(lMonth);
    this.setReceiptDateDay(lDay);
  }
  
  // setter of 入金日
  public void setReceiptDate(String lReceiptDate) {
    if (SIUtil.isNull(lReceiptDate)) lReceiptDate = "";
    else {
      try {
        SIDateTime lDateTime = new SIDateTime(lReceiptDate, SIConfig.SIDATE_FORMAT);
        setReceiptDate(lDateTime.getYearStr(), lDateTime.getMonthStr(), lDateTime.getDayStr());
      } catch (ParseException e) {
        e.printStackTrace();
      }
    }
    this.receiptDate = lReceiptDate;
  }
  
  // setter of 入金日の年
  public void setReceiptDateYear(String lReceiptDateYear) {
    if (SIUtil.isNull(lReceiptDateYear)) this.receiptDateYear = "";
    else this.receiptDateYear = lReceiptDateYear;
  }
  
  // setter of 入金日の月
  public void setReceiptDateMonth(String lReceiptDateMonth) {
    if (SIUtil.isNull(lReceiptDateMonth)) this.receiptDateMonth = "";
    else this.receiptDateMonth = lReceiptDateMonth;
  }
  
  // setter of 入金日の日
  public void setReceiptDateDay(String lReceiptDateDay) {
    if (SIUtil.isNull(lReceiptDateDay)) this.receiptDateDay = "";
    else this.receiptDateDay = lReceiptDateDay;
  }
  
  // setter of メール送信フラグ
  public void setSendMailFlg(String lSendMailFlg) {
    if (SIUtil.isNull(lSendMailFlg)) lSendMailFlg = "0";
    this.sendMailFlg = SIUtil.changeTo(lSendMailFlg.trim(), this.encode);
  }
  
  // setter of 合計価格
  public void setSumOfPrice(String lSumOfPrice) {
    if (SIUtil.isNull(lSumOfPrice)) lSumOfPrice = "0";
    this.sumOfPrice = SIUtil.changeTo(lSumOfPrice.trim(), this.encode);
  }
  
  // setter of 合計価格
  public void setTotalOfPrice(String lTotalOfPrice) {
    if (SIUtil.isNull(lTotalOfPrice)) lTotalOfPrice = "0";
    this.totalOfPrice = SIUtil.changeTo(lTotalOfPrice.trim(), this.encode);
  }
  
  // setter of 値引き合計
  public void setSumOfDiscount(String lSumOfDiscount) {
    if (SIUtil.isNull(lSumOfDiscount)) lSumOfDiscount = "0";
    this.sumOfDiscount = SIUtil.changeTo(lSumOfDiscount.trim(), this.encode);
  }
  
  // setter of ポイント使用額
  public void setSumByPoint(String lSumByPoint) {
    if (SIUtil.isNull(lSumByPoint)) lSumByPoint = "0";
    this.sumByPoint = SIUtil.changeTo(lSumByPoint.trim(), this.encode);
  }
  
  // setter of 連絡事項
  public void setContactMsg(String lContactMsg) {
    if (SIUtil.isNull(lContactMsg)) lContactMsg = "";
    this.contactMsg = SIUtil.changeTo(lContactMsg.trim(), this.encode);
  }
  
  // setter of 備考
  public void setMemo(String lMemo) {
    if (SIUtil.isNull(lMemo)) lMemo = "";
    this.memo = SIUtil.changeTo(lMemo.trim(), this.encode);
  }
  
  // setter of 送料合計
  public void setTotalOfDeliveryFee(String lTotalOfDeliveryFee) {
    if (SIUtil.isNull(lTotalOfDeliveryFee)) lTotalOfDeliveryFee = "0";
    this.totalOfDeliveryFee = SIUtil.changeTo(lTotalOfDeliveryFee.trim(), this.encode);
  }
  
  // setter of 送料合計
  public void setTotalOfFee(String lTotalOfFee) {
    if (SIUtil.isNull(lTotalOfFee)) lTotalOfFee = "0";
    this.totalOfFee = SIUtil.changeTo(lTotalOfFee.trim(), this.encode);
  }
  
  // setter of 受注状態
  public void setStatus(String lStatus) {
    if (SIUtil.isNull(lStatus)) lStatus = "1";
    this.status = SIUtil.changeTo(lStatus.trim(), this.encode);
  }
  
  // setter of 入金メール送信フラグ
  public void setReceiptMailFlg(String lReceiptMailFlg) {
    if (SIUtil.isNull(lReceiptMailFlg)) lReceiptMailFlg = "";
    this.receiptMailFlg = SIUtil.changeTo(lReceiptMailFlg.trim(), this.encode);
  }
  
  // setter of ポイント使用フラグ
  public void setPointEnableFlg(String lPointEnableFlg) {
    if (SIUtil.isNull(lPointEnableFlg)) lPointEnableFlg = "0";
    this.pointEnableFlg = SIUtil.changeTo(lPointEnableFlg.trim(), this.encode);
  }
  
  // 7.2.0 ST0300 追加 ここから
  // setter of コンビニコード
  public void setCvsTypeCode(String lCode) {
    if (SIUtil.isNull(lCode)) lCode = "";
    this.cvsTypeCode = lCode;
  }
  
  // 7.2.0 ST0300 追加 ここまで
  
  // 7.2.0 ST1030 追加 ここから
  // setter of 出荷済みフラグ
  public void setDeliveryedFlg(boolean lFlg) {
    this.deliveryedFlg = lFlg;
  }
  
  // setter of 入金済みフラグ
  public void setReceiptedFlg(boolean lFlg) {
    this.receiptedFlg = lFlg;
  }
  
  // 7.2.0 ST1030 追加 ここまで
  
  // 7.3.0 PI-NES0501 追加 ここから
  // setter of 対応支店
  public void setCompanyCode(String lCompanyCode) {
    if (SIUtil.isNull(lCompanyCode)) lCompanyCode = "";
    this.companyCode = SIUtil.changeTo(lCompanyCode.trim(), this.encode);
  }
  
  // setter of 担当者
  public void setChargeCode(String lChargeCode) {
    if (SIUtil.isNull(lChargeCode)) lChargeCode = "";
    this.chargeCode = SIUtil.changeTo(lChargeCode.trim(), this.encode);
  }
  
  // setter of 支店名
  public void setBranchName(String lBranchName) {
    if (SIUtil.isNull(lBranchName)) lBranchName = "";
    this.branchName = SIUtil.changeTo(lBranchName.trim(), this.encode);
  }
  
  // setter of 担当者名
  public void setChargeName(String lChargeName) {
    if (SIUtil.isNull(lChargeName)) lChargeName = "";
    this.chargeName = SIUtil.changeTo(lChargeName.trim(), this.encode);
  }
  
  // setter of 店舗電話番号
  public void setStoreTel(String lStoreTel) {
    if (SIUtil.isNull(lStoreTel)) lStoreTel = "";
    this.storeTel = SIUtil.changeTo(lStoreTel.trim(), this.encode);
  }
  
  // setter of 出荷メール送信日時
  public void setShippmentMail(String lShippmentMail) {
    if (SIUtil.isNull(lShippmentMail)) lShippmentMail = "";
    this.shippmentMail = SIUtil.changeTo(lShippmentMail.trim(), this.encode);
  }
  
  // setter of 配送先住所
  public void setDeliveryAddress(String lDeliveryAddress) {
    if (SIUtil.isNull(lDeliveryAddress)) lDeliveryAddress = "";
    this.deliveryAddress = SIUtil.changeTo(lDeliveryAddress.trim(), this.encode);
  }
  
  // setter of 受注経路
  public void setOrderRoute(String lOrderRoute) {
    if (SIUtil.isNull(lOrderRoute)) lOrderRoute = "";
    this.orderRoute = SIUtil.changeTo(lOrderRoute.trim(), this.encode);
  }
  
  // 7.3.0 PI-NES0501 追加 ここまで
  
  // getter of 受注番号
  public String getOrderCode() {
    return this.orderCode;
  }
  
  // 7.2.0 ST1030 追加 ここから
  public String getOrderBranchCode() {
    return this.orderBranchCode;
  }
  
  // 7.2.0 ST1030 追加 ここまで
  
  // 7.2.0 ST1035 追加ここから
  // getter of 受注配送先項番
  public String getSelectedDeliveryCode() {
    return this.selectedDeliveryCode;
  }
  
  // 7.2.0 ST1035 追加ここまで
  
  // getter of 顧客コード
  public String getCustCode() {
    return this.custCode;
  }
  
  // getter of 法人フラグ
  public String getCustCompanyFlg() {
    return this.custCompanyFlg;
  }
  
  // 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;
  }
  
  // 7.2.0 ST1018 追加 ここから
  // getter of 現在のEMAIL
  public String getCurrentEmail() {
    return this.currentEmail;
  }
  
  // 7.2.0 ST1018 追加 ここまで
  
  // getter of 請求書宛名
  public String getOrderAddressee() {
    return this.orderAddressee;
  }
  
  // getter of 郵便番号1
  public String getPostCode1() {
    return this.postCode1;
  }
  
  // getter of 郵便番号2
  public String getPostCode2() {
    return this.postCode2;
  }
  
  public String getPostCode() {
    if (SIUtil.isNotNull(getPostCode1()) && SIUtil.isNotNull(getPostCode2())) {
      return getPostCode1() + "-" + getPostCode2();
    } else if (SIUtil.isNotNull(getPostCode1()) || SIUtil.isNotNull(getPostCode2())) {
      return getPostCode1() + getPostCode2();
    } else return "";
  }
  
  public String getPaymentNumber(Connection lConnection) throws SIDBAccessException {
    String result = new String("0");
    StringBuffer lSqlBuf = new StringBuffer();
    lSqlBuf.append("SELECT COALESCE(maxpaymentnumber,0)+1 ");
    lSqlBuf.append("FROM paymentheadertbl ");
    lSqlBuf.append("WHERE ordercode=").append(this.getOrderCode());
    result = SIDBUtil.getFirstData(lConnection, lSqlBuf.toString());
    return result;
  }
  
  // getter of 請求書住所1
  public String getAddress1() {
    return this.address1;
  }
  
  // getter of 請求書住所2
  public String getAddress2() {
    return this.address2;
  }
  
  // getter of 請求書住所3
  public String getAddress3() {
    return this.address3;
  }
  
  public String getAddress() {
    return getAddress1() + getAddress2() + getAddress3();
  }
  
  // getter of 会社名
  public String getCompanyName() {
    return this.companyName;
  }

  // getter of サロン名
  public String getSalonName() {
    return this.salonName;
  }
  
  // getter of 電話番号
  public String getTel() {
    return this.tel;
  }
  
  // getter of FAX番号
  public String getFax() {
    return this.fax;
  }
  
  // getter of 支払方法名称
  public String getPayMethodName() {
    return this.payMethodName;
  }
  
  // getter of 受注日時
  public String getInitDateTime() {
    return this.initDateTime;
  }
  
  // getter of 修正日時
  public String getUpdateDateTime() {
    return this.updateDateTime;
  }
  
  // getter of 先後払いフラグ
  public String getPaymentFlg() {
    return this.paymentFlg;
  }
  
  // getter of 手数料(税別)
  public String getFee() {
    return this.fee;
  }
  
  // getter of 手数料税フラグ
  public String getFeeTaxFlg() {
    return this.feeTaxFlg;
  }
  
  // getter of 手数料(税込み)
  public String getFeeIncTax() {
    if (getFeeTaxFlg().equals("0") || getFeeTaxFlg().equals("2")) return getFee();
    
    String lTax = "0";
    try {
      lTax = SIUtil.multi_LD(getFee(), SIUtil.div_DL(getTaxRate(), "100"));
    } catch (SIFatalException e) {
      e.printStackTrace();
    }
    return SIUtil.add_LL(getFee(), lTax);
  }
  
  // getter of 税率
  public String getTaxRate() {
    return this.taxRate;
  }
  
  // getter of 入金日
  public String getReceiptDate() {
    return SIDateTime.getDate(getReceiptDateYear(), getReceiptDateMonth(), getReceiptDateDay());
  }
  
  public String getReceiptDateYear() {
    return this.receiptDateYear;
  }
  
  public String getReceiptDateMonth() {
    return this.receiptDateMonth;
  }
  
  public String getReceiptDateDay() {
    return this.receiptDateDay;
  }
  
  // getter of メール送信フラグ
  public String getSendMailFlg() {
    return this.sendMailFlg;
  }
  
  // getter of 合計価格
  public String getSumOfPrice() {
    return this.sumOfPrice;
  }
  
  // getter of total
  public String getTotalOfPrice() {
    return this.totalOfPrice;
  }
  
  // getter of 値引き合計
  public String getSumOfDiscount() {
    return this.sumOfDiscount;
  }
  
  // getter of ポイント使用額
  public String getSumByPoint() {
    if (getPointEnableFlg().equals("1")) return this.sumByPoint;
    else return "0";
  }
  
  // getter of ポイント使用額
  public String getSumByPoint2() {
    if (getPointEnableFlg().equals("1") || getPointEnableFlg().equals("2")) return this.sumByPoint;
    else return "0";
  }
  
  // getter of 連絡事項
  public String getContactMsg() {
    return this.contactMsg;
  }
  
  // getter of 備考
  public String getMemo() {
    return this.memo;
  }
  
  // getter of 送料合計
  public String getTotalOfDeliveryFee() {
    return this.totalOfDeliveryFee;
  }
  
  // getter of 手数料合計
  public String getTotalOfFee() {
    return this.totalOfFee;
  }
  
  // getter of カード名義人
  public String getStatus() {
    return this.status;
  }
  
  // getter of 入金メール送信フラグ
  public String getReceiptMailFlg() {
    return this.receiptMailFlg;
  }
  
  // getter of ポイント使用フラグ
  public String getPointEnableFlg() {
    return this.pointEnableFlg;
  }
  
  // 7.2.0 ST0300 追加 ここから
  // getter of コンビニコード
  public String getCvsTypeCode() {
    return this.cvsTypeCode;
  }
  
  // 7.2.0 ST0300 追加 ここまで
  
  // 7.2.0 ST1030 追加 ここから
  // getter of 出荷済みフラグ
  public boolean getDeliveryedFlg() {
    return this.deliveryedFlg;
  }
  
  // getter of 入金済みフラグ
  public boolean getReceiptedFlg() {
    return this.receiptedFlg;
  }
  
  // 7.2.0 ST1030 追加 ここまで
  
  // 7.3.0 ST2027 追加 ここから
  public void setDelFlg(String strDelFlg) {
    this.strDelFlg = strDelFlg;
  }
  
  public String getDelFlg() {
    return this.strDelFlg;
  }
  
  // 7.3.0 ST2027 追加 ここまで
  
  // 7.4.0 ST2057 追加 ここから
  // コンビニ決済.受付番号
  public void setCvsReceiptNo(String argStr) {
    if (SIUtil.isNull(argStr)) this.cvsReceiptNo = "";
    else this.cvsReceiptNo = argStr;
  }
  
  public String getCvsReceiptNo() {
    return this.cvsReceiptNo;
  }
  
  // コンビニ決済.払込票URL
  public void setCvsHaraikomiURL(String argStr) {
    if (SIUtil.isNull(argStr)) this.cvsHaraikomiURL = "";
    else this.cvsHaraikomiURL = argStr;
  }
  
  public String getCvsHaraikomiURL() {
    return this.cvsHaraikomiURL;
  }
  
  // コンビニ決済.支払期限
  public void setCvsShiharaiKigen(String argStr) {
    if (SIUtil.isNull(argStr)) this.cvsShiharaiKigen = "";
    else this.cvsShiharaiKigen = argStr;
  }
  
  public String getCvsShiharaiKigen() {
    return this.cvsShiharaiKigen;
  }
  
  // 7.4.0 ST2057 追加 ここまで
  // 7.3.0 PI-NES0501 追加 ここから
  // getter of 対応支店
  public String getCompanyCode() {
    return this.companyCode;
  }
  
  // getter of 担当者
  public String getChargeCode() {
    return this.chargeCode;
  }
  
  // getter of 支店名
  public String getBranchName() {
    return this.branchName;
  }
  
  // getter of 担当者名
  public String getChargeName() {
    return this.chargeName;
  }
  
  // getter of 店舗電話番号
  public String getStoreTel() {
    return this.storeTel;
  }
  
  // getter of 出荷メール送信日時
  public String getShippmentMail() {
    return this.shippmentMail;
  }
  
  // getter of 配送先住所
  public String getDeliveryAddress() {
    return this.deliveryAddress;
  }
  
  // getter of 受注経路
  public String getOrderRoute() {
    return this.orderRoute;
  }
  
  // getter of 受注経路
  public String getOrderRouteName() {
    String result = "";
    if (SIUtil.isNotNull(this.getOrderRoute())) {
      for(int i=0;i<SIFlagConf.SIFLAG_SEARCH_ORDER_ROUTE_NAME.length;i++){
        if(SIFlagConf.SIFLAG_SEARCH_ORDER_ROUTE_NAME[i][1].equals(this.getOrderRoute()))
        result = SIFlagConf.SIFLAG_SEARCH_ORDER_ROUTE_NAME[i][0];
      }
    }
    return result;
  }
  
  /**
   * @return branchCode を戻します。
   */
  public String getBranchCode() {
    return branchCode;
  }
  
  /**
   * @param branchCode branchCode を設定。
   */
  public void setBranchCode(String branchCode) {
    this.branchCode = branchCode;
  }
  
  /**
   * @return discountDeliveryFee を戻します。
   */
  public String getDiscountDeliveryFee() {
    if (SIUtil.isNull(discountDeliveryFee)) this.discountDeliveryFee = "0";
    return discountDeliveryFee;
  }
  
  /**
   * @param discountDeliveryFee discountDeliveryFee を設定。
   */
  public void setDiscountDeliveryFee(String discountDeliveryFee) {
    this.discountDeliveryFee = discountDeliveryFee;
  }
  
  /**
   * @return discountFee を戻します。
   */
  public String getDiscountFee() {
    if (SIUtil.isNull(discountFee)) this.discountFee = "0";
    return discountFee;
  }
  
  /**
   * @return expectedPaymentDate を戻します。
   */
  public String getExpectedPaymentDate() {
    return expectedPaymentDate;
  }
  
  /**
   * @param expectedPaymentDate expectedPaymentDate を設定。
   */
  public void setExpectedPaymentDate(String expectedPaymentDate) {
    this.expectedPaymentDate = expectedPaymentDate;
  }
  
  /**
   * @return paymentDate を戻します。
   */
  public String getPaymentDate() {
    return paymentDate;
  }
  
  /**
   * @param paymentDate paymentDate を設定。
   */
  public void setPaymentDate(String paymentDate) {
    this.paymentDate = paymentDate;
  }
  
  /**
   * @return totalPaymentPrice を戻します。
   */
  public String getTotalPaymentPrice() {
    if (SIUtil.isNull(totalPaymentPrice)) this.totalPaymentPrice = "0";
    return totalPaymentPrice;
  }
  
  // EDBTG003-00 elecs-tani add start
  /**
   * @return sumOfSetDiscount
   */
  public String getSumOfSetDiscount() {
    return sumOfSetDiscount;
  }
  
  /**
   * @param sumOfSetDiscount セットする sumOfSetDiscount
   */
  public void setSumOfSetDiscount(String sumOfSetDiscount) {
    this.sumOfSetDiscount = sumOfSetDiscount;
  }
  // EDBTG003-00 elecs-tani add end
  
  public String getTotalPaymentPrice(Connection lConnection) {
    String result = new String("0");
    StringBuffer lSqlBuf = new StringBuffer();
    lSqlBuf.append("SELECT totalpaymentprice FROM ").append(SIConfig.SIVIEW_ORDER_PAYMENT_NAME);
    lSqlBuf.append(" WHERE ordercode = ").append(this.getOrderCode());
    lSqlBuf.append(" LIMIT 1");
    try {
      result = SIDBUtil.getFirstData(lConnection, lSqlBuf.toString());
      if (SIUtil.isNull(result)) {
        result = "0";
      }
    } catch (SIDBAccessException e) {
      e.printStackTrace();
    }
    return result;
  }
  
  /**
   * @param totalPaymentPrice totalPaymentPrice を設定。
   */
  public void setTotalPaymentPrice(String totalPaymentPrice) {
    if (SIUtil.isNull(totalPaymentPrice)) this.totalPaymentPrice = "0";
    else this.totalPaymentPrice = totalPaymentPrice;
  }
  
  /**
   * @param discountFee discountFee を設定。
   */
  public void setDiscountFee(String discountFee) {
    if (SIUtil.isNull(discountFee)) this.discountFee = "0";
    else this.discountFee = discountFee;
  }
  
  /**
   * @return salesPrice を戻します。
   */
  public String getSalesPrice() {
    return salesPrice;
  }
  
  /**
   * @param salesPrice salesPrice を設定。
   */
  public void setSalesPrice(String salesPrice) {
    if (SIUtil.isNull(salesPrice)) this.salesPrice = "0";
    else this.salesPrice = salesPrice;
  }
  
  /**
   * @return salesPriceInTax を戻します。
   */
  public String getSalesPriceInTax() {
    return salesPriceInTax;
  }
  
  /**
   * @param salesPriceInTax salesPriceInTax を設定。
   */
  public void setSalesPriceInTax(String salesPriceInTax) {
    if (SIUtil.isNull(salesPriceInTax)) this.salesPriceInTax = "0";
    else this.salesPriceInTax = salesPriceInTax;
  }
  
  /**
   * @return taxOfPrice を戻します。
   */
  public String getTaxOfPrice() {
    return taxOfPrice;
  }
  
  /**
   * @param taxOfPrice taxOfPrice を設定。
   */
  public void setTaxOfPrice(String taxOfPrice) {
    if (SIUtil.isNull(taxOfPrice)) this.taxOfPrice = "0";
    else this.taxOfPrice = taxOfPrice;
  }
  
  /**
   * @return totalShippmentPrice を戻します。
   */
  public String getTotalShippmentPrice() {
    return totalShippmentPrice;
  }
  
  /**
   * @param totalShippmentPrice totalShippmentPrice を設定。
   */
  public void setTotalShippmentPrice(String totalShippmentPrice) {
    if (SIUtil.isNull(totalShippmentPrice)) this.totalShippmentPrice = "0";
    else this.totalShippmentPrice = totalShippmentPrice;
  }
  
  /**
   * @return amount を戻します。
   */
  public String getAmount() {
    return amount;
  }
  
  /**
   * @param amount amount を設定。
   */
  public void setAmount(String amount) {
    if (SIUtil.isNull(amount)) this.amount = "0";
    else this.amount = amount;
  }
  
  /**
   * @return cmdtyName を戻します。
   */
  public String getCmdtyName() {
    return cmdtyName;
  }
  
  /**
   * @param cmdtyName cmdtyName を設定。
   */
  public void setCmdtyName(String cmdtyName) {
    this.cmdtyName = cmdtyName;
  }
  
  /**
   * @return individualCode を戻します。
   */
  public String getIndividualCode() {
    return individualCode;
  }
  
  /**
   * @param individualCode individualCode を設定。
   */
  public void setIndividualCode(String individualCode) {
    this.individualCode = individualCode;
  }
  
  /**
   * @return price を戻します。
   */
  public String getPrice() {
    return price;
  }
  
  /**
   * @param price price を設定。
   */
  public void setPrice(String price) {
    if (SIUtil.isNull(price)) this.price = "0";
    else this.price = price;
  }
  
  /**
   * @return shippmentDate を戻します。
   */
  public String getShippmentDate() {
    return shippmentDate;
  }
  
  /**
   * @param shippmentDate shippmentDate を設定。
   */
  public void setShippmentDate(String shippmentDate) {
    this.shippmentDate = shippmentDate;
  }
  
  public String getShippmentDate(Connection lConnection) {
    String result = new String("");
    StringBuffer lSqlBuf = new StringBuffer();
    lSqlBuf.append(" SELECT MAX(detail.shippmentdate) AS shippmentdate,detail.ordercode FROM orderdetaillatestvw AS detail ");
    lSqlBuf.append(" WHERE detail.ordercode=").append(this.getOrderCode());
    lSqlBuf.append(" GROUP BY detail.ordercode ");
    try {
      result = SIDBUtil.getFirstData(lConnection, lSqlBuf.toString());
      if (SIUtil.isNull(result)) result = "";
    } catch (SIDBAccessException e) {
      e.printStackTrace();
    }
    return result;
  }
  
  /**
   * @return usednewFlg を戻します。
   */
  public String getUsednewFlg() {
    return usednewFlg;
  }
  
  /**
   * @return usednewFlg を戻します。
   */
  public String getUsednewFlgName() {
    int lUsedNewFlg = 0;
    String lUsedNewName = "";
    int lconsignGoodsFlg = 0;
    if (SIUtil.isNotNull(this.getConsignGoodsFlg())) {
      lconsignGoodsFlg = Integer.parseInt(this.getConsignGoodsFlg());
    }
    if (SIUtil.isNotNull(getUsednewFlg())) {
      lUsedNewFlg = Integer.parseInt(getUsednewFlg());
      if (lUsedNewFlg == 6) lUsedNewFlg = 1;
      lUsedNewName = SIFlagConf.SIFLAG_USED_NEW_FLG_LIST_NAME[lUsedNewFlg][0];
      if (lconsignGoodsFlg == 1) {
        lUsedNewName = lUsedNewName + "[委託]";
      }
    }
    return lUsedNewName;
  }
  
  /**
   * @param usednewFlg usednewFlg を設定。
   */
  public void setUsednewFlg(String usednewFlg) {
    this.usednewFlg = usednewFlg;
  }
  
  /**
   * @return cmdtyCode を戻します。
   */
  public String getCmdtyCode() {
    return cmdtyCode;
  }
  
  /**
   * @param cmdtyCode cmdtyCode を設定。
   */
  public void setCmdtyCode(String cmdtyCode) {
    this.cmdtyCode = cmdtyCode;
  }
  
  /**
   * @return cmdtyPrice を戻します。
   */
  public String getCmdtyPrice() {
    return cmdtyPrice;
  }
  
  /**
   * @param cmdtyPrice cmdtyPrice を設定。
   */
  public void setCmdtyPrice(String cmdtyPrice) {
    if (SIUtil.isNull(cmdtyPrice)) this.cmdtyPrice = "0";
    else this.cmdtyPrice = cmdtyPrice;
  }
  
  /**
   * @return cmdtyPriceInTax を戻します。
   */
  public String getCmdtyPriceInTax() {
    return cmdtyPriceInTax;
  }
  
  /**
   * @param cmdtyPriceInTax cmdtyPriceInTax を設定。
   */
  public void setCmdtyPriceInTax(String cmdtyPriceInTax) {
    if (SIUtil.isNull(cmdtyPriceInTax)) this.cmdtyPriceInTax = "0";
    else this.cmdtyPriceInTax = cmdtyPriceInTax;
  }
  
  /**
   * @return profitPrice を戻します。
   */
  public String getProfitPrice() {
    return profitPrice;
  }
  
  /**
   * @param profitPrice profitPrice を設定。
   */
  public void setProfitPrice(String profitPrice) {
    if (SIUtil.isNull(profitPrice)) this.profitPrice = "0";
    else this.profitPrice = profitPrice;
  }
  
  /**
   * @return shipAmount を戻します。
   */
  public String getShipAmount() {
    return shipAmount;
  }
  
  /**
   * @param shipAmount shipAmount を設定。
   */
  public void setShipAmount(String shipAmount) {
    if (SIUtil.isNull(shipAmount)) this.shipAmount = "0";
    else this.shipAmount = shipAmount;
  }
  
  /**
   * @return shipBranch を戻します。
   */
  public String getShipBranch() {
    return shipBranch;
  }
  
  /**
   * @param shipBranch shipBranch を設定。
   */
  public void setShipBranch(String shipBranch) {
    this.shipBranch = shipBranch;
  }
  
  /**
   * @return orderStatus を戻します。
   */
  public String getOrderStatus() {
    return orderStatus;
  }
  
  /**
   * @param orderStatus orderStatus を設定。
   */
  public void setOrderStatus(String orderStatus) {
    if (SIUtil.isNull(orderStatus)) this.orderStatus = "0";
    else this.orderStatus = orderStatus;
  }
  
  /**
   * @return consignGoodsFlg を戻します。
   */
  public String getConsignGoodsFlg() {
    return consignGoodsFlg;
  }
  
  /**
   * @param consignGoodsFlg consignGoodsFlg を設定。
   */
  public void setConsignGoodsFlg(String consignGoodsFlg) {
    if (SIUtil.isNull(consignGoodsFlg)) this.consignGoodsFlg = "0";
    else this.consignGoodsFlg = consignGoodsFlg;
  }
  
  // 7.3.0 PI-NES0501 追加 ここまで
  public String getDeliveryStatus() {
    return deliveryStatus;
  }
  
  public void setDeliveryStatus(String deliveryStatus) {
    this.deliveryStatus = deliveryStatus;
  }
  
  public String getKeepMailDate() {
    return keepMailDate;
  }
  
  public void setKeepMailDate(String keepMailDate) {
    this.keepMailDate = keepMailDate;
  }
  
  public String getShippmentMailDate() {
    return shippmentMailDate;
  }
  
  public void setShippmentMailDate(String shippmentMailDate) {
    this.shippmentMailDate = shippmentMailDate;
  }
  
  public String getShippmentMailDateStr() {
    if (SIUtil.isNull(shippmentMailDate) || shippmentMailDate.length() < 10) return shippmentMailDate;
    else return shippmentMailDate.substring(0, 10);
  }
  
  public String getKeepMailDateStr() {
    if (SIUtil.isNull(keepMailDate) || keepMailDate.length() < 10) return keepMailDate;
    else return keepMailDate.substring(0, 10);
  }
  
  public String getReceivableFlg() {
    return receivableFlg;
  }
  
  public void setReceivableFlg(String receivableFlg) {
    if (SIUtil.isNull(receivableFlg)) receivableFlg = "0";
    this.receivableFlg = receivableFlg;
  }
  
  public String getMemberLevelCode() {
    return memberLevelCode;
  }
  
  public void setMemberLevelCode(String memberLevelCode) {
    if (SIUtil.isNull(memberLevelCode)) memberLevelCode = "";
    this.memberLevelCode = memberLevelCode;
  }
  
  public String getMemberLevelName() {
    return memberLevelName;
  }
  
  public void setMemberLevelName(String memberLevelName) {
    if (SIUtil.isNull(memberLevelName)) memberLevelName = "";
    this.memberLevelName = memberLevelName;
  }
  
  public String getHacchuflg() {
    return hacchuflg;
  }
  
  public void setHacchuflg(String hacchuflg) {
    if (SIUtil.isNull(hacchuflg)) hacchuflg = "";
    this.hacchuflg = hacchuflg;
  }
  
  // お支払い合計額計算
  public String getPaymentTotal() {
    String paymentTotal = "0";
    paymentTotal = SIUtil.add_LLL(this.getTotalOfPrice(), SIUtil.add(this.getFee(), this.getDiscountFee()), SIUtil.add(this.getTotalOfDeliveryFee(), this
        .getDiscountDeliveryFee()));
    paymentTotal = SIUtil.sub_LL(paymentTotal, this.getSumOfDiscount());
    // EDBTG003-00 nagayoshi add start
    paymentTotal = SIUtil.sub_LL(paymentTotal, this.getSumOfSetDiscount());
    // EDBTG003-00 nagayoshi add start
    if (getPointEnableFlg().equals("1")) {
      paymentTotal = SIUtil.sub_LL(paymentTotal, this.getSumByPoint());
    }
    return paymentTotal;
  }
  
  public String getPaymentTotal2() {
    String paymentTotal = "0";
    paymentTotal = SIUtil.add_LLL(this.getTotalOfPrice(), SIUtil.add(this.getFee(), this.getDiscountFee()), SIUtil.add(this.getTotalOfDeliveryFee(), this
        .getDiscountDeliveryFee()));
    paymentTotal = SIUtil.sub_LL(paymentTotal, this.getSumOfDiscount());
    // EDBTG003-00 elecs-matsushima add start
    paymentTotal = SIUtil.sub_LL(paymentTotal, this.getSumOfSetDiscount());
    // EDBTG003-00 elecs-matsushima add end
    if (getPointEnableFlg().equals("1")) {
      paymentTotal = SIUtil.sub_LL(paymentTotal, this.getSumByPoint());
    } else if (getPointEnableFlg().equals("2")) {
      paymentTotal = SIUtil.sub_LL(paymentTotal, this.getSumByPoint2());
    }
    return paymentTotal;
  }
  
  // getter of job
  public String getJob() {
    return job;
  }
  
  // setter of job
  public void setJob(String job) {
    this.job = job;
  }
  
  /**
   * @return receiptFlg を戻します。
   */
  public String getReceiptFlg() {
    long payTotal = 0;
    long priceTotal = 0;
    String receiptFlg = "0";
    if (SIUtil.isNotNull(this.getTotalPaymentPrice())) {
      payTotal = Long.parseLong(this.getTotalPaymentPrice());
    }
    if (SIUtil.isNotNull(this.getPaymentTotal2())) {
      priceTotal = Long.parseLong(this.getPaymentTotal2());
    }
    if (payTotal == 0 && Long.parseLong(this.getPaymentTotal2()) > 0) {
      receiptFlg = "0";
    } else if (payTotal != 0 && payTotal < priceTotal) {
      receiptFlg = "1";
    } else if (payTotal >= priceTotal) {
      receiptFlg = "2";
    }
    return receiptFlg;
  }
  
  /**
   * <b>reset</b> 修正モードの場合には、PKのデータを元に、明細データをデータベースから取り込んで 画面に表示します。
   * 
   * @param lConnection データベースへのコネンクション
   * @return なし
   * @throws なし
   */
  public boolean reset(Connection lConnection) {
    boolean lRes = false;
    if (SIUtil.isNull(this.getOrderCode())) return lRes;
    Statement lStatement = null;
    ResultSet lResultSet = null;
    StringBuffer lSqlBuf = new StringBuffer();
    lSqlBuf.append("SELECT aa.* ");
    lSqlBuf.append(",bb.email AS CurrentEmail ");
    lSqlBuf.append(",bb.delflg as delflg ");
    lSqlBuf.append(",bb.job AS job ");
    lSqlBuf.append(",bb.memberlevelcode AS memberlevelcode ");
    lSqlBuf.append(",bb.memberlevelname AS memberlevelname ");
    lSqlBuf.append(",trunc(aa.totalOfPrice - (aa.totalOfPrice / (1 + (aa.taxRate/100)))) AS taxOfPrice ");
    lSqlBuf.append("FROM OrderSumVW aa ");
    lSqlBuf.append("LEFT OUTER JOIN (SELECT b.custcode,b.email,b.delflg,b.job,c.memberlevelcode,c.memberlevelname FROM CustTbl b,MemberlevelMTbl c WHERE b.memberlevelcode=c.memberlevelcode) bb ");
    lSqlBuf.append("ON aa.CustCode=bb.CustCode ");
    lSqlBuf.append("WHERE aa.OrderCode=").append(SIDBUtil.SQL2Str(this.getOrderCode()));
    
    log.debug("reset:lSqlBuf=" + lSqlBuf.toString());
    try {
      lStatement = lConnection.createStatement();
      lResultSet = lStatement.executeQuery(lSqlBuf.toString());
      
      if (lResultSet.next()) {
        this.setEncode(SIConfig.SIENCODE_NONE);
        this.setOrderCode(lResultSet.getString("orderCode"));// 受注番号
        // 7.2.0 ST1030 追加 ここから
        this.setOrderBranchCode(lResultSet.getString("ORDERBRANCHCODE"));// 受注枝番
        // 7.2.0 ST1030 追加 ここまで
        this.setCustCode(lResultSet.getString("custCode"));// 顧客コード
        this.setCustCompanyFlg(lResultSet.getString("custCompanyFlg"));// 法人フラグ
        this.setCustName(lResultSet.getString("custName"));// 顧客名
        this.setCustPronName(lResultSet.getString("custPronName"));// 顧客名カナ
        this.setEmail(lResultSet.getString("email"));// EMAIL
        this.setCurrentEmail(lResultSet.getString("currentEmail"));// 現在のEMAIL //7.2.0 ST1018 追加
        this.setOrderAddressee(lResultSet.getString("orderAddressee"));// 請求書宛名
        this.setPostCode1(lResultSet.getString("postCode1"));// 郵便番号1
        this.setPostCode2(lResultSet.getString("postCode2"));// 郵便番号2
        this.setAddress1(lResultSet.getString("address1"));// 請求書住所1
        this.setAddress2(lResultSet.getString("address2"));// 請求書住所2
        this.setAddress3(lResultSet.getString("address3"));// 請求書住所3
        this.setCompanyName(lResultSet.getString("companyName"));// 会社名
        this.setStoreTel(lResultSet.getString("storetel"));// 店舗電話番号 //7.3.0 PI-NES0501 追加
        this.setTel(lResultSet.getString("tel"));// 電話番号
        this.setFax(lResultSet.getString("fax"));// FAX番号
        this.setPayMethodName(lResultSet.getString("payMethodName"));// 支払方法名称
        this.setInitDateTime(SIDBUtil.getDateTime(lResultSet.getTimestamp("initDateTime")));// 受注日時
        this.setUpdateDateTime(SIDBUtil.getDateTime(lResultSet.getTimestamp("updateDateTime")));// 修正日時
        this.setPaymentFlg(lResultSet.getString("paymentFlg"));// 先後払いフラグ
        this.setFee(lResultSet.getString("fee"));// 手数料
        this.setFeeTaxFlg(lResultSet.getString("feeTaxFlg"));// 手数料税フラグ
        this.setTaxRate(lResultSet.getString("taxRate"));// 税率
        this.setTaxOfPrice(lResultSet.getString("taxOfPrice"));
        this.setReceiptDate(SIDBUtil.getDate(lResultSet.getTimestamp("receiptDate")));// 入金日
        this.setSumOfDiscount(lResultSet.getString("sumOfDiscount"));// 値引き合計
        this.setSumByPoint(lResultSet.getString("SumByPoint"));// ポイント使用額
        this.setDiscountDeliveryFee(lResultSet.getString("discountDeliveryFee"));// 送料調整額
        this.setDiscountFee(lResultSet.getString("discountFee"));// 手数料調整額
        this.setSendMailFlg(lResultSet.getString("sendMailFlg"));// メール送信フラグ
        this.setContactMsg(lResultSet.getString("contactMsg"));// 連絡事項
        this.setMemo(lResultSet.getString("memo"));// 備考
        this.setStatus(lResultSet.getString("status"));// 受注状態
        this.setTotalOfPrice(lResultSet.getString("totalOfPrice"));// 合計価格
        this.setTotalOfDeliveryFee(lResultSet.getString("totalOfDeliveryFee"));// 送料合計
        this.setPointEnableFlg(lResultSet.getString("PointEnableFlg"));// ポイント使用フラグ
        // 7.2.0 ST0300 追加 ここから
        this.setCvsTypeCode(lResultSet.getString("CVSTYPECODE"));// コンビニコード
        // 7.2.0 ST0300 追加 ここまで
        this.setDelFlg(Integer.toString(lResultSet.getInt("DelFlg"))); // 削除区分 //7.3.0 ST2027 追加
        // 7.4.0 ST2057 追加 ここから
        /*
         * this.setCvsReceiptNo(lResultSet.getString("CVS_RECEIPT_NO"));//コンビニ決済.受付番号 this.setCvsHaraikomiURL(lResultSet.getString("CVS_HARAIKOMI_URL"));//コンビニ決済.払込票URL
         * this.setCvsShiharaiKigen(SIDBUtil.getDate(lResultSet.getTimestamp("CVS_SHIHARAI_KIGEN")));//コンビニ決済.支払期限
         */
        // 7.4.0 ST2057 追加 ここまで
        // 7.3.0 PI-NES0501 追加 ここから
        this.setJob(lResultSet.getString("job"));
        this.setCompanyCode(lResultSet.getString("branchcode"));
        this.setChargeCode(lResultSet.getString("chargecode"));
        this.setReceiptDate(lResultSet.getString("receiptdate"));
        this.setOrderRoute(lResultSet.getString("orderRoute"));
        // 7.3.0 PI-NES0501 追加 ここまで
        this.setShippmentMailDate(SIDBUtil.getDateTime(lResultSet.getTimestamp("shippmentmaildate")));
        this.setKeepMailDate(SIDBUtil.getDateTime(lResultSet.getTimestamp("keepmaildate")));
        this.setMemberLevelCode(lResultSet.getString("memberLevelCode"));
        this.setMemberLevelName(lResultSet.getString("memberLevelName"));
        this.setSumOfSetDiscount(lResultSet.getString("setDiscount")); // セット値引き合計 EDBTG003-00 elecs-tani add
        lRes = true;
      } else {
        log.error("not find record for ordercode=" + getOrderCode());
      }
    } catch (SQLException sqle) {
      sqle.printStackTrace();
    } finally {
      SIDBUtil.close(lStatement, lResultSet);
    }
    return lRes;
  }
  
  /**
   * <b>reset</b> 修正モードの場合には、PKのデータを元に、明細データをデータベースから取り込んで 画面に表示します。
   * 
   * @param lConnection データベースへのコネンクション
   * @return なし
   * @throws なし
   */
  public boolean resetOrder(Connection lConnection) {
    boolean lRes = false;
    if (SIUtil.isNull(this.getOrderCode())) return lRes;
    Statement lStatement = null;
    ResultSet lResultSet = null;
    StringBuffer lSqlBuf = new StringBuffer();
    lSqlBuf.append(" SELECT aa.orderCode,aa.ORDERBRANCHCODE,aa.custName,aa.orderAddressee,aa.address1,aa.address2,aa.address3, ");
    lSqlBuf.append(" aa.companyName,aa.storetel,aa.tel,aa.initDateTime,aa.branchcode,bb.shippmentdate,aa.paymethodname,aa.orderroute,aa.taxrate, ");
    lSqlBuf.append(" (aa.totalofprice+aa.totalofdeliveryfee+aa.totaloffee+COALESCE(aa.discountfee,0)+COALESCE(aa.discountdeliveryfee,0)-aa.sumofdiscount-aa.sumbypoint) AS sumTotal ");
    lSqlBuf.append(" FROM OrderSumVW AS aa, ");
    lSqlBuf.append(" (SELECT MAX(detail.shippmentdate) AS shippmentdate,detail.ordercode FROM orderdetaillatestvw AS detail GROUP BY detail.ordercode) AS bb ");
    lSqlBuf.append(" WHERE aa.OrderCode = ").append(SIDBUtil.SQL2Str(this.getOrderCode()));
    lSqlBuf.append(" AND aa.OrderCode = bb.OrderCode ");
    log.debug("reset:lSqlBuf=" + lSqlBuf.toString());
    try {
      lStatement = lConnection.createStatement();
      lResultSet = lStatement.executeQuery(lSqlBuf.toString());
      
      if (lResultSet.next()) {
        this.setEncode(SIConfig.SIENCODE_NONE);
        this.setOrderCode(lResultSet.getString("orderCode"));// 受注番号
        this.setOrderBranchCode(lResultSet.getString("ORDERBRANCHCODE"));// 受注枝番
        this.setCustName(lResultSet.getString("custName"));// 顧客名
        this.setOrderAddressee(lResultSet.getString("orderAddressee"));// 請求書宛名
        this.setAddress1(lResultSet.getString("address1"));// 請求書住所1
        this.setAddress2(lResultSet.getString("address2"));// 請求書住所2
        this.setAddress3(lResultSet.getString("address3"));// 請求書住所3
        this.setCompanyName(lResultSet.getString("companyName"));// 会社名
        this.setStoreTel(lResultSet.getString("storetel"));// 店舗電話番号
        this.setTel(lResultSet.getString("tel"));// 電話番号
        this.setInitDateTime(SIDBUtil.getDate2(lResultSet.getTimestamp("initDateTime")));// 受注日時
        this.setCompanyCode(lResultSet.getString("branchcode"));
        this.setShippmentDate(lResultSet.getString("shippmentdate"));
        this.setPayMethodName(lResultSet.getString("paymethodname"));
        this.setOrderRoute(lResultSet.getString("orderroute"));
        this.setTotalOfPrice(lResultSet.getString("sumTotal"));
        this.setTaxRate(lResultSet.getString("taxrate"));
        lRes = true;
      } else {
        log.error("not find record for ordercode=" + getOrderCode());
      }
    } catch (SQLException sqle) {
      sqle.printStackTrace();
    } finally {
      SIDBUtil.close(lStatement, lResultSet);
    }
    return lRes;
  }
  
  // 7.3.0 PI-NES0501 追加 ここから
  /**
   * <b>getCompanyFullName</b> 支店コードから支店名を取得
   * 
   * @param lConnection コネクション
   * @return companyFullName 支店名
   * @throws SIDBAccessException
   */
  
  public String getCompanyFullName(Connection lConnection) throws SIDBAccessException {
    String tableName = "BranchTbl";
    String targetColName = "BranchName";
    String conditionColName = "BranchCode";
    String lCompanyCode = this.companyCode;
    try {
      String companyFullName = SIBGUtil.getDBParameter(lConnection, tableName, targetColName, conditionColName, lCompanyCode);
      return companyFullName;
    } catch (Exception ex) {
      throw new SIDBAccessException(ex);
    }
  }
  
  /**
   * <b>getChargeFullName</b> 担当者コードから担当者名を取得
   * 
   * @param lConnection コネクション
   * @return chargeFullName 担当者名
   * @throws SIDBAccessException
   */
  
  public String getChargeFullName(Connection lConnection) throws SIDBAccessException {
    String tableName = "ChargeTbl";
    String targetColName = "ChargeName";
    String conditionColName = "ChargeCode";
    String lChargeCode = this.chargeCode;
    try {
      String chargeFullName = SIBGUtil.getDBParameter(lConnection, tableName, targetColName, conditionColName, lChargeCode);
      return chargeFullName;
    } catch (Exception ex) {
      throw new SIDBAccessException(ex);
    }
  }
  
  // 7.3.0 PI-NES0501 追加 ここまで
  /**
   * <b>checkPrice</b> 合計金額をチェックします
   * 
   * @param lConnection
   * @param lOrderCode 受注コード
   * @throws SIMismatchException
   */
  public static void checkPrice(Connection lConnection, String lOrderCode) throws SIMismatchException {
    boolean lRes = false;
    StringBuffer lSqlBuf = new StringBuffer();
    // EDBTG003-00 elecs-matsushima mod start
    //lSqlBuf.append("SELECT (TotalOfPrice+TotalOfDeliveryFee+TotalOfFee-SumOfDiscount-SumByPoint+ COALESCE(discountFee,0) + COALESCE(discountDeliveryFee,0)) AS Diff ");
    lSqlBuf.append("SELECT (TotalOfPrice+TotalOfDeliveryFee+TotalOfFee-SumOfDiscount-SumByPoint+ COALESCE(discountFee,0) + COALESCE(discountDeliveryFee,0) - setdiscount) AS Diff ");
    // EDBTG003-00 elecs-matsushima mod end
    lSqlBuf.append("FROM OrderSumVW WHERE OrderCode=").append(SIDBUtil.SQL2Str(lOrderCode));
    
    log.debug("checkPrice:lSqlBuf=" + lSqlBuf.toString());
    
    Statement lStatement = null;
    ResultSet lResultSet = null;
    try {
      lStatement = lConnection.createStatement();
      lResultSet = lStatement.executeQuery(lSqlBuf.toString());
      
      if (lResultSet.next()) {
        log.debug("diff=" + lResultSet.getLong("Diff"));
        lRes = (lResultSet.getLong("Diff") >= 0);
      } else {
        log.error("not find record for ordercode=" + lOrderCode);
      }
    } catch (SQLException sqle) {
      sqle.printStackTrace();
    } finally {
      SIDBUtil.close(lStatement, lResultSet);
    }
    if (!lRes) { throw new SIMismatchException("注文コード" + lOrderCode + "に対する各合計金額が合いません。"); }
  }
  
  /**
   * <b>getMailShopCode</b> 受注番号からショップコードを取得します
   * 
   * @param lConnection
   * @param orderCode 受注コード
   * @return String ショップコード
   */
  public String getMailShopCode(Connection lConnection, String orderCode) {
    if (SIConfig.SIRUNNING_MODE_CURRENT == SIConfig.SIRUNNING_MODE_TOGETHER) {
      return SIConfig.SIMALL.getMallShopCode();
    } else if (SIConfig.SIRUNNING_MODE_CURRENT == SIConfig.SIRUNNING_MODE_INDIVIDUAL) {
      StringBuffer lSqlBuf = new StringBuffer();
      // 7.2.0 ST1030 修正ここから
      lSqlBuf.append("SELECT DISTINCT ShopCode FROM ").append(SIConfig.SIVIEW_ORDER_DETAIL_LATEST_NAME);
      lSqlBuf.append(" WHERE OrderCode=" + SIDBUtil.SQL2Str(orderCode));
      // lSqlBuf.append("SELECT DISTINCT ShopCode FROM OrderDetailTbl WHERE OrderCode="+SIDBUtil.SQL2Str(orderCode));
      // 7.2.0 ST1030 修正ここまで
      Statement lStatement = null;
      ResultSet lResultSet = null;
      try {
        lStatement = lConnection.createStatement();
        lResultSet = lStatement.executeQuery(lSqlBuf.toString());
        if (lResultSet.next()) { return lResultSet.getString("ShopCode"); }
      } catch (SQLException sqle) {
        sqle.printStackTrace();
      } finally {
        SIDBUtil.close(lStatement, lResultSet);
      }
    }
    return "";
  }
}