/**
 * 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 jp.co.sint.config.SIConfig;
import jp.co.sint.database.SIDBAccessException;
import jp.co.sint.database.SIDBUtil;
import jp.co.sint.tools.SIUtil;

import org.apache.log4j.Category;

/**
 * @version $Id: SISearch.java,v 1.0 Exp $
 * @author Fujita Jun <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>
 *         Fujita Jun 2005/08/31 Original
 */

public class SISearch extends SIBasic {
  //ログ用のインスタンスの生成
  private static Category log = Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  public SISearch(){}
  
  //希望製品カテゴリ1
  private String hopeProduct1 = "";
  
  //希望製品カテゴリ2
  private String hopeProduct2 = "";
  
  //希望製品カテゴリ3
  private String hopeProduct3 = "";
  
  //希望製品カテゴリ4
  private String hopeProduct4 = "";
  
  //希望製品カテゴリ5
  private String hopeProduct5 = "";
  
  //希望商品名1
  private String hopeCmdtyName1="";

  //希望商品名2
  private String hopeCmdtyName2="";

  //希望商品名3
  private String hopeCmdtyName3="";

  //希望商品名4
  private String hopeCmdtyName4="";

  //希望商品名5
  private String hopeCmdtyName5="";
  
  //希望数量1
  private String hopeAmount1="";

  //希望数量2
  private String hopeAmount2="";

  //希望数量3
  private String hopeAmount3="";

  //希望数量4
  private String hopeAmount4="";

  //希望数量5
  private String hopeAmount5="";
  
  //希望納品日1
  private String hopeDeliveryDate1 ="";
  
  //希望納品日2
  private String hopeDeliveryDate2 ="";
  
  //希望納品日3
  private String hopeDeliveryDate3 ="";
  
  //希望納品日4
  private String hopeDeliveryDate4 ="";
  
  //希望納品日5
  private String hopeDeliveryDate5 ="";
  
  //依頼者コメント1
  private String clientComment1 ="";
  
  //依頼者コメント2
  private String clientComment2 ="";
  
  //依頼者コメント3
  private String clientComment3 ="";
  
  //依頼者コメント4
  private String clientComment4 ="";
  
  //依頼者コメント5
  private String clientComment5 ="";
    
  //顧客コード
  private String custCode = "";

  //氏名
  private String custName = "";

  //フリガナ
  private String custPronName = "";
  
  //郵便番号1
  private String postCode1 = "";

  //郵便番号2
  private String postCode2 = "";
  
  //住所1
  private String address1 = "";

  //住所2
  private String address2 = "";

  //住所3
  private String address3 = "";
  
  //店舗電話番号
  private String storeTel = "";

  //連絡先電話番号
  private String tel = "";
  
  //連絡先FAX番号
  private String fax = "";
  
  //サロン名
  private String salonName = "";

  //メールアドレス
  private String email = "";
  
  public SISearch(String lCustCode) {
    setCustCode(lCustCode);
  }

  //setter of 希望カテゴリ1 of setter
  public void setHopeProduct1(String lHopeProduct1){
    if (SIUtil.isNull(lHopeProduct1)) lHopeProduct1="";
    this.hopeProduct1=SIUtil.changeTo(lHopeProduct1.trim(),this.encode);
  }
  
  //setter of 希望カテゴリ2 of setter
  public void setHopeProduct2(String lHopeProduct2){
    if (SIUtil.isNull(lHopeProduct2)) lHopeProduct2="";
    this.hopeProduct2=SIUtil.changeTo(lHopeProduct2.trim(),this.encode);
  }
  
  //setter of 希望カテゴリ3 of setter
  public void setHopeProduct3(String lHopeProduct3){
    if (SIUtil.isNull(lHopeProduct3)) lHopeProduct3="";
    this.hopeProduct3=SIUtil.changeTo(lHopeProduct3.trim(),this.encode);
  }
  
  //setter of 希望カテゴリ4 of setter
  public void setHopeProduct4(String lHopeProduct4){
    if (SIUtil.isNull(lHopeProduct4)) lHopeProduct4="";
    this.hopeProduct4=SIUtil.changeTo(lHopeProduct4.trim(),this.encode);
  }
  
  //setter of 希望カテゴリ5 of setter
  public void setHopeProduct5(String lHopeProduct5){
    if (SIUtil.isNull(lHopeProduct5)) lHopeProduct5="";
    this.hopeProduct5=SIUtil.changeTo(lHopeProduct5.trim(),this.encode);
  }
  
  //setter of 希望商品名1 of setter
  public void setHopeCmdtyName1(String lHopeCmdtyName1){
    if (SIUtil.isNull(lHopeCmdtyName1)) lHopeCmdtyName1="";
    this.hopeCmdtyName1=SIUtil.changeTo(lHopeCmdtyName1.trim(),this.encode);
  }
  
  //setter of 希望商品名2 of setter
  public void setHopeCmdtyName2(String lHopeCmdtyName2){
    if (SIUtil.isNull(lHopeCmdtyName2)) lHopeCmdtyName2="";
    this.hopeCmdtyName2=SIUtil.changeTo(lHopeCmdtyName2.trim(),this.encode);
  }
  
  //setter of 希望商品名3 of setter
  public void setHopeCmdtyName3(String lHopeCmdtyName3){
    if (SIUtil.isNull(lHopeCmdtyName3)) lHopeCmdtyName3="";
    this.hopeCmdtyName3=SIUtil.changeTo(lHopeCmdtyName3.trim(),this.encode);
  }
  
  //setter of 希望商品名4 of setter
  public void setHopeCmdtyName4(String lHopeCmdtyName4){
    if (SIUtil.isNull(lHopeCmdtyName4)) lHopeCmdtyName4="";
    this.hopeCmdtyName4=SIUtil.changeTo(lHopeCmdtyName4.trim(),this.encode);
  }
  
  //setter of 希望商品名5 of setter
  public void setHopeCmdtyName5(String lHopeCmdtyName5){
    if (SIUtil.isNull(lHopeCmdtyName5)) lHopeCmdtyName5="";
    this.hopeCmdtyName5=SIUtil.changeTo(lHopeCmdtyName5.trim(),this.encode);
  }
    
  //setter of 希望数量1 of setter
  public void setHopeAmount1(String lHopeAmount1){
    if (SIUtil.isNull(lHopeAmount1)) lHopeAmount1="";
    this.hopeAmount1=SIUtil.changeTo(lHopeAmount1.trim(),this.encode);
  }
  
  //setter of 希望数量2 of setter
  public void setHopeAmount2(String lHopeAmount2){
    if (SIUtil.isNull(lHopeAmount2)) lHopeAmount2="";
    this.hopeAmount2=SIUtil.changeTo(lHopeAmount2.trim(),this.encode);
  }
  
  //setter of 希望数量3 of setter
  public void setHopeAmount3(String lHopeAmount3){
    if (SIUtil.isNull(lHopeAmount3)) lHopeAmount3="";
    this.hopeAmount3=SIUtil.changeTo(lHopeAmount3.trim(),this.encode);
  }
  
  //setter of 希望数量4 of setter
  public void setHopeAmount4(String lHopeAmount4){
    if (SIUtil.isNull(lHopeAmount4)) lHopeAmount4="";
    this.hopeAmount4=SIUtil.changeTo(lHopeAmount4.trim(),this.encode);
  }
  
  //setter of 希望数量5 of setter
  public void setHopeAmount5(String lHopeAmount5){
    if (SIUtil.isNull(lHopeAmount5)) lHopeAmount5="";
    this.hopeAmount5=SIUtil.changeTo(lHopeAmount5.trim(),this.encode);
  }
      
  //希望納品日1 of setter
  public void setHopeDeliveryDate1(String lHopeDeliveryDate1){
    if (SIUtil.isNull(lHopeDeliveryDate1))lHopeDeliveryDate1="";
    this.hopeDeliveryDate1 =lHopeDeliveryDate1;
  }
  
  //希望納品日2 of setter
  public void setHopeDeliveryDate2(String lHopeDeliveryDate2){
    if (SIUtil.isNull(lHopeDeliveryDate2))lHopeDeliveryDate2="";
    this.hopeDeliveryDate2 =lHopeDeliveryDate2;
  }
  
  //希望納品日3 of setter
  public void setHopeDeliveryDate3(String lHopeDeliveryDate3){
    if (SIUtil.isNull(lHopeDeliveryDate3))lHopeDeliveryDate3="";
    this.hopeDeliveryDate3 =lHopeDeliveryDate3;
  }
  
  //希望納品日4 of setter
  public void setHopeDeliveryDate4(String lHopeDeliveryDate4){
    if (SIUtil.isNull(lHopeDeliveryDate4))lHopeDeliveryDate4="";
    this.hopeDeliveryDate4 =lHopeDeliveryDate4;
  }
  
  //希望納品日5 of setter
  public void setHopeDeliveryDate5(String lHopeDeliveryDate5){
    if (SIUtil.isNull(lHopeDeliveryDate5))lHopeDeliveryDate5="";
    this.hopeDeliveryDate5 =lHopeDeliveryDate5;
  }
   
  //依頼者コメント1 of setter
  public void setClientComment1(String lClientComment1){
    if (SIUtil.isNull(lClientComment1))lClientComment1="";
    this.clientComment1 =lClientComment1;
  }
  
  //依頼者コメント2 of setter
  public void setClientComment2(String lClientComment2){
    if (SIUtil.isNull(lClientComment2))lClientComment2="";
    this.clientComment2 =lClientComment2;
  }
  
  //依頼者コメント3 of setter
  public void setClientComment3(String lClientComment3){
    if (SIUtil.isNull(lClientComment3))lClientComment3="";
    this.clientComment3 =lClientComment3;
  }
  
  //依頼者コメント4 of setter
  public void setClientComment4(String lClientComment4){
    if (SIUtil.isNull(lClientComment4))lClientComment4="";
    this.clientComment4 =lClientComment4;
  }
  
  //依頼者コメント5 of setter
  public void setClientComment5(String lClientComment5){
    if (SIUtil.isNull(lClientComment5))lClientComment5="";
    this.clientComment5 =lClientComment5;
  }

  //顧客コード of setter
  public void setCustCode(String val) {
    if (SIUtil.isNull(val))
      val = "";
    val = SIUtil.changeTo(val.trim(), this.encode);
    this.custCode = val;
  }

  //氏名 of setter
  public void setCustName(String val) {
    if (SIUtil.isNull(val))
      val = "";
    this.custName = SIUtil.changeTo(val.trim(), this.encode);
  }

  //フリガナ of setter
  public void setCustPronName(String val) {
    if (SIUtil.isNull(val))
      val = "";
    this.custPronName = SIUtil.changeTo(val.trim(), this.encode);
  }

  //郵便番号1 of setter
  public void setPostCode1(String val) {
    if (SIUtil.isNull(val))
      val = "";
    val = SIUtil.changeTo(val.trim(), this.encode);
    this.postCode1 = val;
  }

  //郵便番号2 of setter
  public void setPostCode2(String val) {
    if (SIUtil.isNull(val))
      val = "";
    val = SIUtil.changeTo(val.trim(), this.encode);
    this.postCode2 = val;
  }
  
  //住所1 of setter
  public void setAddress1(String val) {
    if (SIUtil.isNull(val))
      val = "";
    this.address1 = SIUtil.changeTo(val.trim(), this.encode);
  }

  //住所2 of setter
  public void setAddress2(String val) {
    if (SIUtil.isNull(val))
      val = "";
    this.address2 = SIUtil.changeTo(val.trim(), this.encode);
  }

  //住所3 of setter
  public void setAddress3(String val) {
    if (SIUtil.isNull(val))
      val = "";
    this.address3 = SIUtil.changeTo(val.trim(), this.encode);
  }
  
  //店舗電話番号 of setter
  public void setStoreTel(String val) {
    if (SIUtil.isNull(val))
      val = "";
    val = SIUtil.changeTo(val.trim(), this.encode);
    this.storeTel = val;
  }
  
  //連絡先電話番号 of setter
  public void setTel(String val) {
    if (SIUtil.isNull(val))
      val = "";
    val = SIUtil.changeTo(val.trim(), this.encode);
    this.tel = val;
  }

  //連絡先FAX番号 of setter
  public void setFax(String val) {
    if (SIUtil.isNull(val))
      val = "";
    val = SIUtil.changeTo(val.trim(), this.encode);
    this.fax = val;
  }

  //サロン名 of setter
  public void setSalonName(String val) {
    if (SIUtil.isNull(val))
      val = "";
    this.salonName = SIUtil.changeTo(val.trim(), this.encode);
  }
  
  //メールアドレス of setter
  public void setEmail(String val) {
    if (SIUtil.isNull(val))
      val = "";
    this.email = SIUtil.changeTo(val.trim(), this.encode);
  }
  
  //希望カテゴリ1 of getter
  public String getHopeProduct1() {
    return this.hopeProduct1;
  }
  
  //希望カテゴリ2 of getter
  public String getHopeProduct2() {
    return this.hopeProduct2;
  }
  
  //希望カテゴリ3 of getter
  public String getHopeProduct3() {
    return this.hopeProduct3;
  }
  
  //希望カテゴリ4 of getter
  public String getHopeProduct4() {
    return this.hopeProduct4;
  }
  
  //希望カテゴリ5 of getter
  public String getHopeProduct5() {
    return this.hopeProduct5;
  }

  //希望商品名1 of getter
  public String getHopeCmdtyName1() {
    return this.hopeCmdtyName1;
  }
  
  //希望商品名2 of getter
  public String getHopeCmdtyName2() {
    return this.hopeCmdtyName2;
  }
  
  //希望商品名3 of getter
  public String getHopeCmdtyName3() {
    return this.hopeCmdtyName3;
  }
  
  //希望商品名4 of getter
  public String getHopeCmdtyName4() {
    return this.hopeCmdtyName4;
  }
  
  //希望商品名5 of getter
  public String getHopeCmdtyName5() {
    return this.hopeCmdtyName5;
  }
    
  //希望数量1 of getter
  public String getHopeAmount1() {
    return this.hopeAmount1;
  }
  
  //希望数量2 of getter
  public String getHopeAmount2() {
    return this.hopeAmount2;
  }
  
  //希望数量3 of getter
  public String getHopeAmount3() {
    return this.hopeAmount3;
  }
  
  //希望数量4 of getter
  public String getHopeAmount4() {
    return this.hopeAmount4;
  }
  
  //希望数量5 of getter
  public String getHopeAmount5() {
    return this.hopeAmount5;
  }  
    
  //希望納品日1 of getter
  public String getHopeDeliveryDate1() {
    return this.hopeDeliveryDate1;
  }
  
  //希望納品日2 of getter
  public String getHopeDeliveryDate2() {
    return this.hopeDeliveryDate2;
  }
  
  //希望納品日3 of getter
  public String getHopeDeliveryDate3() {
    return this.hopeDeliveryDate3;
  }
  
  //希望納品日4 of getter
  public String getHopeDeliveryDate4() {
    return this.hopeDeliveryDate4;
  }
  
  //希望納品日5 of getter
  public String getHopeDeliveryDate5() {
    return this.hopeDeliveryDate5;
  }
  
  //依頼者コメント1 of getter
  public String getClientComment1() {
    return this.clientComment1;
  }
  
  //依頼者コメント2 of getter
  public String getClientComment2() {
    return this.clientComment2;
  }
  
  //依頼者コメント3 of getter
  public String getClientComment3() {
    return this.clientComment3;
  }
  
  //依頼者コメント4 of getter
  public String getClientComment4() {
    return this.clientComment4;
  }
  
  //依頼者コメント5 of getter
  public String getClientComment5() {
    return this.clientComment5;
  }
  
  //顧客コード of getter
  public String getCustCode() {
    return this.custCode;
  }

  //氏名 of getter
  public String getCustName() {
    return this.custName;
  }

  //フリガナ of getter
  public String getCustPronName() {
    return this.custPronName;
  }
  
  //郵便番号1 of getter
  public String getPostCode1() {
    return this.postCode1;
  }

  //郵便番号2 of getter
  public String getPostCode2() {
    return this.postCode2;
  }
  
  //住所1 of getter
  public String getAddress1() {
    return this.address1;
  }

  //住所2 of getter
  public String getAddress2() {
    return this.address2;
  }

  //住所3 of getter
  public String getAddress3() {
    return this.address3;
  }

  //住所まとめ
  public String getAddress() {
    return getAddress1() + getAddress2() + getAddress3();
  }
  
  //店舗電話番号 of getter
  public String getStoreTel() {
    return this.storeTel;
  }
  
  //連絡先電話番号 of getter
  public String getTel() {
    return this.tel;
  }
  
  //連絡先FAX番号 of getter
  public String getFax() {
    return this.fax;
  }
  
  //サロン名 of getter
  public String getSalonName() {
    return this.salonName;
  }
  
  //メールアドレス of getter
  public String getEmail() {
    return this.email;
  }

  /**
   * @return
   */
  public Category getLog() {
    return log;
  }

  /**
   * @param category
   */
  public void setLog(Category category) {
    log = category;
  }

  /**
   * @return
   */
  public String getEncode() {
    return encode;
  }

  /**
   * @param string
   */
  public void setEncode(String string) {
    if (SIUtil.isNull(string))
      string = "";
    this.encode = string.trim();
  }

  /**
   * <b>reset </b> 顧客コードから顧客情報を取得するSQLを書き出す
   * 
   * @param Connection
   * @return なし
   * @throws なし
   */
  public void reset(Connection lConnection) throws SIDBAccessException {
    setEncode(SIConfig.SIENCODE_NONE);

    StringBuffer lSqlBuf = new StringBuffer("SELECT * ");
    lSqlBuf.append("FROM CustTbl");
    lSqlBuf.append("WHERE CustCode=" + SIDBUtil.SQL2Str(getCustCode()));

    setup(lConnection, lSqlBuf.toString());
  }

  /**
   * <b>setup </b> resetで取得したSQLを実行し、顧客情報をセットする
   * 
   * @param Connection
   * @return なし
   * @throws なし
   */
  private void setup(Connection lConnection, String lSql) {
    Statement lStatement = null;
    ResultSet lResultSet = null;
    try {
      log.debug("setup:lSql=" + lSql);

      lStatement = lConnection.createStatement();
      lResultSet = lStatement.executeQuery(lSql);

      if (lResultSet.next()) {
        this.setEncode(SIConfig.SIENCODE_NONE);
        this.setCustName(lResultSet.getString("custName")); //お客様名
        this.setCustPronName(lResultSet.getString("custPronName")); //お客様名カナ
        this.setPostCode1(lResultSet.getString("postCode1")); //郵便番号1
        this.setPostCode2(lResultSet.getString("postCode2")); //郵便番号2
        this.setAddress1(lResultSet.getString("address1")); //住所１
        this.setAddress2(lResultSet.getString("address2")); //住所２
        this.setAddress3(lResultSet.getString("address3")); //住所３
        this.setStoreTel(lResultSet.getString("storetel")); //店舗電話番号
        this.setTel(lResultSet.getString("tel")); //連絡先電話番号
        this.setFax(lResultSet.getString("fax")); //連絡先FAX番号
        this.setSalonName(lResultSet.getString("companyName")); //サロン名
        this.setEmail(lResultSet.getString("email")); //メールアドレス      
      }
    } catch (SQLException sqle) {
      sqle.printStackTrace();
    } finally {
      SIDBUtil.close(lStatement, lResultSet);
    }
  }
}